Add option for monochrome tray icon
This commit is contained in:
@@ -93,7 +93,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
||||
{Config::GUI_HidePreviewPanel, {QS("GUI/HidePreviewPanel"), Roaming, false}},
|
||||
{Config::GUI_ToolButtonStyle, {QS("GUI/ToolButtonStyle"), Roaming, Qt::ToolButtonIconOnly}},
|
||||
{Config::GUI_ShowTrayIcon, {QS("GUI/ShowTrayIcon"), Roaming, false}},
|
||||
{Config::GUI_DarkTrayIcon, {QS("GUI/DarkTrayIcon"), Roaming, false}},
|
||||
{Config::GUI_TrayIconAppearance, {QS("GUI/TrayIconAppearance"), Roaming, {}}},
|
||||
{Config::GUI_MinimizeToTray, {QS("GUI/MinimizeToTray"), Roaming, false}},
|
||||
{Config::GUI_MinimizeOnStartup, {QS("GUI/MinimizeOnStartup"), Roaming, false}},
|
||||
{Config::GUI_MinimizeOnClose, {QS("GUI/MinimizeOnClose"), Roaming, false}},
|
||||
@@ -345,7 +345,8 @@ static const QHash<QString, Config::ConfigKey> deprecationMap = {
|
||||
{QS("generator/WordCase"), Config::PasswordGenerator_WordCase},
|
||||
{QS("generator/Type"), Config::PasswordGenerator_Type},
|
||||
{QS("QtErrorMessageShown"), Config::Messages_Qt55CompatibilityWarning},
|
||||
{QS("GUI/HidePasswords"), Config::Deleted}};
|
||||
{QS("GUI/HidePasswords"), Config::Deleted},
|
||||
{QS("GUI/DarkTrayIcon"), Config::Deleted}};
|
||||
|
||||
/**
|
||||
* Migrate settings from previous versions.
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
GUI_HidePreviewPanel,
|
||||
GUI_ToolButtonStyle,
|
||||
GUI_ShowTrayIcon,
|
||||
GUI_DarkTrayIcon,
|
||||
GUI_TrayIconAppearance,
|
||||
GUI_MinimizeToTray,
|
||||
GUI_MinimizeOnStartup,
|
||||
GUI_MinimizeOnClose,
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "core/Config.h"
|
||||
#include "core/Global.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "gui/osutils/OSUtils.h"
|
||||
|
||||
Resources* Resources::m_instance(nullptr);
|
||||
|
||||
@@ -100,19 +101,48 @@ QIcon Resources::applicationIcon()
|
||||
return icon("keepassxc", false);
|
||||
}
|
||||
|
||||
QString Resources::getTrayIconAppearance() const
|
||||
{
|
||||
auto iconAppearance = config()->get(Config::GUI_TrayIconAppearance).toString();
|
||||
if (iconAppearance.isNull()) {
|
||||
#ifdef Q_OS_MACOS
|
||||
iconAppearance = osUtils->isDarkMode() ? "monochrome-light" : "monochrome-dark";
|
||||
#else
|
||||
iconAppearance = "monochrome-light";
|
||||
#endif
|
||||
}
|
||||
return iconAppearance;
|
||||
}
|
||||
|
||||
QIcon Resources::trayIcon()
|
||||
{
|
||||
return useDarkIcon() ? icon("keepassxc-dark", false) : icon("keepassxc", false);
|
||||
return trayIconUnlocked();
|
||||
}
|
||||
|
||||
QIcon Resources::trayIconLocked()
|
||||
{
|
||||
auto iconApperance = getTrayIconAppearance();
|
||||
|
||||
if (iconApperance == "monochrome-light") {
|
||||
return icon("keepassxc-monochrome-light-locked", false);
|
||||
}
|
||||
if (iconApperance == "monochrome-dark") {
|
||||
return icon("keepassxc-monochrome-dark-locked", false);
|
||||
}
|
||||
return icon("keepassxc-locked", false);
|
||||
}
|
||||
|
||||
QIcon Resources::trayIconUnlocked()
|
||||
{
|
||||
return useDarkIcon() ? icon("keepassxc-dark", false) : icon("keepassxc-unlocked", false);
|
||||
auto iconApperance = getTrayIconAppearance();
|
||||
|
||||
if (iconApperance == "monochrome-light") {
|
||||
return icon("keepassxc-monochrome-light", false);
|
||||
}
|
||||
if (iconApperance == "monochrome-dark") {
|
||||
return icon("keepassxc-monochrome-dark", false);
|
||||
}
|
||||
return icon("keepassxc", false);
|
||||
}
|
||||
|
||||
QIcon Resources::icon(const QString& name, bool recolor, const QColor& overrideColor)
|
||||
@@ -223,11 +253,6 @@ bool Resources::testResourceDir(const QString& dir)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Resources::useDarkIcon()
|
||||
{
|
||||
return config()->get(Config::GUI_DarkTrayIcon).toBool();
|
||||
}
|
||||
|
||||
Resources* Resources::instance()
|
||||
{
|
||||
if (!m_instance) {
|
||||
|
||||
@@ -40,9 +40,9 @@ public:
|
||||
static Resources* instance();
|
||||
|
||||
private:
|
||||
QString getTrayIconAppearance() const;
|
||||
Resources();
|
||||
bool testResourceDir(const QString& dir);
|
||||
bool useDarkIcon();
|
||||
|
||||
static Resources* m_instance;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user