From d54a515574a014645c634b5c123eb624bda33fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haris=20Gu=C5=A1i=C4=87?= Date: Mon, 30 Aug 2021 15:39:59 +0200 Subject: [PATCH] Make CLI and GUI version info match (#1853) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `flameshot --version` now includes the git commit hash, same as the About window. Signed-off-by: Haris Gušić --- src/cli/commandlineparser.cpp | 4 ++-- src/utils/globalvalues.cpp | 6 ++++++ src/utils/globalvalues.h | 3 +++ src/widgets/infowindow.cpp | 16 ++++------------ src/widgets/infowindow.h | 1 - 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cli/commandlineparser.cpp b/src/cli/commandlineparser.cpp index 1a742366..87018bfe 100644 --- a/src/cli/commandlineparser.cpp +++ b/src/cli/commandlineparser.cpp @@ -2,6 +2,7 @@ // SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors #include "commandlineparser.h" +#include "src/utils/globalvalues.h" #include #include @@ -305,8 +306,7 @@ QString CommandLineParser::value(const CommandOption& option) const void CommandLineParser::printVersion() { - out << "Flameshot " << qApp->applicationVersion() << "\nCompiled with Qt " - << static_cast(QT_VERSION_STR) << "\n"; + out << GlobalValues::versionInfo() << QStringLiteral("\n"); } void CommandLineParser::printHelp(QStringList args, const Node* node) diff --git a/src/utils/globalvalues.cpp b/src/utils/globalvalues.cpp index ae9f8c6a..6aee2188 100644 --- a/src/utils/globalvalues.cpp +++ b/src/utils/globalvalues.cpp @@ -9,3 +9,9 @@ int GlobalValues::buttonBaseSize() { return QApplication::fontMetrics().lineSpacing() * 2.2; } + +QString GlobalValues::versionInfo() +{ + return QStringLiteral("Flameshot " APP_VERSION " (" FLAMESHOT_GIT_HASH ")" + "\nCompiled with Qt " QT_VERSION_STR); +} diff --git a/src/utils/globalvalues.h b/src/utils/globalvalues.h index 641a992b..c51b5555 100644 --- a/src/utils/globalvalues.h +++ b/src/utils/globalvalues.h @@ -3,8 +3,11 @@ #pragma once +class QString; + namespace GlobalValues { int buttonBaseSize(); +QString versionInfo(); } diff --git a/src/widgets/infowindow.cpp b/src/widgets/infowindow.cpp index 3f367557..be8036fb 100644 --- a/src/widgets/infowindow.cpp +++ b/src/widgets/infowindow.cpp @@ -3,6 +3,7 @@ #include "infowindow.h" #include "src/core/qguiappcurrentscreen.h" +#include "src/utils/globalvalues.h" #include #include #include @@ -65,9 +66,7 @@ void InfoWindow::initLabels() versionTitleLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); m_layout->addWidget(versionTitleLabel); - QString versionMsg = generateVersionString(); - - auto* versionLabel = new QLabel(versionMsg, this); + auto* versionLabel = new QLabel(GlobalValues::versionInfo(), this); versionLabel->setAlignment(Qt::AlignHCenter); versionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); m_layout->addWidget(versionLabel); @@ -88,7 +87,8 @@ void InfoWindow::initLabels() void InfoWindow::copyInfo() { QClipboard* clipboard = QApplication::clipboard(); - clipboard->setText(generateVersionString() + "\n" + generateKernelString()); + clipboard->setText(GlobalValues::versionInfo() + "\n" + + generateKernelString()); } void InfoWindow::keyPressEvent(QKeyEvent* e) @@ -98,14 +98,6 @@ void InfoWindow::keyPressEvent(QKeyEvent* e) } } -QString generateVersionString() -{ - QString version = "Flameshot " + QStringLiteral(APP_VERSION) + " (" + - QStringLiteral(FLAMESHOT_GIT_HASH) + - ")\nCompiled with Qt " + QT_VERSION_STR; - return version; -} - QString generateKernelString() { QString kernelVersion = diff --git a/src/widgets/infowindow.h b/src/widgets/infowindow.h index 1f7efe3a..acf74b8e 100644 --- a/src/widgets/infowindow.h +++ b/src/widgets/infowindow.h @@ -24,5 +24,4 @@ private: QVBoxLayout* m_layout; }; -QString generateVersionString(); QString generateKernelString();