gui: Improve conditions where progressbar visible, minor useability improvemnets

This commit is contained in:
Albert S. 2022-04-17 20:52:07 +02:00
parent 0503325c47
commit 2a024a9b40

View File

@ -85,6 +85,12 @@ void MainWindow::connectSignals()
[&](int index) { previewReceived(previewWorkerWatcher.resultAt(index)); }); [&](int index) { previewReceived(previewWorkerWatcher.resultAt(index)); });
connect(&previewWorkerWatcher, &QFutureWatcher<QSharedPointer<PreviewResult>>::progressValueChanged, connect(&previewWorkerWatcher, &QFutureWatcher<QSharedPointer<PreviewResult>>::progressValueChanged,
ui->previewProcessBar, &QProgressBar::setValue); ui->previewProcessBar, &QProgressBar::setValue);
connect(&previewWorkerWatcher, &QFutureWatcher<QSharedPointer<PreviewResult>>::started, this,
[&] { ui->indexerTab->setEnabled(false); });
connect(&previewWorkerWatcher, &QFutureWatcher<QSharedPointer<PreviewResult>>::finished, this,
[&] { ui->indexerTab->setEnabled(true); });
connect(ui->treeResultsList, &QTreeWidget::itemActivated, this, &MainWindow::treeSearchItemActivated); connect(ui->treeResultsList, &QTreeWidget::itemActivated, this, &MainWindow::treeSearchItemActivated);
connect(ui->treeResultsList, &QTreeWidget::customContextMenuRequested, this, connect(ui->treeResultsList, &QTreeWidget::customContextMenuRequested, this,
&MainWindow::showSearchResultsContextMenu); &MainWindow::showSearchResultsContextMenu);
@ -145,6 +151,7 @@ void MainWindow::startIndexing()
ui->txtPathScanAdd->setEnabled(false); ui->txtPathScanAdd->setEnabled(false);
ui->txtSearch->setEnabled(false); ui->txtSearch->setEnabled(false);
ui->previewProcessBar->setValue(0); ui->previewProcessBar->setValue(0);
ui->previewProcessBar->setVisible(true);
QVector<QString> paths; QVector<QString> paths;
QStringList pathSettingsValue; QStringList pathSettingsValue;
@ -218,18 +225,23 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
void MainWindow::tabChanged() void MainWindow::tabChanged()
{ {
if(previewTabActive() || indexerTabActive()) if(ui->tabWidget->currentIndex() == 0)
{
ui->previewProcessBar->hide();
}
else
{
if(ui->previewProcessBar->value() > 0)
{
ui->previewProcessBar->show();
}
}
if(previewTabActive())
{ {
if(previewDirty) if(previewDirty)
{ {
makePreviews(ui->spinPreviewPage->value()); makePreviews(ui->spinPreviewPage->value());
} }
ui->previewProcessBar->show();
}
else
{
ui->previewProcessBar->hide();
} }
} }
@ -265,6 +277,7 @@ void MainWindow::lineEditReturnPressed()
return; return;
} }
// TODO: validate q; // TODO: validate q;
ui->treeResultsList->clear();
ui->lblSearchResults->setText("Searching..."); ui->lblSearchResults->setText("Searching...");
this->ui->txtSearch->setEnabled(false); this->ui->txtSearch->setEnabled(false);
QFuture<QVector<SearchResult>> searchFuture = QtConcurrent::run( QFuture<QVector<SearchResult>> searchFuture = QtConcurrent::run(
@ -387,6 +400,7 @@ void MainWindow::makePreviews(int page)
wordsToHighlight, scaleText.toInt() / 100.)); wordsToHighlight, scaleText.toInt() / 100.));
ui->previewProcessBar->setMaximum(this->previewWorkerWatcher.progressMaximum()); ui->previewProcessBar->setMaximum(this->previewWorkerWatcher.progressMaximum());
ui->previewProcessBar->setMinimum(this->previewWorkerWatcher.progressMinimum()); ui->previewProcessBar->setMinimum(this->previewWorkerWatcher.progressMinimum());
ui->previewProcessBar->setVisible(this->previewableSearchResults.size() > 0);
} }
void MainWindow::handleSearchError(QString error) void MainWindow::handleSearchError(QString error)