From 9faa465cceeb04208b288789b7a3a6cef56a1565 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Sun, 26 Jun 2022 21:30:54 -0400 Subject: [PATCH] Local library: Support PDFs and pictures listing --- locallibrarywidget.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/locallibrarywidget.cpp b/locallibrarywidget.cpp index 879382f..2d8e85c 100644 --- a/locallibrarywidget.cpp +++ b/locallibrarywidget.cpp @@ -109,11 +109,10 @@ void localLibraryWidget::setupDatabase() { } } - QString prog("sh"); + QString prog("busybox-initrd"); QStringList args; - args << "explore_local_library.sh" << booksList; + args << "sh" << "explore_local_library.sh" << booksList; QProcess *proc = new QProcess(); - proc->setEnvironment((QStringList() << "EXTRACT_COVER=1")); proc->start(prog, args); proc->waitForFinished(); QJsonDocument jsonDocument = QJsonDocument::fromJson(proc->readAllStandardOutput()); @@ -164,6 +163,7 @@ void localLibraryWidget::setupBooksList(int pageNumber) { QString bookAuthor = jsonObject["Author"].toString(); QString coverPath = jsonObject["CoverPath"].toString(); QString bookID = jsonObject["BookID"].toString(); + if(!coverPath.isEmpty()) { // Display book cover if found QPixmap pixmap(coverPath); @@ -173,13 +173,22 @@ void localLibraryWidget::setupBooksList(int pageNumber) { QPixmap pixmap(":/resources/cover_unavailable.png"); bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio)); } + // Display book title idList.append(bookID.toInt()); if(bookTitle.length() > bookTitleTruncateThreshold) { bookTitle.truncate(bookTitleTruncateThreshold); bookTitle.append("..."); } - bookBtnArray[in]->setText("" + bookTitle + "" + "
" + bookAuthor); + if(!bookAuthor.isEmpty()) { + // Book is likely an ePUB + bookBtnArray[in]->setText("" + bookTitle + "" + "
" + bookAuthor); + } + else { + // Book is likely a PDF or a picture + bookBtnArray[in]->setText("" + bookTitle + ""); + } + if(!bookID.isEmpty()) { in++; }