Gutenberg: improvements

This commit is contained in:
Nicolas Mailloux 2022-01-04 19:06:47 -05:00
parent 1ad1da2fa5
commit bbc5c3b927
4 changed files with 15 additions and 3 deletions

View file

@ -183,6 +183,11 @@ void libraryWidget::showToast(QString messageToDisplay) {
toastWindow->show(); toastWindow->show();
} }
void libraryWidget::closeIndefiniteToast() {
// Warning: use with caution
toastWindow->close();
}
void libraryWidget::syncCatalog() { void libraryWidget::syncCatalog() {
global::toast::modalToast = true; global::toast::modalToast = true;
global::toast::indefiniteToast = true; global::toast::indefiniteToast = true;
@ -202,7 +207,7 @@ void libraryWidget::syncCatalog() {
qDebug() << "Gutenberg sync encountered an error"; qDebug() << "Gutenberg sync encountered an error";
toastWindow->close(); toastWindow->close();
showToast("Error"); showToast("Error");
libraryWidget::close(); QTimer::singleShot(5000, this, SLOT(close()));
} }
QFile::remove("/inkbox/gutenbergSyncDone"); QFile::remove("/inkbox/gutenbergSyncDone");
} }
@ -243,6 +248,7 @@ void libraryWidget::openLatestBookInfoDialog(int bookNumber, QString title) {
bookInfoDialogWindow = new bookInfoDialog(this); bookInfoDialogWindow = new bookInfoDialog(this);
connect(bookInfoDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString))); connect(bookInfoDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
connect(bookInfoDialogWindow, SIGNAL(closeIndefiniteToast()), SLOT(closeIndefiniteToast()));
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose); bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
bookInfoDialogWindow->setModal(true); bookInfoDialogWindow->setModal(true);
bookInfoDialogWindow->show(); bookInfoDialogWindow->show();

View file

@ -30,6 +30,7 @@ private slots:
void syncCatalog(); void syncCatalog();
void setupView(); void setupView();
void showToast(QString messageToDisplay); void showToast(QString messageToDisplay);
void closeIndefiniteToast();
QString getTitle(int bookNumber); QString getTitle(int bookNumber);
void openLatestBookInfoDialog(int bookNumber, QString title); void openLatestBookInfoDialog(int bookNumber, QString title);

View file

@ -1057,6 +1057,7 @@ void MainWindow::on_libraryButton_clicked()
// Create widget // Create widget
libraryWidgetWindow = new libraryWidget(); libraryWidgetWindow = new libraryWidget();
connect(libraryWidgetWindow, SIGNAL(destroyed(QObject*)), SLOT(resetFullWindow()));
libraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose); libraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
ui->stackedWidget->insertWidget(3, libraryWidgetWindow); ui->stackedWidget->insertWidget(3, libraryWidgetWindow);
global::mainwindow::tabSwitcher::libraryWidgetCreated = true; global::mainwindow::tabSwitcher::libraryWidgetCreated = true;
@ -1072,3 +1073,7 @@ void MainWindow::on_libraryButton_clicked()
; ;
} }
} }
void MainWindow::resetFullWindow() {
resetWindow(true);
}

View file

@ -53,7 +53,6 @@ public:
void openLowBatteryDialog(); void openLowBatteryDialog();
void openCriticalBatteryAlertWindow(); void openCriticalBatteryAlertWindow();
void openUsbmsDialog(); void openUsbmsDialog();
void resetWindow(bool resetStackedWidget);
void resetIcons(); void resetIcons();
void setBatteryIcon(); void setBatteryIcon();
int testPing(); int testPing();
@ -90,8 +89,9 @@ private slots:
void openReaderFramework(); void openReaderFramework();
void checkForUpdate(); void checkForUpdate();
void openEncfsRepackDialog(); void openEncfsRepackDialog();
void on_libraryButton_clicked(); void on_libraryButton_clicked();
void resetWindow(bool resetStackedWidget);
void resetFullWindow();
private: private:
Ui::MainWindow * ui; Ui::MainWindow * ui;