Changeset View
Changeset View
Standalone View
Standalone View
part.cpp
Show All 21 Lines | |||||
22 | * it under the terms of the GNU General Public License as published by * | 22 | * it under the terms of the GNU General Public License as published by * | ||
23 | * the Free Software Foundation; either version 2 of the License, or * | 23 | * the Free Software Foundation; either version 2 of the License, or * | ||
24 | * (at your option) any later version. * | 24 | * (at your option) any later version. * | ||
25 | ***************************************************************************/ | 25 | ***************************************************************************/ | ||
26 | 26 | | |||
27 | #include "part.h" | 27 | #include "part.h" | ||
28 | 28 | | |||
29 | // qt/kde includes | 29 | // qt/kde includes | ||
30 | #include <QDebug> | ||||
30 | #include <QApplication> | 31 | #include <QApplication> | ||
31 | #include <QDialog> | 32 | #include <QDialog> | ||
32 | #include <QDialogButtonBox> | 33 | #include <QDialogButtonBox> | ||
33 | #include <QFile> | 34 | #include <QFile> | ||
34 | #include <QFileDialog> | 35 | #include <QFileDialog> | ||
35 | #include <QIcon> | 36 | #include <QIcon> | ||
36 | #include <QInputDialog> | 37 | #include <QInputDialog> | ||
37 | #include <QLayout> | 38 | #include <QLayout> | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | |||||
111 | #include "settings.h" | 112 | #include "settings.h" | ||
112 | #include "core/action.h" | 113 | #include "core/action.h" | ||
113 | #include "core/annotations.h" | 114 | #include "core/annotations.h" | ||
114 | #include "core/bookmarkmanager.h" | 115 | #include "core/bookmarkmanager.h" | ||
115 | #include "core/document.h" | 116 | #include "core/document.h" | ||
116 | #include "core/document_p.h" | 117 | #include "core/document_p.h" | ||
117 | #include "core/generator.h" | 118 | #include "core/generator.h" | ||
118 | #include "core/page.h" | 119 | #include "core/page.h" | ||
120 | #include "core/page_p.h" | ||||
119 | #include "core/fileprinter.h" | 121 | #include "core/fileprinter.h" | ||
120 | #include <memory> | 122 | #include <memory> | ||
121 | 123 | | |||
122 | #ifdef OKULAR_KEEP_FILE_OPEN | 124 | #ifdef OKULAR_KEEP_FILE_OPEN | ||
123 | class FileKeeper | 125 | class FileKeeper | ||
124 | { | 126 | { | ||
125 | public: | 127 | public: | ||
126 | FileKeeper() | 128 | FileKeeper() | ||
▲ Show 20 Lines • Show All 572 Lines • ▼ Show 20 Line(s) | 683 | #endif | |||
699 | m_addBookmarkIcon = m_addBookmark->icon(); | 701 | m_addBookmarkIcon = m_addBookmark->icon(); | ||
700 | 702 | | |||
701 | m_renameBookmark = ac->addAction(QStringLiteral("rename_bookmark")); | 703 | m_renameBookmark = ac->addAction(QStringLiteral("rename_bookmark")); | ||
702 | m_renameBookmark->setText(i18n( "Rename Bookmark" )); | 704 | m_renameBookmark->setText(i18n( "Rename Bookmark" )); | ||
703 | m_renameBookmark->setIcon(QIcon::fromTheme( QStringLiteral("edit-rename") )); | 705 | m_renameBookmark->setIcon(QIcon::fromTheme( QStringLiteral("edit-rename") )); | ||
704 | m_renameBookmark->setWhatsThis( i18n( "Rename the current bookmark" ) ); | 706 | m_renameBookmark->setWhatsThis( i18n( "Rename the current bookmark" ) ); | ||
705 | connect( m_renameBookmark, &QAction::triggered, this, &Part::slotRenameCurrentViewportBookmark ); | 707 | connect( m_renameBookmark, &QAction::triggered, this, &Part::slotRenameCurrentViewportBookmark ); | ||
706 | 708 | | |||
709 | m_rotateAntiClockwise = ac->addAction(QStringLiteral("Rotate Left")); | ||||
710 | m_rotateAntiClockwise->setText(i18n("Rotate Left")); | ||||
711 | m_rotateAntiClockwise->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-left"))); | ||||
712 | m_rotateAntiClockwise->setWhatsThis( i18n( "Rotate the selected page 90 degrees counter clockwise" ) ); | ||||
713 | connect(m_rotateAntiClockwise, &QAction::triggered, this, &Part::slotRotateAntiClockwise); | ||||
714 | | ||||
715 | m_rotateClockwise = ac->addAction(QStringLiteral("Rotate Right")); | ||||
716 | m_rotateClockwise->setText(i18n("Rotate Right")); | ||||
717 | m_rotateClockwise->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-right"))); | ||||
718 | m_rotateClockwise->setWhatsThis( i18n( "Rotate the selected page 90 degrees clockwise" ) ); | ||||
719 | connect(m_rotateClockwise, &QAction::triggered, this, &Part::slotRotateClockwise); | ||||
720 | | ||||
707 | m_prevBookmark = ac->addAction(QStringLiteral("previous_bookmark")); | 721 | m_prevBookmark = ac->addAction(QStringLiteral("previous_bookmark")); | ||
708 | m_prevBookmark->setText(i18n( "Previous Bookmark" )); | 722 | m_prevBookmark->setText(i18n( "Previous Bookmark" )); | ||
709 | m_prevBookmark->setIcon(QIcon::fromTheme( QStringLiteral("go-up-search") )); | 723 | m_prevBookmark->setIcon(QIcon::fromTheme( QStringLiteral("go-up-search") )); | ||
710 | m_prevBookmark->setWhatsThis( i18n( "Go to the previous bookmark" ) ); | 724 | m_prevBookmark->setWhatsThis( i18n( "Go to the previous bookmark" ) ); | ||
711 | connect( m_prevBookmark, &QAction::triggered, this, &Part::slotPreviousBookmark ); | 725 | connect( m_prevBookmark, &QAction::triggered, this, &Part::slotPreviousBookmark ); | ||
712 | 726 | | |||
713 | m_nextBookmark = ac->addAction(QStringLiteral("next_bookmark")); | 727 | m_nextBookmark = ac->addAction(QStringLiteral("next_bookmark")); | ||
714 | m_nextBookmark->setText(i18n( "Next Bookmark" )); | 728 | m_nextBookmark->setText(i18n( "Next Bookmark" )); | ||
▲ Show 20 Lines • Show All 1711 Lines • ▼ Show 20 Line(s) | 2435 | { | |||
2426 | renameAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | 2440 | renameAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | ||
2427 | QAction *deleteAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("list-remove") ), i18n("Remove this Bookmark"), this, SLOT(slotRemoveBookmarkFromMenu())); | 2441 | QAction *deleteAction = contextMenu->addAction( QIcon::fromTheme( QStringLiteral("list-remove") ), i18n("Remove this Bookmark"), this, SLOT(slotRemoveBookmarkFromMenu())); | ||
2428 | deleteAction->setData(ba->property("htmlRef").toString()); | 2442 | deleteAction->setData(ba->property("htmlRef").toString()); | ||
2429 | deleteAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | 2443 | deleteAction->setObjectName(QStringLiteral("OkularPrivateRenameBookmarkActions")); | ||
2430 | } | 2444 | } | ||
2431 | return ba; | 2445 | return ba; | ||
2432 | } | 2446 | } | ||
2433 | 2447 | | |||
2448 | void Part::slotRotateAntiClockwise() | ||||
2449 | { | ||||
2450 | const Okular::Page *page = m_document->page( m_document->currentPage()); | ||||
2451 | int value = ( page->rotation() + 3 ) % 4; | ||||
2452 | m_pagePrivate->rotateAt( qobject_cast<Okular::Rotation>(value) ); | ||||
shubham: This is valid statement, but why does this produce error? | |||||
2453 | } | ||||
This gives error, any help how could I access rotateAt() function of private API without actually making PagePrivate *d in Page as public (Though it is a wrong way to do so)? shubham: This gives error, any help how could I access rotateAt() function of private API without… | |||||
2454 | | ||||
2455 | void Part::slotRotateClockwise() | ||||
2456 | { | ||||
2457 | const Okular::Page *page = m_document->page( m_document->currentPage() ); | ||||
2458 | int value = ( page->rotation() + 1 ) % 4; | ||||
2459 | m_pagePrivate->rotateAt( qobject_cast<Okular::Rotation>(value) ); | ||||
2460 | } | ||||
2461 | | ||||
2434 | void Part::slotPreviousBookmark() | 2462 | void Part::slotPreviousBookmark() | ||
2435 | { | 2463 | { | ||
2436 | const KBookmark bookmark = m_document->bookmarkManager()->previousBookmark( m_document->viewport() ); | 2464 | const KBookmark bookmark = m_document->bookmarkManager()->previousBookmark( m_document->viewport() ); | ||
2437 | 2465 | | |||
2438 | if ( !bookmark.isNull() ) | 2466 | if ( !bookmark.isNull() ) | ||
2439 | { | 2467 | { | ||
2440 | DocumentViewport vp( bookmark.url().fragment(QUrl::FullyDecoded) ); | 2468 | DocumentViewport vp( bookmark.url().fragment(QUrl::FullyDecoded) ); | ||
2441 | m_document->setViewport( vp ); | 2469 | m_document->setViewport( vp ); | ||
▲ Show 20 Lines • Show All 627 Lines • ▼ Show 20 Line(s) | 3053 | { | |||
3069 | } | 3097 | } | ||
3070 | 3098 | | |||
3071 | QAction *addBookmark = nullptr; | 3099 | QAction *addBookmark = nullptr; | ||
3072 | QAction *removeBookmark = nullptr; | 3100 | QAction *removeBookmark = nullptr; | ||
3073 | QAction *fitPageWidth = nullptr; | 3101 | QAction *fitPageWidth = nullptr; | ||
3074 | if (page) | 3102 | if (page) | ||
3075 | { | 3103 | { | ||
3076 | popup->addAction( new OKMenuTitle( popup, i18n( "Page %1", page->number() + 1 ) ) ); | 3104 | popup->addAction( new OKMenuTitle( popup, i18n( "Page %1", page->number() + 1 ) ) ); | ||
3105 | popup->addAction( m_rotateAntiClockwise ); | ||||
3106 | popup->addAction( m_rotateClockwise ); | ||||
3077 | if ( ( !currentPage && m_document->bookmarkManager()->isBookmarked( page->number() ) ) || | 3107 | if ( ( !currentPage && m_document->bookmarkManager()->isBookmarked( page->number() ) ) || | ||
3078 | ( currentPage && m_document->bookmarkManager()->isBookmarked( m_document->viewport() ) ) ) | 3108 | ( currentPage && m_document->bookmarkManager()->isBookmarked( m_document->viewport() ) ) ) | ||
3079 | removeBookmark = popup->addAction( QIcon::fromTheme(QStringLiteral("edit-delete-bookmark")), i18n("Remove Bookmark") ); | 3109 | removeBookmark = popup->addAction( QIcon::fromTheme(QStringLiteral("edit-delete-bookmark")), i18n("Remove Bookmark") ); | ||
3080 | else | 3110 | else | ||
3081 | addBookmark = popup->addAction( QIcon::fromTheme(QStringLiteral("bookmark-new")), i18n("Add Bookmark") ); | 3111 | addBookmark = popup->addAction( QIcon::fromTheme(QStringLiteral("bookmark-new")), i18n("Add Bookmark") ); | ||
3082 | if ( m_pageView->canFitPageWidth() ) | 3112 | if ( m_pageView->canFitPageWidth() ) | ||
3083 | fitPageWidth = popup->addAction( QIcon::fromTheme(QStringLiteral("zoom-fit-best")), i18n("Fit Width") ); | 3113 | fitPageWidth = popup->addAction( QIcon::fromTheme(QStringLiteral("zoom-fit-best")), i18n("Fit Width") ); | ||
3084 | popup->addAction( m_prevBookmark ); | 3114 | popup->addAction( m_prevBookmark ); | ||
▲ Show 20 Lines • Show All 581 Lines • Show Last 20 Lines |
This is valid statement, but why does this produce error?