gui: Add 'Settings' tab
This commit is contained in:
parent
e76988ee77
commit
dd479fa668
@ -215,6 +215,7 @@ void MainWindow::connectSignals()
|
|||||||
});
|
});
|
||||||
connect(this, &MainWindow::beginIndexSync, indexSyncer, &IndexSyncer::sync);
|
connect(this, &MainWindow::beginIndexSync, indexSyncer, &IndexSyncer::sync);
|
||||||
connect(&this->progressDialog, &QProgressDialog::canceled, indexSyncer, &IndexSyncer::cancel);
|
connect(&this->progressDialog, &QProgressDialog::canceled, indexSyncer, &IndexSyncer::cancel);
|
||||||
|
connect(ui->btnSaveSettings, &QPushButton::clicked, this, &MainWindow::saveSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::startIndexSync()
|
void MainWindow::startIndexSync()
|
||||||
@ -236,6 +237,7 @@ void MainWindow::startIndexSync()
|
|||||||
|
|
||||||
emit beginIndexSync();
|
emit beginIndexSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::spinPreviewPageValueChanged(int val)
|
void MainWindow::spinPreviewPageValueChanged(int val)
|
||||||
{
|
{
|
||||||
makePreviews(val);
|
makePreviews(val);
|
||||||
@ -351,6 +353,45 @@ void MainWindow::tabChanged()
|
|||||||
makePreviews(ui->spinPreviewPage->value());
|
makePreviews(ui->spinPreviewPage->value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Settings tab active */
|
||||||
|
if(ui->tabWidget->currentIndex() == 3)
|
||||||
|
{
|
||||||
|
initSettingsTabs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::initSettingsTabs()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
QString pdfViewerCmd = settings.value(SETTINGS_KEY_PDFVIEWER).toString();
|
||||||
|
QString excludedPaths = Common::excludedPaths().join(';');
|
||||||
|
QString mountPaths = Common::mountPaths().join(';');
|
||||||
|
int numPagesPerPreview = settings.value(SETTINGS_KEY_PREVIEWSPERPAGE, 20).toInt();
|
||||||
|
|
||||||
|
ui->txtSettingPdfPreviewerCmd->setText(pdfViewerCmd);
|
||||||
|
ui->txtSettingIgnoredPaths->setText(excludedPaths);
|
||||||
|
ui->txtSettingMountPaths->setText(mountPaths);
|
||||||
|
ui->spinSettingNumerPerPages->setValue(numPagesPerPreview);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::saveSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
QString pdfViewerCmd = ui->txtSettingPdfPreviewerCmd->text();
|
||||||
|
QStringList excludedPaths = ui->txtSettingIgnoredPaths->text().split(';');
|
||||||
|
QStringList mountPaths = ui->txtSettingMountPaths->text().split(';');
|
||||||
|
|
||||||
|
settings.setValue(SETTINGS_KEY_PDFVIEWER, pdfViewerCmd);
|
||||||
|
settings.setValue(SETTINGS_KEY_EXCLUDEDPATHS, excludedPaths);
|
||||||
|
settings.setValue(SETTINGS_KEY_MOUNTPATHS, mountPaths);
|
||||||
|
settings.setValue(SETTINGS_KEY_PREVIEWSPERPAGE, ui->spinSettingNumerPerPages->value());
|
||||||
|
|
||||||
|
settings.sync();
|
||||||
|
|
||||||
|
QProcess::startDetached(qApp->arguments()[0], qApp->arguments().mid(1));
|
||||||
|
qApp->quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::previewReceived(QSharedPointer<PreviewResult> preview, unsigned int previewGeneration)
|
void MainWindow::previewReceived(QSharedPointer<PreviewResult> preview, unsigned int previewGeneration)
|
||||||
@ -389,7 +430,7 @@ void MainWindow::lineEditReturnPressed()
|
|||||||
ui->lblSearchResults->setText("Invalid paranthesis");
|
ui->lblSearchResults->setText("Invalid paranthesis");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(indexerTabActive())
|
if(ui->tabWidget->currentIndex() > 1)
|
||||||
{
|
{
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ class MainWindow : public QMainWindow
|
|||||||
void openDocument(QString path, int num);
|
void openDocument(QString path, int num);
|
||||||
void openFile(QString path);
|
void openFile(QString path);
|
||||||
unsigned int currentPreviewGeneration = 1;
|
unsigned int currentPreviewGeneration = 1;
|
||||||
|
void initSettingsTabs();
|
||||||
private slots:
|
private slots:
|
||||||
void lineEditReturnPressed();
|
void lineEditReturnPressed();
|
||||||
void treeSearchItemActivated(QTreeWidgetItem *item, int i);
|
void treeSearchItemActivated(QTreeWidgetItem *item, int i);
|
||||||
@ -73,6 +74,7 @@ class MainWindow : public QMainWindow
|
|||||||
void finishIndexing();
|
void finishIndexing();
|
||||||
void addPathToIndex();
|
void addPathToIndex();
|
||||||
void startIndexSync();
|
void startIndexSync();
|
||||||
|
void saveSettings();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets);
|
void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets);
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1221</width>
|
<width>1280</width>
|
||||||
<height>709</height>
|
<height>736</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -27,7 +27,7 @@
|
|||||||
<enum>QTabWidget::South</enum>
|
<enum>QTabWidget::South</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="resultsTab">
|
<widget class="QWidget" name="resultsTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@ -81,8 +81,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1185</width>
|
<width>1244</width>
|
||||||
<height>419</height>
|
<height>446</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||||
@ -344,6 +344,126 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="settingsTab">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Settings</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupPdfSettings">
|
||||||
|
<property name="title">
|
||||||
|
<string>PDF Viewer</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command to open PDF pages in (%f = file path; %p = page number)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="txtSettingPdfPreviewerCmd"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupMountPaths">
|
||||||
|
<property name="title">
|
||||||
|
<string>Mount paths</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblMountPaths">
|
||||||
|
<property name="text">
|
||||||
|
<string>Path prefixes of files that should not be removed during sync, even if they cannot be accessed (e . g. files indexed on external disks) . Separated by ;</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="txtSettingMountPaths"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Ignored paths</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Path prefixes that should always be ignored during indexing (will be applied before the ignore patterns). Separated by ;</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="txtSettingIgnoredPaths"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="Misc">
|
||||||
|
<property name="title">
|
||||||
|
<string>Misc</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_9">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Max number of previews per 'page' in 'Previews' tab: </string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinSettingNumerPerPages"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnSaveSettings">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save settings and restart</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -368,7 +488,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1221</width>
|
<width>1280</width>
|
||||||
<height>35</height>
|
<height>35</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -14,13 +14,6 @@
|
|||||||
#include "databasefactory.h"
|
#include "databasefactory.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
#define SETTINGS_KEY_DBPATH "dbpath"
|
|
||||||
#define SETTINGS_KEY_FIRSTRUN "firstrun"
|
|
||||||
#define SETTINGS_KEY_IPCSOCKETPATH "ipcsocketpath"
|
|
||||||
#define SETTINGS_KEY_PDFVIEWER "pdfviewer"
|
|
||||||
#define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths"
|
|
||||||
#define SETTINGS_KEY_MOUNTPATHS "mountpaths"
|
|
||||||
|
|
||||||
inline void initResources()
|
inline void initResources()
|
||||||
{
|
{
|
||||||
Q_INIT_RESOURCE(migrations);
|
Q_INIT_RESOURCE(migrations);
|
||||||
@ -176,19 +169,18 @@ QString Common::ipcSocketPath()
|
|||||||
// return settings.value(SETTINGS_KEY_IPCSOCKETPATH, "/tmp/.looqs/looqs-ipc-socket").toString();
|
// return settings.value(SETTINGS_KEY_IPCSOCKETPATH, "/tmp/.looqs/looqs-ipc-socket").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList excludedPaths = {"/proc", "/sys", "/dev", "/tmp", "/var/run", "/run"};
|
|
||||||
|
|
||||||
QStringList Common::excludedPaths()
|
QStringList Common::excludedPaths()
|
||||||
{
|
{
|
||||||
static int ran = false;
|
static int ran = false;
|
||||||
|
static QStringList excludedPaths;
|
||||||
if(!ran)
|
if(!ran)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QStringList userExcludedPaths = settings.value(SETTINGS_KEY_EXCLUDEDPATHS).toStringList();
|
QStringList defaults{"/proc", "/sys", "/dev", "/tmp", "/var/run", "/run"};
|
||||||
|
excludedPaths = settings.value(SETTINGS_KEY_EXCLUDEDPATHS, defaults).toStringList();
|
||||||
ran = true;
|
ran = true;
|
||||||
::excludedPaths.append(userExcludedPaths);
|
|
||||||
}
|
}
|
||||||
return ::excludedPaths;
|
return excludedPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Common::mountPaths()
|
QStringList Common::mountPaths()
|
||||||
|
@ -2,6 +2,15 @@
|
|||||||
#define COMMON_H
|
#define COMMON_H
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#define SETTINGS_KEY_DBPATH "dbpath"
|
||||||
|
#define SETTINGS_KEY_FIRSTRUN "firstrun"
|
||||||
|
#define SETTINGS_KEY_IPCSOCKETPATH "ipcsocketpath"
|
||||||
|
#define SETTINGS_KEY_PDFVIEWER "pdfviewer"
|
||||||
|
#define SETTINGS_KEY_EXCLUDEDPATHS "excludedpaths"
|
||||||
|
#define SETTINGS_KEY_MOUNTPATHS "mountpaths"
|
||||||
|
#define SETTINGS_KEY_PREVIEWSPERPAGE "previewsPerPage"
|
||||||
|
|
||||||
namespace Common
|
namespace Common
|
||||||
{
|
{
|
||||||
void setupAppInfo();
|
void setupAppInfo();
|
||||||
|
Loading…
Reference in New Issue
Block a user