diff options
author | ZackaryWelch <welch.zackary@gmail.com> | 2017-12-18 16:05:27 -0500 |
---|---|---|
committer | ZackaryWelch <welch.zackary@gmail.com> | 2017-12-18 16:05:37 -0500 |
commit | 6c5a1d42db02985ed64ca744215bb23fca276143 (patch) | |
tree | 5a0241b0010583456b0ef214065f0b1e6c95ce8d | |
parent | Translated using Weblate (Danish) (diff) | |
download | lumina-6c5a1d42db02985ed64ca744215bb23fca276143.tar.gz lumina-6c5a1d42db02985ed64ca744215bb23fca276143.tar.bz2 lumina-6c5a1d42db02985ed64ca744215bb23fca276143.zip |
Finished rotation and working on changing keys in lumina-pdf
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.cpp | 136 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.h | 47 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-pdf/mainUI.ui | 24 |
3 files changed, 123 insertions, 84 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp index ce2707c9..b4847609 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.cpp @@ -28,7 +28,6 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ this->setWindowIcon( LXDG::findIcon("application-pdf","unknown")); presentationLabel = 0; CurrentPage = 0; - ccw = 0; lastdir = QDir::homePath(); Printer = new QPrinter(); //Create the interface widgets @@ -91,8 +90,10 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ connect(ui->actionScroll_Mode, SIGNAL(toggled(bool)), this, SLOT(setScroll(bool)) ); 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(Printer, true); }); - connect(ui->actionRotate_Clockwise, &QAction::triggered, this, [&] { this->rotate(Printer, false); }); + connect(ui->actionRotate_Counterclockwise, &QAction::triggered, this, [&] { this->rotate(true); }); + connect(ui->actionRotate_Clockwise, &QAction::triggered, this, [&] { this->rotate(false); }); + connect(ui->actionZoom_In_2, &QAction::triggered, WIDGET, [&] { WIDGET->zoomIn(1.2); }); + connect(ui->actionZoom_Out_2, &QAction::triggered, WIDGET, [&] { WIDGET->zoomOut(1.2); }); //Setup all the icons ui->actionPrint->setIcon( LXDG::findIcon("document-print","")); @@ -106,6 +107,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI()){ ui->actionScroll_Mode->setIcon(LXDG::findIcon("cursor-pointer","")); ui->actionZoom_In->setIcon(LXDG::findIcon("zoom-in","")); ui->actionZoom_Out->setIcon(LXDG::findIcon("zoom-out","")); + ui->actionZoom_In_2->setIcon(LXDG::findIcon("zoom-in","")); + ui->actionZoom_Out_2->setIcon(LXDG::findIcon("zoom-out","")); ui->actionRotate_Counterclockwise->setIcon(LXDG::findIcon("object-rotate-left","")); ui->actionRotate_Clockwise->setIcon(LXDG::findIcon("object-rotate-right","")); @@ -311,8 +314,6 @@ void MainUI::startLoadingPages(QPrinter *printer){ progress->setValue(0); progAct->setVisible(true); QRectF pageSize = printer->pageRect(QPrinter::DevicePixel); - printer->setPageSize(QPageSize(QSize(pageSize.width()*2, pageSize.height()*2))); - qDebug() << "Starting size" << pageSize.size(); QSize DPI(printer->resolution(),printer->resolution()); /*qDebug() << "Screen Resolutions:"; QList<QScreen*> screens = QApplication::screens(); @@ -321,7 +322,7 @@ void MainUI::startLoadingPages(QPrinter *printer){ }*/ for(int i=0; i<numPages; i++){ //qDebug() << " - Kickoff page load:" << i; - this->ccw = 0; + //this->ccw = 0; QtConcurrent::run(this, &MainUI::loadPage, i, DOC, this, DPI, pageSize.size()); } } @@ -332,7 +333,7 @@ void MainUI::slotPageLoaded(int page){ if(finished == numPages){ progAct->setVisible(false); QTimer::singleShot(0, WIDGET, SLOT(updatePreview())); - qDebug() << "Updating"; + //qDebug() << "Updating"; ui->actionStop_Presentation->setEnabled(false); ui->menuStart_Presentation->setEnabled(true); }else{ @@ -346,24 +347,19 @@ void MainUI::slotStartPresentation(QAction *act){ void MainUI::paintOnWidget(QPrinter *PRINTER){ if(DOC==0){ return; } - //this->show(); - qDebug() << "Painting"; - qDebug() << numPages << loadingHash.keys().length(); if(loadingHash.keys().length() != numPages){ startLoadingPages(PRINTER); return; } + //Increase the resolution of the page to match the image to prevent downscaling + PRINTER->setPageSize(QPageSize(PRINTER->pageRect().size()*2)); + qDebug() << PRINTER->pageRect().size() << loadingHash[0].size(); QPainter painter(PRINTER); - for(int i=0; i<numPages; i++){ - if(i != 0){ PRINTER->newPage(); } //this is the start of the next page (not needed for first) - if(loadingHash.contains(i)){ painter.drawImage(0,0, loadingHash[i].scaled(PRINTER->pageRect().size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); qDebug() << PRINTER->pageRect().size();} - else{ painter.drawImage(0,0, QImage()); } - if(ccw != 0) { - QTransform transform; - transform.rotate((ccw-1) ? 270 : 90); - painter.setTransform(transform); - //painter.rotate((ccw-1) ? 270 : 90); - } - } + for(int i=0; i<numPages; i++){ + if(i != 0){ PRINTER->newPage(); } //this is the start of the next page (not needed for first) + if(loadingHash.contains(i)){ painter.drawImage(0,0, loadingHash[i].scaled(PRINTER->pageRect().size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); } + else{ painter.drawImage(0,0, QImage()); } + } WIDGET->setContextMenuPolicy(Qt::CustomContextMenu); + loadingHash.clear(); } void MainUI::paintToPrinter(QPrinter *PRINTER){ @@ -403,7 +399,6 @@ void MainUI::paintToPrinter(QPrinter *PRINTER){ } } //qDebug() << "Final Page Range:" << pageCount; - //return; //Generate the sizing information for the printer QSize sz(PRINTER->pageRect().width(), PRINTER->pageRect().height()); bool landscape = PRINTER->orientation()==QPrinter::Landscape; @@ -443,15 +438,20 @@ void MainUI::setScroll(bool tog) { }else{ QApplication::setOverrideCursor(Qt::IBeamCursor); } - //WIDGET-> } -void MainUI::rotate(QPrinter *printer, bool ccw) { - QRectF pageSize = printer->pageRect(QPrinter::DevicePixel); - QSize dpi(printer->resolution(),printer->resolution()); - this->ccw = ccw+1; - for(int i=0; i < numPages; i++) - QtConcurrent::run(this, &MainUI::loadPage, i, DOC, this, dpi, pageSize.size()); +void MainUI::rotate(bool ccw) { + for(int i = 0; i < numPages; i++) { + QImage image = loadingHash[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() == QPrinter::Landscape) ? QPrinter::Portrait : QPrinter::Landscape); + WIDGET->updatePreview(); } void MainUI::updateContextMenu(){ @@ -472,3 +472,81 @@ void MainUI::updateContextMenu(){ contextMenu->addAction(tr("Stop Presentation"), this, SLOT(closePresentation()) ); } } + +void MainUI::keyPressEvent(QKeyEvent *event){ + //See if this is one of the special hotkeys and act appropriately + bool inPresentation = (presentationLabel!=0); + /*QWheelEvent wEvent( WIDGET->mapFromGlobal(QCursor::pos()), QCursor::pos(),QPoint(0,0), QPoint(0,30), 0, Qt::Vertical, Qt::LeftButton, Qt::NoModifier); + qDebug() << "KeyPressed"; + switch(event->key()) { + case Qt::Key_Escape: + case Qt::Key_Backspace: + qDebug() << " - Escape/Backspace"; + if(inPresentation){ endPresentation(); } + break; + case Qt::Key_Right: + case Qt::Key_Space: + case Qt::Key_PageDown: + qDebug() << " - Right/Down/Spacebar" << inPresentation; + nextPage(); + break; + case Qt::Key_Left: + case Qt::Key_PageUp: + qDebug() << " - Left/Up"; + prevPage(); + break; + case Qt::Key_Home: + qDebug() << " - Home"; + firstPage(); + break; + case Qt::Key_End: + qDebug() << " - End"; + lastPage(); + break; + case Qt::Key_F11: + qDebug() << " - F11"; + if(inPresentation){ endPresentation(); } + else{ startPresentationHere(); } + break; + case Qt::Key_Up: + break; + case Qt::Key_Down: + qDebug() << "Send Wheel Event"; + QApplication::sendEvent(WIDGET, &wEvent); + //WIDGET->scrollDown(); + break; + default: + QMainWindow::keyPressEvent(event); + }*/ + if( event->key()==Qt::Key_Escape || event->key()==Qt::Key_Backspace){ + qDebug() << " - Escape/Backspace"; + if(inPresentation){ endPresentation(); } + }else if(event->key()==Qt::Key_Right || event->key()==Qt::Key_Space || event->key()==Qt::Key_PageDown){ + qDebug() << " - Right/Down/Spacebar" << inPresentation; + nextPage(); + }else if(event->key()==Qt::Key_Left || event->key()==Qt::Key_PageUp){ + qDebug() << " - Left/Up"; + prevPage(); + }else if(event->key()==Qt::Key_Home){ + qDebug() << " - Home"; + firstPage(); + }else if(event->key()==Qt::Key_End){ + qDebug() << " - End"; + lastPage(); + }else if(event->key()==Qt::Key_F11){ + qDebug() << " - F11"; + if(inPresentation){ endPresentation(); } + else{ startPresentationHere(); } + }else if(event->key() == Qt::Key_Up) { + qDebug() << " - KeyUp"; + + }else if(event->key() == Qt::Key_Down) { + /*qDebug() << "Send Wheel Event"; + QWheelEvent wEvent( WIDGET->mapFromGlobal(QCursor::pos()), QCursor::pos(),QPoint(0,0), QPoint(0,30), 0, Qt::Vertical, Qt::LeftButton, Qt::NoModifier); + QApplication::sendEvent(WIDGET, &wEvent);*/ + qDebug() << " - KeyDown"; + //WIDGET->scroll(0, 30); + }else{ + QMainWindow::keyPressEvent(event); + } +} diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.h b/src-qt5/desktop-utils/lumina-pdf/mainUI.h index 527bcb2a..078caaca 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.h +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.h @@ -41,9 +41,6 @@ private: Ui::MainUI *ui; QPrinter* Printer; QPrintDialog *PrintDLG; - - int ccw; - QString lastdir; //Other Interface elements @@ -96,51 +93,13 @@ private slots: void updateContextMenu(); void setScroll(bool); - void rotate(QPrinter*, bool); + void rotate(bool); + //void rotate(QPrinter*, bool); signals: void PageLoaded(int); protected: - void keyPressEvent(QKeyEvent *event){ - //See if this is one of the special hotkeys and act appropriately - //qDebug() << "Got Key Press:"; - bool inPresentation = (presentationLabel!=0); - if(!inPresentation){ - //Alternate functionality when **not** in presentation mode - /*if(event->key()==Qt::Key_Down){ - qDebug() << "Send Wheel Event"; - QWheelEvent event( WIDGET->mapFromGlobal(QCursor::pos()), QCursor::pos(),QPoint(0,0), QPoint(0,30), 0, Qt::Vertical, Qt::LeftButton, Qt::NoModifier); - QApplication::sendEvent(WIDGET, &event); - //WIDGET->scrollDown(); - return; - }else if(event->key()==Qt::Key_Up){ - return; - }*/ - } - - if( event->key()==Qt::Key_Escape || event->key()==Qt::Key_Backspace){ - //qDebug() << " - Escape/Backspace"; - if(inPresentation){ endPresentation(); } - }else if(event->key()==Qt::Key_Right || event->key()==Qt::Key_Down || event->key()==Qt::Key_Space || event->key()==Qt::Key_PageDown){ - //qDebug() << " - Right/Down/Spacebar" << inPresentation; - nextPage(); - }else if(event->key()==Qt::Key_Left || event->key()==Qt::Key_Up || event->key()==Qt::Key_PageUp){ - //qDebug() << " - Left/Up"; - prevPage(); - }else if(event->key()==Qt::Key_Home){ - //qDebug() << " - Home"; - firstPage(); - }else if(event->key()==Qt::Key_End){ - //qDebug() << " - End"; - lastPage(); - }else if(event->key()==Qt::Key_F11){ - //qDebug() << " - F11"; - if(inPresentation){ endPresentation(); } - else{ startPresentationHere(); } - }else{ - QMainWindow::keyPressEvent(event); - } - } + void keyPressEvent(QKeyEvent*); }; #endif diff --git a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui index 20a79cf2..8ce8c989 100644 --- a/src-qt5/desktop-utils/lumina-pdf/mainUI.ui +++ b/src-qt5/desktop-utils/lumina-pdf/mainUI.ui @@ -105,6 +105,9 @@ <addaction name="actionSingle_Page"/> <addaction name="actionDual_Pages"/> <addaction name="actionAll_Pages"/> + <addaction name="separator"/> + <addaction name="actionZoom_In_2"/> + <addaction name="actionZoom_Out_2"/> </widget> <action name="actionOpen_PDF"> <property name="text"> @@ -250,17 +253,6 @@ <string>Rotate Clockwise</string> </property> </action> - <action name="actionSelect_Mode"> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>true</bool> - </property> - <property name="text"> - <string>Select Mode</string> - </property> - </action> <action name="actionScroll_Mode"> <property name="checkable"> <bool>true</bool> @@ -275,6 +267,16 @@ <string>Scroll Mode</string> </property> </action> + <action name="actionZoom_Out_2"> + <property name="text"> + <string/> + </property> + </action> + <action name="actionZoom_In_2"> + <property name="text"> + <string/> + </property> + </action> </widget> <resources/> <connections/> |