From d39c6b9dd219f4db1a765c67a34ca67c0d9a001e Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Tue, 18 Feb 2020 17:34:02 +0100 Subject: [PATCH] print preview zoom --- cprint.cpp | 34 +++++++++++++++++++++++++++++----- cprint.h | 26 ++++++++++++++++++++++++++ cprint.ui | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- pictureprint.qrc | 11 +++++++++++ 4 files changed, 112 insertions(+), 7 deletions(-) diff --git a/cprint.cpp b/cprint.cpp index 596fb3d..c44a760 100644 --- a/cprint.cpp +++ b/cprint.cpp @@ -67,17 +67,21 @@ cPrint::cPrint(QProgressBar* lpProgressBar, QListView* lpSelectedList, QStandard m_lpPrintPreviewWidget->setObjectName(QString::fromUtf8("m_lpPrintPreviewWidget")); ui->m_lpSplitter->insertWidget(0, m_lpPrintPreviewWidget); - const QIcon zoomOutIcon = QIcon::fromTheme("document-new"); - const QIcon zoomInIcon = QIcon::fromTheme("zoom-in"); - - ui->m_lpZoomOut->setIcon(zoomOutIcon); - ui->m_lpZoomIn->setIcon(zoomInIcon); + ui->m_lpZoomOut->setIcon(QIcon::fromTheme("zoom-out")); + ui->m_lpZoomFit->setIcon(QIcon::fromTheme("zoom-fit")); + ui->m_lpZoomOriginal->setIcon(QIcon::fromTheme("zoom-original")); + ui->m_lpZoomIn->setIcon(QIcon::fromTheme("zoom-in")); connect(ui->m_lpPrinterSelect, &QComboBox::currentTextChanged, this, &cPrint::onPrinterChanged); connect(ui->m_lpPrinterProperties, &QPushButton::clicked, this, &cPrint::onPrinterSettings); connect(ui->m_lpPrintPreview, &QPushButton::clicked, this, &cPrint::onPrintPreview); connect(ui->m_lpPrint, &QPushButton::clicked, this, &cPrint::onPrint); + connect(ui->m_lpZoomOut, &QPushButton::clicked, this, &cPrint::onZoomOut); + connect(ui->m_lpZoomFit, &QPushButton::clicked, this, &cPrint::onZoomFit); + connect(ui->m_lpZoomOriginal, &QPushButton::clicked, this, &cPrint::onZoomOriginal); + connect(ui->m_lpZoomIn, &QPushButton::clicked, this, &cPrint::onZoomIn); + connect(m_lpPrintPreviewWidget, &QPrintPreviewWidget::paintRequested, this, &cPrint::onPaintRequested); } @@ -194,3 +198,23 @@ void cPrint::onPrint() // painter.drawPixmap(0, 0, pixmap); // } } + +void cPrint::onZoomOut() +{ + m_lpPrintPreviewWidget->zoomOut(); +} + +void cPrint::onZoomFit() +{ + m_lpPrintPreviewWidget->fitInView(); +} + +void cPrint::onZoomOriginal() +{ + m_lpPrintPreviewWidget->setZoomFactor(1.0); +} + +void cPrint::onZoomIn() +{ + m_lpPrintPreviewWidget->zoomIn(); +} diff --git a/cprint.h b/cprint.h index d5671ae..898e528 100644 --- a/cprint.h +++ b/cprint.h @@ -92,6 +92,32 @@ private slots: \param printer */ void onPaintRequested(QPrinter* printer); + + /*! + \brief + + \fn onZoomOut + */ + void onZoomOut(); + /*! + \brief + + \fn onZoomFit + */ + void onZoomFit(); + /*! + \brief + + \fn onZoomOriginal + */ + void onZoomOriginal(); + /*! + \brief + + \fn onZoomIn + */ + void onZoomIn(); + }; #endif // CPRINT_H diff --git a/cprint.ui b/cprint.ui index 976a6a4..1b61328 100644 --- a/cprint.ui +++ b/cprint.ui @@ -197,15 +197,59 @@ + + zoom out + + + zoom out + - ... + zoom out + + + + 24 + 24 + + + + + + + + zoo to fit + + + zoom to fit + + + zoom to fit + + + + + + + zoom original + + + zoom original + + + zoom original + + zoom in + + + zoom in + - ... + zoom in diff --git a/pictureprint.qrc b/pictureprint.qrc index 16118c4..e047c37 100644 --- a/pictureprint.qrc +++ b/pictureprint.qrc @@ -5,5 +5,16 @@ images/arc/index.theme images/arc/16x16/actions/zoom-in.png + images/arc/16x16/actions/zoom-fit.png + images/arc/16x16/actions/zoom-original.png + images/arc/16x16/actions/zoom-out.png + images/arc/22x22/actions/zoom-fit.png + images/arc/22x22/actions/zoom-in.png + images/arc/22x22/actions/zoom-original.png + images/arc/22x22/actions/zoom-out.png + images/arc/24x24/actions/zoom-fit.png + images/arc/24x24/actions/zoom-in.png + images/arc/24x24/actions/zoom-original.png + images/arc/24x24/actions/zoom-out.png