bookInfoDialog successfully bridged with search dialog

This commit is contained in:
Nicolas Mailloux 2021-12-28 19:08:14 -05:00
parent 4b30573899
commit 3ebdce1f07
5 changed files with 47 additions and 5 deletions

View file

@ -45,7 +45,31 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
global::library::bookTitle = "";
}
else {
ui->bookTitleLabel->setText(global::library::bookTitle);
global::library::bookTitle = "";
QDir dictdir;
dictdir.mkpath("/inkbox/gutenberg");
string_writeconfig("/inkbox/gutenberg/bookid", QString::number(global::library::bookId).toStdString());
string_writeconfig("/opt/ibxd", "gutenberg_get_cover\n");
while(true) {
if(QFile::exists("/inkbox/gutenberg/getCoverDone")) {
if(checkconfig("/inkbox/gutenberg/getCoverDone") == true) {
QPixmap coverPixmap("/inkbox/gutenberg/book_cover.jpg");
QPixmap scaledCoverPixmap = coverPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->bookCoverLabel->setPixmap(scaledCoverPixmap);
QFile::remove("/inkbox/gutenberg/getCoverDone");
break;
}
else {
QPixmap coverPixmap(":/resources/cover_unavailable.png");
QPixmap scaledCoverPixmap = coverPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
ui->bookCoverLabel->setPixmap(scaledCoverPixmap);
QFile::remove("/inkbox/gutenberg/getCoverDone");
break;
}
}
}
}
// Centering dialog

View file

@ -70,5 +70,6 @@
<file>resources/alert-triangle.png</file>
<file>resources/online-library.png</file>
<file>resources/online-library-inverted.png</file>
<file>resources/cover_unavailable.png</file>
</qresource>
</RCC>

View file

@ -367,6 +367,7 @@ void generalDialog::on_okBtn_clicked()
connect(searchResultsWidgetWindow, SIGNAL(destroyed(QObject*)), SLOT(restartSearchDialog()));
searchResultsWidgetWindow->setListViewContents(searchResults);
ui->mainStackedWidget->insertWidget(1, searchResultsWidgetWindow);
QFile::remove("/inkbox/gutenberg-search/search_done");
break;
}
else {
@ -374,9 +375,9 @@ void generalDialog::on_okBtn_clicked()
emit showToast("No results found");
keyboardWidget->clearLineEdit();
global::keyboard::keyboardText = "";
QFile::remove("/inkbox/gutenberg-search/search_done");
break;
}
QFile::remove("/inkbox/gutenberg-search/search_done");
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View file

@ -39,16 +39,32 @@ void searchResultsWidget::on_openBtn_clicked()
// Get currently selected row number
int selectedRow = ui->listView->currentIndex().row();
// So that row 0 becomes row 1
selectedRow = selectedRow++;
selectedRow = selectedRow + 1;
QString selectedRowQstr = QString::number(selectedRow);
// TODO: Find book ID and pass it on to bookInfoDialog, then retrieve cover.jpg for display
QString prog ("sed");
QStringList args;
args << "-n" << selectedRowQstr + "p" << "/inkbox/gutenberg-search/search_results_ids";
QProcess *proc = new QProcess();
proc->start(prog, args);
proc->waitForFinished();
QString bookIdQstr = proc->readAllStandardOutput();
proc->deleteLater();
global::keyboard::searchDialog = false;
global::keyboard::keyboardDialog = false;
unsigned long bookId = bookIdQstr.toULong();
global::library::bookId = bookId;
index = ui->listView->currentIndex();
itemText = index.data(Qt::DisplayRole).toString();
global::library::bookTitle = itemText;
bookInfoDialog * bookInfoDialogWindow = new bookInfoDialog();
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
bookInfoDialogWindow->show();
global::keyboard::searchDialog = false;
global::keyboard::keyboardDialog = false;
searchResultsWidget::close();
}
else {
index = ui->listView->currentIndex();