mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Settings update: Fix broken UpdateManger logic
In commit b76c1846bb
("Settings update: Simplify Update Manager")
the logic for when to show the UpdateManger question to the user got
broken. Unintuitively, a boolean setting actually has three possible
values. True, False, and Unset. This patch fixes things to work as
designed again.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f745a25cb7
commit
1bf76dd3db
4 changed files with 10 additions and 1 deletions
|
@ -45,6 +45,7 @@ enum deco_mode {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool dont_check_for_updates;
|
bool dont_check_for_updates;
|
||||||
|
bool dont_check_exists;
|
||||||
char *last_version_used;
|
char *last_version_used;
|
||||||
char *next_check;
|
char *next_check;
|
||||||
} update_manager_prefs_t;
|
} update_manager_prefs_t;
|
||||||
|
|
|
@ -78,6 +78,11 @@ bool UpdateManagerSettings::dontCheckForUpdates() const
|
||||||
return prefs.update_manager.dont_check_for_updates;
|
return prefs.update_manager.dont_check_for_updates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UpdateManagerSettings::dontCheckExists() const
|
||||||
|
{
|
||||||
|
return prefs.update_manager.dont_check_exists;
|
||||||
|
}
|
||||||
|
|
||||||
QString UpdateManagerSettings::lastVersionUsed() const
|
QString UpdateManagerSettings::lastVersionUsed() const
|
||||||
{
|
{
|
||||||
return prefs.update_manager.last_version_used;
|
return prefs.update_manager.last_version_used;
|
||||||
|
@ -94,6 +99,7 @@ void UpdateManagerSettings::setDontCheckForUpdates(bool value)
|
||||||
s.beginGroup(group);
|
s.beginGroup(group);
|
||||||
s.setValue("DontCheckForUpdates", value);
|
s.setValue("DontCheckForUpdates", value);
|
||||||
prefs.update_manager.dont_check_for_updates = value;
|
prefs.update_manager.dont_check_for_updates = value;
|
||||||
|
prefs.update_manager.dont_check_exists = true;
|
||||||
emit dontCheckForUpdatesChanged(value);
|
emit dontCheckForUpdatesChanged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1934,6 +1940,7 @@ void SettingsObjectWrapper::load()
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("UpdateManager");
|
s.beginGroup("UpdateManager");
|
||||||
|
prefs.update_manager.dont_check_exists = s.contains("DontCheckForUpdates");
|
||||||
prefs.update_manager.dont_check_for_updates = s.value("DontCheckForUpdates").toBool();
|
prefs.update_manager.dont_check_for_updates = s.value("DontCheckForUpdates").toBool();
|
||||||
prefs.update_manager.last_version_used = copy_string(qPrintable(s.value("LastVersionUsed").toString()));
|
prefs.update_manager.last_version_used = copy_string(qPrintable(s.value("LastVersionUsed").toString()));
|
||||||
prefs.update_manager.next_check = copy_string(qPrintable(s.value("NextCheck").toString()));
|
prefs.update_manager.next_check = copy_string(qPrintable(s.value("NextCheck").toString()));
|
||||||
|
|
|
@ -47,6 +47,7 @@ class UpdateManagerSettings : public QObject {
|
||||||
public:
|
public:
|
||||||
UpdateManagerSettings(QObject *parent);
|
UpdateManagerSettings(QObject *parent);
|
||||||
bool dontCheckForUpdates() const;
|
bool dontCheckForUpdates() const;
|
||||||
|
bool dontCheckExists() const;
|
||||||
QString lastVersionUsed() const;
|
QString lastVersionUsed() const;
|
||||||
QDate nextCheck() const;
|
QDate nextCheck() const;
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ void UpdateManager::requestReceived()
|
||||||
}
|
}
|
||||||
if (isAutomaticCheck) {
|
if (isAutomaticCheck) {
|
||||||
auto update_settings = SettingsObjectWrapper::instance()->update_manager_settings;
|
auto update_settings = SettingsObjectWrapper::instance()->update_manager_settings;
|
||||||
if (!update_settings->dontCheckForUpdates()) {
|
if (!update_settings->dontCheckExists()) {
|
||||||
|
|
||||||
// we allow an opt out of future checks
|
// we allow an opt out of future checks
|
||||||
QMessageBox response(MainWindow::instance());
|
QMessageBox response(MainWindow::instance());
|
||||||
|
|
Loading…
Add table
Reference in a new issue