scale combobox: regenerate pdfs preview with choosen scale

This commit is contained in:
Albert S. 2018-09-02 20:30:52 +02:00
parent 5d8de075be
commit cd3a160aa6
5 changed files with 17 additions and 5 deletions

View File

@ -5,9 +5,11 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QUrl> #include <QUrl>
#include <QClipboard> #include <QClipboard>
#include <QtGlobal>
#include <QSettings> #include <QSettings>
#include <QDateTime> #include <QDateTime>
#include <QProcess> #include <QProcess>
#include <QComboBox>
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "clicklabel.h" #include "clicklabel.h"
@ -44,8 +46,13 @@ void MainWindow::connectSignals()
connect(this, &MainWindow::startPdfPreviewGeneration, pdfWorker, &PdfWorker::generatePreviews); connect(this, &MainWindow::startPdfPreviewGeneration, pdfWorker, &PdfWorker::generatePreviews);
connect(pdfWorker, &PdfWorker::previewReady, this, &MainWindow::pdfPreviewReceived); connect(pdfWorker, &PdfWorker::previewReady, this, &MainWindow::pdfPreviewReceived);
connect(pdfWorker, &PdfWorker::previewsFinished, [&] { this->pdfDirty = false; }); connect(pdfWorker, &PdfWorker::previewsFinished, [&] { this->pdfDirty = false; });
connect(ui->comboScale, qOverload<const QString &>(&QComboBox::currentIndexChanged), this, &MainWindow::comboScaleChanged);
} }
void MainWindow::comboScaleChanged(QString text)
{
makePdfPreview();
}
bool MainWindow::pdfTabActive() bool MainWindow::pdfTabActive()
{ {
return ui->tabWidget->currentIndex() == 1; return ui->tabWidget->currentIndex() == 1;
@ -155,7 +162,10 @@ void MainWindow::makePdfPreview()
ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout()); ui->scrollAreaWidgetContents->setLayout(new QHBoxLayout());
ui->pdfProcessBar->setMaximum(this->pdfSearchResults.size()); ui->pdfProcessBar->setMaximum(this->pdfSearchResults.size());
processedPdfPreviews = 0; processedPdfPreviews = 0;
emit startPdfPreviewGeneration(this->pdfSearchResults, 0.75); QString scaleText = ui->comboScale->currentText();
scaleText.chop(1);
emit startPdfPreviewGeneration(this->pdfSearchResults, scaleText.toInt() / 100.);
} }

View File

@ -45,6 +45,7 @@ private slots:
void showSearchResultsContextMenu(const QPoint &point); void showSearchResultsContextMenu(const QPoint &point);
void tabChanged(); void tabChanged();
void pdfPreviewReceived(PdfPreview preview); void pdfPreviewReceived(PdfPreview preview);
void comboScaleChanged(QString text);
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -27,7 +27,7 @@
<enum>QTabWidget::South</enum> <enum>QTabWidget::South</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="resultsTab"> <widget class="QWidget" name="resultsTab">
<attribute name="title"> <attribute name="title">
@ -99,9 +99,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox"> <widget class="QComboBox" name="comboScale">
<property name="currentText"> <property name="currentText">
<string>25%</string> <string>75%</string>
</property> </property>
<item> <item>
<property name="text"> <property name="text">

View File

@ -7,7 +7,7 @@
QT += core gui QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++14
TARGET = qss TARGET = qss
TEMPLATE = app TEMPLATE = app

View File

@ -90,6 +90,7 @@ QString SearchWorker::createSql(const SearchWorker::Command &cmd)
{ {
QString key = cmd.key; QString key = cmd.key;
QString value = cmd.value; QString value = cmd.value;
value = value.replace("'", "\\'");
if(key == "AND" || key == "OR" || key=="(" || key==")") if(key == "AND" || key == "OR" || key=="(" || key==")")
{ {
return " " + key + " "; return " " + key + " ";