Open book file from local storage search in Reader

This commit is contained in:
Nicolas Mailloux 2021-09-05 11:47:09 -04:00
parent 1e6e6ede6b
commit 6b8875272f
6 changed files with 27 additions and 21 deletions

View file

@ -94,6 +94,7 @@ namespace global {
inline bool isN905C;
inline bool isN613;
inline bool isN873;
inline bool runningInstanceIsReaderOnly;
}
// https://stackoverflow.com/questions/6080853/c-multiple-definition-error-for-global-functions-in-the-header-file/20679534#20679534

View file

@ -60,7 +60,7 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
alert w;
const QScreen* screen = qApp->primaryScreen();
const QScreen * screen = qApp->primaryScreen();
w.setGeometry(QRect(QPoint(0,0), screen->geometry().size()));
w.show();
return a.exec();
@ -68,6 +68,7 @@ int main(int argc, char *argv[])
// If we're waking from sleep and we have the lockscreen enabled, we'll "resume" the book from scratch
else if(checkconfig("/tmp/suspendBook") == true && checkconfig("/inkbox/bookIsEpub") == false) {
// Start the low/critical battery alert timer from the Reader framework since MainWindow is not going to be shown
global::runningInstanceIsReaderOnly = true;
global::reader::startBatteryWatchdog = true;
global::reader::startUsbmsPrompt = true;
global::reader::skipOpenDialog = true;
@ -154,7 +155,7 @@ int main(int argc, char *argv[])
;
}
const QScreen* screen = qApp->primaryScreen();
const QScreen * screen = qApp->primaryScreen();
w.setGeometry(QRect(QPoint(0,0), screen->geometry ().size()));
w.show();
return a.exec();

View file

@ -643,9 +643,7 @@ void MainWindow::on_appsBtn_clicked()
void MainWindow::on_pushButton_clicked()
{
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
openReaderFramework();
}
void MainWindow::on_searchBtn_clicked()
@ -666,9 +664,7 @@ void MainWindow::on_book1Btn_clicked()
global::reader::skipOpenDialog = true;
global::reader::bookNumber = 1;
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
openReaderFramework();
}
void MainWindow::on_book2Btn_clicked()
@ -676,9 +672,7 @@ void MainWindow::on_book2Btn_clicked()
global::reader::skipOpenDialog = true;
global::reader::bookNumber = 2;
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
openReaderFramework();
}
void MainWindow::on_book3Btn_clicked()
@ -686,9 +680,7 @@ void MainWindow::on_book3Btn_clicked()
global::reader::skipOpenDialog = true;
global::reader::bookNumber = 3;
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
openReaderFramework();
}
void MainWindow::on_book4Btn_clicked()
@ -696,9 +688,7 @@ void MainWindow::on_book4Btn_clicked()
global::reader::skipOpenDialog = true;
global::reader::bookNumber = 4;
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
readerWindow->showFullScreen();
openReaderFramework();
}
void MainWindow::on_brightnessBtn_clicked()
@ -1011,7 +1001,12 @@ void MainWindow::openBookFile(QString book, bool relativePath) {
global::reader::skipOpenDialog = true;
global::reader::bookFile = book;
openReaderFramework();
}
void MainWindow::openReaderFramework() {
readerWindow = new reader();
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
connect(readerWindow, SIGNAL(openBookFile(QString, bool)), SLOT(openBookFile(QString, bool)));
readerWindow->showFullScreen();
}

View file

@ -86,6 +86,7 @@ private slots:
void openUpdateDialogOTA(bool open);
void launchOtaUpdater();
void openBookFile(QString book, bool relativePath);
void openReaderFramework();
private:
Ui::MainWindow *ui;

View file

@ -1856,7 +1856,7 @@ void reader::setupSearchDialog() {
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(searchRefreshScreen()));
connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(setupSearchDialog()));
connect(generalDialogWindow, SIGNAL(openBookFile(QString, bool)), SLOT(openBookFile(QString, bool)));
connect(generalDialogWindow, SIGNAL(openBookFile(QString, bool)), SLOT(openBookFileNative(QString, bool)));
connect(generalDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
generalDialogWindow->show();
}
@ -2062,6 +2062,11 @@ void reader::on_increaseScaleBtn_clicked()
}
}
void reader::openBookFile(QString book, bool relativePath) {
qDebug() << "Open book:" << book;
void reader::openBookFileNative(QString book, bool relativePath) {
if(global::runningInstanceIsReaderOnly == false) {
emit openBookFile(book, relativePath);
}
else {
showToast("Not supported");
}
}

View file

@ -119,7 +119,6 @@ public:
void setBitterFont();
void setCrimsonProFont();
void setIbarraFont();
void showToast(QString messageToDisplay);
bool pdf_file_match(QString file);
private slots:
@ -156,6 +155,10 @@ private slots:
void on_pdfScaleSlider_valueChanged(int value);
void on_decreaseScaleBtn_clicked();
void on_increaseScaleBtn_clicked();
void openBookFileNative(QString book, bool relativePath);
void showToast(QString messageToDisplay);
signals:
void openBookFile(QString book, bool relativePath);
private: