aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-01-24 12:24:09 -0500
committerKen Moore <ken@ixsystems.com>2018-01-24 12:24:09 -0500
commit768822f63c5e8086543438765450d8d20ce0a0fe (patch)
tree869aba8006dba9f454afafc618ad05cbdae9184b /src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
parenta Couple more minor tweaks. (diff)
downloadlumina-768822f63c5e8086543438765450d8d20ce0a0fe.tar.gz
lumina-768822f63c5e8086543438765450d8d20ce0a0fe.tar.bz2
lumina-768822f63c5e8086543438765450d8d20ce0a0fe.zip
Fix up the rendering quality of the lumina-pdf pages.
Also get the new backend working properly with the next/previous page system and presentation mode.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
index be00e675..30f94e32 100644
--- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp
@@ -1,6 +1,6 @@
#include "PrintWidget.h"
-PrintWidget::PrintWidget(QWidget *parent) : QGraphicsView(parent), scene(0), curPage(1),
+PrintWidget::PrintWidget(QWidget *parent) : QGraphicsView(parent), scene(0), curPage(1),
viewMode(SinglePageView), zoomMode(FitInView), zoomFactor(1), initialized(false), fitting(true) {
this->setMouseTracking(true);
@@ -101,9 +101,10 @@ void PrintWidget::setVisible(bool visible) {
}
void PrintWidget::setCurrentPage(int pageNumber) {
+ if(pageNumber < 0 || pageNumber > (pages.count()+1) ){ return; }
+ publicPageNum = pageNumber; //publicly requested page number (+/- 1 from actual page range)
if(pageNumber < 1 || pageNumber > pages.count())
return;
-
int lastPage = curPage;
curPage = pageNumber;
@@ -132,8 +133,8 @@ void PrintWidget::generatePreview() {
populateScene(); // i.e. setPreviewPrintedPictures() e.l.
layoutPages();
curPage = qBound(1, curPage, pages.count());
- if (fitting)
- fit();
+ publicPageNum = curPage;
+ if (fitting){ fit(); }
}
void PrintWidget::layoutPages() {
@@ -145,22 +146,22 @@ void PrintWidget::layoutPages() {
int cols = 1; // singleMode and default
if (viewMode == AllPagesView) {
cols = ((pictures->value(0)).width() > (pictures->value(0)).height()) ? qFloor(qSqrt(numPages)) : qCeil(qSqrt(numPages));
- cols += cols % 2; // Nicer with an even number of cols
- } else if (viewMode == FacingPagesView) {
+ cols += cols % 2; // Nicer with an even number of cols
+ } else if (viewMode == FacingPagesView) {
cols = 2;
- numPagePlaces += 1;
- }
+ numPagePlaces += 1;
+ }
int rows = qCeil(double(numPagePlaces) / cols);
- double itemWidth = pages.at(0)->boundingRect().width();
- double itemHeight = pages.at(0)->boundingRect().height();
- int pageNum = 1; for (int i = 0; i < rows && pageNum <= numPages; i++) {
- for (int j = 0; j < cols && pageNum <= numPages; j++) {
+ double itemWidth = pages.at(0)->boundingRect().width();
+ double itemHeight = pages.at(0)->boundingRect().height();
+ int pageNum = 1; for (int i = 0; i < rows && pageNum <= numPages; i++) {
+ for (int j = 0; j < cols && pageNum <= numPages; j++) {
if (!i && !j && viewMode == FacingPagesView) {
- continue;
- } else {
- pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
- pageNum++;
+ continue;
+ } else {
+ pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
+ pageNum++;
}
}
}
@@ -180,7 +181,7 @@ void PrintWidget::populateScene()
qDebug() << "Image paperSize" << paperSize;
for (int i = 0; i < numPages; i++) {
- PageItem* item = new PageItem(i+1, (*pictures)[i], paperSize);
+ PageItem* item = new PageItem(i+1, (*pictures)[i].scaled( paperSize, Qt::KeepAspectRatio, Qt::SmoothTransformation), paperSize);
scene->addItem(item);
pages.append(item);
}
@@ -194,6 +195,7 @@ void PrintWidget::updateCurrentPage() {
int newPage = calcCurrentPage();
if (newPage != curPage) {
curPage = newPage;
+ publicPageNum = curPage;
}
}
@@ -272,7 +274,7 @@ void PrintWidget::fit(bool doFitting) {
void PrintWidget::setPictures(QHash<int, QImage> *hash) {
pictures = hash;
-}
+}
void PrintWidget::setOrientation(QPageLayout::Orientation ori) {
this->orientation = ori;
bgstack15