gui: mainwindow: Add 'sync index' menu option
Opens a progress dialog while syncing takes place.
Bu işleme şunda yer alıyor:
ebeveyn
1ec7a5a865
işleme
1ec42e4949
@ -14,6 +14,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <QProgressDialog>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "clicklabel.h"
|
#include "clicklabel.h"
|
||||||
@ -23,8 +24,10 @@
|
|||||||
#include "ipcpreviewclient.h"
|
#include "ipcpreviewclient.h"
|
||||||
#include "previewgenerator.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);
|
ui->setupUi(this);
|
||||||
setWindowTitle(QCoreApplication::applicationName());
|
setWindowTitle(QCoreApplication::applicationName());
|
||||||
this->ipcPreviewClient.moveToThread(&this->ipcClientThread);
|
this->ipcPreviewClient.moveToThread(&this->ipcClientThread);
|
||||||
@ -56,6 +59,8 @@ MainWindow::MainWindow(QWidget *parent, QString socketPath) : QMainWindow(parent
|
|||||||
|
|
||||||
db = this->dbFactory->forCurrentThread();
|
db = this->dbFactory->forCurrentThread();
|
||||||
this->dbService = new SqliteDbService(*this->dbFactory);
|
this->dbService = new SqliteDbService(*this->dbFactory);
|
||||||
|
this->indexSyncer = new IndexSyncer(*this->dbService);
|
||||||
|
this->indexSyncer->moveToThread(&this->syncerThread);
|
||||||
|
|
||||||
indexer = new Indexer(*(this->dbService));
|
indexer = new Indexer(*(this->dbService));
|
||||||
indexer->setParent(this);
|
indexer->setParent(this);
|
||||||
@ -96,6 +101,7 @@ void MainWindow::addPathToIndex()
|
|||||||
this->ui->lstPaths->addItem(path);
|
this->ui->lstPaths->addItem(path);
|
||||||
this->ui->txtPathScanAdd->clear();
|
this->ui->txtPathScanAdd->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::connectSignals()
|
void MainWindow::connectSignals()
|
||||||
{
|
{
|
||||||
connect(ui->txtSearch, &QLineEdit::returnPressed, this, &MainWindow::lineEditReturnPressed);
|
connect(ui->txtSearch, &QLineEdit::returnPressed, this, &MainWindow::lineEditReturnPressed);
|
||||||
@ -194,8 +200,42 @@ void MainWindow::connectSignals()
|
|||||||
});
|
});
|
||||||
connect(ui->menuAboutQtAction, &QAction::triggered, this,
|
connect(ui->menuAboutQtAction, &QAction::triggered, this,
|
||||||
[this](bool checked) { QMessageBox::aboutQt(this, "About Qt"); });
|
[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)
|
void MainWindow::spinPreviewPageValueChanged(int val)
|
||||||
{
|
{
|
||||||
makePreviews(val);
|
makePreviews(val);
|
||||||
@ -563,5 +603,11 @@ void MainWindow::showSearchResultsContextMenu(const QPoint &point)
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
syncerThread.terminate();
|
||||||
|
ipcClientThread.terminate();
|
||||||
|
delete this->indexSyncer;
|
||||||
|
delete this->dbService;
|
||||||
|
delete this->dbFactory;
|
||||||
|
delete this->indexer;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
|
#include <QProgressDialog>
|
||||||
#include "../shared/looqsquery.h"
|
#include "../shared/looqsquery.h"
|
||||||
|
#include "../shared/indexsyncer.h"
|
||||||
#include "ipcpreviewclient.h"
|
#include "ipcpreviewclient.h"
|
||||||
#include "indexer.h"
|
#include "indexer.h"
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@ -34,6 +36,9 @@ class MainWindow : public QMainWindow
|
|||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
IPCPreviewClient ipcPreviewClient;
|
IPCPreviewClient ipcPreviewClient;
|
||||||
QThread ipcClientThread;
|
QThread ipcClientThread;
|
||||||
|
QThread syncerThread;
|
||||||
|
IndexSyncer *indexSyncer;
|
||||||
|
QProgressDialog progressDialog;
|
||||||
|
|
||||||
Indexer *indexer;
|
Indexer *indexer;
|
||||||
QFileIconProvider iconProvider;
|
QFileIconProvider iconProvider;
|
||||||
@ -67,10 +72,12 @@ class MainWindow : public QMainWindow
|
|||||||
void startIndexing();
|
void startIndexing();
|
||||||
void finishIndexing();
|
void finishIndexing();
|
||||||
void addPathToIndex();
|
void addPathToIndex();
|
||||||
|
void startIndexSync();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets);
|
void startIpcPreviews(RenderConfig config, const QVector<RenderTarget> &targets);
|
||||||
void stopIpcPreviews();
|
void stopIpcPreviews();
|
||||||
|
void beginIndexSync();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1221</width>
|
<width>1221</width>
|
||||||
<height>674</height>
|
<height>709</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -82,7 +82,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1185</width>
|
<width>1185</width>
|
||||||
<height>384</height>
|
<height>419</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||||
@ -377,8 +377,10 @@
|
|||||||
<string>looqs</string>
|
<string>looqs</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="menuOpenConfigInTextEditorAction"/>
|
<addaction name="menuOpenConfigInTextEditorAction"/>
|
||||||
|
<addaction name="menuSyncIndexAction"/>
|
||||||
<addaction name="menuAboutAction"/>
|
<addaction name="menuAboutAction"/>
|
||||||
<addaction name="menuAboutQtAction"/>
|
<addaction name="menuAboutQtAction"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menulooqs"/>
|
<addaction name="menulooqs"/>
|
||||||
</widget>
|
</widget>
|
||||||
@ -397,6 +399,11 @@
|
|||||||
<string>About Qt</string>
|
<string>About Qt</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="menuSyncIndexAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sync index (remove deleted, update existing files)</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Yükleniyor…
Yeni konuda referans
Bir kullanıcı engelle