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 <QTimer>
|
||||
#include <QMessageBox>
|
||||
#include <QDirIterator>
|
||||
#include <QStringListModel>
|
||||
#include <QListView>
|
||||
|
||||
generalDialog::generalDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
|
@ -252,6 +255,43 @@ void generalDialog::on_okBtn_clicked()
|
|||
connect(dictionaryWidgetWindow, SIGNAL(destroyed(QObject*)), SLOT(restartSearchDialog()));
|
||||
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 {
|
||||
;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "virtualkeypad.h"
|
||||
#include "dictionarywidget.h"
|
||||
#include "otamanager.h"
|
||||
#include "searchresultswidget.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -62,6 +63,7 @@ private:
|
|||
virtualkeypad *keypadWidget;
|
||||
dictionaryWidget *dictionaryWidgetWindow;
|
||||
otaManager *otaManagerWindow;
|
||||
searchResultsWidget * searchResultsWidgetWindow;
|
||||
|
||||
signals:
|
||||
void gotoPageSelected(int value);
|
||||
|
|
|
@ -218,6 +218,11 @@
|
|||
<string>Dictionary</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Local storage</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -25,6 +25,7 @@ SOURCES += \
|
|||
quit.cpp \
|
||||
reader.cpp \
|
||||
savedwords.cpp \
|
||||
searchresultswidget.cpp \
|
||||
settings.cpp \
|
||||
settingschooser.cpp \
|
||||
textwidget.cpp \
|
||||
|
@ -49,6 +50,7 @@ HEADERS += \
|
|||
quit.h \
|
||||
reader.h \
|
||||
savedwords.h \
|
||||
searchresultswidget.h \
|
||||
settings.h \
|
||||
settingschooser.h \
|
||||
textwidget.h \
|
||||
|
@ -72,6 +74,7 @@ FORMS += \
|
|||
quit.ui \
|
||||
reader.ui \
|
||||
savedwords.ui \
|
||||
searchresultswidget.ui \
|
||||
settings.ui \
|
||||
settingschooser.ui \
|
||||
textwidget.ui \
|
||||
|
|
|
@ -18,7 +18,7 @@ savedwords::savedwords(QWidget *parent) :
|
|||
|
||||
checkwords();
|
||||
|
||||
QStringListModel* model = new QStringListModel(this);
|
||||
QStringListModel * model = new QStringListModel(this);
|
||||
QStringList list = words.split("\n", QString::SkipEmptyParts);
|
||||
model->setStringList(list);
|
||||
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) {
|
||||
emit closeIndefiniteToast();
|
||||
if(open == true) {
|
||||
global::otaUpdate::isUpdateOta = true;
|
||||
openUpdateDialog();
|
||||
|
|
Loading…
Reference in a new issue