diff --git a/src/apps/deskflow-gui/MainWindow.cpp b/src/apps/deskflow-gui/MainWindow.cpp index b44b886181..84ea7090e7 100644 --- a/src/apps/deskflow-gui/MainWindow.cpp +++ b/src/apps/deskflow-gui/MainWindow.cpp @@ -15,7 +15,7 @@ #include "dialogs/SettingsDialog.h" #include "base/String.h" -#include "common/constants.h" +#include "common/Settings.h" #include "gui/Logger.h" #include "gui/config/ConfigScopes.h" #include "gui/constants.h" @@ -226,7 +226,7 @@ void MainWindow::setupControls() // Setup the log toggle, set its initial state to closed ui->btnToggleLog->setStyleSheet(kStyleFlatButton); - if (m_appConfig.logExpanded()) { + if (Settings::value(Settings::Gui::LogExpanded).toBool()) { ui->btnToggleLog->setArrowType(Qt::DownArrow); ui->textLog->setVisible(true); ui->btnToggleLog->click(); @@ -361,14 +361,12 @@ void MainWindow::toggleLogVisible(bool visible) { if (visible) { ui->btnToggleLog->setArrowType(Qt::DownArrow); - ui->textLog->setVisible(true); - m_appConfig.setLogExpanded(true); } else { ui->btnToggleLog->setArrowType(Qt::RightArrow); m_expandedSize = size(); - ui->textLog->setVisible(false); - m_appConfig.setLogExpanded(false); } + ui->textLog->setVisible(visible); + Settings::setValue(Settings::Gui::LogExpanded, visible); // 1 ms delay is to make sure we have left the function before calling updateSize QTimer::singleShot(1, this, &MainWindow::updateSize); } @@ -516,7 +514,7 @@ void MainWindow::resetCore() void MainWindow::updateSize() { - if (m_appConfig.logExpanded()) { + if (Settings::value(Settings::Gui::LogExpanded).toBool()) { setMaximumHeight(16777215); setMaximumWidth(16777215); resize(m_expandedSize); diff --git a/src/lib/common/Settings.cpp b/src/lib/common/Settings.cpp index 35fc502d08..1eed38a92a 100644 --- a/src/lib/common/Settings.cpp +++ b/src/lib/common/Settings.cpp @@ -73,6 +73,10 @@ QVariant Settings::defaultValue(const QString &key) return false; } + if (key == Gui::LogExpanded) { + return true; + } + return QVariant(); } @@ -101,11 +105,11 @@ void Settings::setScope(bool systemScope) const bool wasWritable = instance()->m_settings->isWritable(); QSettings userSettings(Settings::UserSettingFile, QSettings::IniFormat); - userSettings.setValue(Settings::Core::Scope, systemScope); + userSettings.setValue(Core::Scope, systemScope); userSettings.sync(); QSettings systemSettings(Settings::SystemSettingFile, QSettings::IniFormat); - systemSettings.setValue(Settings::Core::Scope, systemScope); + systemSettings.setValue(Core::Scope, systemScope); systemSettings.sync(); instance()->initSettings(); diff --git a/src/lib/common/Settings.h b/src/lib/common/Settings.h index a8ab660175..9e266e2a2f 100644 --- a/src/lib/common/Settings.h +++ b/src/lib/common/Settings.h @@ -34,6 +34,10 @@ public: { inline static const auto Scope = QStringLiteral("core/loadFromSystemScope"); }; + struct Gui + { + inline static const auto LogExpanded = QStringLiteral("gui/logExpanded"); + }; static Settings *instance(); static void setSettingFile(const QString &settingsFile = QString()); @@ -63,5 +67,10 @@ private: QSettings *m_settings = nullptr; QString m_portableSettingsFile = QStringLiteral("%1.conf").arg(kAppName); - inline static const QStringList m_validKeys = {Settings::Core::Scope}; + // clang-format off + inline static const QStringList m_validKeys = { + Core::Scope + , Gui::LogExpanded + }; + // clang-format on }; diff --git a/src/lib/gui/CMakeLists.txt b/src/lib/gui/CMakeLists.txt index 409cb740de..edd5b4feba 100644 --- a/src/lib/gui/CMakeLists.txt +++ b/src/lib/gui/CMakeLists.txt @@ -95,6 +95,7 @@ add_library(${target} STATIC target_link_libraries( ${target} + common platform Qt6::Core Qt6::Widgets diff --git a/src/lib/gui/config/AppConfig.cpp b/src/lib/gui/config/AppConfig.cpp index 00a66eb521..e35e687854 100644 --- a/src/lib/gui/config/AppConfig.cpp +++ b/src/lib/gui/config/AppConfig.cpp @@ -77,7 +77,7 @@ const char *const AppConfig::m_SettingsName[] = { "", // 41 = Show dev thanks, obsolete "showCloseReminder", "enableUpdateCheck", - "logExpanded", + "", // 44, Moved to deskflow settings. "colorfulIcon", "requireClientCerts", }; @@ -143,7 +143,6 @@ void AppConfig::recallFromCurrentScope() 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(); }); - m_logExpanded = getFromCurrentScope(kLogExpanded, m_logExpanded).toBool(); m_colorfulTrayIcon = getFromCurrentScope(kColorfulIcon, m_colorfulTrayIcon).toBool(); } @@ -200,7 +199,6 @@ void AppConfig::commit() setInCurrentScope(kMainWindowPosition, m_MainWindowPosition); setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder); setInCurrentScope(kEnableUpdateCheck, m_EnableUpdateCheck); - setInCurrentScope(kLogExpanded, m_logExpanded); setInCurrentScope(kColorfulIcon, m_colorfulTrayIcon); setInCurrentScope(kRequireClientCert, m_RequireClientCert); } @@ -574,11 +572,6 @@ std::optional AppConfig::enableUpdateCheck() const return m_EnableUpdateCheck; } -bool AppConfig::logExpanded() const -{ - return m_logExpanded; -} - bool AppConfig::colorfulTrayIcon() const { return m_colorfulTrayIcon; @@ -756,13 +749,6 @@ void AppConfig::setEnableUpdateCheck(bool value) m_EnableUpdateCheck = value; } -void AppConfig::setLogExpanded(bool expanded) -{ - if (expanded == m_logExpanded) - return; - m_logExpanded = expanded; -} - void AppConfig::setColorfulTrayIcon(bool colorful) { if (colorful == m_colorfulTrayIcon) diff --git a/src/lib/gui/config/AppConfig.h b/src/lib/gui/config/AppConfig.h index c4472e316a..4f244d5443 100644 --- a/src/lib/gui/config/AppConfig.h +++ b/src/lib/gui/config/AppConfig.h @@ -99,7 +99,7 @@ private: // 41 = show dev thanks, obsolete kShowCloseReminder = 42, kEnableUpdateCheck = 43, - kLogExpanded = 44, + // 44 = LogExpanded, Moved to deskflow settings kColorfulIcon = 45, kRequireClientCert = 46 }; @@ -175,7 +175,6 @@ public: std::optional mainWindowPosition() const; bool showCloseReminder() const; std::optional enableUpdateCheck() const; - bool logExpanded() const; bool colorfulTrayIcon() const; // @@ -216,7 +215,6 @@ public: void setMainWindowPosition(const QPoint &position); void setShowCloseReminder(bool show); void setEnableUpdateCheck(bool value); - void setLogExpanded(bool expanded); void setColorfulTrayIcon(bool color); /// @brief Sets the user preference to load from SystemScope. @@ -321,7 +319,6 @@ private: bool m_LoadFromSystemScope = false; bool m_ShowCloseReminder = true; std::optional m_EnableUpdateCheck; - bool m_logExpanded = true; bool m_colorfulTrayIcon = false; bool m_RequireClientCert = true;