From 1e46bd27277ee0ab398778768a0330b5d523c5d8 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Wed, 5 Mar 2025 00:11:41 -0500 Subject: [PATCH] refactor: move CloseReminder setting to Settings newkeyL gui/closeReminder <= General/showCloseReminder remove closeReminder from `AppConfig` --- src/apps/deskflow-gui/MainWindow.cpp | 4 ++-- src/lib/common/Settings.cpp | 3 ++- src/lib/common/Settings.h | 2 ++ src/lib/gui/config/AppConfig.cpp | 14 +------------- src/lib/gui/config/AppConfig.h | 5 +---- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/apps/deskflow-gui/MainWindow.cpp b/src/apps/deskflow-gui/MainWindow.cpp index 1bbc251d8..1e53ec02d 100644 --- a/src/apps/deskflow-gui/MainWindow.cpp +++ b/src/apps/deskflow-gui/MainWindow.cpp @@ -852,9 +852,9 @@ void MainWindow::showEvent(QShowEvent *event) void MainWindow::closeEvent(QCloseEvent *event) { if (Settings::value(Settings::Gui::CloseToTray).toBool() && event->spontaneous()) { - if (m_appConfig.showCloseReminder()) { + if (Settings::value(Settings::Gui::CloseReminder).toBool()) { messages::showCloseReminder(this); - m_appConfig.setShowCloseReminder(false); + Settings::setValue(Settings::Gui::CloseReminder, false); } qDebug() << "hiding to tray"; hide(); diff --git a/src/lib/common/Settings.cpp b/src/lib/common/Settings.cpp index fc9ba4bfd..350527da1 100644 --- a/src/lib/common/Settings.cpp +++ b/src/lib/common/Settings.cpp @@ -73,7 +73,8 @@ QVariant Settings::defaultValue(const QString &key) return false; } - if ((key == Gui::CloseToTray) || (key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon)) { + if ((key == Gui::CloseToTray) || (key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon) + || (key == Gui::CloseReminder)) { return true; } diff --git a/src/lib/common/Settings.h b/src/lib/common/Settings.h index 83b81b672..7af7602f6 100644 --- a/src/lib/common/Settings.h +++ b/src/lib/common/Settings.h @@ -39,6 +39,7 @@ public: { inline static const auto Autohide = QStringLiteral("gui/autoHide"); inline static const auto AutoUpdateCheck = QStringLiteral("gui/enableUpdateCheck"); + inline static const auto CloseReminder = QStringLiteral("gui/closeReminder"); inline static const auto CloseToTray = QStringLiteral("gui/closeToTray"); inline static const auto LogExpanded = QStringLiteral("gui/logExpanded"); inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon"); @@ -78,6 +79,7 @@ private: , Core::StartedBefore , Gui::Autohide , Gui::AutoUpdateCheck + , Gui::CloseReminder , Gui::CloseToTray , Gui::LogExpanded , Gui::SymbolicTrayIcon diff --git a/src/lib/gui/config/AppConfig.cpp b/src/lib/gui/config/AppConfig.cpp index 68982fc01..65c0a742f 100644 --- a/src/lib/gui/config/AppConfig.cpp +++ b/src/lib/gui/config/AppConfig.cpp @@ -75,7 +75,7 @@ const char *const AppConfig::m_SettingsName[] = { "mainWindowSize", "mainWindowPosition", "", // 41 = Show dev thanks, obsolete - "showCloseReminder", + "", // 42 show Close Reminder moved to deskflow settings "", // 43 Moved to deskflow settings "", // 44, Moved to deskflow settings. "", // 45 Moved to deskflow settings @@ -138,7 +138,6 @@ void AppConfig::recallFromCurrentScope() m_MainWindowPosition = 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(); } void AppConfig::recallScreenName() @@ -189,7 +188,6 @@ void AppConfig::commit() setInCurrentScope(kEnableService, m_EnableService); setInCurrentScope(kMainWindowSize, m_MainWindowSize); setInCurrentScope(kMainWindowPosition, m_MainWindowPosition); - setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder); setInCurrentScope(kRequireClientCert, m_RequireClientCert); } @@ -537,11 +535,6 @@ std::optional AppConfig::mainWindowPosition() const return m_MainWindowPosition; } -bool AppConfig::showCloseReminder() const -{ - return m_ShowCloseReminder; -} - /////////////////////////////////////////////////////////////////////////////// // End getters /////////////////////////////////////////////////////////////////////////////// @@ -689,11 +682,6 @@ void AppConfig::setMainWindowPosition(const QPoint &position) m_MainWindowPosition = position; } -void AppConfig::setShowCloseReminder(bool value) -{ - m_ShowCloseReminder = value; -} - /////////////////////////////////////////////////////////////////////////////// // End setters /////////////////////////////////////////////////////////////////////////////// diff --git a/src/lib/gui/config/AppConfig.h b/src/lib/gui/config/AppConfig.h index 5342eac44..4612957bc 100644 --- a/src/lib/gui/config/AppConfig.h +++ b/src/lib/gui/config/AppConfig.h @@ -97,7 +97,7 @@ private: kMainWindowSize = 39, kMainWindowPosition = 40, // 41 = show dev thanks, obsolete - kShowCloseReminder = 42, + // 42, close reminder moved to deskflow settings // 43 = Enable Update Check, // 44 = LogExpanded, Moved to deskflow settings // 45 = Colorful Icon, Moved to deskflow settings @@ -170,7 +170,6 @@ public: QString lastVersion() const; std::optional mainWindowSize() const; std::optional mainWindowPosition() const; - bool showCloseReminder() const; // // Setters (overrides) @@ -205,7 +204,6 @@ public: void setLastVersion(const QString &version); void setMainWindowSize(const QSize &size); void setMainWindowPosition(const QPoint &position); - void setShowCloseReminder(bool show); /// @brief Sets the user preference to load from SystemScope. /// @param [in] value @@ -304,7 +302,6 @@ private: std::optional m_MainWindowSize; std::optional m_MainWindowPosition; bool m_LoadFromSystemScope = false; - bool m_ShowCloseReminder = true; bool m_RequireClientCert = true; /**