diff options
Diffstat (limited to 'src-qt5')
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp | 16 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/PrintWidget.h | 36 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.cpp | 38 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.h | 6 |
4 files changed, 52 insertions, 44 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp index d2f2cd46..4f3e0acc 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.cpp @@ -125,7 +125,7 @@ void PrintWidget::setCurrentPage(int pageNumber) { } void PrintWidget::highlightText(int pageNum, QRectF textBox) { - PageItem *item = static_cast<PageItem*>(pages[pageNum]); + //PageItem *item = static_cast<PageItem*>(pages[pageNum]); QPainter painter(this); painter.fillRect(textBox, QColor(255, 255, 177, 128)); } @@ -182,10 +182,10 @@ void PrintWidget::populateScene() int numPages = pictures->count(); //Replace from loadingHash resolution QSize paperSize = pictures->value(0).size(); - qDebug() << "Image paperSize" << paperSize; + //qDebug() << "Image paperSize" << paperSize; for (int i = 0; i < numPages; i++) { - PageItem* item = new PageItem(i+1, (*pictures)[i].scaled( paperSize, Qt::KeepAspectRatio, Qt::SmoothTransformation), paperSize); + PageItem* item = new PageItem(i+1, (*pictures)[i].scaled( paperSize, Qt::KeepAspectRatio, Qt::SmoothTransformation), paperSize, degrees); scene->addItem(item); pages.append(item); } @@ -281,6 +281,12 @@ void PrintWidget::setPictures(QHash<int, QImage> *hash) { pictures = hash; } -void PrintWidget::setOrientation(QPageLayout::Orientation ori) { - this->orientation = ori; +void PrintWidget::receiveDocument(Poppler::Document *DOC) { + this->doc = DOC; + this->setVisible(true); +} + +void PrintWidget::setDegrees(int degrees) { + this->degrees = degrees; + this->updatePreview(); } diff --git a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h index 0bc2dbac..da0dc8d3 100644 --- a/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h +++ b/src-qt5/desktop-utils/lumina-pdf/PrintWidget.h @@ -20,10 +20,12 @@ #include <QtMath> #include <QPageLayout> +#include <poppler/qt5/poppler-qt5.h> + class PageItem : public QGraphicsItem { public: - PageItem(int _pageNum, const QImage _pagePicture, QSize _paperSize) - : pageNum(_pageNum), pagePicture(_pagePicture), paperSize(_paperSize) + PageItem(int _pageNum, QImage _pagePicture, QSize _paperSize, int _degrees) + : pageNum(_pageNum), pagePicture(_pagePicture), paperSize(_paperSize), degrees(_degrees) { brect = QRectF(QPointF(-25, -25), QSizeF(paperSize)+QSizeF(50, 50)); @@ -68,20 +70,37 @@ public: cgrad.setColorAt(1.0, QColor(0,0,0,0)); painter->fillRect(cshadow, QBrush(cgrad)); + QMatrix matrix; + switch(degrees) { + case -90: + matrix = QMatrix(0, -1, 1, 0, 0, 0); + break; + case 90: + matrix = QMatrix(0, 1, -1, 0, 0, 0); + break; + default: + matrix = QMatrix(1, 0, 0, 1, 0 ,0); + } + painter->setClipRect(paperRect & option->exposedRect); painter->fillRect(paperRect, Qt::white); if (pagePicture.isNull()){ qDebug() << "NULL"; return; } + + if(degrees != 0) + pagePicture = pagePicture.transformed(matrix, Qt::SmoothTransformation); + painter->drawImage(QPoint(0,0), pagePicture); } private: - int pageNum; - const QImage pagePicture; - QSize paperSize; - QRectF brect; + int pageNum; + QImage pagePicture; + QSize paperSize; + QRectF brect; + int degrees; }; @@ -118,6 +137,8 @@ private: bool initialized, fitting; QList<QGraphicsItem*> pages; QHash<int, QImage> *pictures; + Poppler::Document *doc; + int degrees; public: PrintWidget(QWidget *parent = 0); @@ -138,8 +159,9 @@ public slots: void zoomOut(double factor=1.2); void setCurrentPage(int); void setVisible(bool) Q_DECL_OVERRIDE; - void setOrientation(QPageLayout::Orientation); void highlightText(int, QRectF); + void receiveDocument(Poppler::Document*); + void setDegrees(int); void updatePreview(); void fitView(); diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp index fc7c1105..01639b87 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp @@ -61,6 +61,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ connect(WIDGET, SIGNAL(currentPageChanged()), this, SLOT(updatePageNumber()) ); DOC = 0; connect(this, SIGNAL(PageLoaded(int)), this, SLOT(slotPageLoaded(int)) ); + connect(this, SIGNAL(sendDocument(Poppler::Document*)), WIDGET, SLOT(receiveDocument(Poppler::Document*))); PrintDLG = new QPrintDialog(this); connect(PrintDLG, SIGNAL(accepted(QPrinter*)), this, SLOT(paintToPrinter(QPrinter*)) ); @@ -91,7 +92,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ tmp->addAction(ui->actionAll_Pages); ui->actionSingle_Page->setChecked(true); - qDebug() << "Starting connections"; + //qDebug() << "Starting connections"; //Connect up the buttons connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()) ); @@ -106,8 +107,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ //connect(ui->actionSelect_Mode, &QAction::triggered, this, [&] { this->setScroll(false); }); connect(ui->actionZoom_In, &QAction::triggered, WIDGET, [&] { WIDGET->zoomIn(1.2); }); connect(ui->actionZoom_Out, &QAction::triggered, WIDGET, [&] { WIDGET->zoomOut(1.2); }); - connect(ui->actionRotate_Counterclockwise, &QAction::triggered, this, [&] { this->rotate(true); }); - connect(ui->actionRotate_Clockwise, &QAction::triggered, this, [&] { this->rotate(false); }); + connect(ui->actionRotate_Counterclockwise, &QAction::triggered, this, [&] { WIDGET->setDegrees(-90); }); + connect(ui->actionRotate_Clockwise, &QAction::triggered, this, [&] { WIDGET->setDegrees(90); }); connect(ui->actionZoom_In_2, &QAction::triggered, WIDGET, [&] { WIDGET->zoomIn(1.2); }); connect(ui->actionZoom_Out_2, &QAction::triggered, WIDGET, [&] { WIDGET->zoomOut(1.2); }); connect(ui->actionFirst_Page, SIGNAL(triggered()), this, SLOT(firstPage()) ); @@ -187,7 +188,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ ui->matchCase->setIcon(LXDG::findIcon("format-text-italic")); ui->closeFind->setIcon(LXDG::findIcon("dialog-close")); - qDebug() << "Finished setting icons"; + //qDebug() << "Finished setting icons"; //Now set the default state of the menu's and actions ui->actionStop_Presentation->setEnabled(false); @@ -237,12 +238,12 @@ void MainUI::loadFile(QString path){ Poppler::Page *PAGE = DOC->page(0); if(PAGE!=0){ lastdir = path.section("/",0,-2); //save this for later - switch(PAGE->orientation()){ + /*switch(PAGE->orientation()){ case Poppler::Page::Landscape: WIDGET->setOrientation(QPageLayout::Landscape); break; default: WIDGET->setOrientation(QPageLayout::Portrait); - } + }*/ delete PAGE; qDebug() << " - Document Setup : start loading pages now"; startLoadingPages(); @@ -422,11 +423,8 @@ void MainUI::slotPageLoaded(int page){ //qDebug() << " - finished:" << finished; if(finished == numPages){ progAct->setVisible(false); - //qDebug() << "Setting Pictures"; WIDGET->setPictures(&loadingHash); - WIDGET->setVisible(true); - QTimer::singleShot(10, WIDGET, SLOT(updatePreview())); - //qDebug() << "Updating"; + emit sendDocument(DOC); ui->actionStop_Presentation->setEnabled(false); ui->actionStart_Here->setEnabled(true); ui->actionStart_Begin->setEnabled(true); @@ -526,29 +524,13 @@ void MainUI::updatePageNumber(){ label_page->setText( text.arg( QString::number(WIDGET->currentPage()), QString::number(numPages) )); } -void MainUI::setScroll(bool tog) { +/*void MainUI::setScroll(bool tog) { if(tog) { QApplication::setOverrideCursor(Qt::OpenHandCursor); }else{ QApplication::setOverrideCursor(Qt::IBeamCursor); } -} - -void MainUI::rotate(bool ccw) { - for(int i = 0; i < numPages; i++) { - QImage image = loadingHash[i]; - qDebug() << "Page rotating: " << i; - //Setup a rotation matrix that rotates 90 degrees clockwise or counterclockwise - QMatrix matrix = (ccw) ? QMatrix(0, -1, 1, 0, 0, 0) : QMatrix(0, 1, -1, 0, 0, 0); - image = image.transformed(matrix, Qt::SmoothTransformation); - //Updates the image in the hash - loadingHash.insert(i, image); - } - //Rotates the page as well as the image - //WIDGET->setOrientation((WIDGET->orientation() == QPageLayout::Landscape) ? - //QPageLayout::Portrait : QPageLayout::Landscape); - QTimer::singleShot(0, WIDGET, SLOT(updatePreview())); -} +}*/ void MainUI::updateContextMenu(){ contextMenu->clear(); diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h index 5a22905a..399404a1 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.h +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.h @@ -98,13 +98,11 @@ private slots: void updatePageNumber(); void showContextMenu(const QPoint&){ contextMenu->popup(QCursor::pos()); } void updateContextMenu(); - - void setScroll(bool); - void rotate(bool); - + //void setScroll(bool); signals: void PageLoaded(int); + void sendDocument(Poppler::Document*); protected: void keyPressEvent(QKeyEvent*); |