From 788f6c3eb257c07dfa3fee0665f3f26d68230a42 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Tue, 4 Mar 2025 23:25:38 -0500 Subject: [PATCH] refactor: Move update check setting to Settings newkey: gui/enableUpdateCheck <= General/enableUpdateCheck remove update check from `AppConfig` --- src/apps/deskflow-gui/MainWindow.cpp | 8 ++++---- src/apps/deskflow-gui/dialogs/SettingsDialog.cpp | 8 ++------ src/lib/common/Settings.h | 2 ++ src/lib/gui/config/AppConfig.cpp | 14 +------------- src/lib/gui/config/AppConfig.h | 5 +---- 5 files changed, 10 insertions(+), 27 deletions(-) diff --git a/src/apps/deskflow-gui/MainWindow.cpp b/src/apps/deskflow-gui/MainWindow.cpp index 4445fe36e..2393305b7 100644 --- a/src/apps/deskflow-gui/MainWindow.cpp +++ b/src/apps/deskflow-gui/MainWindow.cpp @@ -619,13 +619,13 @@ void MainWindow::serverConnectionConfigureClient(const QString &clientName) void MainWindow::open() { - if (!m_appConfig.enableUpdateCheck().has_value()) { + + if (!Settings::value(Settings::Gui::AutoUpdateCheck).isValid()) { showAndActivate(); - m_appConfig.setEnableUpdateCheck(messages::showUpdateCheckOption(this)); - m_configScopes.save(); + Settings::setValue(Settings::Gui::AutoUpdateCheck, messages::showUpdateCheckOption(this)); } - if (m_appConfig.enableUpdateCheck().value()) { + if (Settings::value(Settings::Gui::AutoUpdateCheck).toBool()) { m_versionChecker.checkLatest(); } else { qDebug() << "update check disabled"; diff --git a/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp b/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp index 2e4b2718d..8e6237774 100644 --- a/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp +++ b/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp @@ -150,7 +150,7 @@ void SettingsDialog::accept() m_appConfig.setLogFilename(ui->lineLogFilename->text()); m_appConfig.setElevateMode(static_cast(ui->comboElevate->currentIndex())); Settings::setValue(Settings::Gui::Autohide, ui->cbAutoHide->isChecked()); - m_appConfig.setEnableUpdateCheck(ui->cbAutoUpdate->isChecked()); + Settings::setValue(Settings::Gui::AutoUpdateCheck, ui->cbAutoUpdate->isChecked()); m_appConfig.setPreventSleep(ui->cbPreventSleep->isChecked()); m_appConfig.setTlsCertPath(ui->lineTlsCertPath->text()); m_appConfig.setTlsKeyLength(ui->comboTlsKeyLength->currentText().toInt()); @@ -191,11 +191,7 @@ void SettingsDialog::loadFromConfig() ui->cbCloseToTray->setChecked(m_appConfig.closeToTray()); ui->comboElevate->setCurrentIndex(static_cast(m_appConfig.elevateMode())); - if (m_appConfig.enableUpdateCheck().has_value()) { - ui->cbAutoUpdate->setChecked(m_appConfig.enableUpdateCheck().value()); - } else { - ui->cbAutoUpdate->setChecked(false); - } + ui->cbAutoUpdate->setChecked(Settings::value(Settings::Gui::Autohide).toBool()); if (m_appConfig.isActiveScopeSystem()) { ui->rbScopeSystem->setChecked(true); diff --git a/src/lib/common/Settings.h b/src/lib/common/Settings.h index 362c45f45..e088f170c 100644 --- a/src/lib/common/Settings.h +++ b/src/lib/common/Settings.h @@ -37,6 +37,7 @@ public: struct Gui { inline static const auto Autohide = QStringLiteral("gui/autoHide"); + inline static const auto AutoUpdateCheck = QStringLiteral("gui/enableUpdateCheck"); inline static const auto LogExpanded = QStringLiteral("gui/logExpanded"); inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon"); }; @@ -73,6 +74,7 @@ private: inline static const QStringList m_validKeys = { Core::Scope , Gui::Autohide + , Gui::AutoUpdateCheck , Gui::LogExpanded , Gui::SymbolicTrayIcon }; diff --git a/src/lib/gui/config/AppConfig.cpp b/src/lib/gui/config/AppConfig.cpp index d1fb38c8c..276487aa8 100644 --- a/src/lib/gui/config/AppConfig.cpp +++ b/src/lib/gui/config/AppConfig.cpp @@ -76,7 +76,7 @@ const char *const AppConfig::m_SettingsName[] = { "mainWindowPosition", "", // 41 = Show dev thanks, obsolete "showCloseReminder", - "enableUpdateCheck", + "", // 43 Moved to deskflow settings "", // 44, Moved to deskflow settings. "", // 45 Moved to deskflow settings "requireClientCerts", @@ -141,7 +141,6 @@ void AppConfig::recallFromCurrentScope() getFromCurrentScope(kMainWindowPosition, [](const QVariant &v) { return v.toPoint(); }); m_MainWindowSize = getFromCurrentScope(kMainWindowSize, [](const QVariant &v) { return v.toSize(); }); m_ShowCloseReminder = getFromCurrentScope(kShowCloseReminder, m_ShowCloseReminder).toBool(); - m_EnableUpdateCheck = getFromCurrentScope(kEnableUpdateCheck, [](const QVariant &v) { return v.toBool(); }); } void AppConfig::recallScreenName() @@ -195,7 +194,6 @@ void AppConfig::commit() setInCurrentScope(kMainWindowSize, m_MainWindowSize); setInCurrentScope(kMainWindowPosition, m_MainWindowPosition); setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder); - setInCurrentScope(kEnableUpdateCheck, m_EnableUpdateCheck); setInCurrentScope(kRequireClientCert, m_RequireClientCert); } @@ -558,11 +556,6 @@ bool AppConfig::showCloseReminder() const return m_ShowCloseReminder; } -std::optional AppConfig::enableUpdateCheck() const -{ - return m_EnableUpdateCheck; -} - /////////////////////////////////////////////////////////////////////////////// // End getters /////////////////////////////////////////////////////////////////////////////// @@ -725,11 +718,6 @@ void AppConfig::setShowCloseReminder(bool value) m_ShowCloseReminder = value; } -void AppConfig::setEnableUpdateCheck(bool value) -{ - m_EnableUpdateCheck = value; -} - /////////////////////////////////////////////////////////////////////////////// // End setters /////////////////////////////////////////////////////////////////////////////// diff --git a/src/lib/gui/config/AppConfig.h b/src/lib/gui/config/AppConfig.h index aa6fa35dc..bc8d0b364 100644 --- a/src/lib/gui/config/AppConfig.h +++ b/src/lib/gui/config/AppConfig.h @@ -98,7 +98,7 @@ private: kMainWindowPosition = 40, // 41 = show dev thanks, obsolete kShowCloseReminder = 42, - kEnableUpdateCheck = 43, + // 43 = Enable Update Check, // 44 = LogExpanded, Moved to deskflow settings // 45 = Colorful Icon, Moved to deskflow settings kRequireClientCert = 46 @@ -173,7 +173,6 @@ public: std::optional mainWindowSize() const; std::optional mainWindowPosition() const; bool showCloseReminder() const; - std::optional enableUpdateCheck() const; // // Setters (overrides) @@ -211,7 +210,6 @@ public: void setMainWindowSize(const QSize &size); void setMainWindowPosition(const QPoint &position); void setShowCloseReminder(bool show); - void setEnableUpdateCheck(bool value); /// @brief Sets the user preference to load from SystemScope. /// @param [in] value @@ -313,7 +311,6 @@ private: std::optional m_MainWindowPosition; bool m_LoadFromSystemScope = false; bool m_ShowCloseReminder = true; - std::optional m_EnableUpdateCheck; bool m_RequireClientCert = true; /**