]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
Fix minimize to tray. Add setting: toggle focus on tray left-click.
authorgg <chown_tee@proton.me>
Mon, 12 Jan 2026 15:52:44 +0000 (10:52 -0500)
committergg <chown_tee@proton.me>
Mon, 12 Jan 2026 17:39:11 +0000 (12:39 -0500)
setup_flags.sh [deleted file]
src/MainWindow.cpp
src/SettingsDialog.cpp
src/SettingsDialog.ui
src/WindowManager.cpp
src/WindowManager.h
src/libwalletqt/Wallet.cpp
src/libwalletqt/Wallet.h
src/utils/config.cpp
src/utils/config.h

diff --git a/setup_flags.sh b/setup_flags.sh
deleted file mode 100644 (file)
index 9112cf7..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-
-# Configure CMake with custom flags
-# - FEATHER_VERSION_DEBUG_BUILD=ON : Use git describe for version string
-# - CHECK_UPDATES=OFF              : Disable built-in update checker
-# - USE_DEVICE_TREZOR=OFF          : Disable Trezor hardware wallet support
-# - WITH_SCANNER=OFF               : Disable webcam QR scanner support
-
-cmake \
-    -DCMAKE_BUILD_TYPE=Debug \
-    -DFEATHER_VERSION_DEBUG_BUILD=ON \
-    -DCHECK_UPDATES=OFF \
-    -DUSE_DEVICE_TREZOR=OFF \
-    -DWITH_SCANNER=OFF \
-    ..
index fbcbc010848261feb142dfd410b594248acb1fd3..e0645c4ac1734e8cef66613391578a7703b2a79f 100644 (file)
@@ -1523,31 +1523,6 @@ void MainWindow::closeEvent(QCloseEvent *event) {
 void MainWindow::showEvent(QShowEvent *event)
 {
     QMainWindow::showEvent(event);
-    qDebug() << "MainWindow::showEvent. WindowHandle:" << this->windowHandle();
-    if (auto *window = this->windowHandle()) {
-        if (!m_visibilityConnection) {
-            m_visibilityConnection = connect(window, &QWindow::visibilityChanged, this, [this](QWindow::Visibility visibility){
-                qDebug() << "Visibility changed:" << visibility << " WindowState:" << this->windowHandle()->windowState();
-                if (visibility == QWindow::Minimized || this->windowHandle()->windowState() & Qt::WindowMinimized) {
-                    if (conf()->get(Config::lockOnMinimize).toBool()) {
-                        this->lockWallet();
-                    }
-
-                    bool showTray = conf()->get(Config::showTrayIcon).toBool();
-                    bool minimizeToTray = conf()->get(Config::minimizeToTray).toBool();
-
-                    qInfo() << "Visibility: Minimized. Tray=" << showTray << " MinToTray=" << minimizeToTray;
-
-                    if (showTray && minimizeToTray) {
-                        this->hide();
-                    }
-                }
-            });
-            qDebug() << "Connected to visibilityChanged signal:" << (bool)m_visibilityConnection;
-        }
-    } else {
-        qDebug() << "MainWindow::showEvent: No window handle available!";
-    }
 }
 
 void MainWindow::changeEvent(QEvent* event)
@@ -1573,21 +1548,22 @@ void MainWindow::changeEvent(QEvent* event)
             }
         }
     } else if (event->type() == QEvent::ActivationChange) {
-        auto winHandleState = this->windowHandle() ? this->windowHandle()->windowState() : Qt::WindowNoState;
-        qInfo() << "changeEvent: ActivationChange. State:" << this->windowState() << " isActive:" << this->isActiveWindow() << " WinHandleState:" << winHandleState;
-        if (this->windowHandle() && (this->windowHandle()->windowState() & Qt::WindowMinimized || this->isMinimized())) {
-             qInfo() << "changeEvent: ActivationChange -> detected Minimized state";
-             if (conf()->get(Config::lockOnMinimize).toBool()) {
-                this->lockWallet();
-            }
-
-            bool showTray = conf()->get(Config::showTrayIcon).toBool();
-            bool minimizeToTray = conf()->get(Config::minimizeToTray).toBool();
+        qInfo() << "changeEvent: ActivationChange. Active:" << this->isActiveWindow();
+        QTimer::singleShot(500, this, [this](){
+            auto handle = this->windowHandle();
+            if (handle && !handle->isExposed()) {
+                qInfo() << "ActivationChange (delayed): Window not exposed -> Hiding to tray";
+                if (conf()->get(Config::lockOnMinimize).toBool()) {
+                    this->lockWallet();
+                }
 
-            if (showTray && minimizeToTray) {
-                this->hide();
+                bool showTray = conf()->get(Config::showTrayIcon).toBool();
+                bool minimizeToTray = conf()->get(Config::minimizeToTray).toBool();
+                if (showTray && minimizeToTray) {
+                    this->hide();
+                }
             }
-        }
+        });
     }
 }
 
index 982fef249e9ff5ccb8836e791c8750f2c29f7d47..9dabad09583ef63a7d79fb71c7fd8a589ee0a881 100644 (file)
@@ -314,6 +314,7 @@ void Settings::setupDisplayTab() {
     connect(ui->checkBox_showTrayIcon, &QCheckBox::toggled, [this](bool toggled) {
         conf()->set(Config::showTrayIcon, toggled);
         ui->checkBox_minimizeToTray->setEnabled(toggled);
+        ui->checkBox_trayLeftClickToggles->setEnabled(toggled);
         emit showTrayIcon(toggled);
     });
 
@@ -323,6 +324,13 @@ void Settings::setupDisplayTab() {
     connect(ui->checkBox_minimizeToTray, &QCheckBox::toggled, [this](bool toggled) {
         conf()->set(Config::minimizeToTray, toggled);
     });
+
+    // [Left click system tray icon to toggle focus]
+    ui->checkBox_trayLeftClickToggles->setEnabled(ui->checkBox_showTrayIcon->isChecked());
+    ui->checkBox_trayLeftClickToggles->setChecked(conf()->get(Config::trayLeftClickToggles).toBool());
+    connect(ui->checkBox_trayLeftClickToggles, &QCheckBox::toggled, [this](bool toggled) {
+        conf()->set(Config::trayLeftClickToggles, toggled);
+    });
 }
 
 void Settings::setupMemoryTab() {
index ccaad42534e9ed6e7b2eb377fde572652ce169e3..f4f01107eb8d65a7f8224237bf0a9d6f61360c35 100644 (file)
                 </item>
                </layout>
               </item>
+              <item>
+               <layout class="QHBoxLayout" name="horizontalLayout_17">
+                <item>
+                 <spacer name="horizontalSpacer_3">
+                  <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_trayLeftClickToggles">
+                  <property name="enabled">
+                   <bool>false</bool>
+                  </property>
+                  <property name="text">
+                   <string>Left click system tray icon to toggle focus</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </item>
              </layout>
             </item>
             <item>
index 48daf0082be0fa06c5095423f0bbe909a14a6b35..d3f72c48eda91d73c49f4f9068978db8c16f8273 100644 (file)
@@ -7,7 +7,6 @@
 #include <QInputDialog>
 #include <QMessageBox>
 #include <QWindow>
-#include <QFontMetrics>
 
 #include "Application.h"
 #include "constants.h"
@@ -48,6 +47,24 @@ WindowManager::WindowManager(QObject *parent)
     this->buildTrayMenu();
     m_tray->setVisible(conf()->get(Config::showTrayIcon).toBool());
 
+    connect(m_tray, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) {
+        if (reason == QSystemTrayIcon::Trigger) {
+            if (conf()->get(Config::trayLeftClickToggles).toBool()) {
+                for (const auto &window : m_windows) {
+                    if (window->isVisible()) {
+                        window->hide();
+                    } else {
+                        window->show();
+                        window->raise();
+                        window->activateWindow();
+                    }
+                }
+            } else {
+                m_tray->contextMenu()->popup(QCursor::pos());
+            }
+        }
+    });
+
     this->initSkins();
     this->patchMacStylesheet();
 
@@ -95,6 +112,12 @@ void WindowManager::quitAfterLastWindow() {
 void WindowManager::close() {
     qDebug() << Q_FUNC_INFO << QThread::currentThreadId();
 
+    if (m_closing) {
+        return;
+    }
+    m_closing = true;
+
+
     // Stop all threads before application shutdown to avoid QThreadStorage warnings
     if (m_cleanupThread && m_cleanupThread->isRunning()) {
         m_cleanupThread->quit();
@@ -102,6 +125,13 @@ void WindowManager::close() {
         qDebug() << "WindowManager: cleanup thread stopped in close()";
     }
 
+    // Close all windows first to ensure they cancel their tasks/connections
+    // Iterate over a copy because close() modifies m_windows
+    auto windows = m_windows;
+    for (const auto &window: windows) {
+        window->close();
+    }
+
     // Stop Tor manager threads
     torManager()->stop();
 
@@ -112,10 +142,6 @@ void WindowManager::close() {
         std::_Exit(1);  // Fast exit without cleanup - threads may still hold resources
     }
 
-    for (const auto &window: m_windows) {
-        window->close();
-    }
-
     if (m_splashDialog) {
         m_splashDialog->deleteLater();
     }
@@ -656,14 +682,7 @@ void WindowManager::buildTrayMenu() {
 
     for (const auto &window : m_windows) {
         QString name = window->walletName();
-        QString displayName = name;
-        if (name.length() > 20) {
-            displayName = name.left(17) + "...";
-        }
-
-        QMenu *submenu = menu->addMenu(displayName);
-        submenu->setToolTip(name);
-        submenu->menuAction()->setToolTip(name);
+        QMenu *submenu = menu->addMenu(name);
         submenu->addAction("Show/Hide", window, &MainWindow::showOrHide);
         submenu->addAction("Close", window, &MainWindow::close);
     }
index d0f3e46073a969d9a9854b24df47ba0fb45d01c2..54690e2e5a1ec35e4e7b642755a001cc5d273aa0 100644 (file)
@@ -113,6 +113,7 @@ private:
     bool m_openWalletTriedOnce = false;
     bool m_openingWallet = false;
     bool m_initialNetworkConfigured = false;
+    bool m_closing = false;
 
     QThread *m_cleanupThread;
 };
index df7179cb69b6c5fbb634aec9199310d5594fbbd7..cfde59f52489390b5d43fa86cfe7618f14fdedbf 100644 (file)
@@ -561,15 +561,6 @@ quint64 Wallet::daemonBlockChainTargetHeight() const {
     return m_daemonBlockChainTargetHeight;
 }
 
-void Wallet::syncStatusUpdated(quint64 height, quint64 target) {
-    if (height >= (target - 1)) {
-        // TODO: is this needed?
-        this->updateBalance();
-    }
-
-    emit syncStatus(height, target, false);
-}
-
 void Wallet::setSyncPaused(bool paused) {
     m_syncPaused = paused;
     if (paused) {
index 4341efe2051bbd7aee05459b930eaa597d367dca..d09604e46c2a778c31774709188fd628607882cc 100644 (file)
@@ -458,7 +458,6 @@ signals:
     void connectionStatusChanged(int status) const;
     void currentSubaddressAccountChanged() const;
 
-
     void syncStatus(quint64 height, quint64 target, bool daemonSync = false);
 
     void balanceUpdated(quint64 balance, quint64 spendable);
index f9453d5cee41f7aa7aeee71af0e8213cce984f4d..9da3d876ffc28286255126db2b8900bb9f10ff65 100644 (file)
@@ -75,6 +75,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
         {Config::lockOnMinimize, {QS("lockOnMinimize"), false}},
         {Config::showTrayIcon, {QS("showTrayIcon"), true}},
         {Config::minimizeToTray, {QS("minimizeToTray"), false}},
+        {Config::trayLeftClickToggles, {QS("trayLeftClickToggles"), false}},
         {Config::disableWebsocket, {QS("disableWebsocket"), false}},
         {Config::disableAutoRefresh, {QS("disableAutoRefresh"), false}},
         {Config::offlineMode, {QS("offlineMode"), false}},
index ffe9a6e674970064d4f8b53270fdcf8d83a84ebd..085c1331075f755b757dcb66b8a12058031c631a 100644 (file)
@@ -109,6 +109,7 @@ public:
         lockOnMinimize,
         showTrayIcon,
         minimizeToTray,
+        trayLeftClickToggles,
 
         // Transactions
         multiBroadcast,