mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Progress in implementing "Open" function from search
This commit is contained in:
parent
f670ba207b
commit
34252c01bc
9 changed files with 90 additions and 6 deletions
|
@ -23,6 +23,7 @@ namespace global {
|
|||
inline bool batteryAlertLock;
|
||||
}
|
||||
namespace reader {
|
||||
inline QString bookFile;
|
||||
inline int pageNumber;
|
||||
inline int bookNumber;
|
||||
inline bool skipOpenDialog;
|
||||
|
|
|
@ -39,6 +39,19 @@ generalDialog::generalDialog(QWidget *parent) :
|
|||
ui->bodyLabel->setStyleSheet("font-size: 9pt");
|
||||
ui->searchComboBox->setStyleSheet("font-size: 9pt");
|
||||
|
||||
if(QFile::exists("/inkbox/searchComboBoxFunction") == true) {
|
||||
string_checkconfig_ro("/inkbox/searchComboBoxFunction");
|
||||
if(checkconfig_str_val == "Dictionary") {
|
||||
ui->searchComboBox->setCurrentIndex(0);
|
||||
}
|
||||
else if(checkconfig_str_val == "Local storage") {
|
||||
ui->searchComboBox->setCurrentIndex(1);
|
||||
}
|
||||
else {
|
||||
ui->searchComboBox->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(checkconfig("/inkbox/resetDialog") == true) {
|
||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||
resetDialog = true;
|
||||
|
@ -242,6 +255,7 @@ void generalDialog::on_okBtn_clicked()
|
|||
if(global::keyboard::searchDialog == true) {
|
||||
if(global::keyboard::keyboardText != "") {
|
||||
if(ui->searchComboBox->currentText() == "Dictionary") {
|
||||
string_writeconfig("/inkbox/searchComboBoxFunction", "Dictionary");
|
||||
for(int i = ui->mainStackedWidget->count(); i >= 0; i--) {
|
||||
QWidget * widget = ui->mainStackedWidget->widget(i);
|
||||
ui->mainStackedWidget->removeWidget(widget);
|
||||
|
@ -256,6 +270,7 @@ void generalDialog::on_okBtn_clicked()
|
|||
ui->mainStackedWidget->insertWidget(1, dictionaryWidgetWindow);
|
||||
}
|
||||
else if(ui->searchComboBox->currentText() == "Local storage") {
|
||||
string_writeconfig("/inkbox/searchComboBoxFunction", "Local storage");
|
||||
QString onboardPath;
|
||||
QStringList storageSearchResults;
|
||||
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||
|
@ -285,6 +300,9 @@ void generalDialog::on_okBtn_clicked()
|
|||
ui->topStackedWidget->setVisible(false);
|
||||
ui->stackedWidget->setVisible(false);
|
||||
searchResultsWidgetWindow = new searchResultsWidget(this);
|
||||
searchResultsWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(searchResultsWidgetWindow, SIGNAL(destroyed(QObject*)), SLOT(restartSearchDialog()));
|
||||
connect(searchResultsWidgetWindow, SIGNAL(openBookFile(QString)), SLOT(openBookFileNative(QString)));
|
||||
searchResultsWidgetWindow->setListViewContents(storageSearchResults);
|
||||
ui->mainStackedWidget->insertWidget(1, searchResultsWidgetWindow);
|
||||
}
|
||||
|
@ -459,3 +477,7 @@ void generalDialog::startOtaUpdate(bool wasDownloadSuccessful) {
|
|||
}
|
||||
generalDialog::close();
|
||||
}
|
||||
|
||||
void generalDialog::openBookFileNative(QString book) {
|
||||
emit openBookFile(book);
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ private slots:
|
|||
void refreshScreenNative();
|
||||
void connectToNetworkSlot();
|
||||
void startOtaUpdate(bool wasDownloadSuccessful);
|
||||
void openBookFileNative(QString book);
|
||||
|
||||
private:
|
||||
Ui::generalDialog *ui;
|
||||
|
@ -71,6 +72,7 @@ signals:
|
|||
void updateWifiIcon(int mode);
|
||||
void showToast(QString messageToDisplay);
|
||||
void closeIndefiniteToast();
|
||||
void openBookFile(QString book);
|
||||
};
|
||||
|
||||
#endif // GENERALDIALOG_H
|
||||
|
|
|
@ -861,6 +861,7 @@ void MainWindow::setupSearchDialog() {
|
|||
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)));
|
||||
generalDialogWindow->show();
|
||||
}
|
||||
else {
|
||||
|
@ -996,3 +997,11 @@ void MainWindow::launchOtaUpdater() {
|
|||
connect(otaManagerWindow, SIGNAL(canOtaUpdate(bool)), SLOT(openUpdateDialogOTA(bool)));
|
||||
otaManagerWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
}
|
||||
|
||||
void MainWindow::openBookFile(QString book) {
|
||||
global::reader::skipOpenDialog = true;
|
||||
global::reader::bookFile = book;
|
||||
readerWindow = new reader();
|
||||
readerWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
readerWindow->showFullScreen();
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ private slots:
|
|||
void closeIndefiniteToast();
|
||||
void openUpdateDialogOTA(bool open);
|
||||
void launchOtaUpdater();
|
||||
void openBookFile(QString book);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
|
|
@ -117,6 +117,10 @@ reader::reader(QWidget *parent) :
|
|||
string_writeconfig("/tmp/suspendBook", "false");
|
||||
book_file = "/inkbox/book/book.txt";
|
||||
}
|
||||
else if(global::reader::bookFile.isEmpty() == false) {
|
||||
book_file = global::reader::bookFile;
|
||||
global::reader::bookFile = "";
|
||||
}
|
||||
else {
|
||||
if(global::reader::bookNumber == 1) {
|
||||
string_checkconfig(".config/08-recent_books/1");
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
#include "searchresultswidget.h"
|
||||
#include "ui_searchresultswidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
|
||||
searchResultsWidget::searchResultsWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::searchResultsWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->listView->setStyleSheet("font-size: 9pt");
|
||||
ui->listView->setStyleSheet("font-size: 10pt");
|
||||
ui->backBtn->setProperty("type", "borderless");
|
||||
ui->backBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
|
||||
ui->openBtn->setProperty("type", "borderless");
|
||||
ui->openBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
|
||||
}
|
||||
|
||||
searchResultsWidget::~searchResultsWidget()
|
||||
|
@ -23,3 +25,23 @@ void searchResultsWidget::setListViewContents(QStringList searchResults) {
|
|||
model->setStringList(searchResults);
|
||||
ui->listView->setModel(model);
|
||||
}
|
||||
|
||||
void searchResultsWidget::on_openBtn_clicked()
|
||||
{
|
||||
index = ui->listView->currentIndex();
|
||||
itemText = index.data(Qt::DisplayRole).toString();
|
||||
if(!itemText.isEmpty()) {
|
||||
emit openBookFile(itemText);
|
||||
searchResultsWidget::close();
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(this, tr("Invalid argument"), tr("Please select a search result."));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void searchResultsWidget::on_backBtn_clicked()
|
||||
{
|
||||
searchResultsWidget::close();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,9 +16,18 @@ public:
|
|||
explicit searchResultsWidget(QWidget *parent = nullptr);
|
||||
~searchResultsWidget();
|
||||
void setListViewContents(QStringList searchResults);
|
||||
QModelIndex index;
|
||||
QString itemText;
|
||||
|
||||
private slots:
|
||||
void on_openBtn_clicked();
|
||||
void on_backBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::searchResultsWidget *ui;
|
||||
|
||||
signals:
|
||||
void openBookFile(QString book);
|
||||
};
|
||||
|
||||
#endif // SEARCHRESULTSWIDGET_H
|
||||
|
|
|
@ -48,11 +48,25 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="backBtn">
|
||||
<property name="text">
|
||||
<string>Back</string>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="openBtn">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="backBtn">
|
||||
<property name="text">
|
||||
<string>Back</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
|
Loading…
Reference in a new issue