From ec8804185dd092c5e16c7258533d76b0494fdbcd Mon Sep 17 00:00:00 2001 From: Albert S Date: Fri, 31 Aug 2018 20:40:07 +0200 Subject: [PATCH] begin status bar and progress bar for pdfpreviews --- gui/mainwindow.cpp | 20 +++++++++++++++++--- gui/mainwindow.h | 1 + gui/mainwindow.ui | 16 +++++++++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index fb9e456..5a589ec 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -24,6 +24,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi ui->treeResultsList->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); ui->tabWidget->setCurrentIndex(0); + ui->statusBar->addWidget(ui->lblSearchResults); + ui->statusBar->addWidget(ui->pdfProcessBar); + ui->pdfProcessBar->hide(); } void MainWindow::connectSignals() @@ -50,9 +53,17 @@ bool MainWindow::pdfTabActive() void MainWindow::tabChanged() { - if(pdfTabActive() && pdfDirty) + if(pdfTabActive()) { - makePdfPreview(); + if(pdfDirty) + { + makePdfPreview(); + } + ui->pdfProcessBar->show(); + } + else + { + ui->pdfProcessBar->hide(); } } @@ -61,6 +72,7 @@ void MainWindow::pdfPreviewReceived(PdfPreview preview) ClickLabel *label = new ClickLabel(); label->setPixmap(QPixmap::fromImage(preview.previewImage)); ui->scrollAreaWidgetContents->layout()->addWidget(label); + ui->pdfProcessBar->setValue(++processedPdfPreviews); connect(label, &ClickLabel::clicked, [=]() { @@ -112,7 +124,7 @@ void MainWindow::handleSearchResults(const QVector &results) { this->pdfSearchResults.clear(); ui->treeResultsList->clear(); - + ui->lblSearchResults->setText("Results: " + QString::number(results.size())); for(const SearchResult &result : results) { QFileInfo pathInfo(result.path); @@ -147,6 +159,8 @@ void MainWindow::makePdfPreview() qDeleteAll(ui->scrollAreaWidgetContents->children()); ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout()); + ui->pdfProcessBar->setMaximum(this->pdfSearchResults.size()); + processedPdfPreviews = 0; emit startPdfPreviewGeneration(this->pdfSearchResults, 0.75); } diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 2749dc7..99417ad 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -38,6 +38,7 @@ class MainWindow : public QMainWindow void connectSignals(); void makePdfPreview(); bool pdfTabActive(); + unsigned int processedPdfPreviews; private slots: void lineEditReturnPressed(); void lineEditTextChanged(); diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 7e53986..5acefc1 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -82,7 +82,7 @@ 0 0 1179 - 420 + 370 @@ -154,6 +154,20 @@ + + + + TextLabel + + + + + + + 24 + + +