mirror of
https://github.com/Quill-OS/quill.git
synced 2024-12-26 23:57:22 -08:00
Search in local storage implemented
Now I have to implement an "Open" function
This commit is contained in:
parent
f4a842a55d
commit
f670ba207b
9 changed files with 164 additions and 1 deletions
|
@ -10,6 +10,9 @@
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QDirIterator>
|
||||||
|
#include <QStringListModel>
|
||||||
|
#include <QListView>
|
||||||
|
|
||||||
generalDialog::generalDialog(QWidget *parent) :
|
generalDialog::generalDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -252,6 +255,43 @@ void generalDialog::on_okBtn_clicked()
|
||||||
connect(dictionaryWidgetWindow, SIGNAL(destroyed(QObject*)), SLOT(restartSearchDialog()));
|
connect(dictionaryWidgetWindow, SIGNAL(destroyed(QObject*)), SLOT(restartSearchDialog()));
|
||||||
ui->mainStackedWidget->insertWidget(1, dictionaryWidgetWindow);
|
ui->mainStackedWidget->insertWidget(1, dictionaryWidgetWindow);
|
||||||
}
|
}
|
||||||
|
else if(ui->searchComboBox->currentText() == "Local storage") {
|
||||||
|
QString onboardPath;
|
||||||
|
QStringList storageSearchResults;
|
||||||
|
if(checkconfig("/opt/inkbox_genuine") == true) {
|
||||||
|
onboardPath = "/mnt/onboard/onboard/";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
onboardPath = "/mnt/onboard/";
|
||||||
|
}
|
||||||
|
QDirIterator dirIt(onboardPath, QDirIterator::Subdirectories);
|
||||||
|
while(dirIt.hasNext()) {
|
||||||
|
dirIt.next();
|
||||||
|
if(QFileInfo(dirIt.filePath()).isFile()) {
|
||||||
|
QString suffix = QFileInfo(dirIt.filePath()).suffix();
|
||||||
|
if(suffix == "txt" or suffix == "TXT" or suffix == "epub" or suffix == "pdf" or suffix == "PDF") {
|
||||||
|
if(dirIt.fileName().contains(global::keyboard::keyboardText) == true) {
|
||||||
|
storageSearchResults.append(dirIt.fileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!storageSearchResults.isEmpty()) {
|
||||||
|
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->setListViewContents(storageSearchResults);
|
||||||
|
ui->mainStackedWidget->insertWidget(1, searchResultsWidgetWindow);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit showToast("No results found");
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "virtualkeypad.h"
|
#include "virtualkeypad.h"
|
||||||
#include "dictionarywidget.h"
|
#include "dictionarywidget.h"
|
||||||
#include "otamanager.h"
|
#include "otamanager.h"
|
||||||
|
#include "searchresultswidget.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ private:
|
||||||
virtualkeypad *keypadWidget;
|
virtualkeypad *keypadWidget;
|
||||||
dictionaryWidget *dictionaryWidgetWindow;
|
dictionaryWidget *dictionaryWidgetWindow;
|
||||||
otaManager *otaManagerWindow;
|
otaManager *otaManagerWindow;
|
||||||
|
searchResultsWidget * searchResultsWidgetWindow;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void gotoPageSelected(int value);
|
void gotoPageSelected(int value);
|
||||||
|
|
|
@ -218,6 +218,11 @@
|
||||||
<string>Dictionary</string>
|
<string>Dictionary</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Local storage</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -25,6 +25,7 @@ SOURCES += \
|
||||||
quit.cpp \
|
quit.cpp \
|
||||||
reader.cpp \
|
reader.cpp \
|
||||||
savedwords.cpp \
|
savedwords.cpp \
|
||||||
|
searchresultswidget.cpp \
|
||||||
settings.cpp \
|
settings.cpp \
|
||||||
settingschooser.cpp \
|
settingschooser.cpp \
|
||||||
textwidget.cpp \
|
textwidget.cpp \
|
||||||
|
@ -49,6 +50,7 @@ HEADERS += \
|
||||||
quit.h \
|
quit.h \
|
||||||
reader.h \
|
reader.h \
|
||||||
savedwords.h \
|
savedwords.h \
|
||||||
|
searchresultswidget.h \
|
||||||
settings.h \
|
settings.h \
|
||||||
settingschooser.h \
|
settingschooser.h \
|
||||||
textwidget.h \
|
textwidget.h \
|
||||||
|
@ -72,6 +74,7 @@ FORMS += \
|
||||||
quit.ui \
|
quit.ui \
|
||||||
reader.ui \
|
reader.ui \
|
||||||
savedwords.ui \
|
savedwords.ui \
|
||||||
|
searchresultswidget.ui \
|
||||||
settings.ui \
|
settings.ui \
|
||||||
settingschooser.ui \
|
settingschooser.ui \
|
||||||
textwidget.ui \
|
textwidget.ui \
|
||||||
|
|
|
@ -18,7 +18,7 @@ savedwords::savedwords(QWidget *parent) :
|
||||||
|
|
||||||
checkwords();
|
checkwords();
|
||||||
|
|
||||||
QStringListModel* model = new QStringListModel(this);
|
QStringListModel * model = new QStringListModel(this);
|
||||||
QStringList list = words.split("\n", QString::SkipEmptyParts);
|
QStringList list = words.split("\n", QString::SkipEmptyParts);
|
||||||
model->setStringList(list);
|
model->setStringList(list);
|
||||||
ui->wordsList->setModel(model);
|
ui->wordsList->setModel(model);
|
||||||
|
|
25
searchresultswidget.cpp
Normal file
25
searchresultswidget.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#include "searchresultswidget.h"
|
||||||
|
#include "ui_searchresultswidget.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
searchResultsWidget::searchResultsWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
ui(new Ui::searchResultsWidget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
ui->listView->setStyleSheet("font-size: 9pt");
|
||||||
|
ui->backBtn->setProperty("type", "borderless");
|
||||||
|
ui->backBtn->setStyleSheet("font-size: 9pt; padding: 10px; font-weight: bold; background: lightGrey");
|
||||||
|
}
|
||||||
|
|
||||||
|
searchResultsWidget::~searchResultsWidget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void searchResultsWidget::setListViewContents(QStringList searchResults) {
|
||||||
|
QStringListModel * model = new QStringListModel(this);
|
||||||
|
model->setStringList(searchResults);
|
||||||
|
ui->listView->setModel(model);
|
||||||
|
}
|
24
searchresultswidget.h
Normal file
24
searchresultswidget.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef SEARCHRESULTSWIDGET_H
|
||||||
|
#define SEARCHRESULTSWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QStringListModel>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class searchResultsWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class searchResultsWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit searchResultsWidget(QWidget *parent = nullptr);
|
||||||
|
~searchResultsWidget();
|
||||||
|
void setListViewContents(QStringList searchResults);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::searchResultsWidget *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SEARCHRESULTSWIDGET_H
|
63
searchresultswidget.ui
Normal file
63
searchresultswidget.ui
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>searchResultsWidget</class>
|
||||||
|
<widget class="QWidget" name="searchResultsWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QListView" name="listView"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="searchResultsLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Search results</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QPushButton" name="backBtn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Back</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -900,6 +900,7 @@ void settings::launchOtaUpdater() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings::openUpdateDialogOTA(bool open) {
|
void settings::openUpdateDialogOTA(bool open) {
|
||||||
|
emit closeIndefiniteToast();
|
||||||
if(open == true) {
|
if(open == true) {
|
||||||
global::otaUpdate::isUpdateOta = true;
|
global::otaUpdate::isUpdateOta = true;
|
||||||
openUpdateDialog();
|
openUpdateDialog();
|
||||||
|
|
Loading…
Reference in a new issue