diff --git a/gui/common.h b/gui/common.h index 3a780f152..8d42648e6 100644 --- a/gui/common.h +++ b/gui/common.h @@ -90,6 +90,7 @@ #define SETTINGS_SHOW_STATISTICS "Show statistics" #define SETTINGS_OPEN_PROJECT "Open Project" #define SETTINGS_CHECK_VERSION "Check Version" +#define SETTINGS_CHECK_FOR_UPDATES "Check for updates" // The maximum value for the progress bar #define PROGRESS_MAX 1024.0 diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index f5563e9c2..65b303b50 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -258,13 +258,20 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) : connect(mUI->mButtonHideInformation, &QPushButton::clicked, this, &MainWindow::hideInformation); - // Is there a new version? - if (isCppcheckPremium()) { - const QUrl url("https://files.cppchecksolutions.com/version.txt"); - mNetworkAccessManager->get(QNetworkRequest(url)); + if (!mSettings->contains(SETTINGS_CHECK_FOR_UPDATES)) + mSettings->setValue(SETTINGS_CHECK_FOR_UPDATES, isCppcheckPremium()); + + if (mSettings->value(SETTINGS_CHECK_FOR_UPDATES, false).toBool()) { + // Is there a new version? + if (isCppcheckPremium()) { + const QUrl url("https://files.cppchecksolutions.com/version.txt"); + mNetworkAccessManager->get(QNetworkRequest(url)); + } else { + const QUrl url("https://cppcheck.sourceforge.io/version.txt"); + mNetworkAccessManager->get(QNetworkRequest(url)); + } } else { - const QUrl url("https://cppcheck.sourceforge.io/version.txt"); - mNetworkAccessManager->get(QNetworkRequest(url)); + delete mUI->mLayoutInformation; } } @@ -1956,6 +1963,7 @@ void MainWindow::hideInformation() { mSettings->setValue(SETTINGS_CHECK_VERSION, version); mUI->mLabelInformation->setVisible(false); mUI->mButtonHideInformation->setVisible(false); + mUI->mLayoutInformation->deleteLater(); } bool MainWindow::isCppcheckPremium() const { diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 824fd135c..6f7841023 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -62,7 +62,7 @@ - + QLayout::SetDefaultConstraint diff --git a/gui/settings.ui b/gui/settings.ui index 4cd2c93fc..d2a08907b 100644 --- a/gui/settings.ui +++ b/gui/settings.ui @@ -6,8 +6,8 @@ 0 0 - 589 - 346 + 627 + 411 @@ -157,6 +157,13 @@ + + + + Check for updates + + + @@ -293,27 +300,27 @@ Python binary (leave this empty to use python in the PATH) - - - - - - - - - ... - - - - - - - + + + + + + + - + ... - + + + + + + + + + + diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index be83ea9e6..d53b2212d 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -60,6 +60,7 @@ SettingsDialog::SettingsDialog(ApplicationList *list, mUI->mEnableInconclusive->setCheckState(boolToCheckState(settings.value(SETTINGS_INCONCLUSIVE_ERRORS, false).toBool())); mUI->mShowStatistics->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_STATISTICS, false).toBool())); mUI->mShowErrorId->setCheckState(boolToCheckState(settings.value(SETTINGS_SHOW_ERROR_ID, false).toBool())); + mUI->mCheckForUpdates->setCheckState(boolToCheckState(settings.value(SETTINGS_CHECK_FOR_UPDATES, false).toBool())); mUI->mEditPythonPath->setText(settings.value(SETTINGS_PYTHON_PATH, QString()).toString()); validateEditPythonPath(); mUI->mEditMisraFile->setText(settings.value(SETTINGS_MISRA_FILE, QString()).toString()); @@ -182,6 +183,7 @@ void SettingsDialog::saveSettingValues() const saveCheckboxValue(&settings, mUI->mEnableInconclusive, SETTINGS_INCONCLUSIVE_ERRORS); saveCheckboxValue(&settings, mUI->mShowStatistics, SETTINGS_SHOW_STATISTICS); saveCheckboxValue(&settings, mUI->mShowErrorId, SETTINGS_SHOW_ERROR_ID); + saveCheckboxValue(&settings, mUI->mCheckForUpdates, SETTINGS_CHECK_FOR_UPDATES); settings.setValue(SETTINGS_PYTHON_PATH, mUI->mEditPythonPath->text()); settings.setValue(SETTINGS_MISRA_FILE, mUI->mEditMisraFile->text());