From 180ef9618b3ba5f18660aa8e5ffea65e54e7e70f Mon Sep 17 00:00:00 2001 From: tobtoht Date: Sat, 2 Jul 2022 22:41:46 +0200 Subject: [PATCH] Avoid writing config on tab change --- src/MainWindow.cpp | 5 ++--- src/MainWindow.h | 6 ++++-- src/SettingsDialog.cpp | 9 ++++++--- src/SettingsDialog.h | 2 ++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 2262a2b..a421607 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -170,9 +170,6 @@ void MainWindow::initStatusBar() { void MainWindow::initWidgets() { int homeWidget = config()->get(Config::homeWidget).toInt(); ui->tabHomeWidget->setCurrentIndex(TabsHome(homeWidget)); - connect(ui->tabHomeWidget, &QTabWidget::currentChanged, [](int index){ - config()->set(Config::homeWidget, TabsHome(index)); - }); // [History] m_historyWidget = new HistoryWidget(m_ctx, this); @@ -908,6 +905,8 @@ void MainWindow::closeEvent(QCloseEvent *event) { if (!this->cleanedUp) { this->cleanedUp = true; + config()->set(Config::homeWidget, ui->tabHomeWidget->currentIndex()); + m_historyWidget->resetModel(); m_updateBytes.stop(); diff --git a/src/MainWindow.h b/src/MainWindow.h index b8fdfa2..fd25106 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -90,8 +90,10 @@ public: }; enum TabsHome { - CCS, - REDDIT + CCS = 0, + BOUNTIES, + REDDIT, + REVUO }; void showOrHide(); diff --git a/src/SettingsDialog.cpp b/src/SettingsDialog.cpp index 6fb4c15..de9bbe6 100644 --- a/src/SettingsDialog.cpp +++ b/src/SettingsDialog.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "Icons.h" #include "utils/WebsocketNotifier.h" @@ -22,9 +23,6 @@ Settings::Settings(QSharedPointer ctx, QWidget *parent) ui->tabWidget->setTabVisible(5, false); ui->tabWidget->setCurrentIndex(config()->get(Config::lastSettingsPage).toInt()); - connect(ui->tabWidget, &QTabWidget::currentChanged, [](int index){ - config()->set(Config::lastSettingsPage, index); - }); this->setupGeneralTab(); this->setupPrivacyTab(); @@ -270,4 +268,9 @@ void Settings::enableWebsocket(bool enabled) { emit websocketStatusChanged(enabled); } +void Settings::closeEvent(QCloseEvent *event) { + config()->set(Config::lastSettingsPage, ui->tabWidget->currentIndex()); + event->accept(); +} + Settings::~Settings() = default; \ No newline at end of file diff --git a/src/SettingsDialog.h b/src/SettingsDialog.h index d6342f8..dacfe6e 100644 --- a/src/SettingsDialog.h +++ b/src/SettingsDialog.h @@ -53,6 +53,8 @@ private: void setupLocalMoneroFrontendCombobox(); void enableWebsocket(bool enabled); + void closeEvent(QCloseEvent *event) override; + QScopedPointer ui; QSharedPointer m_ctx;