From bbc5c3b9276cb1377005667acd5c4d71c11f6744 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Tue, 4 Jan 2022 19:06:47 -0500 Subject: [PATCH] Gutenberg: improvements --- librarywidget.cpp | 8 +++++++- librarywidget.h | 1 + mainwindow.cpp | 5 +++++ mainwindow.h | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/librarywidget.cpp b/librarywidget.cpp index 0104495..e477dbc 100644 --- a/librarywidget.cpp +++ b/librarywidget.cpp @@ -183,6 +183,11 @@ void libraryWidget::showToast(QString messageToDisplay) { toastWindow->show(); } +void libraryWidget::closeIndefiniteToast() { + // Warning: use with caution + toastWindow->close(); +} + void libraryWidget::syncCatalog() { global::toast::modalToast = true; global::toast::indefiniteToast = true; @@ -202,7 +207,7 @@ void libraryWidget::syncCatalog() { qDebug() << "Gutenberg sync encountered an error"; toastWindow->close(); showToast("Error"); - libraryWidget::close(); + QTimer::singleShot(5000, this, SLOT(close())); } QFile::remove("/inkbox/gutenbergSyncDone"); } @@ -243,6 +248,7 @@ void libraryWidget::openLatestBookInfoDialog(int bookNumber, QString title) { bookInfoDialogWindow = new bookInfoDialog(this); connect(bookInfoDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString))); + connect(bookInfoDialogWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast())); bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose); bookInfoDialogWindow->setModal(true); bookInfoDialogWindow->show(); diff --git a/librarywidget.h b/librarywidget.h index 276bc28..5c67bf8 100644 --- a/librarywidget.h +++ b/librarywidget.h @@ -30,6 +30,7 @@ private slots: void syncCatalog(); void setupView(); void showToast(QString messageToDisplay); + void closeIndefiniteToast(); QString getTitle(int bookNumber); void openLatestBookInfoDialog(int bookNumber, QString title); diff --git a/mainwindow.cpp b/mainwindow.cpp index 9729fef..6775ae2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1057,6 +1057,7 @@ void MainWindow::on_libraryButton_clicked() // Create widget libraryWidgetWindow = new libraryWidget(); + connect(libraryWidgetWindow, SIGNAL(destroyed(QObject*)), SLOT(resetFullWindow())); libraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose); ui->stackedWidget->insertWidget(3, libraryWidgetWindow); global::mainwindow::tabSwitcher::libraryWidgetCreated = true; @@ -1072,3 +1073,7 @@ void MainWindow::on_libraryButton_clicked() ; } } + +void MainWindow::resetFullWindow() { + resetWindow(true); +} diff --git a/mainwindow.h b/mainwindow.h index 701ac58..42aa112 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -53,7 +53,6 @@ public: void openLowBatteryDialog(); void openCriticalBatteryAlertWindow(); void openUsbmsDialog(); - void resetWindow(bool resetStackedWidget); void resetIcons(); void setBatteryIcon(); int testPing(); @@ -90,8 +89,9 @@ private slots: void openReaderFramework(); void checkForUpdate(); void openEncfsRepackDialog(); - void on_libraryButton_clicked(); + void resetWindow(bool resetStackedWidget); + void resetFullWindow(); private: Ui::MainWindow * ui;