Avoid writing config on tab change

This commit is contained in:
tobtoht 2022-07-02 22:41:46 +02:00
parent 2ba7467674
commit 180ef9618b
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
4 changed files with 14 additions and 8 deletions

View file

@ -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();

View file

@ -90,8 +90,10 @@ public:
};
enum TabsHome {
CCS,
REDDIT
CCS = 0,
BOUNTIES,
REDDIT,
REVUO
};
void showOrHide();

View file

@ -6,6 +6,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QCloseEvent>
#include "Icons.h"
#include "utils/WebsocketNotifier.h"
@ -22,9 +23,6 @@ Settings::Settings(QSharedPointer<AppContext> 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;

View file

@ -53,6 +53,8 @@ private:
void setupLocalMoneroFrontendCombobox();
void enableWebsocket(bool enabled);
void closeEvent(QCloseEvent *event) override;
QScopedPointer<Ui::Settings> ui;
QSharedPointer<AppContext> m_ctx;