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()
|
void bookOptionsDialog::on_pinBtn_clicked()
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
log("Pinned book with ID " + QString::number(global::localLibrary::bookOptionsDialog::bookID), className);
|
||||||
}
|
}
|
||||||
|
|
||||||
void bookOptionsDialog::on_deleteBtn_clicked()
|
void bookOptionsDialog::on_deleteBtn_clicked()
|
||||||
{
|
{
|
||||||
log("Deleting book '" + bookPath + "'", className);
|
log("Deleting book '" + bookPath + "'", className);
|
||||||
QFile::remove(bookPath);
|
global::toast::delay = 3000;
|
||||||
global::localLibrary::bookOptionsDialog::bookDeleted = true;
|
if(QFile::remove(bookPath)) {
|
||||||
QFile::remove(global::localLibrary::databasePath);
|
emit showToast("Book deleted successfully");
|
||||||
ui->deleteBtn->setEnabled(false);
|
global::localLibrary::bookOptionsDialog::bookDeleted = true;
|
||||||
ui->deleteBtn->setStyleSheet("padding: 10px; color: lightGrey");
|
QFile::remove(global::localLibrary::databasePath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit showToast("Failed to delete book");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bookOptionsDialog::on_infoBtn_clicked()
|
void bookOptionsDialog::on_infoBtn_clicked()
|
||||||
|
|
|
@ -25,6 +25,7 @@ private slots:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openLocalBookInfoDialog();
|
void openLocalBookInfoDialog();
|
||||||
|
void showToast(QString messageToDisplay);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::bookOptionsDialog *ui;
|
Ui::bookOptionsDialog *ui;
|
||||||
|
|
|
@ -358,11 +358,15 @@ void localLibraryWidget::showToast(QString messageToDisplay) {
|
||||||
toastWindow->show();
|
toastWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openBookOptionsDialog(int bookID) {
|
void localLibraryWidget::openBookOptionsDialog(int pseudoBookID) {
|
||||||
log("Opening book options dialog for book with pseudo-ID " + QString::number(bookID), className);
|
// 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;
|
global::localLibrary::bookOptionsDialog::bookID = bookID;
|
||||||
bookOptionsDialog * bookOptionsDialogWindow = new bookOptionsDialog(this);
|
bookOptionsDialog * bookOptionsDialogWindow = new bookOptionsDialog(this);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::openLocalBookInfoDialog, this, &localLibraryWidget::openLocalBookInfoDialog);
|
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::openLocalBookInfoDialog, this, &localLibraryWidget::openLocalBookInfoDialog);
|
||||||
|
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::showToast, this, &localLibraryWidget::showToast);
|
||||||
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::destroyed, this, &localLibraryWidget::handlePossibleBookDeletion);
|
QObject::connect(bookOptionsDialogWindow, &bookOptionsDialog::destroyed, this, &localLibraryWidget::handlePossibleBookDeletion);
|
||||||
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
||||||
|
@ -371,11 +375,13 @@ void localLibraryWidget::openBookOptionsDialog(int bookID) {
|
||||||
|
|
||||||
void localLibraryWidget::handlePossibleBookDeletion() {
|
void localLibraryWidget::handlePossibleBookDeletion() {
|
||||||
if(global::localLibrary::bookOptionsDialog::bookDeleted == true) {
|
if(global::localLibrary::bookOptionsDialog::bookDeleted == true) {
|
||||||
global::localLibrary::bookOptionsDialog::bookDeleted = false;
|
QTimer::singleShot(3100, this, [&]() {
|
||||||
global::toast::modalToast = true;
|
global::localLibrary::bookOptionsDialog::bookDeleted = false;
|
||||||
global::toast::indefiniteToast = true;
|
global::toast::modalToast = true;
|
||||||
showToast("Generating database");
|
global::toast::indefiniteToast = true;
|
||||||
QTimer::singleShot(100, this, SLOT(setupDisplay()));
|
showToast("Generating database");
|
||||||
|
QTimer::singleShot(100, this, SLOT(setupDisplay()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ private slots:
|
||||||
void goToPage(int page);
|
void goToPage(int page);
|
||||||
void setupDisplay();
|
void setupDisplay();
|
||||||
void showToast(QString messageToDisplay);
|
void showToast(QString messageToDisplay);
|
||||||
void openBookOptionsDialog(int bookID);
|
void openBookOptionsDialog(int pseudoBookID);
|
||||||
void handlePossibleBookDeletion();
|
void handlePossibleBookDeletion();
|
||||||
void openLocalBookInfoDialog();
|
void openLocalBookInfoDialog();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue