mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-28 08:37: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(new Ui::bookInfoDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
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->setProperty("type", "borderless");
|
||||||
ui->closeBtn->setText("");
|
ui->closeBtn->setText("");
|
||||||
ui->closeBtn->setIcon(QIcon(":/resources/close.png"));
|
ui->closeBtn->setIcon(QIcon(":/resources/close.png"));
|
||||||
|
|
|
@ -108,6 +108,7 @@ namespace global {
|
||||||
inline int latestBookNumber;
|
inline int latestBookNumber;
|
||||||
inline QString bookTitle;
|
inline QString bookTitle;
|
||||||
inline bool librarySearchDialog;
|
inline bool librarySearchDialog;
|
||||||
|
inline bool libraryResults;
|
||||||
}
|
}
|
||||||
inline QString systemInfoText;
|
inline QString systemInfoText;
|
||||||
inline bool forbidOpenSearchDialog;
|
inline bool forbidOpenSearchDialog;
|
||||||
|
|
|
@ -345,7 +345,40 @@ void generalDialog::on_okBtn_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(ui->searchComboBox->currentText() == "Online library") {
|
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 {
|
else {
|
||||||
;
|
;
|
||||||
|
|
|
@ -9,11 +9,17 @@ searchResultsWidget::searchResultsWidget(QWidget *parent) :
|
||||||
ui(new Ui::searchResultsWidget)
|
ui(new Ui::searchResultsWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->listView->setStyleSheet("font-size: 10pt");
|
ui->listView->setStyleSheet("font-size: 10pt");
|
||||||
ui->backBtn->setProperty("type", "borderless");
|
ui->backBtn->setProperty("type", "borderless");
|
||||||
ui->backBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
|
ui->backBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
|
||||||
ui->openBtn->setProperty("type", "borderless");
|
ui->openBtn->setProperty("type", "borderless");
|
||||||
ui->openBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
|
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()
|
searchResultsWidget::~searchResultsWidget()
|
||||||
|
@ -29,8 +35,20 @@ void searchResultsWidget::setListViewContents(QStringList searchResults) {
|
||||||
|
|
||||||
void searchResultsWidget::on_openBtn_clicked()
|
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 {
|
else {
|
||||||
index = ui->listView->currentIndex();
|
index = ui->listView->currentIndex();
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
|
#include "bookinfodialog.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class searchResultsWidget;
|
class searchResultsWidget;
|
||||||
|
@ -18,6 +19,7 @@ public:
|
||||||
void setListViewContents(QStringList searchResults);
|
void setListViewContents(QStringList searchResults);
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
QString itemText;
|
QString itemText;
|
||||||
|
bool libraryResults;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_openBtn_clicked();
|
void on_openBtn_clicked();
|
||||||
|
@ -25,6 +27,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::searchResultsWidget *ui;
|
Ui::searchResultsWidget *ui;
|
||||||
|
bookInfoDialog * bookInfoDialogWindow;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openBookFile(QString book, bool relativePath);
|
void openBookFile(QString book, bool relativePath);
|
||||||
|
|
Loading…
Reference in a new issue