Skip to content

Commit

Permalink
settings: add option to minimize to tray
Browse files Browse the repository at this point in the history
  • Loading branch information
tobtoht committed Mar 4, 2025
1 parent e55afe9 commit bb10157
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,9 @@ void MainWindow::changeEvent(QEvent* event)
if (conf()->get(Config::lockOnMinimize).toBool()) {
this->lockWallet();
}
if (conf()->get(Config::showTrayIcon).toBool() && conf()->get(Config::minimizeToTray).toBool()) {
this->hide();
}
} else {
QMainWindow::changeEvent(event);
}
Expand Down
22 changes: 15 additions & 7 deletions src/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,6 @@ void Settings::setupDisplayTab() {
conf()->set(Config::hideNotifications, toggled);
});

// [Hide tray icon]
ui->checkBox_hideTrayIcon->setChecked(conf()->get(Config::hideTrayIcon).toBool());
connect(ui->checkBox_hideTrayIcon, &QCheckBox::toggled, [this](bool toggled) {
conf()->set(Config::hideTrayIcon, toggled);
emit hideTrayIcon(toggled);
});

// [Warn before opening external link]
ui->checkBox_warnOnExternalLink->setChecked(conf()->get(Config::warnOnExternalLink).toBool());
connect(ui->checkBox_warnOnExternalLink, &QCheckBox::clicked, this, [this]{
Expand All @@ -315,6 +308,21 @@ void Settings::setupDisplayTab() {
connect(ui->checkBox_lockOnMinimize, &QCheckBox::toggled, [](bool toggled){
conf()->set(Config::lockOnMinimize, toggled);
});

// [Show tray icon]
ui->checkBox_showTrayIcon->setChecked(conf()->get(Config::showTrayIcon).toBool());
connect(ui->checkBox_showTrayIcon, &QCheckBox::toggled, [this](bool toggled) {
conf()->set(Config::showTrayIcon, toggled);
ui->checkBox_minimizeToTray->setEnabled(toggled);
emit showTrayIcon(toggled);
});

// [Hide window to system tray when minimized]
ui->checkBox_minimizeToTray->setEnabled(ui->checkBox_showTrayIcon->isChecked());
ui->checkBox_minimizeToTray->setChecked(conf()->get(Config::minimizeToTray).toBool());
connect(ui->checkBox_minimizeToTray, &QCheckBox::toggled, [this](bool toggled) {
conf()->set(Config::minimizeToTray, toggled);
});
}

void Settings::setupMemoryTab() {
Expand Down
2 changes: 1 addition & 1 deletion src/SettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Q_OBJECT
void preferredFiatCurrencyChanged(QString currency);
void skinChanged(QString skinName);
void hideUpdateNotifications(bool hidden);
void hideTrayIcon(bool hidden);
void showTrayIcon(bool visible);
void websocketStatusChanged(bool enabled);
void proxySettingsChanged();
void updateBalance();
Expand Down
54 changes: 42 additions & 12 deletions src/SettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<layout class="QVBoxLayout" name="verticalLayout_19" stretch="1,1,1,0,1,1,1">
<layout class="QVBoxLayout" name="verticalLayout_19" stretch="1,1,1,1,1,0,0,0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
Expand Down Expand Up @@ -723,17 +723,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QCheckBox" name="checkBox_hideTrayIcon">
<property name="text">
<string>Hide tray icon</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
Expand Down Expand Up @@ -808,6 +797,47 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QCheckBox" name="checkBox_showTrayIcon">
<property name="text">
<string>Show tray icon</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="checkBox_minimizeToTray">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Hide window to system tray when minimized</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
Expand Down
6 changes: 3 additions & 3 deletions src/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ WindowManager::WindowManager(QObject *parent)
m_tray = new QSystemTrayIcon(icons()->icon("appicons/64x64.png"));
m_tray->setToolTip("Feather Wallet");
this->buildTrayMenu();
m_tray->setVisible(!conf()->get(Config::hideTrayIcon).toBool());
m_tray->setVisible(conf()->get(Config::showTrayIcon).toBool());

this->initSkins();
this->patchMacStylesheet();
Expand Down Expand Up @@ -194,8 +194,8 @@ void WindowManager::showSettings(Nodes *nodes, QWidget *parent, bool showProxyTa
window->onHideUpdateNotifications(hidden);
}
});
connect(&settings, &Settings::hideTrayIcon, [this](bool hidden) {
m_tray->setVisible(!hidden);
connect(&settings, &Settings::showTrayIcon, [this](bool visible) {
m_tray->setVisible(visible);
});
connect(&settings, &Settings::pluginConfigured, [this](const QString &id) {
emit pluginConfigured(id);
Expand Down
3 changes: 2 additions & 1 deletion src/utils/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::inactivityLockEnabled, {QS("inactivityLockEnabled"), false}},
{Config::inactivityLockTimeout, {QS("inactivityLockTimeout"), 10}},
{Config::lockOnMinimize, {QS("lockOnMinimize"), false}},
{Config::showTrayIcon, {QS("showTrayIcon"), true}},
{Config::minimizeToTray, {QS("minimizeToTray"), false}},
{Config::disableWebsocket, {QS("disableWebsocket"), false}},
{Config::offlineMode, {QS("offlineMode"), false}},

Expand All @@ -98,7 +100,6 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::hideBalance, {QS("hideBalance"), false}},
{Config::hideNotifications, {QS("hideNotifications"), false}},
{Config::hideUpdateNotifications, {QS("hideUpdateNotifications"), false}},
{Config::hideTrayIcon, {QS("hideTrayIcon"), false}},
{Config::disableLogging, {QS("disableLogging"), true}},
{Config::writeStackTraceToDisk, {QS("writeStackTraceToDisk"), true}},
{Config::writeRecentlyOpenedWallets, {QS("writeRecentlyOpenedWallets"), true}},
Expand Down
3 changes: 2 additions & 1 deletion src/utils/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ class Config : public QObject
hideBalance,
hideUpdateNotifications,
hideNotifications,
hideTrayIcon,
warnOnExternalLink,
inactivityLockEnabled,
inactivityLockTimeout,
lockOnMinimize,
showTrayIcon,
minimizeToTray,

// Transactions
multiBroadcast,
Expand Down

0 comments on commit bb10157

Please sign in to comment.