mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Implement local book info dialog
This commit is contained in:
parent
80bdeb32ed
commit
03c2732aff
9 changed files with 120 additions and 58 deletions
|
@ -30,57 +30,95 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
|
|||
stdIconWidth = sW / 4;
|
||||
stdIconHeight = sH / 4;
|
||||
|
||||
if(global::library::isLatestBook == true) {
|
||||
QString bookNumberQstr = QString::number(global::library::latestBookNumber);
|
||||
if(global::bookInfoDialog::localInfoDialog == false) {
|
||||
if(global::library::isLatestBook == true) {
|
||||
QString bookNumberQstr = QString::number(global::library::latestBookNumber);
|
||||
|
||||
QString coverPath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
|
||||
coverPath = coverPath.append(bookNumberQstr);
|
||||
coverPath = coverPath.append("/cover.jpg");
|
||||
QString coverPath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
|
||||
coverPath = coverPath.append(bookNumberQstr);
|
||||
coverPath = coverPath.append("/cover.jpg");
|
||||
|
||||
QString idPath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
|
||||
idPath = idPath.append(bookNumberQstr);
|
||||
idPath = idPath.append("/id");
|
||||
global::library::bookId = readFile(idPath).toULong();
|
||||
QString idPath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
|
||||
idPath = idPath.append(bookNumberQstr);
|
||||
idPath = idPath.append("/id");
|
||||
global::library::bookId = readFile(idPath).toULong();
|
||||
|
||||
QPixmap coverPixmap(coverPath);
|
||||
QPixmap scaledCoverPixmap = coverPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||
ui->bookCoverLabel->setPixmap(scaledCoverPixmap);
|
||||
global::library::isLatestBook = false;
|
||||
QPixmap coverPixmap(coverPath);
|
||||
QPixmap scaledCoverPixmap = coverPixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio);
|
||||
ui->bookCoverLabel->setPixmap(scaledCoverPixmap);
|
||||
global::library::isLatestBook = false;
|
||||
|
||||
ui->bookTitleLabel->setText(global::library::bookTitle);
|
||||
}
|
||||
else {
|
||||
ui->bookTitleLabel->setText(global::library::bookTitle);
|
||||
ui->bookTitleLabel->setText(global::library::bookTitle);
|
||||
}
|
||||
else {
|
||||
ui->bookTitleLabel->setText(global::library::bookTitle);
|
||||
|
||||
QDir gutenbergDir;
|
||||
gutenbergDir.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;
|
||||
QDir gutenbergDir;
|
||||
gutenbergDir.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log("Setting up book info dialog, ID: " + QString::number(global::library::bookId) + ", title: " + global::library::bookTitle, className);
|
||||
}
|
||||
else {
|
||||
QJsonObject bookJsonObject = getBookMetadata(global::localLibrary::bookOptionsDialog::bookID);
|
||||
QString bookInfo;
|
||||
QString title = bookJsonObject["Title"].toString();
|
||||
QString author = bookJsonObject["Author"].toString();
|
||||
QString publicationDate = bookJsonObject["PublicationDate"].toString();
|
||||
QString path = bookJsonObject["BookPath"].toString();
|
||||
if(!title.isEmpty()) {
|
||||
bookInfo.append("<b>Title:</b> " + title + "<br>");
|
||||
}
|
||||
if(!author.isEmpty()) {
|
||||
bookInfo.append("<b>Author:</b> " + author + "<br>");
|
||||
}
|
||||
if(!publicationDate.isEmpty()) {
|
||||
bookInfo.append("<b>Publication date:</b> " + publicationDate + "<br>");
|
||||
}
|
||||
if(!path.isEmpty()) {
|
||||
bookInfo.append("<b>Path:</b> " + path + "<br>");
|
||||
}
|
||||
|
||||
log(bookInfo, className);
|
||||
global::text::textBrowserContents = bookInfo;
|
||||
textwidget * textwidgetWindow = new textwidget(this);
|
||||
ui->stackedWidget->insertWidget(1, textwidgetWindow);
|
||||
ui->stackedWidget->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
log("Setting up book info dialog, ID: " + QString::number(global::library::bookId) + ", title: " + global::library::bookTitle, className);
|
||||
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
|
||||
{
|
||||
int wx = screenGeometry.width();
|
||||
|
||||
int x = wx - 25;
|
||||
int y = this->height() * determineYIncrease();
|
||||
this->setFixedWidth(x);
|
||||
this->setFixedHeight(y);
|
||||
|
||||
this->adjustSize();
|
||||
}
|
||||
|
||||
// Centering dialog
|
||||
this->adjustSize();
|
||||
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
|
||||
int x = (screenGeometry.width() - this->width()) / 2;
|
||||
int y = (screenGeometry.height() - this->height()) / 2;
|
||||
this->move(x, y);
|
||||
|
@ -94,6 +132,7 @@ bookInfoDialog::~bookInfoDialog()
|
|||
void bookInfoDialog::on_closeBtn_clicked()
|
||||
{
|
||||
global::library::bookTitle = "";
|
||||
global::bookInfoDialog::localInfoDialog = false;
|
||||
bookInfoDialog::close();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <QDialog>
|
||||
|
||||
#include "textwidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class bookInfoDialog;
|
||||
}
|
||||
|
@ -30,7 +32,8 @@ signals:
|
|||
void closeIndefiniteToast();
|
||||
|
||||
private:
|
||||
Ui::bookInfoDialog *ui;
|
||||
Ui::bookInfoDialog * ui;
|
||||
textwidget * textwidgetWindow;
|
||||
};
|
||||
|
||||
#endif // BOOKINFODIALOG_H
|
||||
|
|
|
@ -183,7 +183,9 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2"/>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -35,9 +35,7 @@ void bookOptionsDialog::on_deleteBtn_clicked()
|
|||
ui->deleteBtn->setStyleSheet("padding: 10px; color: lightGrey");
|
||||
}
|
||||
|
||||
|
||||
void bookOptionsDialog::on_infoBtn_clicked()
|
||||
{
|
||||
// TODO
|
||||
emit openLocalBookInfoDialog();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ private slots:
|
|||
void on_deleteBtn_clicked();
|
||||
void on_infoBtn_clicked();
|
||||
|
||||
signals:
|
||||
void openLocalBookInfoDialog();
|
||||
|
||||
private:
|
||||
Ui::bookOptionsDialog *ui;
|
||||
};
|
||||
|
|
19
functions.h
19
functions.h
|
@ -126,6 +126,9 @@ namespace global {
|
|||
inline bool librarySearchDialog;
|
||||
inline bool libraryResults;
|
||||
}
|
||||
namespace bookInfoDialog {
|
||||
inline bool localInfoDialog;
|
||||
}
|
||||
namespace localLibrary {
|
||||
static inline QString rawDatabasePath = "/inkbox/LocalLibrary.db.raw";
|
||||
static inline QString databaseDirectoryPath = "/mnt/onboard/onboard/.database/";
|
||||
|
@ -184,7 +187,7 @@ namespace {
|
|||
int defaultPdfPageHeight;
|
||||
bool checked_box = false;
|
||||
QFile logFile("/external_root/var/log/inkbox-gui.log");
|
||||
void log(QString message, QString className, bool applicationStart = false) {
|
||||
void log(QString message, QString className = "undefined", bool applicationStart = false) {
|
||||
if(global::logger::status == true) {
|
||||
QString initialTime;
|
||||
if(applicationStart == true) {
|
||||
|
@ -1001,6 +1004,20 @@ namespace {
|
|||
QJsonArray jsonArrayList = jsonObject["database"].toArray();
|
||||
return jsonArrayList.at(bookID - 1).toObject();
|
||||
}
|
||||
float determineYIncrease() {
|
||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n") {
|
||||
return 2;
|
||||
}
|
||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n") {
|
||||
return 2.6;
|
||||
}
|
||||
else if(global::deviceID == "n437\n" or global::deviceID == "n873\n") {
|
||||
return 3;
|
||||
}
|
||||
else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FUNCTIONS_H
|
||||
|
|
|
@ -359,9 +359,10 @@ void localLibraryWidget::showToast(QString messageToDisplay) {
|
|||
}
|
||||
|
||||
void localLibraryWidget::openBookOptionsDialog(int bookID) {
|
||||
log("Opening book options dialog for book with ID " + QString::number(bookID), className);
|
||||
log("Opening book options dialog for book with pseudo-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::destroyed, this, &localLibraryWidget::handlePossibleBookDeletion);
|
||||
bookOptionsDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
bookOptionsDialogWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
|
||||
|
@ -377,3 +378,10 @@ void localLibraryWidget::handlePossibleBookDeletion() {
|
|||
QTimer::singleShot(100, this, SLOT(setupDisplay()));
|
||||
}
|
||||
}
|
||||
|
||||
void localLibraryWidget::openLocalBookInfoDialog() {
|
||||
global::bookInfoDialog::localInfoDialog = true;
|
||||
bookInfoDialog * bookInfoDialogWindow = new bookInfoDialog(this);
|
||||
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
bookInfoDialogWindow->show();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "generaldialog.h"
|
||||
#include "toast.h"
|
||||
#include "bookoptionsdialog.h"
|
||||
#include "bookinfodialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class localLibraryWidget;
|
||||
|
@ -55,12 +56,14 @@ private slots:
|
|||
void showToast(QString messageToDisplay);
|
||||
void openBookOptionsDialog(int bookID);
|
||||
void handlePossibleBookDeletion();
|
||||
void openLocalBookInfoDialog();
|
||||
|
||||
private:
|
||||
Ui::localLibraryWidget * ui;
|
||||
generalDialog * generalDialogWindow;
|
||||
bookOptionsDialog * bookOptionsDialogWindow;
|
||||
toast * toastWindow;
|
||||
bookInfoDialog * bookInfoDialogWindow;
|
||||
QVector<QHBoxLayout*> horizontalLayoutArray;
|
||||
QVector<QLabel*> bookIconArray;
|
||||
QVector<QClickableLabel*> bookBtnArray;
|
||||
|
|
13
settings.cpp
13
settings.cpp
|
@ -822,18 +822,7 @@ void settings::on_showSystemInfoBtn_clicked()
|
|||
// Show a system info dialog
|
||||
log("Showing system info dialog", className);
|
||||
generalDialogWindow = new generalDialog();
|
||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n") {
|
||||
generalDialogWindow->yIncrease = 2;
|
||||
}
|
||||
else if(global::deviceID == "n613\n" or global::deviceID == "n236\n" or global::deviceID == "n306\n") {
|
||||
generalDialogWindow->yIncrease = 2.6;
|
||||
}
|
||||
else if(global::deviceID == "n437\n" or global::deviceID == "n873\n") {
|
||||
generalDialogWindow->yIncrease = 3;
|
||||
}
|
||||
else {
|
||||
generalDialogWindow->yIncrease = 2;
|
||||
}
|
||||
generalDialogWindow->yIncrease = determineYIncrease();
|
||||
generalDialogWindow->increaseSize();
|
||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue