bookInfoDialog half-implemented

This commit is contained in:
Nicolas Mailloux 2021-12-27 15:04:39 -05:00
parent 5cf39fb0ad
commit 7df1a38240
11 changed files with 302 additions and 10 deletions

61
bookinfodialog.cpp Normal file
View file

@ -0,0 +1,61 @@
#include "bookinfodialog.h"
#include "ui_bookinfodialog.h"
#include "functions.h"
#include <QScreen>
bookInfoDialog::bookInfoDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::bookInfoDialog)
{
ui->setupUi(this);
ui->closeBtn->setProperty("type", "borderless");
ui->closeBtn->setText("");
ui->closeBtn->setIcon(QIcon(":/resources/close.png"));
ui->bookCoverLabel->setText("");
ui->getBtn->setStyleSheet("background: lightGrey; font-size: 9pt; padding: 8px");
// Getting the screen's size
sW = QGuiApplication::screens()[0]->size().width();
sH = QGuiApplication::screens()[0]->size().height();
// Setting icons up
stdIconWidth = sW / 4;
stdIconHeight = sH / 4;
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");
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);
global::library::bookTitle = "";
}
else {
}
// 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);
}
bookInfoDialog::~bookInfoDialog()
{
delete ui;
}
void bookInfoDialog::on_closeBtn_clicked()
{
bookInfoDialog::close();
}

29
bookinfodialog.h Normal file
View file

@ -0,0 +1,29 @@
#ifndef BOOKINFODIALOG_H
#define BOOKINFODIALOG_H
#include <QDialog>
namespace Ui {
class bookInfoDialog;
}
class bookInfoDialog : public QDialog
{
Q_OBJECT
public:
explicit bookInfoDialog(QWidget *parent = nullptr);
~bookInfoDialog();
float sH;
float sW;
float stdIconHeight;
float stdIconWidth;
private slots:
void on_closeBtn_clicked();
private:
Ui::bookInfoDialog *ui;
};
#endif // BOOKINFODIALOG_H

163
bookinfodialog.ui Normal file
View file

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>bookInfoDialog</class>
<widget class="QDialog" name="bookInfoDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>377</width>
<height>209</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="closeBtn">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="bookCoverLabel">
<property name="text">
<string>Cover</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="bookTitleLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Book title</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="getBtn">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>GET</string>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -102,6 +102,13 @@ namespace global {
inline bool disableStorageEncryptionDialog; inline bool disableStorageEncryptionDialog;
inline bool errorNoBooksInDropboxDialog; inline bool errorNoBooksInDropboxDialog;
} }
namespace library {
inline unsigned long bookId;
inline bool isLatestBook;
inline int latestBookNumber;
inline QString bookTitle;
inline bool librarySearchDialog;
}
inline QString systemInfoText; inline QString systemInfoText;
inline bool forbidOpenSearchDialog; inline bool forbidOpenSearchDialog;
inline bool isN705; inline bool isN705;

View file

@ -47,6 +47,9 @@ generalDialog::generalDialog(QWidget *parent) :
else if(checkconfig_str_val == "Local storage") { else if(checkconfig_str_val == "Local storage") {
ui->searchComboBox->setCurrentIndex(1); ui->searchComboBox->setCurrentIndex(1);
} }
else if(checkconfig_str_val == "Online library") {
ui->searchComboBox->setCurrentIndex(2);
}
else { else {
ui->searchComboBox->setCurrentIndex(0); ui->searchComboBox->setCurrentIndex(0);
} }
@ -198,6 +201,7 @@ void generalDialog::on_cancelBtn_clicked()
global::forbidOpenSearchDialog = true; global::forbidOpenSearchDialog = true;
global::keyboard::keyboardDialog = false; global::keyboard::keyboardDialog = false;
global::keyboard::keyboardText = ""; global::keyboard::keyboardText = "";
global::library::librarySearchDialog = false;
} }
else if(global::keyboard::vncDialog == true) { else if(global::keyboard::vncDialog == true) {
global::keyboard::vncDialog = false; global::keyboard::vncDialog = false;
@ -339,6 +343,9 @@ void generalDialog::on_okBtn_clicked()
keyboardWidget->clearLineEdit(); keyboardWidget->clearLineEdit();
global::keyboard::keyboardText = ""; global::keyboard::keyboardText = "";
} }
}
else if(ui->searchComboBox->currentText() == "Online library") {
} }
else { else {
; ;

View file

@ -223,6 +223,11 @@
<string>Local storage</string> <string>Local storage</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Online library</string>
</property>
</item>
</widget> </widget>
</item> </item>
</layout> </layout>

View file

@ -13,6 +13,7 @@ QMAKE_CXXFLAGS += -Wno-unused-function -Wno-unused-parameter
SOURCES += \ SOURCES += \
alert.cpp \ alert.cpp \
apps.cpp \ apps.cpp \
bookinfodialog.cpp \
brightnessdialog.cpp \ brightnessdialog.cpp \
calendarapp.cpp \ calendarapp.cpp \
dictionarywidget.cpp \ dictionarywidget.cpp \
@ -41,6 +42,7 @@ SOURCES += \
HEADERS += \ HEADERS += \
alert.h \ alert.h \
apps.h \ apps.h \
bookinfodialog.h \
brightnessdialog.h \ brightnessdialog.h \
calendarapp.h \ calendarapp.h \
dictionarywidget.h \ dictionarywidget.h \
@ -69,6 +71,7 @@ HEADERS += \
FORMS += \ FORMS += \
alert.ui \ alert.ui \
apps.ui \ apps.ui \
bookinfodialog.ui \
brightnessdialog.ui \ brightnessdialog.ui \
calendarapp.ui \ calendarapp.ui \
dictionarywidget.ui \ dictionarywidget.ui \

View file

@ -228,13 +228,23 @@ QString libraryWidget::getTitle(int bookNumber) {
QString fullTitlePath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/"; QString fullTitlePath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
fullTitlePath = fullTitlePath.append(bookNumberQstr); fullTitlePath = fullTitlePath.append(bookNumberQstr);
fullTitlePath = fullTitlePath.append("/title_full"); fullTitlePath = fullTitlePath.append("/title_full");
qDebug() << fullTitlePath;
return readFile(fullTitlePath); return readFile(fullTitlePath);
} }
void libraryWidget::openLatestBookInfoDialog(int bookNumber, QString title) { void libraryWidget::openLatestBookInfoDialog(int bookNumber, QString title) {
QString idPath = "/mnt/onboard/onboard/.inkbox/gutenberg-data/latest-books/";
idPath = idPath.append(bookNumber);
idPath = idPath.append("/id");
global::library::isLatestBook = true;
global::library::bookId = readFile(idPath).toULong();
global::library::latestBookNumber = bookNumber;
global::library::bookTitle = title;
bookInfoDialogWindow = new bookInfoDialog(this);
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
bookInfoDialogWindow->setModal(true);
bookInfoDialogWindow->show();
} }

View file

@ -3,6 +3,7 @@
#include <QWidget> #include <QWidget>
#include <toast.h> #include <toast.h>
#include <bookinfodialog.h>
namespace Ui { namespace Ui {
class libraryWidget; class libraryWidget;
@ -23,6 +24,7 @@ public:
private: private:
Ui::libraryWidget * ui; Ui::libraryWidget * ui;
toast * toastWindow; toast * toastWindow;
bookInfoDialog * bookInfoDialogWindow;
private slots: private slots:
void syncCatalog(); void syncCatalog();

View file

@ -47,7 +47,7 @@
<item row="4" column="0"> <item row="4" column="0">
<widget class="QStackedWidget" name="booksStackedWidget"> <widget class="QStackedWidget" name="booksStackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="page_2"> <widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">

View file

@ -29,16 +29,21 @@ void searchResultsWidget::setListViewContents(QStringList searchResults) {
void searchResultsWidget::on_openBtn_clicked() void searchResultsWidget::on_openBtn_clicked()
{ {
index = ui->listView->currentIndex(); if(global::library::librarySearchDialog == true) {
itemText = index.data(Qt::DisplayRole).toString();
if(!itemText.isEmpty()) {
emit openBookFile(itemText, true);
global::keyboard::searchDialog = false;
global::keyboard::keyboardDialog = false;
searchResultsWidget::close();
} }
else { else {
QMessageBox::critical(this, tr("Invalid argument"), tr("Please select a search result.")); index = ui->listView->currentIndex();
itemText = index.data(Qt::DisplayRole).toString();
if(!itemText.isEmpty()) {
emit openBookFile(itemText, true);
global::keyboard::searchDialog = false;
global::keyboard::keyboardDialog = false;
searchResultsWidget::close();
}
else {
QMessageBox::critical(this, tr("Invalid argument"), tr("Please select a search result."));
}
} }
} }