mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Add warning about expire and redesign warning/error popup
Fixes Github Issue #38
This commit is contained in:
committed by
Mat Sutcliffe
parent
189bb15936
commit
1d4aa96e9b
@@ -97,6 +97,11 @@ namespace BlackConfig
|
|||||||
return QDateTime::currentDateTime() > getEol();
|
return QDateTime::currentDateTime() > getEol();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CBuildConfig::daysTillLifetimeExpiry()
|
||||||
|
{
|
||||||
|
return QDateTime::currentDateTime().daysTo(getEol());
|
||||||
|
}
|
||||||
|
|
||||||
const QString boolToYesNo(bool v)
|
const QString boolToYesNo(bool v)
|
||||||
{
|
{
|
||||||
return v ? QStringLiteral("yes") : QStringLiteral("no");
|
return v ? QStringLiteral("yes") : QStringLiteral("no");
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ namespace BlackConfig
|
|||||||
//! Lifetime ended?
|
//! Lifetime ended?
|
||||||
static bool isLifetimeExpired();
|
static bool isLifetimeExpired();
|
||||||
|
|
||||||
|
//! Days till lifetime end
|
||||||
|
static int daysTillLifetimeExpiry();
|
||||||
|
|
||||||
//! Vatsim client id
|
//! Vatsim client id
|
||||||
static int vatsimClientId(); // defined in buildconfig_gen.cpp.in
|
static int vatsimClientId(); // defined in buildconfig_gen.cpp.in
|
||||||
|
|
||||||
|
|||||||
@@ -1404,14 +1404,21 @@ namespace BlackCore
|
|||||||
// checks
|
// checks
|
||||||
if (CBuildConfig::isLifetimeExpired())
|
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;
|
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();
|
const QStringList verifyErrors = CDirectoryUtils::verifyRuntimeDirectoriesAndFiles();
|
||||||
if (!verifyErrors.isEmpty() && !m_applicationInfo.isUnitTest())
|
if (!verifyErrors.isEmpty() && !m_applicationInfo.isUnitTest())
|
||||||
{
|
{
|
||||||
this->cmdLineErrorMessage("Missing runtime directories/files: " + verifyErrors.join(", "));
|
this->cmdLineErrorMessage("Missing runtime directories/files:", verifyErrors.join(", "));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1419,13 +1426,13 @@ namespace BlackCore
|
|||||||
const QStringList args(QCoreApplication::instance()->arguments());
|
const QStringList args(QCoreApplication::instance()->arguments());
|
||||||
if (!m_parser.parse(args))
|
if (!m_parser.parse(args))
|
||||||
{
|
{
|
||||||
this->cmdLineErrorMessage(m_parser.errorText());
|
this->cmdLineErrorMessage("Parser error:", m_parser.errorText());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_singleApplication && m_alreadyRunning && !this->skipSingleApplicationCheck())
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1461,12 +1468,16 @@ namespace BlackCore
|
|||||||
return !this->synchronizeSetup(timeoutMs).hasErrorMessages();
|
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
|
Q_UNUSED(retry) // only works with UI version
|
||||||
fputs(qPrintable(errorMessage), stderr);
|
fputs(qPrintable(text + informativeText), stderr);
|
||||||
fputs("\n\n", stderr);
|
|
||||||
fputs(qPrintable(m_parser.helpText()), stderr);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -299,8 +299,11 @@ namespace BlackCore
|
|||||||
//! \see synchronizeSetup
|
//! \see synchronizeSetup
|
||||||
virtual bool parseAndSynchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs());
|
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
|
//! 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
|
//! Display error message
|
||||||
virtual bool cmdLineErrorMessage(const BlackMisc::CStatusMessageList &msgs, bool retry = false) const;
|
virtual bool cmdLineErrorMessage(const BlackMisc::CStatusMessageList &msgs, bool retry = false) const;
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ namespace BlackCore
|
|||||||
ok = true;
|
ok = true;
|
||||||
break;
|
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);
|
while (retry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -590,26 +590,27 @@ namespace BlackGui
|
|||||||
return "1.0";
|
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()));
|
QMessageBox warningBox(QMessageBox::Warning, QGuiApplication::applicationDisplayName(), "<b>" +text + "</b>");
|
||||||
constexpr int MaxLength = 60;
|
warningBox.setInformativeText(informativeText);
|
||||||
|
return warningBox.exec();
|
||||||
|
}
|
||||||
|
|
||||||
QString htmlMsg;
|
bool CGuiApplication::cmdLineErrorMessage(const QString &text, const QString &informativeText, bool retry) const
|
||||||
if (errorMessage.length() > MaxLength)
|
{
|
||||||
{
|
QMessageBox errorBox(QMessageBox::Critical, QGuiApplication::applicationDisplayName(), "<b>" +text + "</b>");
|
||||||
htmlMsg = "<html><head/><body><h4>" + errorMessage.left(MaxLength) + "..." + "</h4>" +
|
if(informativeText.length() < 300)
|
||||||
"Details: " + errorMessage + "<br><br>";
|
errorBox.setInformativeText(informativeText);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
errorBox.setDetailedText(informativeText);
|
||||||
htmlMsg = "<html><head/><body><h4>" + errorMessage + "</h4>";
|
|
||||||
}
|
errorBox.addButton(QMessageBox::Abort);
|
||||||
htmlMsg += helpText + "</body></html>";
|
if(retry)
|
||||||
|
errorBox.addButton(QMessageBox::Retry);
|
||||||
|
|
||||||
|
const int r = errorBox.exec();
|
||||||
|
|
||||||
const int r = QMessageBox::warning(nullptr,
|
|
||||||
QGuiApplication::applicationDisplayName(),
|
|
||||||
htmlMsg, QMessageBox::Abort, retry ? QMessageBox::Retry : QMessageBox::NoButton);
|
|
||||||
return (r == QMessageBox::Retry);
|
return (r == QMessageBox::Retry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,11 +620,10 @@ namespace BlackGui
|
|||||||
if (!msgs.hasErrorMessages()) { return false; }
|
if (!msgs.hasErrorMessages()) { return false; }
|
||||||
static const CPropertyIndexList propertiesSingle({ CStatusMessage::IndexMessage });
|
static const CPropertyIndexList propertiesSingle({ CStatusMessage::IndexMessage });
|
||||||
static const CPropertyIndexList propertiesMulti({ CStatusMessage::IndexSeverityAsString, CStatusMessage::IndexMessage });
|
static const CPropertyIndexList propertiesMulti({ CStatusMessage::IndexSeverityAsString, CStatusMessage::IndexMessage });
|
||||||
const QString helpText(CGuiApplication::beautifyHelpMessage(m_parser.helpText()));
|
|
||||||
const QString msgsHtml = msgs.toHtml(msgs.size() > 1 ? propertiesMulti : propertiesSingle);
|
const QString msgsHtml = msgs.toHtml(msgs.size() > 1 ? propertiesMulti : propertiesSingle);
|
||||||
const int r = QMessageBox::critical(nullptr,
|
const int r = QMessageBox::critical(nullptr,
|
||||||
QGuiApplication::applicationDisplayName(),
|
QGuiApplication::applicationDisplayName(),
|
||||||
"<html><head><body>" + msgsHtml + "<br><br>" + helpText + "</body></html>", QMessageBox::Abort, retry ? QMessageBox::Retry : QMessageBox::NoButton);
|
"<html><head><body>" + msgsHtml + "</body></html>", QMessageBox::Abort, retry ? QMessageBox::Retry : QMessageBox::NoButton);
|
||||||
return (r == QMessageBox::Retry);
|
return (r == QMessageBox::Retry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,9 +125,14 @@ namespace BlackGui
|
|||||||
//! Set window title
|
//! Set window title
|
||||||
QString setExtraWindowTitle(const QString &extraInfo, QWidget *mainWindowWidget = mainApplicationWidget()) const;
|
QString setExtraWindowTitle(const QString &extraInfo, QWidget *mainWindowWidget = mainApplicationWidget()) const;
|
||||||
|
|
||||||
|
//! \name print warning message
|
||||||
|
//! @{
|
||||||
|
virtual bool cmdLineWarningMessage(const QString &text, const QString &informativeText) const override;
|
||||||
|
//! @}
|
||||||
|
|
||||||
//! \name print messages generated during parsing / cmd handling
|
//! \name print messages generated during parsing / cmd handling
|
||||||
//! @{
|
//! @{
|
||||||
virtual bool cmdLineErrorMessage(const QString &cmdLineErrorMessage, bool retry = false) const override;
|
virtual bool cmdLineErrorMessage(const QString &text, const QString &informativeText = "", bool retry = false) const override;
|
||||||
virtual bool cmdLineErrorMessage(const BlackMisc::CStatusMessageList &msgs, bool retry = false) const override;
|
virtual bool cmdLineErrorMessage(const BlackMisc::CStatusMessageList &msgs, bool retry = false) const override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user