diff --git a/core/page.h b/core/page.h --- a/core/page.h +++ b/core/page.h @@ -396,7 +396,7 @@ private: PagePrivate* d; - /// @cond PRIVATE + /// @cond PRIVATE friend class PagePrivate; friend class Document; friend class DocumentPrivate; diff --git a/part.h b/part.h --- a/part.h +++ b/part.h @@ -34,6 +34,8 @@ #include "core/observer.h" #include "core/document.h" +#include "core/page.h" +#include "core/page_p.h" #include "kdocumentviewer.h" #include "interfaces/viewerinterface.h" @@ -75,6 +77,7 @@ class DrawingToolActions; class Layers; class SignaturePanel; +class PagePrivate; #if PURPOSE_FOUND namespace Purpose { class Menu; } @@ -204,6 +207,8 @@ void slotRenameBookmarkFromMenu(); void slotRemoveBookmarkFromMenu(); void slotRenameCurrentViewportBookmark(); + void slotRotateAntiClockwise(); + void slotRotateClockwise(); void slotPreviousBookmark(); void slotNextBookmark(); void slotFindNext(); @@ -327,6 +332,7 @@ QPointer m_bookmarkList; QPointer m_layers; QPointer m_signaturePanel; + QPointer m_pagePrivate; // document watcher (and reloader) variables KDirWatch *m_watcher; @@ -371,6 +377,8 @@ QAction *m_exportAs; QAction *m_exportAsText; QAction *m_exportAsDocArchive; + QAction *m_rotateClockwise; + QAction *m_rotateAntiClockwise; #if PURPOSE_FOUND QAction *m_share; #endif diff --git a/part.cpp b/part.cpp --- a/part.cpp +++ b/part.cpp @@ -27,6 +27,7 @@ #include "part.h" // qt/kde includes +#include #include #include #include @@ -116,6 +117,7 @@ #include "core/document_p.h" #include "core/generator.h" #include "core/page.h" +#include "core/page_p.h" #include "core/fileprinter.h" #include @@ -704,6 +706,18 @@ m_renameBookmark->setWhatsThis( i18n( "Rename the current bookmark" ) ); connect( m_renameBookmark, &QAction::triggered, this, &Part::slotRenameCurrentViewportBookmark ); + m_rotateAntiClockwise = ac->addAction(QStringLiteral("Rotate Left")); + m_rotateAntiClockwise->setText(i18n("Rotate Left")); + m_rotateAntiClockwise->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-left"))); + m_rotateAntiClockwise->setWhatsThis( i18n( "Rotate the selected page 90 degrees counter clockwise" ) ); + connect(m_rotateAntiClockwise, &QAction::triggered, this, &Part::slotRotateAntiClockwise); + + m_rotateClockwise = ac->addAction(QStringLiteral("Rotate Right")); + m_rotateClockwise->setText(i18n("Rotate Right")); + m_rotateClockwise->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-right"))); + m_rotateClockwise->setWhatsThis( i18n( "Rotate the selected page 90 degrees clockwise" ) ); + connect(m_rotateClockwise, &QAction::triggered, this, &Part::slotRotateClockwise); + m_prevBookmark = ac->addAction(QStringLiteral("previous_bookmark")); m_prevBookmark->setText(i18n( "Previous Bookmark" )); m_prevBookmark->setIcon(QIcon::fromTheme( QStringLiteral("go-up-search") )); @@ -2431,6 +2445,20 @@ return ba; } +void Part::slotRotateAntiClockwise() +{ + const Okular::Page *page = m_document->page( m_document->currentPage()); + int value = ( page->rotation() + 3 ) % 4; + m_pagePrivate->rotateAt( qobject_cast(value) ); +} + +void Part::slotRotateClockwise() +{ + const Okular::Page *page = m_document->page( m_document->currentPage() ); + int value = ( page->rotation() + 1 ) % 4; + m_pagePrivate->rotateAt( qobject_cast(value) ); +} + void Part::slotPreviousBookmark() { const KBookmark bookmark = m_document->bookmarkManager()->previousBookmark( m_document->viewport() ); @@ -3074,6 +3102,8 @@ if (page) { popup->addAction( new OKMenuTitle( popup, i18n( "Page %1", page->number() + 1 ) ) ); + popup->addAction( m_rotateAntiClockwise ); + popup->addAction( m_rotateClockwise ); if ( ( !currentPage && m_document->bookmarkManager()->isBookmarked( page->number() ) ) || ( currentPage && m_document->bookmarkManager()->isBookmarked( m_document->viewport() ) ) ) removeBookmark = popup->addAction( QIcon::fromTheme(QStringLiteral("edit-delete-bookmark")), i18n("Remove Bookmark") );