diff --git a/src/apps/deskflow-gui/MainWindow.cpp b/src/apps/deskflow-gui/MainWindow.cpp index ae84e4ae3..4445fe36e 100644 --- a/src/apps/deskflow-gui/MainWindow.cpp +++ b/src/apps/deskflow-gui/MainWindow.cpp @@ -725,19 +725,19 @@ void MainWindow::setIcon() // Using a theme icon that is packed in exe renders an invisible icon // Instead use the resource path of the packed icon // TODO Report to Qt ref the bug here + const bool symbolicIcon = Settings::value(Settings::Gui::SymbolicTrayIcon).toBool(); #ifndef Q_OS_MAC QString iconString = QStringLiteral(":/icons/deskflow-%1/apps/64/deskflow").arg(iconMode()); - if (!appConfig().colorfulTrayIcon()) { + if (symbolicIcon) iconString.append(QStringLiteral("-symbolic")); - } m_trayIcon->setIcon(QIcon(iconString)); #else - if (m_appConfig.colorfulTrayIcon()) { - m_trayIcon->setIcon(QIcon::fromTheme(QStringLiteral("deskflow"))); - } else { + if (symbolicIcon) { auto icon = QIcon::fromTheme(QStringLiteral("deskflow-symbolic")); icon.setIsMask(true); m_trayIcon->setIcon(icon); + } else { + m_trayIcon->setIcon(QIcon::fromTheme(QStringLiteral("deskflow"))); } #endif } diff --git a/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp b/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp index c8fc9d74e..2e4b2718d 100644 --- a/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp +++ b/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp @@ -159,7 +159,7 @@ void SettingsDialog::accept() m_appConfig.setInvertScrollDirection(ui->cbScrollDirection->isChecked()); m_appConfig.setEnableService(ui->cbServiceEnabled->isChecked()); m_appConfig.setCloseToTray(ui->cbCloseToTray->isChecked()); - m_appConfig.setColorfulTrayIcon(ui->rbIconColorful->isChecked()); + Settings::setValue(Settings::Gui::SymbolicTrayIcon, ui->rbIconMono->isChecked()); m_appConfig.setRequireClientCerts(ui->cbRequireClientCert->isChecked()); QDialog::accept(); @@ -203,10 +203,10 @@ void SettingsDialog::loadFromConfig() ui->rbScopeUser->setChecked(true); } - if (m_appConfig.colorfulTrayIcon()) - ui->rbIconColorful->setChecked(true); - else + if (Settings::value(Settings::Gui::SymbolicTrayIcon).toBool()) ui->rbIconMono->setChecked(true); + else + ui->rbIconColorful->setChecked(true); qDebug() << "load from config done"; updateTlsControls(); diff --git a/src/lib/common/Settings.cpp b/src/lib/common/Settings.cpp index 1944214c9..ff13fa75a 100644 --- a/src/lib/common/Settings.cpp +++ b/src/lib/common/Settings.cpp @@ -73,7 +73,7 @@ QVariant Settings::defaultValue(const QString &key) return false; } - if (key == Gui::LogExpanded) { + if ((key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon)) { return true; } diff --git a/src/lib/common/Settings.h b/src/lib/common/Settings.h index 2d13166eb..362c45f45 100644 --- a/src/lib/common/Settings.h +++ b/src/lib/common/Settings.h @@ -38,6 +38,7 @@ public: { inline static const auto Autohide = QStringLiteral("gui/autoHide"); inline static const auto LogExpanded = QStringLiteral("gui/logExpanded"); + inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon"); }; static Settings *instance(); @@ -73,6 +74,7 @@ private: Core::Scope , Gui::Autohide , Gui::LogExpanded + , Gui::SymbolicTrayIcon }; // clang-format on }; diff --git a/src/lib/gui/config/AppConfig.cpp b/src/lib/gui/config/AppConfig.cpp index 1b3e45560..d1fb38c8c 100644 --- a/src/lib/gui/config/AppConfig.cpp +++ b/src/lib/gui/config/AppConfig.cpp @@ -78,7 +78,7 @@ const char *const AppConfig::m_SettingsName[] = { "showCloseReminder", "enableUpdateCheck", "", // 44, Moved to deskflow settings. - "colorfulIcon", + "", // 45 Moved to deskflow settings "requireClientCerts", }; @@ -142,7 +142,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_colorfulTrayIcon = getFromCurrentScope(kColorfulIcon, m_colorfulTrayIcon).toBool(); } void AppConfig::recallScreenName() @@ -197,7 +196,6 @@ void AppConfig::commit() setInCurrentScope(kMainWindowPosition, m_MainWindowPosition); setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder); setInCurrentScope(kEnableUpdateCheck, m_EnableUpdateCheck); - setInCurrentScope(kColorfulIcon, m_colorfulTrayIcon); setInCurrentScope(kRequireClientCert, m_RequireClientCert); } @@ -565,11 +563,6 @@ std::optional AppConfig::enableUpdateCheck() const return m_EnableUpdateCheck; } -bool AppConfig::colorfulTrayIcon() const -{ - return m_colorfulTrayIcon; -} - /////////////////////////////////////////////////////////////////////////////// // End getters /////////////////////////////////////////////////////////////////////////////// @@ -737,13 +730,6 @@ void AppConfig::setEnableUpdateCheck(bool value) m_EnableUpdateCheck = value; } -void AppConfig::setColorfulTrayIcon(bool colorful) -{ - if (colorful == m_colorfulTrayIcon) - return; - m_colorfulTrayIcon = colorful; -} - /////////////////////////////////////////////////////////////////////////////// // End setters /////////////////////////////////////////////////////////////////////////////// diff --git a/src/lib/gui/config/AppConfig.h b/src/lib/gui/config/AppConfig.h index 03f492f84..aa6fa35dc 100644 --- a/src/lib/gui/config/AppConfig.h +++ b/src/lib/gui/config/AppConfig.h @@ -100,7 +100,7 @@ private: kShowCloseReminder = 42, kEnableUpdateCheck = 43, // 44 = LogExpanded, Moved to deskflow settings - kColorfulIcon = 45, + // 45 = Colorful Icon, Moved to deskflow settings kRequireClientCert = 46 }; @@ -174,7 +174,6 @@ public: std::optional mainWindowPosition() const; bool showCloseReminder() const; std::optional enableUpdateCheck() const; - bool colorfulTrayIcon() const; // // Setters (overrides) @@ -213,7 +212,6 @@ public: void setMainWindowPosition(const QPoint &position); void setShowCloseReminder(bool show); void setEnableUpdateCheck(bool value); - void setColorfulTrayIcon(bool color); /// @brief Sets the user preference to load from SystemScope. /// @param [in] value @@ -316,7 +314,6 @@ private: bool m_LoadFromSystemScope = false; bool m_ShowCloseReminder = true; std::optional m_EnableUpdateCheck; - bool m_colorfulTrayIcon = false; bool m_RequireClientCert = true; /**