]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
p log minimize event# Please enter the commit message for your changes. Lines starting
authorgg <chown_tee@proton.me>
Mon, 12 Jan 2026 15:38:30 +0000 (10:38 -0500)
committergg <chown_tee@proton.me>
Mon, 12 Jan 2026 15:38:30 +0000 (10:38 -0500)
src/MainWindow.cpp
src/MainWindow.h
src/WindowManager.cpp
src/dialog/TxImportDialog.cpp

index a67be3d4b4e92848a44064b3eaec0a4eeced1b5d..fbcbc010848261feb142dfd410b594248acb1fd3 100644 (file)
@@ -216,6 +216,7 @@ void MainWindow::initStatusBar() {
     ui->menuTools->addAction(scanTxAction);
 
     connect(pauseSyncAction, &QAction::toggled, this, [this](bool checked) {
+        qInfo() << "Pause Sync toggled. Checked =" << checked;
         conf()->set(Config::syncPaused, checked);
         if (m_wallet) {
             if (checked) {
@@ -864,6 +865,7 @@ void MainWindow::onBalanceUpdated(quint64 balance, quint64 spendable) {
 }
 
 void MainWindow::setPausedSyncStatus() {
+    qInfo() << "setPausedSyncStatus called. Sync paused:" << conf()->get(Config::syncPaused).toBool();
     QString tooltip;
     QString status = Utils::getPausedSyncStatus(m_wallet, m_nodes, &tooltip);
     this->setStatusText(status);
@@ -981,6 +983,7 @@ void MainWindow::onMultiBroadcast(const QMap<QString, QString> &txHexMap) {
 }
 
 void MainWindow::onSyncStatus(quint64 height, quint64 target, bool daemonSync) {
+    qInfo() << "onSyncStatus: Height" << height << "Target" << target << "DaemonSync" << daemonSync;
     if (height >= (target - 1) && target > 0) {
         this->updateNetStats();
         this->setStatusText(QString("Synchronized (%1)").arg(QLocale().toString(height)));
@@ -1517,20 +1520,79 @@ void MainWindow::closeEvent(QCloseEvent *event) {
     event->accept();
 }
 
+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)
 {
-    if ((event->type() == QEvent::WindowStateChange) && this->isMinimized()) {
-        if (conf()->get(Config::lockOnMinimize).toBool()) {
-            this->lockWallet();
+    QMainWindow::changeEvent(event);
+
+// In changeEvent:
+    if (event->type() == QEvent::WindowStateChange) {
+        qInfo() << "changeEvent: WindowStateChange. State:" << this->windowState() << " isMinimized:" << this->isMinimized();
+        if (this->isMinimized()) {
+             // ... existing logic ...
+            if (conf()->get(Config::lockOnMinimize).toBool()) {
+                this->lockWallet();
+            }
+
+            bool showTray = conf()->get(Config::showTrayIcon).toBool();
+            bool minimizeToTray = conf()->get(Config::minimizeToTray).toBool();
+
+            qInfo() << "WindowStateChange: minimized. Tray=" << showTray << " MinToTray=" << minimizeToTray;
+
+            if (showTray && minimizeToTray) {
+                this->hide();
+            }
         }
-        if (conf()->get(Config::showTrayIcon).toBool() && conf()->get(Config::minimizeToTray).toBool()) {
-            this->hide();
+    } 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();
+
+            if (showTray && minimizeToTray) {
+                this->hide();
+            }
         }
-    } else {
-        QMainWindow::changeEvent(event);
     }
 }
 
+// Add logs to sync methods (need to locate them first, assuming onSyncStatus and setPausedSyncStatus)
+
 void MainWindow::showHistoryTab() {
     this->raise();
     ui->tabWidget->setCurrentIndex(this->findTab("History"));
@@ -1826,6 +1888,7 @@ QString MainWindow::statusDots() {
 }
 
 void MainWindow::showOrHide() {
+    qDebug() << "showOrHide called. isHidden=" << this->isHidden();
     if (this->isHidden())
         this->bringToFront();
     else
index d465ceba8ca817272ef347f020929d48a7972211..da45aab2ccd3b6ba5cd577db046589eef8289e76 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <QMainWindow>
 #include <QSystemTrayIcon>
+#include <QWindow>
 
 #include "components.h"
 #include "SettingsDialog.h"
@@ -97,6 +98,7 @@ signals:
 
 protected:
     void changeEvent(QEvent* event) override;
+    void showEvent(QShowEvent *event) override;
 
 private slots:
     // TODO: use a consistent naming convention for slots
@@ -268,6 +270,8 @@ private:
     EventFilter *m_eventFilter = nullptr;
     qint64 m_userLastActive = QDateTime::currentSecsSinceEpoch();
 
+    QMetaObject::Connection m_visibilityConnection;
+
 #ifdef CHECK_UPDATES
     QSharedPointer<Updater> m_updater = nullptr;
 #endif
index 69d81198c5f6c2690af7da2ad9176b5ac4b03d1b..48daf0082be0fa06c5095423f0bbe909a14a6b35 100644 (file)
@@ -7,6 +7,7 @@
 #include <QInputDialog>
 #include <QMessageBox>
 #include <QWindow>
+#include <QFontMetrics>
 
 #include "Application.h"
 #include "constants.h"
@@ -655,7 +656,14 @@ void WindowManager::buildTrayMenu() {
 
     for (const auto &window : m_windows) {
         QString name = window->walletName();
-        QMenu *submenu = menu->addMenu(name);
+        QString displayName = name;
+        if (name.length() > 20) {
+            displayName = name.left(17) + "...";
+        }
+
+        QMenu *submenu = menu->addMenu(displayName);
+        submenu->setToolTip(name);
+        submenu->menuAction()->setToolTip(name);
         submenu->addAction("Show/Hide", window, &MainWindow::showOrHide);
         submenu->addAction("Close", window, &MainWindow::close);
     }
index 1473311f23124eb8e77e69bac4d5afd6b86fda8d..56b2befce6a258fc80ed5e9737022106354a5cda 100644 (file)
@@ -18,6 +18,7 @@ TxImportDialog::TxImportDialog(QWidget *parent, Wallet *wallet)
     connect(ui->btn_import, &QPushButton::clicked, this, &TxImportDialog::onImport);
 
     this->adjustSize();
+    this->layout()->setSizeConstraint(QLayout::SetFixedSize);
 }
 
 void TxImportDialog::onImport() {