Added dark tray icon parameter to settings.

This commit is contained in:
Vlad N 2017-10-21 15:16:52 +03:00 committed by Janek Bevendorff
parent f80b5af432
commit 55271311c4
6 changed files with 74 additions and 3 deletions

View File

@ -16,6 +16,7 @@ LastOpenedDatabases=@Invalid()
[GUI] [GUI]
Language=system Language=system
ShowTrayIcon=false ShowTrayIcon=false
DarkTrayIcon=false
MinimizeToTray=false MinimizeToTray=false
MinimizeOnClose=false MinimizeOnClose=false
MinimizeOnStartup=false MinimizeOnStartup=false

View File

@ -98,6 +98,15 @@ QIcon FilePath::applicationIcon()
#endif #endif
} }
QIcon FilePath::applicationIconDark()
{
#ifdef KEEPASSXC_DIST_SNAP
return icon("apps", "keepassxc-dark", false);
#else
return icon("apps", "keepassxc-dark");
#endif
}
QIcon FilePath::trayIconLocked() QIcon FilePath::trayIconLocked()
{ {
#ifdef KEEPASSXC_DIST_SNAP #ifdef KEEPASSXC_DIST_SNAP
@ -116,6 +125,15 @@ QIcon FilePath::trayIconUnlocked()
#endif #endif
} }
QIcon FilePath::trayIconUnlockedDark()
{
#ifdef KEEPASSXC_DIST_SNAP
return icon("apps", "keepassxc-dark", false);
#else
return icon("apps", "keepassxc-dark");
#endif
}
QIcon FilePath::icon(const QString& category, const QString& name, bool fromTheme) QIcon FilePath::icon(const QString& category, const QString& name, bool fromTheme)
{ {
QString combinedName = category + "/" + name; QString combinedName = category + "/" + name;

View File

@ -28,8 +28,10 @@ public:
QString dataPath(const QString& name); QString dataPath(const QString& name);
QString pluginPath(const QString& name); QString pluginPath(const QString& name);
QIcon applicationIcon(); QIcon applicationIcon();
QIcon applicationIconDark();
QIcon trayIconLocked(); QIcon trayIconLocked();
QIcon trayIconUnlocked(); QIcon trayIconUnlocked();
QIcon trayIconUnlockedDark();
QIcon icon(const QString& category, const QString& name, bool fromTheme = true); QIcon icon(const QString& category, const QString& name, bool fromTheme = true);
QIcon onOffIcon(const QString& category, const QString& name); QIcon onOffIcon(const QString& category, const QString& name);

View File

@ -773,9 +773,10 @@ bool MainWindow::saveLastDatabases()
void MainWindow::updateTrayIcon() void MainWindow::updateTrayIcon()
{ {
if (isTrayIconEnabled()) { if (isTrayIconEnabled()) {
bool darkIcon = config()->get("GUI/DarkTrayIcon").toBool();
if (!m_trayIcon) { if (!m_trayIcon) {
m_trayIcon = new QSystemTrayIcon(this); m_trayIcon = new QSystemTrayIcon(this);
QMenu* menu = new QMenu(this); QMenu* menu = new QMenu(this);
QAction* actionToggle = new QAction(tr("Toggle window"), menu); QAction* actionToggle = new QAction(tr("Toggle window"), menu);
@ -795,12 +796,22 @@ void MainWindow::updateTrayIcon()
connect(actionToggle, SIGNAL(triggered()), SLOT(toggleWindow())); connect(actionToggle, SIGNAL(triggered()), SLOT(toggleWindow()));
m_trayIcon->setContextMenu(menu); m_trayIcon->setContextMenu(menu);
if(darkIcon){
m_trayIcon->setIcon(filePath()->applicationIconDark());
} else {
m_trayIcon->setIcon(filePath()->applicationIcon()); m_trayIcon->setIcon(filePath()->applicationIcon());
}
m_trayIcon->show(); m_trayIcon->show();
} }
if (m_ui->tabWidget->hasLockableDatabases()) { if (m_ui->tabWidget->hasLockableDatabases()) {
if(darkIcon){
m_trayIcon->setIcon(filePath()->trayIconUnlockedDark());
} else {
m_trayIcon->setIcon(filePath()->trayIconUnlocked()); m_trayIcon->setIcon(filePath()->trayIconUnlocked());
} }
}
else { else {
m_trayIcon->setIcon(filePath()->trayIconLocked()); m_trayIcon->setIcon(filePath()->trayIconLocked());
} }

View File

@ -136,6 +136,7 @@ void SettingsWidget::loadSettings()
m_generalUi->detailsHideCheckBox->setChecked(config()->get("GUI/HideDetailsView").toBool()); m_generalUi->detailsHideCheckBox->setChecked(config()->get("GUI/HideDetailsView").toBool());
m_generalUi->systrayShowCheckBox->setChecked(config()->get("GUI/ShowTrayIcon").toBool()); m_generalUi->systrayShowCheckBox->setChecked(config()->get("GUI/ShowTrayIcon").toBool());
m_generalUi->systrayDarkIconCheckBox->setChecked(config()->get("GUI/DarkTrayIcon").toBool());
m_generalUi->systrayMinimizeToTrayCheckBox->setChecked(config()->get("GUI/MinimizeToTray").toBool()); m_generalUi->systrayMinimizeToTrayCheckBox->setChecked(config()->get("GUI/MinimizeToTray").toBool());
m_generalUi->systrayMinimizeOnCloseCheckBox->setChecked(config()->get("GUI/MinimizeOnClose").toBool()); m_generalUi->systrayMinimizeOnCloseCheckBox->setChecked(config()->get("GUI/MinimizeOnClose").toBool());
m_generalUi->systrayMinimizeOnStartup->setChecked(config()->get("GUI/MinimizeOnStartup").toBool()); m_generalUi->systrayMinimizeOnStartup->setChecked(config()->get("GUI/MinimizeOnStartup").toBool());
@ -208,6 +209,7 @@ void SettingsWidget::saveSettings()
config()->set("GUI/HideDetailsView", m_generalUi->detailsHideCheckBox->isChecked()); config()->set("GUI/HideDetailsView", m_generalUi->detailsHideCheckBox->isChecked());
config()->set("GUI/ShowTrayIcon", m_generalUi->systrayShowCheckBox->isChecked()); config()->set("GUI/ShowTrayIcon", m_generalUi->systrayShowCheckBox->isChecked());
config()->set("GUI/DarkTrayIcon", m_generalUi->systrayDarkIconCheckBox->isChecked());
config()->set("GUI/MinimizeToTray", m_generalUi->systrayMinimizeToTrayCheckBox->isChecked()); config()->set("GUI/MinimizeToTray", m_generalUi->systrayMinimizeToTrayCheckBox->isChecked());
config()->set("GUI/MinimizeOnClose", m_generalUi->systrayMinimizeOnCloseCheckBox->isChecked()); config()->set("GUI/MinimizeOnClose", m_generalUi->systrayMinimizeOnCloseCheckBox->isChecked());
config()->set("GUI/MinimizeOnStartup", m_generalUi->systrayMinimizeOnStartup->isChecked()); config()->set("GUI/MinimizeOnStartup", m_generalUi->systrayMinimizeOnStartup->isChecked());
@ -265,6 +267,7 @@ void SettingsWidget::enableAutoSaveOnExit(bool checked)
void SettingsWidget::enableSystray(bool checked) void SettingsWidget::enableSystray(bool checked)
{ {
m_generalUi->systrayDarkIconCheckBox->setEnabled(checked);
m_generalUi->systrayMinimizeToTrayCheckBox->setEnabled(checked); m_generalUi->systrayMinimizeToTrayCheckBox->setEnabled(checked);
m_generalUi->systrayMinimizeOnCloseCheckBox->setEnabled(checked); m_generalUi->systrayMinimizeOnCloseCheckBox->setEnabled(checked);
} }

View File

@ -245,6 +245,42 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="systrayDarkIconCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Dark system tray icon</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>