refactor move Tray icon setting to Settings

newKey: gui/symbolicTrayIcon <= General/colorfulIcon
the colorfulIcon settings has been removed from `AppConfig`
This commit is contained in:
sithlord48 2025-03-04 23:11:32 -05:00 committed by Nick Bolton
parent bcd90434a2
commit e01c595071
6 changed files with 14 additions and 29 deletions

View file

@ -725,19 +725,19 @@ void MainWindow::setIcon()
// Using a theme icon that is packed in exe renders an invisible icon // Using a theme icon that is packed in exe renders an invisible icon
// Instead use the resource path of the packed icon // Instead use the resource path of the packed icon
// TODO Report to Qt ref the bug here // TODO Report to Qt ref the bug here
const bool symbolicIcon = Settings::value(Settings::Gui::SymbolicTrayIcon).toBool();
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
QString iconString = QStringLiteral(":/icons/deskflow-%1/apps/64/deskflow").arg(iconMode()); QString iconString = QStringLiteral(":/icons/deskflow-%1/apps/64/deskflow").arg(iconMode());
if (!appConfig().colorfulTrayIcon()) { if (symbolicIcon)
iconString.append(QStringLiteral("-symbolic")); iconString.append(QStringLiteral("-symbolic"));
}
m_trayIcon->setIcon(QIcon(iconString)); m_trayIcon->setIcon(QIcon(iconString));
#else #else
if (m_appConfig.colorfulTrayIcon()) { if (symbolicIcon) {
m_trayIcon->setIcon(QIcon::fromTheme(QStringLiteral("deskflow")));
} else {
auto icon = QIcon::fromTheme(QStringLiteral("deskflow-symbolic")); auto icon = QIcon::fromTheme(QStringLiteral("deskflow-symbolic"));
icon.setIsMask(true); icon.setIsMask(true);
m_trayIcon->setIcon(icon); m_trayIcon->setIcon(icon);
} else {
m_trayIcon->setIcon(QIcon::fromTheme(QStringLiteral("deskflow")));
} }
#endif #endif
} }

View file

@ -159,7 +159,7 @@ void SettingsDialog::accept()
m_appConfig.setInvertScrollDirection(ui->cbScrollDirection->isChecked()); m_appConfig.setInvertScrollDirection(ui->cbScrollDirection->isChecked());
m_appConfig.setEnableService(ui->cbServiceEnabled->isChecked()); m_appConfig.setEnableService(ui->cbServiceEnabled->isChecked());
m_appConfig.setCloseToTray(ui->cbCloseToTray->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()); m_appConfig.setRequireClientCerts(ui->cbRequireClientCert->isChecked());
QDialog::accept(); QDialog::accept();
@ -203,10 +203,10 @@ void SettingsDialog::loadFromConfig()
ui->rbScopeUser->setChecked(true); ui->rbScopeUser->setChecked(true);
} }
if (m_appConfig.colorfulTrayIcon()) if (Settings::value(Settings::Gui::SymbolicTrayIcon).toBool())
ui->rbIconColorful->setChecked(true);
else
ui->rbIconMono->setChecked(true); ui->rbIconMono->setChecked(true);
else
ui->rbIconColorful->setChecked(true);
qDebug() << "load from config done"; qDebug() << "load from config done";
updateTlsControls(); updateTlsControls();

View file

@ -73,7 +73,7 @@ QVariant Settings::defaultValue(const QString &key)
return false; return false;
} }
if (key == Gui::LogExpanded) { if ((key == Gui::LogExpanded) || (key == Gui::SymbolicTrayIcon)) {
return true; return true;
} }

View file

@ -38,6 +38,7 @@ public:
{ {
inline static const auto Autohide = QStringLiteral("gui/autoHide"); inline static const auto Autohide = QStringLiteral("gui/autoHide");
inline static const auto LogExpanded = QStringLiteral("gui/logExpanded"); inline static const auto LogExpanded = QStringLiteral("gui/logExpanded");
inline static const auto SymbolicTrayIcon = QStringLiteral("gui/symbolicTrayIcon");
}; };
static Settings *instance(); static Settings *instance();
@ -73,6 +74,7 @@ private:
Core::Scope Core::Scope
, Gui::Autohide , Gui::Autohide
, Gui::LogExpanded , Gui::LogExpanded
, Gui::SymbolicTrayIcon
}; };
// clang-format on // clang-format on
}; };

View file

@ -78,7 +78,7 @@ const char *const AppConfig::m_SettingsName[] = {
"showCloseReminder", "showCloseReminder",
"enableUpdateCheck", "enableUpdateCheck",
"", // 44, Moved to deskflow settings. "", // 44, Moved to deskflow settings.
"colorfulIcon", "", // 45 Moved to deskflow settings
"requireClientCerts", "requireClientCerts",
}; };
@ -142,7 +142,6 @@ void AppConfig::recallFromCurrentScope()
m_MainWindowSize = getFromCurrentScope<QSize>(kMainWindowSize, [](const QVariant &v) { return v.toSize(); }); m_MainWindowSize = getFromCurrentScope<QSize>(kMainWindowSize, [](const QVariant &v) { return v.toSize(); });
m_ShowCloseReminder = getFromCurrentScope(kShowCloseReminder, m_ShowCloseReminder).toBool(); m_ShowCloseReminder = getFromCurrentScope(kShowCloseReminder, m_ShowCloseReminder).toBool();
m_EnableUpdateCheck = getFromCurrentScope<bool>(kEnableUpdateCheck, [](const QVariant &v) { return v.toBool(); }); m_EnableUpdateCheck = getFromCurrentScope<bool>(kEnableUpdateCheck, [](const QVariant &v) { return v.toBool(); });
m_colorfulTrayIcon = getFromCurrentScope(kColorfulIcon, m_colorfulTrayIcon).toBool();
} }
void AppConfig::recallScreenName() void AppConfig::recallScreenName()
@ -197,7 +196,6 @@ void AppConfig::commit()
setInCurrentScope(kMainWindowPosition, m_MainWindowPosition); setInCurrentScope(kMainWindowPosition, m_MainWindowPosition);
setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder); setInCurrentScope(kShowCloseReminder, m_ShowCloseReminder);
setInCurrentScope(kEnableUpdateCheck, m_EnableUpdateCheck); setInCurrentScope(kEnableUpdateCheck, m_EnableUpdateCheck);
setInCurrentScope(kColorfulIcon, m_colorfulTrayIcon);
setInCurrentScope(kRequireClientCert, m_RequireClientCert); setInCurrentScope(kRequireClientCert, m_RequireClientCert);
} }
@ -565,11 +563,6 @@ std::optional<bool> AppConfig::enableUpdateCheck() const
return m_EnableUpdateCheck; return m_EnableUpdateCheck;
} }
bool AppConfig::colorfulTrayIcon() const
{
return m_colorfulTrayIcon;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// End getters // End getters
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -737,13 +730,6 @@ void AppConfig::setEnableUpdateCheck(bool value)
m_EnableUpdateCheck = value; m_EnableUpdateCheck = value;
} }
void AppConfig::setColorfulTrayIcon(bool colorful)
{
if (colorful == m_colorfulTrayIcon)
return;
m_colorfulTrayIcon = colorful;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// End setters // End setters
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View file

@ -100,7 +100,7 @@ private:
kShowCloseReminder = 42, kShowCloseReminder = 42,
kEnableUpdateCheck = 43, kEnableUpdateCheck = 43,
// 44 = LogExpanded, Moved to deskflow settings // 44 = LogExpanded, Moved to deskflow settings
kColorfulIcon = 45, // 45 = Colorful Icon, Moved to deskflow settings
kRequireClientCert = 46 kRequireClientCert = 46
}; };
@ -174,7 +174,6 @@ public:
std::optional<QPoint> mainWindowPosition() const; std::optional<QPoint> mainWindowPosition() const;
bool showCloseReminder() const; bool showCloseReminder() const;
std::optional<bool> enableUpdateCheck() const; std::optional<bool> enableUpdateCheck() const;
bool colorfulTrayIcon() const;
// //
// Setters (overrides) // Setters (overrides)
@ -213,7 +212,6 @@ public:
void setMainWindowPosition(const QPoint &position); void setMainWindowPosition(const QPoint &position);
void setShowCloseReminder(bool show); void setShowCloseReminder(bool show);
void setEnableUpdateCheck(bool value); void setEnableUpdateCheck(bool value);
void setColorfulTrayIcon(bool color);
/// @brief Sets the user preference to load from SystemScope. /// @brief Sets the user preference to load from SystemScope.
/// @param [in] value /// @param [in] value
@ -316,7 +314,6 @@ private:
bool m_LoadFromSystemScope = false; bool m_LoadFromSystemScope = false;
bool m_ShowCloseReminder = true; bool m_ShowCloseReminder = true;
std::optional<bool> m_EnableUpdateCheck; std::optional<bool> m_EnableUpdateCheck;
bool m_colorfulTrayIcon = false;
bool m_RequireClientCert = true; bool m_RequireClientCert = true;
/** /**