mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Local library: Bugfixes
This commit is contained in:
parent
8708246065
commit
8eea1d0df5
15 changed files with 258 additions and 63 deletions
|
@ -122,6 +122,7 @@ void bookInfoDialog::waitForBookFetch() {
|
||||||
QString function = __func__; log(function + ": Download successful", className);
|
QString function = __func__; log(function + ": Download successful", className);
|
||||||
emit showToast("Download successful");
|
emit showToast("Download successful");
|
||||||
QFile::remove("/inkbox/gutenberg/getBookDone");
|
QFile::remove("/inkbox/gutenberg/getBookDone");
|
||||||
|
QFile::remove(global::localLibrary::databasePath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
1
eink.qrc
1
eink.qrc
|
@ -76,5 +76,6 @@
|
||||||
<file>resources/tzlist</file>
|
<file>resources/tzlist</file>
|
||||||
<file>resources/edit.png</file>
|
<file>resources/edit.png</file>
|
||||||
<file>resources/save.png</file>
|
<file>resources/save.png</file>
|
||||||
|
<file>resources/book_inverted.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -58,6 +58,8 @@ namespace global {
|
||||||
inline bool settingsChooserWidgetSelected;
|
inline bool settingsChooserWidgetSelected;
|
||||||
inline bool libraryWidgetCreated;
|
inline bool libraryWidgetCreated;
|
||||||
inline bool libraryWidgetSelected;
|
inline bool libraryWidgetSelected;
|
||||||
|
inline bool localLibraryWidgetCreated;
|
||||||
|
inline bool localLibraryWidgetSelected;
|
||||||
}
|
}
|
||||||
inline bool updateDialog;
|
inline bool updateDialog;
|
||||||
inline bool lowBatteryDialog;
|
inline bool lowBatteryDialog;
|
||||||
|
@ -122,6 +124,10 @@ namespace global {
|
||||||
inline bool librarySearchDialog;
|
inline bool librarySearchDialog;
|
||||||
inline bool libraryResults;
|
inline bool libraryResults;
|
||||||
}
|
}
|
||||||
|
namespace localLibrary {
|
||||||
|
static inline QString rawDatabasePath = "/inkbox/LocalLibrary.db.raw";
|
||||||
|
static inline QString databasePath = "/mnt/onboard/onboard/.inkbox/LocalLibrary.db";
|
||||||
|
}
|
||||||
namespace localStorage {
|
namespace localStorage {
|
||||||
inline QStringList searchResultsPaths;
|
inline QStringList searchResultsPaths;
|
||||||
}
|
}
|
||||||
|
|
|
@ -703,7 +703,7 @@ void generalDialog::syncGutenbergCatalog() {
|
||||||
|
|
||||||
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
|
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
|
||||||
QTimer * syncCheckTimer = new QTimer(this);
|
QTimer * syncCheckTimer = new QTimer(this);
|
||||||
syncCheckTimer->setInterval(100);
|
syncCheckTimer->setInterval(500);
|
||||||
connect(syncCheckTimer, &QTimer::timeout, [&]() {
|
connect(syncCheckTimer, &QTimer::timeout, [&]() {
|
||||||
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
|
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
|
||||||
if(checkconfig("/inkbox/gutenbergSyncDone") == true) {
|
if(checkconfig("/inkbox/gutenbergSyncDone") == true) {
|
||||||
|
|
|
@ -254,7 +254,7 @@ void libraryWidget::syncCatalog() {
|
||||||
|
|
||||||
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
|
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
|
||||||
QTimer * syncCheckTimer = new QTimer(this);
|
QTimer * syncCheckTimer = new QTimer(this);
|
||||||
syncCheckTimer->setInterval(100);
|
syncCheckTimer->setInterval(500);
|
||||||
connect(syncCheckTimer, &QTimer::timeout, [&]() {
|
connect(syncCheckTimer, &QTimer::timeout, [&]() {
|
||||||
if(syncDone == false) {
|
if(syncDone == false) {
|
||||||
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
|
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
|
||||||
|
|
|
@ -411,19 +411,6 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="recentlyAddedLabel">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Recently added books on Gutenberg</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -437,19 +424,12 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="3">
|
||||||
<widget class="QPushButton" name="previousBtn">
|
|
||||||
<property name="text">
|
|
||||||
<string>Previous</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -462,7 +442,27 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="5">
|
||||||
|
<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>
|
||||||
<item row="0" column="4">
|
<item row="0" column="4">
|
||||||
|
<widget class="QLabel" name="pageLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>1 of 2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="6">
|
||||||
<widget class="QPushButton" name="nextBtn">
|
<widget class="QPushButton" name="nextBtn">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Next</string>
|
<string>Next</string>
|
||||||
|
@ -470,14 +470,30 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="pageLabel">
|
<widget class="QPushButton" name="previousBtn">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>1 of 2</string>
|
<string>Previous</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
<item row="0" column="0">
|
||||||
<spacer name="horizontalSpacer_2">
|
<widget class="QLabel" name="recentlyAddedLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Inter</family>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Project Gutenberg's latest books</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -62,8 +62,8 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
||||||
stdIconWidth = sH / stdIconHeightDivider;
|
stdIconWidth = sH / stdIconHeightDivider;
|
||||||
}
|
}
|
||||||
else if(global::deviceID == "n437\n") {
|
else if(global::deviceID == "n437\n") {
|
||||||
stdIconWidthDivider = 7.5;
|
stdIconWidthDivider = 8;
|
||||||
stdIconHeightDivider = 7.5;
|
stdIconHeightDivider = 8;
|
||||||
stdIconWidth = sW / stdIconWidthDivider;
|
stdIconWidth = sW / stdIconWidthDivider;
|
||||||
stdIconHeight = sH / stdIconHeightDivider;
|
stdIconHeight = sH / stdIconHeightDivider;
|
||||||
}
|
}
|
||||||
|
@ -110,8 +110,16 @@ localLibraryWidget::localLibraryWidget(QWidget *parent) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setupDatabase();
|
setupDatabase();
|
||||||
|
if(noBooksInDatabase == false) {
|
||||||
setupBooksList(currentPageNumber);
|
setupBooksList(currentPageNumber);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
ui->previousPageBtn->setEnabled(false);
|
||||||
|
ui->nextPageBtn->setEnabled(false);
|
||||||
|
ui->pageNumberLabel->setText("1 <i>of</i> 1");
|
||||||
|
ui->stackedWidget->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
localLibraryWidget::~localLibraryWidget()
|
localLibraryWidget::~localLibraryWidget()
|
||||||
{
|
{
|
||||||
|
@ -119,10 +127,8 @@ localLibraryWidget::~localLibraryWidget()
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::setupDatabase() {
|
void localLibraryWidget::setupDatabase() {
|
||||||
QString localLibraryDatabasePathRaw = "/inkbox/LocalLibrary.db.raw";
|
|
||||||
QString localLibraryDatabasePath = "/mnt/onboard/onboard/.inkbox/LocalLibrary.db";
|
|
||||||
setDefaultWorkDir();
|
setDefaultWorkDir();
|
||||||
if(!QFile::exists(localLibraryDatabasePath)) {
|
if(!QFile::exists(global::localLibrary::databasePath)) {
|
||||||
log("Generating database", className);
|
log("Generating database", className);
|
||||||
QStringList booksList;
|
QStringList booksList;
|
||||||
QDir dir("/mnt/onboard/onboard");
|
QDir dir("/mnt/onboard/onboard");
|
||||||
|
@ -144,17 +150,17 @@ void localLibraryWidget::setupDatabase() {
|
||||||
QProcess *proc = new QProcess();
|
QProcess *proc = new QProcess();
|
||||||
proc->start(prog, args);
|
proc->start(prog, args);
|
||||||
proc->waitForFinished();
|
proc->waitForFinished();
|
||||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(readFile(localLibraryDatabasePathRaw).toUtf8());
|
QJsonDocument jsonDocument = QJsonDocument::fromJson(readFile(global::localLibrary::rawDatabasePath).toUtf8());
|
||||||
QFile::remove(localLibraryDatabasePathRaw);
|
QFile::remove(global::localLibrary::rawDatabasePath);
|
||||||
proc->deleteLater();
|
proc->deleteLater();
|
||||||
|
|
||||||
// Write database in compressed form, encoded in Base64 format
|
// Write database in compressed form, encoded in Base64 format
|
||||||
writeFile(localLibraryDatabasePath, qCompress(jsonDocument.toJson()).toBase64());
|
writeFile(global::localLibrary::databasePath, qCompress(jsonDocument.toJson()).toBase64());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read library database from file
|
// Read library database from file
|
||||||
log("Reading database", className);
|
log("Reading database", className);
|
||||||
QFile database(localLibraryDatabasePath);
|
QFile database(global::localLibrary::databasePath);
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
if(database.open(QIODevice::ReadOnly)) {
|
if(database.open(QIODevice::ReadOnly)) {
|
||||||
data = database.readAll();
|
data = database.readAll();
|
||||||
|
@ -172,10 +178,17 @@ void localLibraryWidget::setupDatabase() {
|
||||||
// Determine maximum page number
|
// Determine maximum page number
|
||||||
booksNumber = databaseJsonArrayList.size();
|
booksNumber = databaseJsonArrayList.size();
|
||||||
pagesNumber = std::ceil((double)booksNumber / buttonsNumber);
|
pagesNumber = std::ceil((double)booksNumber / buttonsNumber);
|
||||||
|
if(databaseJsonArrayList.isEmpty()) {
|
||||||
|
log("Database is empty", className);
|
||||||
|
noBooksInDatabase = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
noBooksInDatabase = false;
|
||||||
if(pagesNumber == 1) {
|
if(pagesNumber == 1) {
|
||||||
ui->nextPageBtn->setEnabled(false);
|
ui->nextPageBtn->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void localLibraryWidget::setupBooksList(int pageNumber) {
|
void localLibraryWidget::setupBooksList(int pageNumber) {
|
||||||
idList.clear();
|
idList.clear();
|
||||||
|
@ -201,7 +214,7 @@ void localLibraryWidget::setupBooksList(int pageNumber) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QPixmap pixmap(":/resources/cover_unavailable.png");
|
QPixmap pixmap(":/resources/cover_unavailable.png");
|
||||||
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight, Qt::KeepAspectRatio));
|
bookIconArray[in]->setPixmap(pixmap.scaled(stdIconWidth, stdIconHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display book title
|
// Display book title
|
||||||
|
@ -232,13 +245,12 @@ void localLibraryWidget::setupBooksList(int pageNumber) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->pageNumberLabel->setText("Page " + QString::number(pageNumber) + " <i>of</i> " + QString::number(pagesNumber));
|
ui->pageNumberLabel->setText(QString::number(pageNumber) + " <i>of</i> " + QString::number(pagesNumber));
|
||||||
// NOTICE: Memory leak?
|
// NOTICE: Memory leak?
|
||||||
// Do it twice, otherwise the layout doesn't show as intended
|
// Do it twice, otherwise the layout doesn't show as intended
|
||||||
for(int i = 0; i <= 1; i++) {
|
for(int i = 0; i <= 1; i++) {
|
||||||
ui->verticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
|
ui->verticalLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
|
||||||
}
|
}
|
||||||
QTimer::singleShot(100, this, SLOT(refreshScreenNative()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::on_previousPageBtn_clicked()
|
void localLibraryWidget::on_previousPageBtn_clicked()
|
||||||
|
@ -249,6 +261,12 @@ void localLibraryWidget::on_previousPageBtn_clicked()
|
||||||
ui->nextPageBtn->setEnabled(true);
|
ui->nextPageBtn->setEnabled(true);
|
||||||
}
|
}
|
||||||
setupBooksList(currentPageNumber);
|
setupBooksList(currentPageNumber);
|
||||||
|
|
||||||
|
pagesTurned = pagesTurned + 1;
|
||||||
|
if(pagesTurned >= 3) {
|
||||||
|
emit refreshScreen();
|
||||||
|
pagesTurned = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,6 +278,12 @@ void localLibraryWidget::on_nextPageBtn_clicked()
|
||||||
ui->nextPageBtn->setEnabled(false);
|
ui->nextPageBtn->setEnabled(false);
|
||||||
}
|
}
|
||||||
setupBooksList(currentPageNumber);
|
setupBooksList(currentPageNumber);
|
||||||
|
|
||||||
|
pagesTurned = pagesTurned + 1;
|
||||||
|
if(pagesTurned >= 3) {
|
||||||
|
emit refreshScreen();
|
||||||
|
pagesTurned = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void localLibraryWidget::openBook(int bookID) {
|
void localLibraryWidget::openBook(int bookID) {
|
||||||
|
|
|
@ -32,9 +32,11 @@ public:
|
||||||
QJsonArray databaseJsonArrayList;
|
QJsonArray databaseJsonArrayList;
|
||||||
int currentPageNumber = 1;
|
int currentPageNumber = 1;
|
||||||
int pagesNumber;
|
int pagesNumber;
|
||||||
|
int pagesTurned = 0;
|
||||||
int booksNumber;
|
int booksNumber;
|
||||||
int bookTitleTruncateThreshold;
|
int bookTitleTruncateThreshold;
|
||||||
QVector<int> idList;
|
QVector<int> idList;
|
||||||
|
bool noBooksInDatabase = true;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setupDatabase();
|
void setupDatabase();
|
||||||
|
|
|
@ -18,7 +18,10 @@
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<family>Inter</family>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
|
<italic>false</italic>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
|
@ -40,15 +43,44 @@
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="3">
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
<widget class="QLabel" name="pageNumberLabel">
|
<widget class="QLabel" name="pageNumberLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Page</string>
|
<string>Page</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="6">
|
||||||
|
<widget class="QPushButton" name="nextPageBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="localLibraryLabel">
|
<widget class="QLabel" name="localLibraryLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><b>Local library</b></string>
|
<string><b>Local library</b></string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -61,11 +93,14 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="3">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Maximum</enum>
|
||||||
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>40</width>
|
||||||
|
@ -74,15 +109,43 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="4">
|
<item row="0" column="5">
|
||||||
<widget class="QPushButton" name="nextPageBtn">
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="text">
|
<property name="orientation">
|
||||||
<string/>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Maximum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="page">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="booksVerticalLayout">
|
<layout class="QVBoxLayout" name="booksVerticalLayout">
|
||||||
<property name="sizeConstraint">
|
<property name="sizeConstraint">
|
||||||
|
@ -92,6 +155,53 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="page_2">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="noBooksInLibraryLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Chivo</family>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>50</weight>
|
||||||
|
<italic>true</italic>
|
||||||
|
<bold>false</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>There are no books in your eReader yet.
|
||||||
|
Add some via USB or explore the Online Library.</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -313,7 +313,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
ui->homeStackedWidget->setCurrentIndex(0);
|
ui->homeStackedWidget->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setupLocalLibraryWidget();
|
setupHomePageWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if it's the first boot since an update and confirm that it installed successfully
|
// Check if it's the first boot since an update and confirm that it installed successfully
|
||||||
|
@ -507,7 +507,23 @@ void MainWindow::on_appsBtn_clicked()
|
||||||
|
|
||||||
void MainWindow::on_pushButton_clicked()
|
void MainWindow::on_pushButton_clicked()
|
||||||
{
|
{
|
||||||
openReaderFramework();
|
resetFullWindowException = true;
|
||||||
|
resetWindow(false);
|
||||||
|
if(global::mainwindow::tabSwitcher::localLibraryWidgetSelected != true) {
|
||||||
|
ui->pushButton->setStyleSheet("background: black; color: white");
|
||||||
|
ui->pushButton->setIcon(QIcon(":/resources/book_inverted.png"));
|
||||||
|
|
||||||
|
// Create widget
|
||||||
|
setupLocalLibraryWidget();
|
||||||
|
global::mainwindow::tabSwitcher::localLibraryWidgetCreated = true;
|
||||||
|
|
||||||
|
// Switch tab
|
||||||
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
global::mainwindow::tabSwitcher::localLibraryWidgetSelected = true;
|
||||||
|
|
||||||
|
// Repaint
|
||||||
|
this->repaint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_searchBtn_clicked()
|
void MainWindow::on_searchBtn_clicked()
|
||||||
|
@ -543,6 +559,7 @@ void MainWindow::on_homeBtn_clicked()
|
||||||
void MainWindow::resetWindow(bool resetStackedWidget) {
|
void MainWindow::resetWindow(bool resetStackedWidget) {
|
||||||
// Reset layout
|
// Reset layout
|
||||||
if(resetStackedWidget == true) {
|
if(resetStackedWidget == true) {
|
||||||
|
ui->homeStackedWidget->setCurrentIndex(2);
|
||||||
ui->stackedWidget->setCurrentIndex(0);
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,6 +573,9 @@ void MainWindow::resetWindow(bool resetStackedWidget) {
|
||||||
if(global::mainwindow::tabSwitcher::libraryWidgetCreated == true) {
|
if(global::mainwindow::tabSwitcher::libraryWidgetCreated == true) {
|
||||||
libraryWidgetWindow->deleteLater();
|
libraryWidgetWindow->deleteLater();
|
||||||
}
|
}
|
||||||
|
if(global::mainwindow::tabSwitcher::localLibraryWidgetCreated == true) {
|
||||||
|
localLibraryWidgetWindow->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
global::mainwindow::tabSwitcher::appsWidgetCreated = false;
|
global::mainwindow::tabSwitcher::appsWidgetCreated = false;
|
||||||
global::mainwindow::tabSwitcher::settingsChooserWidgetCreated = false;
|
global::mainwindow::tabSwitcher::settingsChooserWidgetCreated = false;
|
||||||
|
@ -563,12 +583,17 @@ void MainWindow::resetWindow(bool resetStackedWidget) {
|
||||||
global::mainwindow::tabSwitcher::settingsChooserWidgetSelected = false;
|
global::mainwindow::tabSwitcher::settingsChooserWidgetSelected = false;
|
||||||
global::mainwindow::tabSwitcher::libraryWidgetCreated = false;
|
global::mainwindow::tabSwitcher::libraryWidgetCreated = false;
|
||||||
global::mainwindow::tabSwitcher::libraryWidgetSelected = false;
|
global::mainwindow::tabSwitcher::libraryWidgetSelected = false;
|
||||||
|
global::mainwindow::tabSwitcher::localLibraryWidgetCreated = false;
|
||||||
|
global::mainwindow::tabSwitcher::localLibraryWidgetSelected = false;
|
||||||
|
|
||||||
resetIcons();
|
resetIcons();
|
||||||
setBatteryIcon();
|
setBatteryIcon();
|
||||||
if(global::mainwindow::tabSwitcher::repaint == true) {
|
if(global::mainwindow::tabSwitcher::repaint == true) {
|
||||||
this->repaint();
|
this->repaint();
|
||||||
}
|
}
|
||||||
|
if(resetStackedWidget == true) {
|
||||||
|
setupHomePageWidget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::resetIcons() {
|
void MainWindow::resetIcons() {
|
||||||
|
@ -579,6 +604,8 @@ void MainWindow::resetIcons() {
|
||||||
ui->settingsBtn->setIcon(QIcon(":/resources/settings.png"));
|
ui->settingsBtn->setIcon(QIcon(":/resources/settings.png"));
|
||||||
ui->libraryButton->setStyleSheet("background: white");
|
ui->libraryButton->setStyleSheet("background: white");
|
||||||
ui->libraryButton->setIcon(QIcon(":/resources/online-library.png"));
|
ui->libraryButton->setIcon(QIcon(":/resources/online-library.png"));
|
||||||
|
ui->pushButton->setStyleSheet("background: white");
|
||||||
|
ui->pushButton->setIcon(QIcon(":/resources/book.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setBatteryIcon() {
|
void MainWindow::setBatteryIcon() {
|
||||||
|
@ -927,7 +954,7 @@ void MainWindow::on_libraryButton_clicked()
|
||||||
{
|
{
|
||||||
log("Launching Online Library", className);
|
log("Launching Online Library", className);
|
||||||
if(testPing(true) == 0 or global::deviceID == "emu\n") {
|
if(testPing(true) == 0 or global::deviceID == "emu\n") {
|
||||||
resetFullWindowException = false;
|
resetFullWindowException = true;
|
||||||
resetWindow(false);
|
resetWindow(false);
|
||||||
if(global::mainwindow::tabSwitcher::libraryWidgetSelected != true) {
|
if(global::mainwindow::tabSwitcher::libraryWidgetSelected != true) {
|
||||||
ui->libraryButton->setStyleSheet("background: black; color: white");
|
ui->libraryButton->setStyleSheet("background: black; color: white");
|
||||||
|
@ -984,10 +1011,14 @@ void MainWindow::resetWifiIconClickedWhileReconnecting() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupLocalLibraryWidget() {
|
void MainWindow::setupLocalLibraryWidget() {
|
||||||
localLibraryWidget * localLibraryWidgetWindow = new localLibraryWidget();
|
localLibraryWidgetWindow = new localLibraryWidget(this);
|
||||||
connect(localLibraryWidgetWindow, SIGNAL(openBookSignal(QString, bool)), SLOT(openBookFile(QString, bool)));
|
connect(localLibraryWidgetWindow, SIGNAL(openBookSignal(QString, bool)), SLOT(openBookFile(QString, bool)));
|
||||||
connect(localLibraryWidgetWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
|
connect(localLibraryWidgetWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
|
||||||
localLibraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
|
localLibraryWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
ui->homeStackedWidget->insertWidget(1, localLibraryWidgetWindow);
|
ui->homeStackedWidget->insertWidget(1, localLibraryWidgetWindow);
|
||||||
ui->homeStackedWidget->setCurrentIndex(1);
|
ui->homeStackedWidget->setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupHomePageWidget() {
|
||||||
|
ui->homeStackedWidget->setCurrentIndex(2);
|
||||||
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ private slots:
|
||||||
void resetFullWindow();
|
void resetFullWindow();
|
||||||
void resetWifiIconClickedWhileReconnecting();
|
void resetWifiIconClickedWhileReconnecting();
|
||||||
void setupLocalLibraryWidget();
|
void setupLocalLibraryWidget();
|
||||||
|
void setupHomePageWidget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow * ui;
|
Ui::MainWindow * ui;
|
||||||
|
|
|
@ -386,6 +386,7 @@
|
||||||
</property>
|
</property>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="page_7"/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -20,11 +20,11 @@ otaManager::otaManager(QWidget *parent) :
|
||||||
connect(otaCheckTimer, &QTimer::timeout, [&]() {
|
connect(otaCheckTimer, &QTimer::timeout, [&]() {
|
||||||
if(QFile::exists("/run/can_ota_update") == true) {
|
if(QFile::exists("/run/can_ota_update") == true) {
|
||||||
if(checkconfig("/run/can_ota_update") == true) {
|
if(checkconfig("/run/can_ota_update") == true) {
|
||||||
log("OTA update is available!", className);
|
log("OTA update is available", className);
|
||||||
emit canOtaUpdate(true);
|
emit canOtaUpdate(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("No OTA update available.", className);
|
log("No OTA update available", className);
|
||||||
emit canOtaUpdate(false);
|
emit canOtaUpdate(false);
|
||||||
}
|
}
|
||||||
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
unsigned long currentEpoch = QDateTime::currentSecsSinceEpoch();
|
||||||
|
@ -44,12 +44,12 @@ otaManager::otaManager(QWidget *parent) :
|
||||||
connect(otaDownloadTimer, &QTimer::timeout, [&]() {
|
connect(otaDownloadTimer, &QTimer::timeout, [&]() {
|
||||||
if(QFile::exists("/run/can_install_ota_update") == true) {
|
if(QFile::exists("/run/can_install_ota_update") == true) {
|
||||||
if(checkconfig("/run/can_install_ota_update") == true) {
|
if(checkconfig("/run/can_install_ota_update") == true) {
|
||||||
log("Download succeeded.", className);
|
log("Download succeeded", className);
|
||||||
emit downloadedOtaUpdate(true);
|
emit downloadedOtaUpdate(true);
|
||||||
global::otaUpdate::downloadOta = false;
|
global::otaUpdate::downloadOta = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log("Download failed.", className);
|
log("Download failed", className);
|
||||||
emit downloadedOtaUpdate(false);
|
emit downloadedOtaUpdate(false);
|
||||||
global::otaUpdate::downloadOta = false;
|
global::otaUpdate::downloadOta = false;
|
||||||
}
|
}
|
||||||
|
|
BIN
resources/book_inverted.png
Normal file
BIN
resources/book_inverted.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
|
@ -216,6 +216,8 @@ void usbms_splash::restartServices() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Re-generate local library on next launch
|
||||||
|
QFile::remove(global::localLibrary::databasePath);
|
||||||
|
|
||||||
quit_restart();
|
quit_restart();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue