mainwindow: Save/Restore history

Cette révision appartient à :
Albert S. 2022-08-21 17:47:34 +02:00
Parent 2885e40a3a
révision 0c1b57d911
3 fichiers modifiés avec 16 ajouts et 0 suppressions

Voir le fichier

@ -60,6 +60,10 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath)
QString ignorePatterns = settings.value("ignorePatterns").toString(); QString ignorePatterns = settings.value("ignorePatterns").toString();
ui->txtIgnorePatterns->setText(ignorePatterns); ui->txtIgnorePatterns->setText(ignorePatterns);
QStringList searchHistoryList = settings.value(SETTINGS_KEY_SEARCHHISTORY).toStringList();
this->searchHistory = searchHistoryList.toVector();
this->currentSearchHistoryIndex = this->searchHistory.size();
ui->spinPreviewPage->setValue(1); ui->spinPreviewPage->setValue(1);
ui->spinPreviewPage->setMinimum(1); ui->spinPreviewPage->setMinimum(1);
@ -989,3 +993,11 @@ MainWindow::~MainWindow()
delete this->indexer; delete this->indexer;
delete ui; delete ui;
} }
void MainWindow::closeEvent(QCloseEvent *event)
{
QStringList list = this->searchHistory.toList();
QSettings settings;
settings.setValue(SETTINGS_KEY_SEARCHHISTORY, list);
settings.sync();
}

Voir le fichier

@ -30,6 +30,9 @@ class MainWindow : public QMainWindow
void beginSearch(const QString &query); void beginSearch(const QString &query);
void startPdfPreviewGeneration(QVector<SearchResult> paths, double scalefactor); void startPdfPreviewGeneration(QVector<SearchResult> paths, double scalefactor);
protected:
void closeEvent(QCloseEvent *event) override;
private: private:
DatabaseFactory *dbFactory; DatabaseFactory *dbFactory;
SqliteDbService *dbService; SqliteDbService *dbService;

Voir le fichier

@ -9,6 +9,7 @@
#define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths" #define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths"
#define SETTINGS_KEY_MOUNTPATHS "mountpaths" #define SETTINGS_KEY_MOUNTPATHS "mountpaths"
#define SETTINGS_KEY_PREVIEWSPERPAGE "previewsPerPage" #define SETTINGS_KEY_PREVIEWSPERPAGE "previewsPerPage"
#define SETTINGS_KEY_SEARCHHISTORY "searchhistory"
namespace Common namespace Common
{ {