From 6155e9344e3982728ba0b5067a089250de3da9cc Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Fri, 28 Jan 2022 00:44:23 -0500 Subject: [PATCH] Fix MainWindow tabSwitcher bug When an user would click another button-tab (e.g. Settings or Apps) after launching libraryWidget, InkBox would reset the window entirely and get back to the Home widget. The user would then have had to re- click on the button-tab he wanted to pick to get the appropriate content. This commit fixes this issue by requiring a resetFullWindowException boolean variable to be set to false (meaning that the user didn't click on any button-tab before leaving libraryWidget) for the resetWindow(true) function to occur as described in resetFullWindow(), when libraryWidget is destroyed. --- mainwindow.cpp | 12 +++++++++++- mainwindow.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index a79c1e0..f897a95 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -62,6 +62,7 @@ MainWindow::MainWindow(QWidget *parent) global::usbms::launchUsbms = false; global::usbms::koboxExportExtensions = false; global::mainwindow::tabSwitcher::repaint = true; + resetFullWindowException = false; // Getting the screen's size sW = QGuiApplication::screens()[0]->size().width(); @@ -611,6 +612,7 @@ void MainWindow::openCriticalBatteryAlertWindow() { void MainWindow::on_settingsBtn_clicked() { + resetFullWindowException = true; resetWindow(false); if(global::mainwindow::tabSwitcher::settingsChooserWidgetSelected != true) { ui->settingsBtn->setStyleSheet("background: black"); @@ -637,6 +639,7 @@ void MainWindow::on_settingsBtn_clicked() void MainWindow::on_appsBtn_clicked() { + resetFullWindowException = true; resetWindow(false); if(global::mainwindow::tabSwitcher::appsWidgetSelected != true) { ui->appsBtn->setStyleSheet("background: black"); @@ -720,6 +723,7 @@ void MainWindow::on_brightnessBtn_clicked() void MainWindow::on_homeBtn_clicked() { global::mainwindow::tabSwitcher::repaint = true; + resetFullWindowException = false; resetWindow(true); } @@ -1060,6 +1064,7 @@ void MainWindow::openEncfsRepackDialog() { void MainWindow::on_libraryButton_clicked() { + resetFullWindowException = false; resetWindow(false); if(global::mainwindow::tabSwitcher::libraryWidgetSelected != true) { ui->libraryButton->setStyleSheet("background: black; color: white"); @@ -1085,7 +1090,12 @@ void MainWindow::on_libraryButton_clicked() } void MainWindow::resetFullWindow() { - resetWindow(true); + if(resetFullWindowException == false) { + resetWindow(true); + } + else { + resetFullWindowException = false; + } } void MainWindow::setRecentBooksLabelsTruncateTreshold() { diff --git a/mainwindow.h b/mainwindow.h index 8e9ffc8..49ac767 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -47,6 +47,7 @@ public: bool existing_recent_books = false; bool reboot_after_update = false; + bool resetFullWindowException; int timerTime = 0; QString relative_path; QString usbmsStatus;