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
// 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
}

View File

@ -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();

View File

@ -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;
}

View File

@ -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
};

View File

@ -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<QSize>(kMainWindowSize, [](const QVariant &v) { return v.toSize(); });
m_ShowCloseReminder = getFromCurrentScope(kShowCloseReminder, m_ShowCloseReminder).toBool();
m_EnableUpdateCheck = getFromCurrentScope<bool>(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<bool> 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
///////////////////////////////////////////////////////////////////////////////

View File

@ -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<QPoint> mainWindowPosition() const;
bool showCloseReminder() const;
std::optional<bool> 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<bool> m_EnableUpdateCheck;
bool m_colorfulTrayIcon = false;
bool m_RequireClientCert = true;
/**