]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
update
authorgg <chown_tee@proton.me>
Sun, 18 Jan 2026 02:59:43 +0000 (21:59 -0500)
committergg <chown_tee@proton.me>
Sun, 18 Jan 2026 02:59:43 +0000 (21:59 -0500)
src/MainWindow.cpp
src/MainWindow.h
src/libwalletqt/Wallet.cpp

index e457221290bb755e71837f87c184edcada48092b..1d27f4835c1269130b0f1d43fc9e99194340dee0 100644 (file)
@@ -133,6 +133,9 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
         if (key == Config::syncInterval && m_wallet) {
             m_wallet->setRefreshInterval(conf()->get(Config::syncInterval).toInt());
         }
+        if (key == Config::syncPaused) {
+            this->setSyncPaused(conf()->get(Config::syncPaused).toBool());
+        }
     });
 
     this->onWalletOpened();
@@ -227,10 +230,10 @@ void MainWindow::initStatusBar() {
 
     m_statusLabelStatus->setContextMenuPolicy(Qt::ActionsContextMenu);
 
-    QAction *pauseSyncAction = new QAction(tr("Pause Sync"), this);
-    pauseSyncAction->setCheckable(true);
-    pauseSyncAction->setChecked(conf()->get(Config::syncPaused).toBool());
-    m_statusLabelStatus->addAction(pauseSyncAction);
+    m_actionPauseSync = new QAction(tr("Pause Sync"), this);
+    m_actionPauseSync->setCheckable(true);
+    m_actionPauseSync->setChecked(conf()->get(Config::syncPaused).toBool());
+    m_statusLabelStatus->addAction(m_actionPauseSync);
 
     m_actionEnableWebsocket = new QAction(tr("Enable Websocket"), this);
     m_actionEnableWebsocket->setCheckable(true);
@@ -262,23 +265,9 @@ void MainWindow::initStatusBar() {
     m_updateNetworkInfoAction = new QAction(tr("Scan Now"), this);
     m_statusLabelStatus->addAction(m_updateNetworkInfoAction);
 
-    connect(pauseSyncAction, &QAction::toggled, this, [this](bool checked) {
+    connect(m_actionPauseSync, &QAction::toggled, this, [this](bool checked) {
         qInfo() << "Pause Sync toggled. Checked =" << checked;
         conf()->set(Config::syncPaused, checked);
-
-        if (m_wallet) {
-            if (checked) {
-                m_wallet->setSyncPaused(true);
-                m_nodes->disconnectCurrentNode();
-                this->onConnectionStatusChanged(Wallet::ConnectionStatus_Disconnected);
-            } else {
-                // Ensure we reconnect everything when unpausing
-                m_wallet->setSyncPaused(false);
-                m_nodes->connectToNode();
-                websocketNotifier()->websocketClient->restart();
-                this->setStatusText(tr("Resuming sync..."));
-            }
-        }
     });
 
     connect(skipSyncAction, &QAction::triggered, this, [this](){
@@ -746,16 +735,6 @@ void MainWindow::onWalletOpened() {
 
     m_wallet->setRingDatabase(Utils::ringDatabasePath());
 
-    // Load persisted sync state
-    // Load persisted sync state
-    QString lastSyncStr = m_wallet->getCacheAttribute("feather.lastSync");
-    if (!lastSyncStr.isEmpty()) {
-        qint64 lastSync = lastSyncStr.toLongLong();
-        if (lastSync > 0) {
-            m_lastSyncStatusUpdate = QDateTime::fromSecsSinceEpoch(lastSync);
-        }
-    }
-
     m_wallet->setRefreshInterval(conf()->get(Config::syncInterval).toInt());
 
     m_wallet->updateBalance();
@@ -2429,3 +2408,28 @@ int MainWindow::findTab(const QString &title) {
 MainWindow::~MainWindow() {
     qDebug() << "~MainWindow" << QThread::currentThreadId();
 }
+
+void MainWindow::setSyncPaused(bool checked) {
+    if (m_actionPauseSync && m_actionPauseSync->isChecked() != checked) {
+        const QSignalBlocker blocker(m_actionPauseSync);
+        m_actionPauseSync->setChecked(checked);
+    }
+
+    if (m_wallet) {
+        if (checked) {
+            qInfo() << "Pausing sync via setSyncPaused";
+            m_wallet->setSyncPaused(true);
+            m_nodes->disconnectCurrentNode();
+            this->onConnectionStatusChanged(Wallet::ConnectionStatus_Disconnected);
+        } else {
+            qInfo() << "Resuming sync via setSyncPaused";
+            m_wallet->setSyncPaused(false);
+            m_nodes->connectToNode();
+
+            if (!conf()->get(Config::disableWebsocket).toBool()) {
+                websocketNotifier()->websocketClient->restart();
+            }
+            this->setStatusText(tr("Resuming sync..."));
+        }
+    }
+}
index 4df669919da23973138b4a51cadee54960627c14..5fb5703affabddb0b708851e82bc04e6034e54b4 100644 (file)
@@ -212,6 +212,7 @@ private:
     void lockWallet();
     void unlockWallet(const QString &password);
     void closeQDialogChildren(QObject *object);
+    void setSyncPaused(bool paused);
     int findTab(const QString &title);
 
     QIcon hardwareDevicePairedIcon();
@@ -237,6 +238,7 @@ private:
     QPointer<QAction> m_clearRecentlyOpenAction;
     QPointer<QAction> m_updateNetworkInfoAction;
     QPointer<QAction> m_actionEnableWebsocket;
+    QPointer<QAction> m_actionPauseSync;
 
     QDateTime m_lastSyncStatusUpdate;
 
index 436be13985fb4bca245ca1ca4b4b792468990a71..5f9e2eb1e5d56e473e278babb5bde2a27cee07ec 100644 (file)
@@ -92,8 +92,14 @@ Wallet::Wallet(Monero::Wallet *wallet, QObject *parent)
     // This protects the restore height from being overwritten by "Skip Sync" or range syncs
     if (!cacheAttributeExists("feather.creation_height")) {
         quint64 height = m_wallet2->get_refresh_from_block_height();
-        if (height > 0) {
-            setCacheAttribute("feather.creation_height", QString::number(height));
+        setCacheAttribute("feather.creation_height", QString::number(height));
+    }
+
+    QString lastSyncStr = getCacheAttribute("feather.lastSync");
+    if (!lastSyncStr.isEmpty()) {
+        qint64 lastSync = lastSyncStr.toLongLong();
+        if (lastSync > 0) {
+            m_lastSyncTime = QDateTime::fromSecsSinceEpoch(lastSync);
         }
     }
 }