begin status bar and progress bar for pdfpreviews

This commit is contained in:
Albert S. 2018-08-31 20:40:07 +02:00
parent 03356b3190
commit ec8804185d
3 changed files with 33 additions and 4 deletions

View File

@ -24,6 +24,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->treeResultsList->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu); ui->treeResultsList->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
ui->tabWidget->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0);
ui->statusBar->addWidget(ui->lblSearchResults);
ui->statusBar->addWidget(ui->pdfProcessBar);
ui->pdfProcessBar->hide();
} }
void MainWindow::connectSignals() void MainWindow::connectSignals()
@ -50,9 +53,17 @@ bool MainWindow::pdfTabActive()
void MainWindow::tabChanged() 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(); ClickLabel *label = new ClickLabel();
label->setPixmap(QPixmap::fromImage(preview.previewImage)); label->setPixmap(QPixmap::fromImage(preview.previewImage));
ui->scrollAreaWidgetContents->layout()->addWidget(label); ui->scrollAreaWidgetContents->layout()->addWidget(label);
ui->pdfProcessBar->setValue(++processedPdfPreviews);
connect(label, &ClickLabel::clicked, connect(label, &ClickLabel::clicked,
[=]() [=]()
{ {
@ -112,7 +124,7 @@ void MainWindow::handleSearchResults(const QVector<SearchResult> &results)
{ {
this->pdfSearchResults.clear(); this->pdfSearchResults.clear();
ui->treeResultsList->clear(); ui->treeResultsList->clear();
ui->lblSearchResults->setText("Results: " + QString::number(results.size()));
for(const SearchResult &result : results) for(const SearchResult &result : results)
{ {
QFileInfo pathInfo(result.path); QFileInfo pathInfo(result.path);
@ -147,6 +159,8 @@ void MainWindow::makePdfPreview()
qDeleteAll(ui->scrollAreaWidgetContents->children()); qDeleteAll(ui->scrollAreaWidgetContents->children());
ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout()); ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout());
ui->pdfProcessBar->setMaximum(this->pdfSearchResults.size());
processedPdfPreviews = 0;
emit startPdfPreviewGeneration(this->pdfSearchResults, 0.75); emit startPdfPreviewGeneration(this->pdfSearchResults, 0.75);
} }

View File

@ -38,6 +38,7 @@ class MainWindow : public QMainWindow
void connectSignals(); void connectSignals();
void makePdfPreview(); void makePdfPreview();
bool pdfTabActive(); bool pdfTabActive();
unsigned int processedPdfPreviews;
private slots: private slots:
void lineEditReturnPressed(); void lineEditReturnPressed();
void lineEditTextChanged(); void lineEditTextChanged();

View File

@ -82,7 +82,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1179</width> <width>1179</width>
<height>420</height> <height>370</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"/> <layout class="QHBoxLayout" name="horizontalLayout"/>
@ -154,6 +154,20 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<widget class="QLabel" name="lblSearchResults">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="pdfProcessBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">