gui: mainwindow: Add 'sync index' menu option
Opens a progress dialog while syncing takes place.
这个提交包含在:
父节点
1ec7a5a865
当前提交
1ec42e4949
@ -14,6 +14,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QScreen>
|
||||
#include <QProgressDialog>
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "clicklabel.h"
|
||||
@ -23,8 +24,10 @@
|
||||
#include "ipcpreviewclient.h"
|
||||
#include "previewgenerator.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent, QString socketPath) : QMainWindow(parent), ui(new Ui::MainWindow)
|
||||
MainWindow::MainWindow(QWidget *parent, QString socketPath)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow), progressDialog(this)
|
||||
{
|
||||
this->progressDialog.cancel(); // because constructing it shows it, quite weird
|
||||
ui->setupUi(this);
|
||||
setWindowTitle(QCoreApplication::applicationName());
|
||||
this->ipcPreviewClient.moveToThread(&this->ipcClientThread);
|
||||
@ -56,6 +59,8 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath) : QMainWindow(parent
|
||||
|
||||
db = this->dbFactory->forCurrentThread();
|
||||
this->dbService = new SqliteDbService(*this->dbFactory);
|
||||
this->indexSyncer = new IndexSyncer(*this->dbService);
|
||||
this->indexSyncer->moveToThread(&this->syncerThread);
|
||||
|
||||
indexer = new Indexer(*(this->dbService));
|
||||
indexer->setParent(this);
|
||||
@ -96,6 +101,7 @@ void MainWindow::addPathToIndex()
|
||||
this->ui->lstPaths->addItem(path);
|
||||
this->ui->txtPathScanAdd->clear();
|
||||
}
|
||||
|
||||
void MainWindow::connectSignals()
|
||||
{
|
||||
connect(ui->txtSearch, &QLineEdit::returnPressed, this, &MainWindow::lineEditReturnPressed);
|
||||
@ -194,8 +200,42 @@ void MainWindow::connectSignals()
|
||||
});
|
||||
connect(ui->menuAboutQtAction, &QAction::triggered, this,
|
||||
[this](bool checked) { QMessageBox::aboutQt(this, "About Qt"); });
|
||||
connect(ui->menuSyncIndexAction, &QAction::triggered, this, &MainWindow::startIndexSync);
|
||||
connect(indexSyncer, &IndexSyncer::finished, this,
|
||||
[&](unsigned int totalUpdated, unsigned int totalDeleted, unsigned int totalErrored)
|
||||
{
|
||||
this->progressDialog.cancel();
|
||||
|
||||
QMessageBox::information(
|
||||
this, "Syncing finished",
|
||||
QString("Syncing finished\n\nTotal updated: %1\nTotal deleted: %2\nTotal errors: %3\n")
|
||||
.arg(QString::number(totalUpdated))
|
||||
.arg(QString::number(totalDeleted))
|
||||
.arg(QString::number(totalErrored)));
|
||||
});
|
||||
connect(this, &MainWindow::beginIndexSync, indexSyncer, &IndexSyncer::sync);
|
||||
connect(&this->progressDialog, &QProgressDialog::canceled, indexSyncer, &IndexSyncer::cancel);
|
||||
}
|
||||
|
||||
void MainWindow::startIndexSync()
|
||||
{
|
||||
progressDialog.setWindowTitle("Syncing");
|
||||
progressDialog.setLabelText("Syncing - this might take a moment, please wait");
|
||||
progressDialog.setWindowModality(Qt::ApplicationModal);
|
||||
progressDialog.setMinimum(0);
|
||||
progressDialog.setMaximum(0);
|
||||
progressDialog.setValue(0);
|
||||
progressDialog.open();
|
||||
|
||||
indexSyncer->setKeepGoing(true);
|
||||
indexSyncer->setVerbose(false);
|
||||
indexSyncer->setDryRun(false);
|
||||
indexSyncer->setRemoveDeletedFromIndex(true);
|
||||
|
||||
this->syncerThread.start();
|
||||
|
||||
emit beginIndexSync();
|
||||
}
|
||||
void MainWindow::spinPreviewPageValueChanged(int val)
|
||||
{
|
||||
makePreviews(val);
|
||||
@ -563,5 +603,11 @@ void MainWindow::showSearchResultsContextMenu(const QPoint &point)
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
syncerThread.terminate();
|
||||
ipcClientThread.terminate();
|
||||
delete this->indexSyncer;
|
||||
delete this->dbService;
|
||||
delete this->dbFactory;
|
||||
delete this->indexer;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -9,7 +9,9 @@
|
||||
#include <QFutureWatcher>
|
||||
#include <QSqlDatabase>
|
||||
#include <QLocalSocket>
|
||||
#include <QProgressDialog>
|
||||
#include "../shared/looqsquery.h"
|
||||
#include "../shared/indexsyncer.h"
|
||||
#include "ipcpreviewclient.h"
|
||||
#include "indexer.h"
|
||||
namespace Ui
|
||||
@ -34,6 +36,9 @@ class MainWindow : public QMainWindow
|
||||
Ui::MainWindow *ui;
|
||||
IPCPreviewClient ipcPreviewClient;
|
||||
QThread ipcClientThread;
|
||||
QThread syncerThread;
|
||||
IndexSyncer *indexSyncer;
|
||||
QProgressDialog progressDialog;
|
||||
|
||||
Indexer *indexer;
|
||||
QFileIconProvider iconProvider;
|
||||
@ -67,10 +72,12 @@ class MainWindow : public QMainWindow
|
||||
void startIndexing();
|
||||
void finishIndexing();
|
||||
void addPathToIndex();
|
||||
void startIndexSync();
|
||||
|
||||
signals:
|
||||
void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets);
|
||||
void stopIpcPreviews();
|
||||
void beginIndexSync();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1221</width>
|
||||
<height>674</height>
|
||||
<height>709</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -82,7 +82,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1185</width>
|
||||
<height>384</height>
|
||||
<height>419</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||
@ -377,8 +377,10 @@
|
||||
<string>looqs</string>
|
||||
</property>
|
||||
<addaction name="menuOpenConfigInTextEditorAction"/>
|
||||
<addaction name="menuSyncIndexAction"/>
|
||||
<addaction name="menuAboutAction"/>
|
||||
<addaction name="menuAboutQtAction"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<addaction name="menulooqs"/>
|
||||
</widget>
|
||||
@ -397,6 +399,11 @@
|
||||
<string>About Qt</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="menuSyncIndexAction">
|
||||
<property name="text">
|
||||
<string>Sync index (remove deleted, update existing files)</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
正在加载...
在新工单中引用
屏蔽一个用户