Local storage book search implemented and working

This commit is contained in:
Nicolas Mailloux 2021-09-05 09:37:07 -04:00
parent 34252c01bc
commit 4c5fd69f57
9 changed files with 35 additions and 14 deletions

View file

@ -76,6 +76,7 @@ namespace global {
inline bool wifiToast;
inline bool modalToast;
inline bool indefiniteToast;
inline int delay;
}
namespace device {
inline bool isWifiAble;

View file

@ -302,12 +302,15 @@ void generalDialog::on_okBtn_clicked()
searchResultsWidgetWindow = new searchResultsWidget(this);
searchResultsWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
connect(searchResultsWidgetWindow, SIGNAL(destroyed(QObject*)), SLOT(restartSearchDialog()));
connect(searchResultsWidgetWindow, SIGNAL(openBookFile(QString)), SLOT(openBookFileNative(QString)));
connect(searchResultsWidgetWindow, SIGNAL(openBookFile(QString, bool)), SLOT(openBookFileNative(QString, bool)));
searchResultsWidgetWindow->setListViewContents(storageSearchResults);
ui->mainStackedWidget->insertWidget(1, searchResultsWidgetWindow);
}
else {
global::toast::delay = 3000;
emit showToast("No results found");
keyboardWidget->clearLineEdit();
global::keyboard::keyboardText = "";
}
}
else {
@ -478,6 +481,6 @@ void generalDialog::startOtaUpdate(bool wasDownloadSuccessful) {
generalDialog::close();
}
void generalDialog::openBookFileNative(QString book) {
emit openBookFile(book);
void generalDialog::openBookFileNative(QString book, bool relativePath) {
emit openBookFile(book, relativePath);
}

View file

@ -54,7 +54,7 @@ private slots:
void refreshScreenNative();
void connectToNetworkSlot();
void startOtaUpdate(bool wasDownloadSuccessful);
void openBookFileNative(QString book);
void openBookFileNative(QString book, bool relativePath);
private:
Ui::generalDialog *ui;
@ -72,7 +72,7 @@ signals:
void updateWifiIcon(int mode);
void showToast(QString messageToDisplay);
void closeIndefiniteToast();
void openBookFile(QString book);
void openBookFile(QString book, bool relativePath);
};
#endif // GENERALDIALOG_H

View file

@ -859,9 +859,10 @@ void MainWindow::setupSearchDialog() {
global::keyboard::keyboardText = "";
generalDialogWindow = new generalDialog();
generalDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
connect(generalDialogWindow, SIGNAL(destroyed(QObject*)), SLOT(setupSearchDialog()));
connect(generalDialogWindow, SIGNAL(openBookFile(QString)), SLOT(openBookFile(QString)));
connect(generalDialogWindow, SIGNAL(refreshScreen()), SLOT(refreshScreen()));
connect(generalDialogWindow, SIGNAL(showToast(QString)), SLOT(showToast(QString)));
connect(generalDialogWindow, SIGNAL(openBookFile(QString, bool)), SLOT(openBookFile(QString, bool)));
generalDialogWindow->show();
}
else {
@ -998,7 +999,16 @@ void MainWindow::launchOtaUpdater() {
otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose);
}
void MainWindow::openBookFile(QString book) {
void MainWindow::openBookFile(QString book, bool relativePath) {
if(relativePath == true) {
if(checkconfig("/opt/inkbox_genuine") == true) {
book.prepend("/mnt/onboard/onboard/");
}
else {
book.prepend("/mnt/onboard/");
}
}
global::reader::skipOpenDialog = true;
global::reader::bookFile = book;
readerWindow = new reader();

View file

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

View file

@ -413,7 +413,7 @@ reader::reader(QWidget *parent) :
}
// Get text; no need to do it multiple times for ePUB books
if(is_epub != true) {
if(is_epub == false or is_pdf == false) {
setDefaultWorkDir();
if(global::reader::globalReadingSettings == false) {
string_checkconfig_ro(".config/A-page_number/config");

View file

@ -31,7 +31,7 @@ void searchResultsWidget::on_openBtn_clicked()
index = ui->listView->currentIndex();
itemText = index.data(Qt::DisplayRole).toString();
if(!itemText.isEmpty()) {
emit openBookFile(itemText);
emit openBookFile(itemText, true);
searchResultsWidget::close();
}
else {

View file

@ -27,7 +27,7 @@ private:
Ui::searchResultsWidget *ui;
signals:
void openBookFile(QString book);
void openBookFile(QString book, bool relativePath);
};
#endif // SEARCHRESULTSWIDGET_H

View file

@ -21,6 +21,12 @@ toast::toast(QWidget *parent) :
ui->messageLabel->setText(global::toast::message);
this->adjustSize();
centerToast();
qDebug() << global::toast::delay;
if(global::toast::indefiniteToast == false) {
if(global::toast::delay == 0) {
global::toast::delay = 5000;
}
}
if(global::toast::wifiToast == true) {
global::toast::wifiToast = false;
this->setModal(true);
@ -36,7 +42,8 @@ toast::toast(QWidget *parent) :
}
else {
if(global::toast::indefiniteToast == false) {
QTimer::singleShot(5000, this, SLOT(close()));
QTimer::singleShot(global::toast::delay, this, SLOT(close()));
global::toast::delay = 0;
}
else {
global::toast::indefiniteToast = false;
@ -77,7 +84,7 @@ void toast::exitSlot(int exitCode) {
}
else {
ui->messageLabel->setText("No networks found");
QTimer::singleShot(5000, this, SLOT(close()));
QTimer::singleShot(global::toast::delay, this, SLOT(close()));
}
}