From caafb114ca16dca19ea676a39cebea513101d5d6 Mon Sep 17 00:00:00 2001 From: Albert S Date: Sun, 2 Sep 2018 20:30:52 +0200 Subject: [PATCH] scale combobox: regenerate pdfs preview with choosen scale --- gui/mainwindow.cpp | 13 ++++++++++++- gui/mainwindow.h | 1 + gui/mainwindow.ui | 6 +++--- gui/qss.pro | 2 +- gui/searchworker.cpp | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 8b6263b..d5ee805 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -5,9 +5,11 @@ #include #include #include +#include #include #include #include +#include #include "mainwindow.h" #include "ui_mainwindow.h" #include "clicklabel.h" @@ -43,8 +45,14 @@ void MainWindow::connectSignals() connect(this, &MainWindow::startPdfPreviewGeneration, pdfWorker, &PdfWorker::generatePreviews); connect(pdfWorker, &PdfWorker::previewReady, this, &MainWindow::pdfPreviewReceived); connect(pdfWorker, &PdfWorker::previewsFinished, [&] { this->pdfDirty = false; }); + connect(ui->comboScale, qOverload(&QComboBox::currentIndexChanged), this, + &MainWindow::comboScaleChanged); } +void MainWindow::comboScaleChanged(QString text) +{ + makePdfPreview(); +} bool MainWindow::pdfTabActive() { return ui->tabWidget->currentIndex() == 1; @@ -155,7 +163,10 @@ void MainWindow::makePdfPreview() ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout()); ui->pdfProcessBar->setMaximum(this->pdfSearchResults.size()); processedPdfPreviews = 0; - emit startPdfPreviewGeneration(this->pdfSearchResults, 0.75); + QString scaleText = ui->comboScale->currentText(); + scaleText.chop(1); + + emit startPdfPreviewGeneration(this->pdfSearchResults, scaleText.toInt() / 100.); } void MainWindow::handleCancelledSearch() diff --git a/gui/mainwindow.h b/gui/mainwindow.h index b72187f..d06077d 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -47,6 +47,7 @@ class MainWindow : public QMainWindow void showSearchResultsContextMenu(const QPoint &point); void tabChanged(); void pdfPreviewReceived(PdfPreview preview); + void comboScaleChanged(QString text); }; #endif // MAINWINDOW_H diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 5acefc1..69af7e1 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -27,7 +27,7 @@ QTabWidget::South - 0 + 1 @@ -99,9 +99,9 @@ - + - 25% + 75% diff --git a/gui/qss.pro b/gui/qss.pro index ae65d8c..fad1970 100644 --- a/gui/qss.pro +++ b/gui/qss.pro @@ -7,7 +7,7 @@ QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - +CONFIG += c++14 TARGET = qss TEMPLATE = app diff --git a/gui/searchworker.cpp b/gui/searchworker.cpp index 59b5e13..8248d64 100644 --- a/gui/searchworker.cpp +++ b/gui/searchworker.cpp @@ -87,6 +87,7 @@ QString SearchWorker::createSql(const SearchWorker::Command &cmd) { QString key = cmd.key; QString value = cmd.value; + value = value.replace("'", "\\'"); if(key == "AND" || key == "OR" || key == "(" || key == ")") { return " " + key + " ";