From 4ff29d3b16542d221a943c975912dd9d83874f85 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Fri, 19 Feb 2021 00:41:36 +0100 Subject: [PATCH] Rename lamexp_version_demo() into lamexp_version_test() + small code refactoring in MainWindow::checkForUpdates(). --- src/Dialog_About.cpp | 2 +- src/Dialog_MainWindow.cpp | 40 ++++++++++++++++++++------------------- src/Dialog_MainWindow.h | 2 +- src/Dialog_Update.cpp | 2 +- src/Global.h | 2 +- src/Global_Version.cpp | 4 ++-- src/Main.cpp | 6 +++--- 7 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/Dialog_About.cpp b/src/Dialog_About.cpp index b8e3b131..6b73f515 100644 --- a/src/Dialog_About.cpp +++ b/src/Dialog_About.cpp @@ -581,7 +581,7 @@ void AboutDialog::initInformationTab(void) int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0); aboutText += QString("
%1").arg(QString("!!! --- DEBUG BUILD --- Expires at: %1 · Days left: %2 --- DEBUG BUILD --- !!!").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))); } - else if(lamexp_version_demo()) + else if(lamexp_version_test()) { int daysLeft = qMax(currentDate.daysTo(lamexp_version_expires()), 0); aboutText += QString("
%1").arg(tr("Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))); diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 2c1b3102..4f7a2774 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -712,8 +712,8 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons ui->actionDisableSlowStartupNotifications->setChecked(!m_settings->antivirNotificationsEnabled()); ui->actionDisableShellIntegration->setChecked(!m_settings->shellIntegrationEnabled()); ui->actionDisableShellIntegration->setDisabled(lamexp_version_portable() && ui->actionDisableShellIntegration->isChecked()); - ui->actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta() || lamexp_version_demo()); - ui->actionCheckForBetaUpdates->setEnabled(!lamexp_version_demo()); + ui->actionCheckForBetaUpdates->setChecked(m_settings->autoUpdateCheckBeta() || lamexp_version_test()); + ui->actionCheckForBetaUpdates->setEnabled(!lamexp_version_test()); ui->actionHibernateComputer->setChecked(m_settings->hibernateComputer()); ui->actionHibernateComputer->setEnabled(MUtils::OS::is_hibernation_supported()); connect(ui->actionDisableUpdateReminder, SIGNAL(triggered(bool)), this, SLOT(disableUpdateReminderActionTriggered(bool))); @@ -937,11 +937,14 @@ void MainWindow::addFolder(const QString &path, bool recursive, bool delayed, QS /* * Check for updates */ -bool MainWindow::checkForUpdates(bool &haveNewVersion) +bool MainWindow::checkForUpdates(bool *const haveNewVersion) { - haveNewVersion = false; bool bReadyToInstall = false; - + if (haveNewVersion) + { + *haveNewVersion = false; + } + UpdateDialog *updateDialog = new UpdateDialog(m_settings, this); updateDialog->exec(); @@ -949,8 +952,11 @@ bool MainWindow::checkForUpdates(bool &haveNewVersion) { SHOW_CORNER_WIDGET(false); m_settings->autoUpdateLastCheck(QDate::currentDate().toString(Qt::ISODate)); - haveNewVersion = updateDialog->haveNewVersion(); bReadyToInstall = updateDialog->updateReadyToInstall(); + if (haveNewVersion) + { + *haveNewVersion = updateDialog->haveNewVersion(); + } } MUTILS_DELETE(updateDialog); @@ -1226,7 +1232,7 @@ void MainWindow::changeEvent(QEvent *e) { setWindowTitle(QString("%1 [!!! DEBUG BUILD !!!]").arg(windowTitle())); } - else if(lamexp_version_demo()) + else if(lamexp_version_test()) { setWindowTitle(QString("%1 [%2]").arg(windowTitle(), tr("DEMO VERSION"))); } @@ -1472,7 +1478,7 @@ void MainWindow::windowShown(void) m_settings->licenseAccepted(1); m_settings->syncNow(); PLAY_SOUND_OPTIONAL("woohoo", false); - if (lamexp_version_demo()) + if (lamexp_version_test()) { showAnnounceBox(); } @@ -1511,7 +1517,7 @@ void MainWindow::windowShown(void) } //Check for expiration - if(lamexp_version_demo()) + if(lamexp_version_test()) { if(MUtils::OS::current_date() >= lamexp_version_expires()) { @@ -1520,7 +1526,7 @@ void MainWindow::windowShown(void) bool haveNewVersion = true; if(QMessageBox::warning(this, tr("LameXP - Expired"), NOBREAK(QString("%1
%2").arg(tr("This demo (pre-release) version of LameXP has expired at %1.").arg(lamexp_version_expires().toString(Qt::ISODate)), tr("LameXP is free software and release versions won't expire."))), tr("Check for Updates"), tr("Exit Program")) == 0) { - if (checkForUpdates(haveNewVersion)) + if (checkForUpdates(&haveNewVersion)) { QApplication::quit(); return; @@ -1548,7 +1554,7 @@ void MainWindow::windowShown(void) } //Update reminder - if(MUtils::OS::current_date() >= MUtils::Version::app_build_date().addYears(1)) + if(MUtils::OS::current_date() >= MUtils::Version::app_build_date().addYears(1).addMonths(3)) { qWarning("Binary is more than a year old, time to update!"); SHOW_CORNER_WIDGET(true); @@ -1556,8 +1562,7 @@ void MainWindow::windowShown(void) switch(ret) { case 0: - bool haveNewVersion; - if(checkForUpdates(haveNewVersion)) + if(checkForUpdates()) { QApplication::quit(); return; @@ -1583,8 +1588,7 @@ void MainWindow::windowShown(void) { if(QMessageBox::information(this, tr("Update Reminder"), NOBREAK(lastUpdateCheck.isValid() ? tr("Your last update check was more than 14 days ago. Check for updates now?") : tr("Your did not check for LameXP updates yet. Check for updates now?")), tr("Check for Updates"), tr("Postpone")) == 0) { - bool haveNewVersion; - if(checkForUpdates(haveNewVersion)) + if(checkForUpdates(NULL)) { QApplication::quit(); return; @@ -2278,8 +2282,7 @@ void MainWindow::checkForBetaUpdatesActionTriggered(bool checked) if(checkUpdatesNow) { - bool haveNewVersion; - if(checkForUpdates(haveNewVersion)) + if(checkForUpdates()) { QApplication::quit(); } @@ -2382,8 +2385,7 @@ void MainWindow::checkUpdatesActionActivated(void) ABORT_IF_BUSY; WidgetHideHelper hiderHelper(m_dropBox.data()); - bool haveNewVersion; - if(checkForUpdates(haveNewVersion)) + if(checkForUpdates()) { QApplication::quit(); } diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index 186df919..32ae6a55 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -208,7 +208,7 @@ private: void addFiles(const QStringList &files); void addFolder(const QString &path, bool recursive = false, bool delayed = false, QString filter = QString()); - bool MainWindow::checkForUpdates(bool &haveNewVersion); + bool MainWindow::checkForUpdates(bool *const haveNewVersion = NULL); void initializeTranslation(void); void refreshFavorites(void); void openDocumentLink(QAction *const action); diff --git a/src/Dialog_Update.cpp b/src/Dialog_Update.cpp index 4ed10ff6..3d3afcdd 100644 --- a/src/Dialog_Update.cpp +++ b/src/Dialog_Update.cpp @@ -77,7 +77,7 @@ UpdateDialog::UpdateDialog(const SettingsModel *const settings, QWidget *parent) m_taskbar(new MUtils::Taskbar7(parent)), m_settings(settings), m_logFile(new QStringList()), - m_betaUpdates(settings ? (settings->autoUpdateCheckBeta() || lamexp_version_demo()) : lamexp_version_demo()), + m_betaUpdates(settings ? (settings->autoUpdateCheckBeta() || lamexp_version_test()) : lamexp_version_test()), m_success(false), m_haveNewVersion(false), m_firstShow(true), diff --git a/src/Global.h b/src/Global.h index 94a7f1af..5697ee23 100644 --- a/src/Global.h +++ b/src/Global.h @@ -57,7 +57,7 @@ unsigned int lamexp_version_build (void); unsigned int lamexp_version_confg (void); const char* lamexp_version_release (void); bool lamexp_version_portable (void); -bool lamexp_version_demo (void); +bool lamexp_version_test (void); const QDate& lamexp_version_expires (void); unsigned int lamexp_toolver_neroaac (void); unsigned int lamexp_toolver_fhgaacenc(void); diff --git a/src/Global_Version.cpp b/src/Global_Version.cpp index b59569b3..ceb56a6b 100644 --- a/src/Global_Version.cpp +++ b/src/Global_Version.cpp @@ -97,9 +97,9 @@ const char *lamexp_support_url(void) { return g_lamexp_support_url; } const char *lamexp_tracker_url(void) { return g_lamexp_tracker_url; } /* - * Check for Demo (pre-release) version + * Check for test (pre-release) version */ -bool lamexp_version_demo(void) +bool lamexp_version_test(void) { QReadLocker readLock(&g_lamexp_version_lock); diff --git a/src/Main.cpp b/src/Main.cpp index d3946384..055e7208 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -237,14 +237,14 @@ static int lamexp_main(int &argc, char **argv) lamexp_initialize_resources(); //Check for expiration - if(lamexp_version_demo()) + if(lamexp_version_test()) { const QDate currentDate = MUtils::OS::current_date(); if(currentDate.addDays(1) < MUtils::Version::app_build_date()) { qFatal("System's date (%s) is before LameXP build date (%s). Huh?", currentDate.toString(Qt::ISODate).toLatin1().constData(), MUtils::Version::app_build_date().toString(Qt::ISODate).toLatin1().constData()); } - qWarning(QString("Note: This demo (pre-release) version of LameXP will expire at %1.\n").arg(lamexp_version_expires().toString(Qt::ISODate)).toLatin1().constData()); + qWarning(QString("Note: This test (pre-release) version of LameXP will expire at %1.\n").arg(lamexp_version_expires().toString(Qt::ISODate)).toLatin1().constData()); } //Initialize IPC @@ -291,5 +291,5 @@ static int lamexp_main(int &argc, char **argv) int main(int argc, char* argv[]) { - return MUtils::Startup::startup(argc, argv, lamexp_main, "LameXP", lamexp_version_demo()); + return MUtils::Startup::startup(argc, argv, lamexp_main, "LameXP", lamexp_version_test()); }