diff --git a/src/blackconfig/buildconfig.cpp b/src/blackconfig/buildconfig.cpp index e920e1c19..72bc98b50 100644 --- a/src/blackconfig/buildconfig.cpp +++ b/src/blackconfig/buildconfig.cpp @@ -97,6 +97,11 @@ namespace BlackConfig return QDateTime::currentDateTime() > getEol(); } + int CBuildConfig::daysTillLifetimeExpiry() + { + return QDateTime::currentDateTime().daysTo(getEol()); + } + const QString boolToYesNo(bool v) { return v ? QStringLiteral("yes") : QStringLiteral("no"); diff --git a/src/blackconfig/buildconfig.h b/src/blackconfig/buildconfig.h index 8cbf3f9cf..94c7ef350 100644 --- a/src/blackconfig/buildconfig.h +++ b/src/blackconfig/buildconfig.h @@ -109,6 +109,9 @@ namespace BlackConfig //! Lifetime ended? static bool isLifetimeExpired(); + //! Days till lifetime end + static int daysTillLifetimeExpiry(); + //! Vatsim client id static int vatsimClientId(); // defined in buildconfig_gen.cpp.in diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index d7ae79086..0872ae238 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -1404,14 +1404,21 @@ namespace BlackCore // checks if (CBuildConfig::isLifetimeExpired()) { - this->cmdLineErrorMessage("Program expired " + CBuildConfig::getEol().toString()); + this->cmdLineErrorMessage("Program expired since " + CBuildConfig::getEol().date().toString(), + "This version is no longer supported and usable. You have to install a newer version."); return false; } + if(CBuildConfig::daysTillLifetimeExpiry() <= 30) + { + this->cmdLineWarningMessage("This version will expire in " + QString::number(CBuildConfig::daysTillLifetimeExpiry()) + " days!", + "You'll need to update swift in order to use it thereafter."); + } + const QStringList verifyErrors = CDirectoryUtils::verifyRuntimeDirectoriesAndFiles(); if (!verifyErrors.isEmpty() && !m_applicationInfo.isUnitTest()) { - this->cmdLineErrorMessage("Missing runtime directories/files: " + verifyErrors.join(", ")); + this->cmdLineErrorMessage("Missing runtime directories/files:", verifyErrors.join(", ")); return false; } @@ -1419,13 +1426,13 @@ namespace BlackCore const QStringList args(QCoreApplication::instance()->arguments()); if (!m_parser.parse(args)) { - this->cmdLineErrorMessage(m_parser.errorText()); + this->cmdLineErrorMessage("Parser error:", m_parser.errorText()); return false; } if (m_singleApplication && m_alreadyRunning && !this->skipSingleApplicationCheck()) { - this->cmdLineErrorMessage("Program must only run once"); + this->cmdLineErrorMessage("Program must only run once", "You cannot run two or more instances side-by-side."); return false; } @@ -1461,12 +1468,16 @@ namespace BlackCore return !this->synchronizeSetup(timeoutMs).hasErrorMessages(); } - bool CApplication::cmdLineErrorMessage(const QString &errorMessage, bool retry) const + bool CApplication::cmdLineWarningMessage(const QString &text, const QString &informativeText) const + { + fputs(qPrintable(text + informativeText), stderr); + return false; + } + + bool CApplication::cmdLineErrorMessage(const QString &text, const QString &informativeText, bool retry) const { Q_UNUSED(retry) // only works with UI version - fputs(qPrintable(errorMessage), stderr); - fputs("\n\n", stderr); - fputs(qPrintable(m_parser.helpText()), stderr); + fputs(qPrintable(text + informativeText), stderr); return false; } diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 2b8dbc6cd..c4b6533d7 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -299,8 +299,11 @@ namespace BlackCore //! \see synchronizeSetup virtual bool parseAndSynchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs()); + //! Display warning message + virtual bool cmdLineWarningMessage(const QString &text, const QString &informativeText = "") const; + //! Display error message - virtual bool cmdLineErrorMessage(const QString &cmdLineErrorMessage, bool retry = false) const; + virtual bool cmdLineErrorMessage(const QString &text, const QString &informativeText = "", bool retry = false) const; //! Display error message virtual bool cmdLineErrorMessage(const BlackMisc::CStatusMessageList &msgs, bool retry = false) const; diff --git a/src/blackcore/setupreader.cpp b/src/blackcore/setupreader.cpp index 722034a7c..0b14b5a20 100644 --- a/src/blackcore/setupreader.cpp +++ b/src/blackcore/setupreader.cpp @@ -184,7 +184,7 @@ namespace BlackCore ok = true; break; } - retry = sApp->cmdLineErrorMessage(QStringLiteral("URL '%1' not reachable").arg(urlString), true); + retry = sApp->cmdLineErrorMessage(QStringLiteral("URL '%1' not reachable").arg(urlString), "", true); } while (retry); } diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index e4a11fbb5..ec26957ef 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -590,26 +590,27 @@ namespace BlackGui return "1.0"; } - bool CGuiApplication::cmdLineErrorMessage(const QString &errorMessage, bool retry) const + bool CGuiApplication::cmdLineWarningMessage(const QString &text, const QString &informativeText) const { - const QString helpText(beautifyHelpMessage(m_parser.helpText())); - constexpr int MaxLength = 60; + QMessageBox warningBox(QMessageBox::Warning, QGuiApplication::applicationDisplayName(), "" +text + ""); + warningBox.setInformativeText(informativeText); + return warningBox.exec(); + } - QString htmlMsg; - if (errorMessage.length() > MaxLength) - { - htmlMsg = "