From 93dca5272ec13a70f2421534e0c2937affa79c0d Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 15 Mar 2017 10:34:32 -0400 Subject: A couple more updates for lumina-pdf, slower loading with 2x DPI right now, still working on finding the right balance of DPI/speed. --- src-qt5/desktop-utils/lumina-pdf/mainUI.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-pdf/mainUI.cpp') diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp index 9e396a40..fefa6158 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -25,12 +26,12 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ lastdir = QDir::homePath(); Printer = new QPrinter(); - WIDGET = new QPrintPreviewWidget(Printer, this); + WIDGET = new QPrintPreviewWidget(Printer,this); this->setCentralWidget(WIDGET); connect(WIDGET, SIGNAL(paintRequested(QPrinter*)), this, SLOT(paintOnWidget(QPrinter*)) ); DOC = 0; - PrintDLG = new QPrintDialog(Printer,this); + PrintDLG = new QPrintDialog(this); connect(PrintDLG, SIGNAL(accepted(QPrinter*)), this, SLOT(paintOnWidget(QPrinter*)) ); //Can change to PaintToPrinter() later //Create the other interface widgets @@ -110,6 +111,7 @@ void MainUI::loadFile(QString path){ if(PAGE!=0){ lastdir = path.section("/",0,-2); //save this for later Printer->setPageSize( QPageSize(PAGE->pageSize(), QPageSize::Point) ); + Printer->setPageMargins(QMarginsF(0,0,0,0), QPageLayout::Point); switch(PAGE->orientation()){ case Poppler::Page::Landscape: Printer->setOrientation(QPrinter::Landscape); break; @@ -137,12 +139,15 @@ void MainUI::paintOnWidget(QPrinter *PRINTER){ //Now start painting all the pages onto the widget QRectF size = PRINTER->pageRect(QPrinter::DevicePixel); QSize DPI(PRINTER->resolution(),PRINTER->resolution()); + //QScreen *scrn = QApplication::screens().first(); + //QSize SDPI(scrn->logicalDotsPerInchX(), scrn->logicalDotsPerInchY()); QPainter painter(PRINTER); //qDebug() << "Set progress bar range:" << firstpage+1 << pages; progress->setRange(firstpage+1,pages+1); //progress->setValue(firstpage); progAct->setVisible(true); - + qDebug() << "Printer DPI:" << DPI; + //qDebug() << "Screen DPI:" << SDPI; for(int i=firstpage; isetValue(i+1); @@ -153,7 +158,7 @@ void MainUI::paintOnWidget(QPrinter *PRINTER){ if(i != firstpage){ PRINTER->newPage(); } //this is the start of the next page (not needed for first) Poppler::Page *PAGE = DOC->page(i); if(PAGE!=0){ - painter.drawImage(0,0,PAGE->renderToImage(DPI.width(), DPI.height()).scaled(size.width(), size.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation) ); + painter.drawImage(0,0,PAGE->renderToImage(2*DPI.width(), 2*DPI.height()).scaled(size.width(), size.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) ); }else{ painter.drawImage(0,0,QImage()); } -- cgit