From cd3a160aa605106f527ddde15a92f1fd36b8f9b4 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 | 12 +++++++++++- gui/mainwindow.h | 1 + gui/mainwindow.ui | 6 +++--- gui/qss.pro | 2 +- gui/searchworker.cpp | 1 + 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index b6366c3..7495fcf 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" @@ -44,8 +46,13 @@ 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 +162,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.); } diff --git a/gui/mainwindow.h b/gui/mainwindow.h index e5ffc03..7ac1b4c 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -45,6 +45,7 @@ private slots: 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 61ff8af..0ce14da 100644 --- a/gui/searchworker.cpp +++ b/gui/searchworker.cpp @@ -90,6 +90,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 + " ";