mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Basic search on online library implemented
This commit is contained in:
parent
9a6533efc8
commit
4b30573899
5 changed files with 63 additions and 1 deletions
|
@ -9,6 +9,13 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) :
|
|||
ui(new Ui::bookInfoDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Stylesheet
|
||||
QFile stylesheetFile(":/resources/eink.qss");
|
||||
stylesheetFile.open(QFile::ReadOnly);
|
||||
this->setStyleSheet(stylesheetFile.readAll());
|
||||
stylesheetFile.close();
|
||||
|
||||
ui->closeBtn->setProperty("type", "borderless");
|
||||
ui->closeBtn->setText("");
|
||||
ui->closeBtn->setIcon(QIcon(":/resources/close.png"));
|
||||
|
|
|
@ -108,6 +108,7 @@ namespace global {
|
|||
inline int latestBookNumber;
|
||||
inline QString bookTitle;
|
||||
inline bool librarySearchDialog;
|
||||
inline bool libraryResults;
|
||||
}
|
||||
inline QString systemInfoText;
|
||||
inline bool forbidOpenSearchDialog;
|
||||
|
|
|
@ -345,7 +345,40 @@ void generalDialog::on_okBtn_clicked()
|
|||
}
|
||||
}
|
||||
else if(ui->searchComboBox->currentText() == "Online library") {
|
||||
string_writeconfig("/inkbox/searchComboBoxFunction", "Online library");
|
||||
string_writeconfig("/inkbox/gutenberg_search_request", global::keyboard::keyboardText.toStdString());
|
||||
string_writeconfig("/opt/ibxd", "gutenberg_search\n");
|
||||
while(true) {
|
||||
if(QFile::exists("/inkbox/gutenberg-search/search_done")) {
|
||||
if(checkconfig("/inkbox/gutenberg-search/search_done") == true) {
|
||||
QStringList searchResults = readFile("/inkbox/gutenberg-search/search_results_titles").split("\n");
|
||||
global::library::libraryResults = true;
|
||||
|
||||
for(int i = ui->mainStackedWidget->count(); i >= 0; i--) {
|
||||
QWidget * widget = ui->mainStackedWidget->widget(i);
|
||||
ui->mainStackedWidget->removeWidget(widget);
|
||||
widget->deleteLater();
|
||||
}
|
||||
ui->topStackedWidget->setVisible(false);
|
||||
ui->stackedWidget->setVisible(false);
|
||||
searchResultsWidgetWindow = new searchResultsWidget(this);
|
||||
searchResultsWidgetWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
global::forbidOpenSearchDialog = true;
|
||||
connect(searchResultsWidgetWindow, SIGNAL(destroyed(QObject*)), SLOT(restartSearchDialog()));
|
||||
searchResultsWidgetWindow->setListViewContents(searchResults);
|
||||
ui->mainStackedWidget->insertWidget(1, searchResultsWidgetWindow);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
global::toast::delay = 3000;
|
||||
emit showToast("No results found");
|
||||
keyboardWidget->clearLineEdit();
|
||||
global::keyboard::keyboardText = "";
|
||||
break;
|
||||
}
|
||||
QFile::remove("/inkbox/gutenberg-search/search_done");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
;
|
||||
|
|
|
@ -9,11 +9,17 @@ searchResultsWidget::searchResultsWidget(QWidget *parent) :
|
|||
ui(new Ui::searchResultsWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
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");
|
||||
|
||||
if(global::library::libraryResults == true) {
|
||||
global::library::libraryResults = false;
|
||||
libraryResults = true;
|
||||
}
|
||||
}
|
||||
|
||||
searchResultsWidget::~searchResultsWidget()
|
||||
|
@ -29,8 +35,20 @@ void searchResultsWidget::setListViewContents(QStringList searchResults) {
|
|||
|
||||
void searchResultsWidget::on_openBtn_clicked()
|
||||
{
|
||||
if(global::library::librarySearchDialog == true) {
|
||||
if(libraryResults == true) {
|
||||
// Get currently selected row number
|
||||
int selectedRow = ui->listView->currentIndex().row();
|
||||
// So that row 0 becomes row 1
|
||||
selectedRow = selectedRow++;
|
||||
|
||||
// TODO: Find book ID and pass it on to bookInfoDialog, then retrieve cover.jpg for display
|
||||
|
||||
global::keyboard::searchDialog = false;
|
||||
global::keyboard::keyboardDialog = false;
|
||||
|
||||
bookInfoDialog * bookInfoDialogWindow = new bookInfoDialog();
|
||||
bookInfoDialogWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
bookInfoDialogWindow->show();
|
||||
}
|
||||
else {
|
||||
index = ui->listView->currentIndex();
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QStringListModel>
|
||||
#include "bookinfodialog.h"
|
||||
|
||||
namespace Ui {
|
||||
class searchResultsWidget;
|
||||
|
@ -18,6 +19,7 @@ public:
|
|||
void setListViewContents(QStringList searchResults);
|
||||
QModelIndex index;
|
||||
QString itemText;
|
||||
bool libraryResults;
|
||||
|
||||
private slots:
|
||||
void on_openBtn_clicked();
|
||||
|
@ -25,6 +27,7 @@ private slots:
|
|||
|
||||
private:
|
||||
Ui::searchResultsWidget *ui;
|
||||
bookInfoDialog * bookInfoDialogWindow;
|
||||
|
||||
signals:
|
||||
void openBookFile(QString book, bool relativePath);
|
||||
|
|
Loading…
Reference in a new issue