mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 07:37:21 -08:00
bookID fix in bookOptionsDialog
This commit is contained in:
parent
b98fee4458
commit
54633f1dc9
4 changed files with 25 additions and 13 deletions
|
@ -23,16 +23,21 @@ bookOptionsDialog::~bookOptionsDialog()
|
|||
void bookOptionsDialog::on_pinBtn_clicked()
|
||||
{
|
||||
// TODO
|
||||
log("Pinned book with ID " + QString::number(global::localLibrary::bookOptionsDialog::bookID), className);
|
||||
}
|
||||
|
||||
void bookOptionsDialog::on_deleteBtn_clicked()
|
||||
{
|
||||
log("Deleting book '" + bookPath + "'", className);
|
||||
QFile::remove(bookPath);
|
||||
global::localLibrary::bookOptionsDialog::bookDeleted = true;
|
||||
QFile::remove(global::localLibrary::databasePath);
|
||||
ui->deleteBtn->setEnabled(false);
|
||||
ui->deleteBtn->setStyleSheet("padding: 10px; color: lightGrey");
|
||||
global::toast::delay = 3000;
|
||||
if(QFile::remove(bookPath)) {
|
||||
emit showToast("Book deleted successfully");
|
||||
global::localLibrary::bookOptionsDialog::bookDeleted = true;
|
||||
QFile::remove(global::localLibrary::databasePath);
|
||||
}
|
||||
else {
|
||||
emit showToast("Failed to delete book");
|
||||
}
|
||||
}
|
||||
|
||||
void bookOptionsDialog::on_infoBtn_clicked()
|
||||
|
|
|
@ -25,6 +25,7 @@ private slots:
|
|||
|
||||
signals:
|
||||
void openLocalBookInfoDialog();
|
||||
void showToast(QString messageToDisplay);
|
||||
|
||||
private:
|
||||
Ui::bookOptionsDialog *ui;
|
||||
|
|
|
@ -358,11 +358,15 @@ void localLibraryWidget::showToast(QString messageToDisplay) {
|
|||
toastWindow->show();
|
||||
}
|
||||
|
||||
void localLibraryWidget::openBookOptionsDialog(int bookID) {
|
||||
log("Opening book options dialog for book with pseudo-ID " + QString::number(bookID), className);
|
||||
void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
||||
// Determine book ID from the book's button number
|
||||
int bookID = ((currentPageNumber * buttonsNumber) - (buttonsNumber - 1)) + (pseudoBookID - 1);
|
||||
|
||||
log("Opening book options dialog for book with pseudo-ID " + QString::number(pseudoBookID) + ", ID " + QString::number(bookID), className);
|
||||
global::localLibrary::bookOptionsDialog::bookID = bookID;
|
||||
bookOptionsDialog * bookOptionsDialogWindow = new bookOptionsDialog(this);
|
||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::openLocalBookInfoDialog, this, &localLibraryWidget::openLocalBookInfoDialog);
|
||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::showToast, this, &localLibraryWidget::showToast);
|
||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::destroyed, this, &localLibraryWidget::handlePossibleBookDeletion);
|
||||
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
||||
|
@ -371,11 +375,13 @@ void localLibraryWidget::openBookOptionsDialog(int bookID) {
|
|||
|
||||
void localLibraryWidget::handlePossibleBookDeletion() {
|
||||
if(global::localLibrary::bookOptionsDialog::bookDeleted == true) {
|
||||
global::localLibrary::bookOptionsDialog::bookDeleted = false;
|
||||
global::toast::modalToast = true;
|
||||
global::toast::indefiniteToast = true;
|
||||
showToast("Generating database");
|
||||
QTimer::singleShot(100, this, SLOT(setupDisplay()));
|
||||
QTimer::singleShot(3100, this, [&]() {
|
||||
global::localLibrary::bookOptionsDialog::bookDeleted = false;
|
||||
global::toast::modalToast = true;
|
||||
global::toast::indefiniteToast = true;
|
||||
showToast("Generating database");
|
||||
QTimer::singleShot(100, this, SLOT(setupDisplay()));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ private slots:
|
|||
void goToPage(int page);
|
||||
void setupDisplay();
|
||||
void showToast(QString messageToDisplay);
|
||||
void openBookOptionsDialog(int bookID);
|
||||
void openBookOptionsDialog(int pseudoBookID);
|
||||
void handlePossibleBookDeletion();
|
||||
void openLocalBookInfoDialog();
|
||||
|
||||
|
|
Loading…
Reference in a new issue