Gutenberg: Improvements

This commit is contained in:
Nicolas Mailloux 2022-02-17 20:13:08 -05:00
parent 4fc7659f9d
commit 1614e51e88
3 changed files with 22 additions and 15 deletions

View file

@ -48,11 +48,9 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
global::library::isLatestBook = false; global::library::isLatestBook = false;
ui->bookTitleLabel->setText(global::library::bookTitle); ui->bookTitleLabel->setText(global::library::bookTitle);
global::library::bookTitle = "";
} }
else { else {
ui->bookTitleLabel->setText(global::library::bookTitle); ui->bookTitleLabel->setText(global::library::bookTitle);
global::library::bookTitle = "";
QDir gutenbergDir; QDir gutenbergDir;
gutenbergDir.mkpath("/inkbox/gutenberg"); gutenbergDir.mkpath("/inkbox/gutenberg");
@ -93,6 +91,7 @@ bookInfoDialog::~bookInfoDialog()
void bookInfoDialog::on_closeBtn_clicked() void bookInfoDialog::on_closeBtn_clicked()
{ {
global::library::bookTitle = "";
bookInfoDialog::close(); bookInfoDialog::close();
} }
@ -102,6 +101,7 @@ void bookInfoDialog::on_getBtn_clicked()
QDir gutenbergDir; QDir gutenbergDir;
gutenbergDir.mkpath("/inkbox/gutenberg"); gutenbergDir.mkpath("/inkbox/gutenberg");
string_writeconfig("/inkbox/gutenberg/bookid", QString::number(global::library::bookId).toStdString()); string_writeconfig("/inkbox/gutenberg/bookid", QString::number(global::library::bookId).toStdString());
string_writeconfig("/inkbox/gutenberg/booktitle", global::library::bookTitle.toStdString());
string_writeconfig("/opt/ibxd", "gutenberg_get_book\n"); string_writeconfig("/opt/ibxd", "gutenberg_get_book\n");
global::toast::modalToast = true; global::toast::modalToast = true;

View file

@ -248,12 +248,14 @@ void libraryWidget::closeIndefiniteToast() {
void libraryWidget::syncCatalog() { void libraryWidget::syncCatalog() {
global::toast::modalToast = true; global::toast::modalToast = true;
global::toast::indefiniteToast = true; global::toast::indefiniteToast = true;
bool syncDone = false;
showToast("Sync in progress"); showToast("Sync in progress");
string_writeconfig("/opt/ibxd", "gutenberg_sync\n"); string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
QTimer * syncCheckTimer = new QTimer(this); QTimer * syncCheckTimer = new QTimer(this);
syncCheckTimer->setInterval(100); syncCheckTimer->setInterval(100);
connect(syncCheckTimer, &QTimer::timeout, [&]() { connect(syncCheckTimer, &QTimer::timeout, [&]() {
if(syncDone == false) {
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) { if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
if(checkconfig("/inkbox/gutenbergSyncDone") == true) { if(checkconfig("/inkbox/gutenbergSyncDone") == true) {
qDebug() << "Gutenberg sync successfully completed"; qDebug() << "Gutenberg sync successfully completed";
@ -268,6 +270,8 @@ void libraryWidget::syncCatalog() {
QTimer::singleShot(5000, this, SLOT(close())); QTimer::singleShot(5000, this, SLOT(close()));
} }
QFile::remove("/inkbox/gutenbergSyncDone"); QFile::remove("/inkbox/gutenbergSyncDone");
syncDone = true;
}
} }
} ); } );
syncCheckTimer->start(); syncCheckTimer->start();

View file

@ -502,6 +502,9 @@ MainWindow::MainWindow(QWidget *parent)
updatemsg = updatemsg.append(checkconfig_str_val); updatemsg = updatemsg.append(checkconfig_str_val);
QMessageBox::information(this, tr("Information"), updatemsg); QMessageBox::information(this, tr("Information"), updatemsg);
string_writeconfig("/external_root/opt/update/inkbox_updated", "false"); string_writeconfig("/external_root/opt/update/inkbox_updated", "false");
if(QFile::exists("/external_root/opt/storage/gutenberg/last_sync")) {
QFile::remove("/external_root/opt/storage/gutenberg/last_sync");
}
} }
} }