GUI: Add setting 'Check for updates'
This commit is contained in:
parent
13d81cdd58
commit
fba70683bc
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QHBoxLayout" name="mLayoutInformation">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>589</width>
|
||||
<height>346</height>
|
||||
<width>627</width>
|
||||
<height>411</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -157,6 +157,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="mCheckForUpdates">
|
||||
<property name="text">
|
||||
<string>Check for updates</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
@ -293,27 +300,27 @@
|
|||
<string>Python binary (leave this empty to use python in the PATH)</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="mEditPythonPath"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="mBtnBrowsePythonPath">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mPythonPathWarning">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="mEditPythonPath"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="mBtnBrowsePythonPath">
|
||||
<property name="text">
|
||||
<string></string>
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mPythonPathWarning">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in New Issue