]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
settings: add option to minimize to tray
authortobtoht <tob@featherwallet.org>
Tue, 4 Mar 2025 14:31:34 +0000 (15:31 +0100)
committertobtoht <tob@featherwallet.org>
Tue, 4 Mar 2025 14:31:34 +0000 (15:31 +0100)
src/MainWindow.cpp
src/SettingsDialog.cpp
src/SettingsDialog.h
src/SettingsDialog.ui
src/WindowManager.cpp
src/utils/config.cpp
src/utils/config.h

index 7c3c98afd4d7a42fff8168adbf5fc48206462fd7..aea3a43a52fe52cc391745d85ef20d184d1f0e7b 100644 (file)
@@ -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);
     }
index 988217ebfa7cb0a26328b29d0bf196065acb6628..982fef249e9ff5ccb8836e791c8750f2c29f7d47 100644 (file)
@@ -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]{
@@ -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() {
index b7c68d12da9b6875b83f32a1fa0e00ab556c182c..891fc5d41b5d83bdadb359e3757136484bfaf336 100644 (file)
@@ -36,7 +36,7 @@ signals:
     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();
index ec55040959e23044819589933e6410077ad21575..ccaad42534e9ed6e7b2eb377fde572652ce169e3 100644 (file)
            </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>
                 </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>
                 </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>
index dcf43956928926d4bda1463845adf77573568412..4c0ff302f83e4dea41dc43599a7b1a334a4bbfac 100644 (file)
@@ -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();
@@ -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);
index 7d19207334dc0ba6e7736e329d88a8626ec83904..adaec28aa13c465b42a33f7f52cff074c654f4fd 100644 (file)
@@ -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}},
 
@@ -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}},
index e874e47f45d998372f9e3431993acba35196119c..a4fc86c73050d3400256ee3ccf677499a2900ca3 100644 (file)
@@ -113,11 +113,12 @@ public:
         hideBalance,
         hideUpdateNotifications,
         hideNotifications,
-        hideTrayIcon,
         warnOnExternalLink,
         inactivityLockEnabled,
         inactivityLockTimeout,
         lockOnMinimize,
+        showTrayIcon,
+        minimizeToTray,
 
         // Transactions
         multiBroadcast,