diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index fc574c00e..5ca2afe68 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -1459,9 +1459,10 @@ namespace BlackCore Q_UNREACHABLE(); } - void CApplication::cmdLineVersionMessage() const + void CApplication::cmdLineVersionMessage() { - printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion())); + m_parser.showVersion(); // terminates + Q_UNREACHABLE(); } QStringList CApplication::argumentsJoined(const QStringList &newArguments, const QStringList &removeArguments) const diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 4726bca0c..37d51999b 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -595,12 +595,6 @@ namespace BlackCore //! Init class, allows to init from BlackGui::CGuiApplication as well (pseudo virtual) void init(bool withMetadata); - //! Display help message - virtual void cmdLineHelpMessage(); - - //! Display version message - virtual void cmdLineVersionMessage() const; - //! Is the command line option represented in the given arguments? static int indexOfCommandLineOption(const QCommandLineOption &option, const QStringList &args = CApplication::arguments()); @@ -660,6 +654,12 @@ namespace BlackCore //! Read the setup BlackMisc::CStatusMessageList loadSetup(); + //! Display help message + void cmdLineHelpMessage(); + + //! Display version message + void cmdLineVersionMessage(); + //! Problem with network access manager void onChangedNetworkAccessibility(QNetworkAccessManager::NetworkAccessibility accessible); diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index cd049bdd5..c1b300a34 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -469,52 +469,6 @@ namespace BlackGui } } - QString CGuiApplication::beautifyHelpMessage(const QString &helpText) - { - // just formatting Qt help message into HTML table - if (helpText.isEmpty()) { return {}; } - const QStringList lines(helpText.split('\n')); - QString html; - bool tableMode = false; - bool pendingTr = false; - for (const QString &l : lines) - { - QString lt(l.trimmed()); - if (!tableMode && lt.startsWith("-")) - { - tableMode = true; - html += "\n"; - } - if (!tableMode) - { - html += l.toHtmlEscaped(); - html += "
"; - } - else - { - // in table mode - if (lt.startsWith("-")) - { - if (pendingTr) - { - html += "\n"; - } - html += "
"; - thread_local const QRegularExpression reg("[ ]{2,}"); - html += lt.replace(reg, ""); - pendingTr = true; - } - else - { - html += " "; - html += l.simplified().toHtmlEscaped(); - } - } - } - html += "
\n"; - return html; - } - double CGuiApplication::parseScaleFactor(int argc, char *argv[]) { for (int i = 1; i < argc; ++i) @@ -1098,35 +1052,6 @@ namespace BlackGui return c; } - void CGuiApplication::cmdLineHelpMessage() - { - if (CBuildConfig::isRunningOnWindowsNtPlatform()) - { - const QString helpText(CGuiApplication::beautifyHelpMessage(m_parser.helpText())); - QMessageBox::information(nullptr, QGuiApplication::applicationDisplayName(), - "" + helpText + ""); - } - else - { - CApplication::cmdLineHelpMessage(); - } - } - - void CGuiApplication::cmdLineVersionMessage() const - { - if (CBuildConfig::isRunningOnWindowsNtPlatform()) - { - QMessageBox::information(nullptr, - QGuiApplication::applicationDisplayName(), - QGuiApplication::applicationDisplayName() + ' ' + - QCoreApplication::applicationVersion()); - } - else - { - CApplication::cmdLineVersionMessage(); - } - } - bool CGuiApplication::parsingHookIn() { return true; diff --git a/src/blackgui/guiapplication.h b/src/blackgui/guiapplication.h index 52fbb3638..4dd7e1dbe 100644 --- a/src/blackgui/guiapplication.h +++ b/src/blackgui/guiapplication.h @@ -309,12 +309,6 @@ namespace BlackGui void alwaysOnTop(bool onTop); protected: - //! @{ - //! print messages generated during parsing / cmd handling - virtual void cmdLineHelpMessage() override; - virtual void cmdLineVersionMessage() const override; - //! @} - //! Handle parsing of special GUI cmd arguments virtual bool parsingHookIn() override; @@ -354,9 +348,6 @@ namespace BlackGui BlackMisc::CSettingReadOnly m_guiSettings { this, &CGuiApplication::settingsChanged }; BlackMisc::CSettingReadOnly m_updateSetting { this }; //!< update notification settings - //! Qt help message to formatted HTML - static QString beautifyHelpMessage(const QString &helpText); - //! Reload widget style from settings void settingsChanged();