This commit is contained in:
Albert S. 2022-06-13 19:36:12 +02:00
джерело e76988ee77
коміт dd479fa668
5 змінених файлів з 183 додано та 19 видалено

@ -215,6 +215,7 @@ void MainWindow::connectSignals()
});
connect(this, &MainWindow::beginIndexSync, indexSyncer, &IndexSyncer::sync);
connect(&this->progressDialog, &QProgressDialog::canceled, indexSyncer, &IndexSyncer::cancel);
connect(ui->btnSaveSettings, &QPushButton::clicked, this, &MainWindow::saveSettings);
}
void MainWindow::startIndexSync()
@ -236,6 +237,7 @@ void MainWindow::startIndexSync()
emit beginIndexSync();
}
void MainWindow::spinPreviewPageValueChanged(int val)
{
makePreviews(val);
@ -351,6 +353,45 @@ void MainWindow::tabChanged()
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)
@ -389,7 +430,7 @@ void MainWindow::lineEditReturnPressed()
ui->lblSearchResults->setText("Invalid paranthesis");
return;
}
if(indexerTabActive())
if(ui->tabWidget->currentIndex() > 1)
{
ui->tabWidget->setCurrentIndex(0);
}

@ -61,6 +61,7 @@ class MainWindow : public QMainWindow
void openDocument(QString path, int num);
void openFile(QString path);
unsigned int currentPreviewGeneration = 1;
void initSettingsTabs();
private slots:
void lineEditReturnPressed();
void treeSearchItemActivated(QTreeWidgetItem *item, int i);
@ -73,6 +74,7 @@ class MainWindow : public QMainWindow
void finishIndexing();
void addPathToIndex();
void startIndexSync();
void saveSettings();
signals:
void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets);

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1221</width>
<height>709</height>
<width>1280</width>
<height>736</height>
</rect>
</property>
<property name="windowTitle">
@ -27,7 +27,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="resultsTab">
<attribute name="title">
@ -81,8 +81,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1185</width>
<height>419</height>
<width>1244</width>
<height>446</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout"/>
@ -344,6 +344,126 @@
</item>
</layout>
</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>
</item>
<item>
@ -368,7 +488,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1221</width>
<width>1280</width>
<height>35</height>
</rect>
</property>

@ -14,13 +14,6 @@
#include "databasefactory.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()
{
Q_INIT_RESOURCE(migrations);
@ -176,19 +169,18 @@ QString Common::ipcSocketPath()
// 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()
{
static int ran = false;
static QStringList excludedPaths;
if(!ran)
{
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;
::excludedPaths.append(userExcludedPaths);
}
return ::excludedPaths;
return excludedPaths;
}
QStringList Common::mountPaths()

@ -2,6 +2,15 @@
#define COMMON_H
#include <QCoreApplication>
#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
{
void setupAppInfo();