From f64519bfbd601d1cfbf733c1d267ec05e6da7c8e Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Fri, 22 Sep 2017 10:16:26 +0200 Subject: [PATCH] Move the --version output text to Theme #5957 Extracted and adjusted from packaging.diff by @jnweiger and @dschmidt --- src/cmd/cmd.cpp | 3 +-- src/gui/application.cpp | 13 +------------ src/libsync/theme.cpp | 15 +++++++++++++++ src/libsync/theme.h | 8 ++++++++ 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index b8116b919..79ff7b35d 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -196,8 +196,7 @@ void help() void showVersion() { - const char *binaryName = APPLICATION_EXECUTABLE "cmd"; - std::cout << binaryName << " version " << qPrintable(Theme::instance()->version()) << std::endl; + std::cout << qPrintableUtf8(Theme::instance()->versionSwitchOutput()); exit(0); } diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 3f58f0bfc..6896857ec 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -487,18 +487,7 @@ void Application::showHelp() void Application::showVersion() { - QString helpText; - QTextStream stream(&helpText); - stream << _theme->appName().toLatin1().constData() - << QLatin1String(" version ") - << _theme->version().toLatin1().constData() << endl; -#ifdef GIT_SHA1 - stream << "Git revision " << GIT_SHA1 << endl; -#endif - stream << "Using Qt " << qVersion() << ", built against Qt " << QT_VERSION_STR << endl; - stream << "Using '" << QSslSocket::sslLibraryVersionString() << "'" << endl; - - displayHelpText(helpText); + displayHelpText(Theme::instance()->versionSwitchOutput()); } void Application::showHint(std::string errorHint) diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 828bbf45e..032a6c761 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -505,5 +505,20 @@ QString Theme::oauthClientSecret() const return "UBntmLjC2yYCeHwsyj73Uwo9TAaecAetRwMw0xYcvNL9yRdLSUi0hUAHfvCHFeFh"; } +QString Theme::versionSwitchOutput() const +{ + QString helpText; + QTextStream stream(&helpText); + stream << appName().toLatin1().constData() + << QLatin1String(" version ") + << version().toLatin1().constData() << endl; +#ifdef GIT_SHA1 + stream << "Git revision " << GIT_SHA1 << endl; +#endif + stream << "Using Qt " << qVersion() << ", built against Qt " << QT_VERSION_STR << endl; + stream << "Using '" << QSslSocket::sslLibraryVersionString() << "'" << endl; + return helpText; +} + } // end namespace client diff --git a/src/libsync/theme.h b/src/libsync/theme.h index bb5c858ae..ffc7569b3 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -327,6 +327,14 @@ public: virtual QString oauthClientId() const; virtual QString oauthClientSecret() const; + /** + * @brief What should be output for the --version command line switch. + * + * By default, it's a combination of appName(), version(), the GIT SHA1 and some + * important dependency versions. + */ + virtual QString versionSwitchOutput() const; + protected: #ifndef TOKEN_AUTH_ONLY -- 2.30.2