mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08: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,6 +30,7 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
|
||||||
stdIconWidth = sW / 4;
|
stdIconWidth = sW / 4;
|
||||||
stdIconHeight = sH / 4;
|
stdIconHeight = sH / 4;
|
||||||
|
|
||||||
|
if(global::bookInfoDialog::localInfoDialog == false) {
|
||||||
if(global::library::isLatestBook == true) {
|
if(global::library::isLatestBook == true) {
|
||||||
QString bookNumberQstr = QString::number(global::library::latestBookNumber);
|
QString bookNumberQstr = QString::number(global::library::latestBookNumber);
|
||||||
|
|
||||||
|
@ -77,10 +78,47 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Setting up book info dialog, ID: " + QString::number(global::library::bookId) + ", title: " + global::library::bookTitle, className);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
// Centering dialog
|
||||||
this->adjustSize();
|
|
||||||
QRect screenGeometry = QGuiApplication::screens()[0]->geometry();
|
|
||||||
int x = (screenGeometry.width() - this->width()) / 2;
|
int x = (screenGeometry.width() - this->width()) / 2;
|
||||||
int y = (screenGeometry.height() - this->height()) / 2;
|
int y = (screenGeometry.height() - this->height()) / 2;
|
||||||
this->move(x, y);
|
this->move(x, y);
|
||||||
|
@ -94,6 +132,7 @@ bookInfoDialog::~bookInfoDialog()
|
||||||
void bookInfoDialog::on_closeBtn_clicked()
|
void bookInfoDialog::on_closeBtn_clicked()
|
||||||
{
|
{
|
||||||
global::library::bookTitle = "";
|
global::library::bookTitle = "";
|
||||||
|
global::bookInfoDialog::localInfoDialog = false;
|
||||||
bookInfoDialog::close();
|
bookInfoDialog::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "textwidget.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class bookInfoDialog;
|
class bookInfoDialog;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +33,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::bookInfoDialog * ui;
|
Ui::bookInfoDialog * ui;
|
||||||
|
textwidget * textwidgetWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BOOKINFODIALOG_H
|
#endif // BOOKINFODIALOG_H
|
||||||
|
|
|
@ -183,7 +183,9 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page_2"/>
|
<widget class="QWidget" name="page_2">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -35,9 +35,7 @@ void bookOptionsDialog::on_deleteBtn_clicked()
|
||||||
ui->deleteBtn->setStyleSheet("padding: 10px; color: lightGrey");
|
ui->deleteBtn->setStyleSheet("padding: 10px; color: lightGrey");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void bookOptionsDialog::on_infoBtn_clicked()
|
void bookOptionsDialog::on_infoBtn_clicked()
|
||||||
{
|
{
|
||||||
// TODO
|
emit openLocalBookInfoDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ private slots:
|
||||||
void on_deleteBtn_clicked();
|
void on_deleteBtn_clicked();
|
||||||
void on_infoBtn_clicked();
|
void on_infoBtn_clicked();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void openLocalBookInfoDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::bookOptionsDialog *ui;
|
Ui::bookOptionsDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
19
functions.h
19
functions.h
|
@ -126,6 +126,9 @@ namespace global {
|
||||||
inline bool librarySearchDialog;
|
inline bool librarySearchDialog;
|
||||||
inline bool libraryResults;
|
inline bool libraryResults;
|
||||||
}
|
}
|
||||||
|
namespace bookInfoDialog {
|
||||||
|
inline bool localInfoDialog;
|
||||||
|
}
|
||||||
namespace localLibrary {
|
namespace localLibrary {
|
||||||
static inline QString rawDatabasePath = "/inkbox/LocalLibrary.db.raw";
|
static inline QString rawDatabasePath = "/inkbox/LocalLibrary.db.raw";
|
||||||
static inline QString databaseDirectoryPath = "/mnt/onboard/onboard/.database/";
|
static inline QString databaseDirectoryPath = "/mnt/onboard/onboard/.database/";
|
||||||
|
@ -184,7 +187,7 @@ namespace {
|
||||||
int defaultPdfPageHeight;
|
int defaultPdfPageHeight;
|
||||||
bool checked_box = false;
|
bool checked_box = false;
|
||||||
QFile logFile("/external_root/var/log/inkbox-gui.log");
|
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) {
|
if(global::logger::status == true) {
|
||||||
QString initialTime;
|
QString initialTime;
|
||||||
if(applicationStart == true) {
|
if(applicationStart == true) {
|
||||||
|
@ -1001,6 +1004,20 @@ namespace {
|
||||||
QJsonArray jsonArrayList = jsonObject["database"].toArray();
|
QJsonArray jsonArrayList = jsonObject["database"].toArray();
|
||||||
return jsonArrayList.at(bookID - 1).toObject();
|
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
|
#endif // FUNCTIONS_H
|
||||||
|
|
|
@ -359,9 +359,10 @@ void localLibraryWidget::showToast(QString messageToDisplay) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openBookOptionsDialog(int bookID) {
|
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;
|
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::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);
|
||||||
|
@ -377,3 +378,10 @@ void localLibraryWidget::handlePossibleBookDeletion() {
|
||||||
QTimer::singleShot(100, this, SLOT(setupDisplay()));
|
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 "generaldialog.h"
|
||||||
#include "toast.h"
|
#include "toast.h"
|
||||||
#include "bookoptionsdialog.h"
|
#include "bookoptionsdialog.h"
|
||||||
|
#include "bookinfodialog.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class localLibraryWidget;
|
class localLibraryWidget;
|
||||||
|
@ -55,12 +56,14 @@ private slots:
|
||||||
void showToast(QString messageToDisplay);
|
void showToast(QString messageToDisplay);
|
||||||
void openBookOptionsDialog(int bookID);
|
void openBookOptionsDialog(int bookID);
|
||||||
void handlePossibleBookDeletion();
|
void handlePossibleBookDeletion();
|
||||||
|
void openLocalBookInfoDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::localLibraryWidget * ui;
|
Ui::localLibraryWidget * ui;
|
||||||
generalDialog * generalDialogWindow;
|
generalDialog * generalDialogWindow;
|
||||||
bookOptionsDialog * bookOptionsDialogWindow;
|
bookOptionsDialog * bookOptionsDialogWindow;
|
||||||
toast * toastWindow;
|
toast * toastWindow;
|
||||||
|
bookInfoDialog * bookInfoDialogWindow;
|
||||||
QVector<QHBoxLayout*> horizontalLayoutArray;
|
QVector<QHBoxLayout*> horizontalLayoutArray;
|
||||||
QVector<QLabel*> bookIconArray;
|
QVector<QLabel*> bookIconArray;
|
||||||
QVector<QClickableLabel*> bookBtnArray;
|
QVector<QClickableLabel*> bookBtnArray;
|
||||||
|
|
13
settings.cpp
13
settings.cpp
|
@ -822,18 +822,7 @@ void settings::on_showSystemInfoBtn_clicked()
|
||||||
// Show a system info dialog
|
// Show a system info dialog
|
||||||
log("Showing system info dialog", className);
|
log("Showing system info dialog", className);
|
||||||
generalDialogWindow = new generalDialog();
|
generalDialogWindow = new generalDialog();
|
||||||
if(global::deviceID == "n705\n" or global::deviceID == "n905\n") {
|
generalDialogWindow->yIncrease = determineYIncrease();
|
||||||
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->increaseSize();
|
generalDialogWindow->increaseSize();
|
||||||
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue