Changeset View
Changeset View
Standalone View
Standalone View
part.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
57 | #include <Kdelibs4Migration> | 57 | #include <Kdelibs4Migration> | ||
58 | #include <KDirWatch> | 58 | #include <KDirWatch> | ||
59 | #include <KFilterBase> | 59 | #include <KFilterBase> | ||
60 | #include <KFilterDev> | 60 | #include <KFilterDev> | ||
61 | #include <KIO/Job> | 61 | #include <KIO/Job> | ||
62 | #include <KIO/OpenFileManagerWindowJob> | 62 | #include <KIO/OpenFileManagerWindowJob> | ||
63 | #include <KJobWidgets> | 63 | #include <KJobWidgets> | ||
64 | #include <KMessageBox> | 64 | #include <KMessageBox> | ||
65 | #include <KParts/MainWindow> | ||||
65 | #include <KPasswordDialog> | 66 | #include <KPasswordDialog> | ||
66 | #include <KPluginFactory> | 67 | #include <KPluginFactory> | ||
67 | #include <KPluginMetaData> | 68 | #include <KPluginMetaData> | ||
68 | #include <KSharedDataCache> | 69 | #include <KSharedDataCache> | ||
69 | #include <KStandardShortcut> | 70 | #include <KStandardShortcut> | ||
70 | #include <KToggleAction> | 71 | #include <KToggleAction> | ||
71 | #include <KToggleFullScreenAction> | 72 | #include <KToggleFullScreenAction> | ||
73 | #include <KToggleToolBarAction> | ||||
72 | #ifdef WITH_KWALLET | 74 | #ifdef WITH_KWALLET | ||
73 | #include <KWallet> | 75 | #include <KWallet> | ||
74 | #endif | 76 | #endif | ||
75 | #include <KXMLGUIClient> | 77 | #include <KXMLGUIClient> | ||
76 | #include <KXMLGUIFactory> | 78 | #include <KXMLGUIFactory> | ||
77 | 79 | | |||
78 | 80 | | |||
79 | #if PURPOSE_FOUND | 81 | #if PURPOSE_FOUND | ||
▲ Show 20 Lines • Show All 362 Lines • ▼ Show 20 Line(s) | 317 | { | |||
442 | // ThumbnailController * m_tc = new ThumbnailController( thumbsBox, m_thumbnailList ); | 444 | // ThumbnailController * m_tc = new ThumbnailController( thumbsBox, m_thumbnailList ); | ||
443 | connect( m_thumbnailList.data(), &ThumbnailList::rightClick, this, &Part::slotShowMenu ); | 445 | connect( m_thumbnailList.data(), &ThumbnailList::rightClick, this, &Part::slotShowMenu ); | ||
444 | m_sidebar->addItem( thumbsBox, QIcon::fromTheme( QStringLiteral("view-preview") ), i18n("Thumbnails") ); | 446 | m_sidebar->addItem( thumbsBox, QIcon::fromTheme( QStringLiteral("view-preview") ), i18n("Thumbnails") ); | ||
445 | 447 | | |||
446 | m_sidebar->setCurrentItem( thumbsBox ); | 448 | m_sidebar->setCurrentItem( thumbsBox ); | ||
447 | 449 | | |||
448 | // [left toolbox: Reviews] | [] | 450 | // [left toolbox: Reviews] | [] | ||
449 | m_reviewsWidget = new Reviews( nullptr, m_document ); | 451 | m_reviewsWidget = new Reviews( nullptr, m_document ); | ||
450 | m_sidebar->addItem( m_reviewsWidget, QIcon::fromTheme(QStringLiteral("draw-freehand")), i18n("Reviews") ); | 452 | m_sidebar->addItem( m_reviewsWidget, QIcon::fromTheme(QStringLiteral("draw-freehand")), i18n("Annotations") ); | ||
451 | m_sidebar->setItemEnabled( m_reviewsWidget, false ); | 453 | m_sidebar->setItemEnabled( m_reviewsWidget, false ); | ||
452 | 454 | | |||
453 | // [left toolbox: Bookmarks] | [] | 455 | // [left toolbox: Bookmarks] | [] | ||
454 | m_bookmarkList = new BookmarkList( m_document, nullptr ); | 456 | m_bookmarkList = new BookmarkList( m_document, nullptr ); | ||
455 | m_sidebar->addItem( m_bookmarkList, QIcon::fromTheme(QStringLiteral("bookmarks")), i18n("Bookmarks") ); | 457 | m_sidebar->addItem( m_bookmarkList, QIcon::fromTheme(QStringLiteral("bookmarks")), i18n("Bookmarks") ); | ||
456 | m_sidebar->setItemEnabled( m_bookmarkList, false ); | 458 | m_sidebar->setItemEnabled( m_bookmarkList, false ); | ||
457 | 459 | | |||
458 | // [left toolbox: Signature Panel] | [] | 460 | // [left toolbox: Signature Panel] | [] | ||
459 | m_signaturePanel = new SignaturePanel( m_document, nullptr ); | 461 | m_signaturePanel = new SignaturePanel( m_document, nullptr ); | ||
460 | connect( m_signaturePanel.data(), &SignaturePanel::documentHasSignatures, this, &Part::showSidebarSignaturesItem ); | 462 | connect( m_signaturePanel.data(), &SignaturePanel::documentHasSignatures, this, &Part::showSidebarSignaturesItem ); | ||
461 | m_sidebar->addItem( m_signaturePanel, QIcon::fromTheme(QStringLiteral("application-pkcs7-signature")), i18n("Signatures") ); | 463 | m_sidebar->addItem( m_signaturePanel, QIcon::fromTheme(QStringLiteral("application-pkcs7-signature")), i18n("Signatures") ); | ||
462 | showSidebarSignaturesItem( false ); | 464 | showSidebarSignaturesItem( false ); | ||
463 | 465 | | |||
464 | // widgets: [../miniBarContainer] | [] | 466 | // widgets: [../miniBarContainer] | [] | ||
465 | #ifdef OKULAR_ENABLE_MINIBAR | 467 | #ifdef OKULAR_ENABLE_MINIBAR | ||
466 | QWidget * miniBarContainer = new QWidget( 0 ); | 468 | QWidget * miniBarContainer = new QWidget( 0 ); | ||
467 | m_sidebar->setBottomWidget( miniBarContainer ); | 469 | m_sidebar->setBottomWidget( miniBarContainer ); | ||
468 | QVBoxLayout * miniBarLayout = new QVBoxLayout( miniBarContainer ); | 470 | QVBoxLayout * miniBarLayout = new QVBoxLayout( miniBarContainer ); | ||
469 | miniBarLayout->setMargin( 0 ); | 471 | miniBarLayout->setContentsMargins( 0, 0, 0, 0 ); | ||
470 | // widgets: [../[spacer/..]] | [] | 472 | // widgets: [../[spacer/..]] | [] | ||
471 | miniBarLayout->addItem( new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); | 473 | miniBarLayout->addItem( new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); | ||
472 | // widgets: [../[../MiniBar]] | [] | 474 | // widgets: [../[../MiniBar]] | [] | ||
473 | QFrame * bevelContainer = new QFrame( miniBarContainer ); | 475 | QFrame * bevelContainer = new QFrame( miniBarContainer ); | ||
474 | bevelContainer->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); | 476 | bevelContainer->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); | ||
475 | QVBoxLayout * bevelContainerLayout = new QVBoxLayout( bevelContainer ); | 477 | QVBoxLayout * bevelContainerLayout = new QVBoxLayout( bevelContainer ); | ||
476 | bevelContainerLayout->setMargin( 4 ); | 478 | bevelContainerLayout->setContentsMargins( 4, 4, 4, 4 ); | ||
477 | m_progressWidget = new ProgressWidget( bevelContainer, m_document ); | 479 | m_progressWidget = new ProgressWidget( bevelContainer, m_document ); | ||
478 | bevelContainerLayout->addWidget( m_progressWidget ); | 480 | bevelContainerLayout->addWidget( m_progressWidget ); | ||
479 | miniBarLayout->addWidget( bevelContainer ); | 481 | miniBarLayout->addWidget( bevelContainer ); | ||
480 | miniBarLayout->addItem( new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); | 482 | miniBarLayout->addItem( new QSpacerItem( 6, 6, QSizePolicy::Fixed, QSizePolicy::Fixed ) ); | ||
481 | #endif | 483 | #endif | ||
482 | 484 | | |||
483 | // widgets: [] | [right 'pageView'] | 485 | // widgets: [] | [right 'pageView'] | ||
484 | QWidget * rightContainer = new QWidget( nullptr ); | 486 | QWidget * rightContainer = new QWidget( nullptr ); | ||
485 | m_sidebar->setMainWidget( rightContainer ); | 487 | m_sidebar->setMainWidget( rightContainer ); | ||
486 | QVBoxLayout * rightLayout = new QVBoxLayout( rightContainer ); | 488 | QVBoxLayout * rightLayout = new QVBoxLayout( rightContainer ); | ||
487 | rightLayout->setMargin( 0 ); | 489 | rightLayout->setContentsMargins( 0, 0, 0, 0 ); | ||
488 | rightLayout->setSpacing( 0 ); | 490 | rightLayout->setSpacing( 0 ); | ||
489 | // KToolBar * rtb = new KToolBar( rightContainer, "mainToolBarSS" ); | 491 | // KToolBar * rtb = new KToolBar( rightContainer, "mainToolBarSS" ); | ||
490 | // rightLayout->addWidget( rtb ); | 492 | // rightLayout->addWidget( rtb ); | ||
491 | m_migrationMessage = new KMessageWidget( rightContainer ); | 493 | m_migrationMessage = new KMessageWidget( rightContainer ); | ||
492 | m_migrationMessage->setVisible( false ); | 494 | m_migrationMessage->setVisible( false ); | ||
493 | m_migrationMessage->setWordWrap( true ); | 495 | m_migrationMessage->setWordWrap( true ); | ||
494 | m_migrationMessage->setMessageType( KMessageWidget::Warning ); | 496 | m_migrationMessage->setMessageType( KMessageWidget::Warning ); | ||
495 | m_migrationMessage->setText( i18n( "This document contains annotations or form data that were saved internally by a previous Okular version. Internal storage is <b>no longer supported</b>.<br/>Please save to a file in order to move them if you want to continue to edit the document." ) ); | 497 | m_migrationMessage->setText( i18n( "This document contains annotations or form data that were saved internally by a previous Okular version. Internal storage is <b>no longer supported</b>.<br/>Please save to a file in order to move them if you want to continue to edit the document." ) ); | ||
Show All 23 Lines | |||||
519 | m_signatureMessage->setVisible( false ); | 521 | m_signatureMessage->setVisible( false ); | ||
520 | m_signatureMessage->setWordWrap( true ); | 522 | m_signatureMessage->setWordWrap( true ); | ||
521 | m_signatureMessage->setMessageType( KMessageWidget::Information ); | 523 | m_signatureMessage->setMessageType( KMessageWidget::Information ); | ||
522 | rightLayout->addWidget( m_signatureMessage ); | 524 | rightLayout->addWidget( m_signatureMessage ); | ||
523 | m_pageView = new PageView( rightContainer, m_document ); | 525 | m_pageView = new PageView( rightContainer, m_document ); | ||
524 | QMetaObject::invokeMethod( m_pageView, "setFocus", Qt::QueuedConnection ); //usability setting | 526 | QMetaObject::invokeMethod( m_pageView, "setFocus", Qt::QueuedConnection ); //usability setting | ||
525 | // m_splitter->setFocusProxy(m_pageView); | 527 | // m_splitter->setFocusProxy(m_pageView); | ||
526 | connect( m_pageView.data(), &PageView::rightClick, this, &Part::slotShowMenu ); | 528 | connect( m_pageView.data(), &PageView::rightClick, this, &Part::slotShowMenu ); | ||
529 | connect( m_pageView, &PageView::triggerSearch, this, | ||||
530 | [this] (const QString& searchText){ | ||||
531 | m_findBar->startSearch(searchText); | ||||
532 | slotShowFindBar(); | ||||
533 | } | ||||
534 | ); | ||||
527 | connect( m_document, &Document::error, this, &Part::errorMessage ); | 535 | connect( m_document, &Document::error, this, &Part::errorMessage ); | ||
528 | connect( m_document, &Document::warning, this, &Part::warningMessage ); | 536 | connect( m_document, &Document::warning, this, &Part::warningMessage ); | ||
529 | connect( m_document, &Document::notice, this, &Part::noticeMessage ); | 537 | connect( m_document, &Document::notice, this, &Part::noticeMessage ); | ||
530 | connect( m_document, &Document::sourceReferenceActivated, this, &Part::slotHandleActivatedSourceReference ); | 538 | connect( m_document, &Document::sourceReferenceActivated, this, &Part::slotHandleActivatedSourceReference ); | ||
531 | connect( m_pageView.data(), &PageView::fitWindowToPage, this, &Part::fitWindowToPage ); | 539 | connect( m_pageView.data(), &PageView::fitWindowToPage, this, &Part::fitWindowToPage ); | ||
532 | rightLayout->addWidget( m_pageView ); | 540 | rightLayout->addWidget( m_pageView ); | ||
533 | m_layers->setPageView( m_pageView ); | 541 | m_layers->setPageView( m_pageView ); | ||
534 | m_signaturePanel->setPageView( m_pageView ); | 542 | m_signaturePanel->setPageView( m_pageView ); | ||
535 | m_findBar = new FindBar( m_document, rightContainer ); | 543 | m_findBar = new FindBar( m_document, rightContainer ); | ||
536 | rightLayout->addWidget( m_findBar ); | 544 | rightLayout->addWidget( m_findBar ); | ||
537 | m_bottomBar = new QWidget( rightContainer ); | 545 | m_bottomBar = new QWidget( rightContainer ); | ||
538 | QHBoxLayout * bottomBarLayout = new QHBoxLayout( m_bottomBar ); | 546 | QHBoxLayout * bottomBarLayout = new QHBoxLayout( m_bottomBar ); | ||
539 | m_pageSizeLabel = new PageSizeLabel( m_bottomBar, m_document ); | 547 | m_pageSizeLabel = new PageSizeLabel( m_bottomBar, m_document ); | ||
540 | bottomBarLayout->setMargin( 0 ); | 548 | bottomBarLayout->setContentsMargins( 0, 0, 0, 0 ); | ||
541 | bottomBarLayout->setSpacing( 0 ); | 549 | bottomBarLayout->setSpacing( 0 ); | ||
542 | bottomBarLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 550 | bottomBarLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | ||
543 | m_miniBarLogic = new MiniBarLogic( this, m_document ); | 551 | m_miniBarLogic = new MiniBarLogic( this, m_document ); | ||
544 | m_miniBar = new MiniBar( m_bottomBar, m_miniBarLogic ); | 552 | m_miniBar = new MiniBar( m_bottomBar, m_miniBarLogic ); | ||
545 | bottomBarLayout->addWidget( m_miniBar ); | 553 | bottomBarLayout->addWidget( m_miniBar ); | ||
546 | bottomBarLayout->addWidget( m_pageSizeLabel ); | 554 | bottomBarLayout->addWidget( m_pageSizeLabel ); | ||
547 | rightLayout->addWidget( m_bottomBar ); | 555 | rightLayout->addWidget( m_bottomBar ); | ||
548 | 556 | | |||
Show All 25 Lines | 577 | #endif | |||
574 | 582 | | |||
575 | connect( m_document->bookmarkManager(), &BookmarkManager::saved, | 583 | connect( m_document->bookmarkManager(), &BookmarkManager::saved, | ||
576 | this, &Part::slotRebuildBookmarkMenu ); | 584 | this, &Part::slotRebuildBookmarkMenu ); | ||
577 | 585 | | |||
578 | setupViewerActions(); | 586 | setupViewerActions(); | ||
579 | 587 | | |||
580 | if ( m_embedMode != ViewerWidgetMode ) | 588 | if ( m_embedMode != ViewerWidgetMode ) | ||
581 | { | 589 | { | ||
582 | setupActions(); | 590 | KParts::MainWindow * shell = qobject_cast<KParts::MainWindow *>( parent ); | ||
591 | setupActions( shell ); | ||||
583 | } | 592 | } | ||
584 | else | 593 | else | ||
585 | { | 594 | { | ||
586 | setViewerShortcuts(); | 595 | setViewerShortcuts(); | ||
587 | } | 596 | } | ||
588 | 597 | | |||
589 | // document watcher and reloader | 598 | // document watcher and reloader | ||
590 | m_watcher = new KDirWatch( this ); | 599 | m_watcher = new KDirWatch( this ); | ||
▲ Show 20 Lines • Show All 242 Lines • ▼ Show 20 Line(s) | 830 | { | |||
833 | ac->setDefaultShortcut(m_endOfDocument, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_End)); | 842 | ac->setDefaultShortcut(m_endOfDocument, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_End)); | ||
834 | 843 | | |||
835 | QAction *action = static_cast<QAction*>( ac->action( QStringLiteral("file_reload") ) ); | 844 | QAction *action = static_cast<QAction*>( ac->action( QStringLiteral("file_reload") ) ); | ||
836 | if (action) { | 845 | if (action) { | ||
837 | ac->setDefaultShortcut(action, QKeySequence(Qt::ALT + Qt::Key_F5)); | 846 | ac->setDefaultShortcut(action, QKeySequence(Qt::ALT + Qt::Key_F5)); | ||
838 | } | 847 | } | ||
839 | } | 848 | } | ||
840 | 849 | | |||
841 | void Part::setupActions() | 850 | void Part::setupActions( KParts::MainWindow * shell ) | ||
842 | { | 851 | { | ||
843 | KActionCollection * ac = actionCollection(); | 852 | KActionCollection * ac = actionCollection(); | ||
844 | 853 | | |||
845 | m_copy = KStandardAction::create( KStandardAction::Copy, m_pageView, SLOT(copyTextSelection()), ac ); | 854 | m_copy = KStandardAction::create( KStandardAction::Copy, m_pageView, SLOT(copyTextSelection()), ac ); | ||
846 | 855 | | |||
847 | m_selectAll = KStandardAction::selectAll( m_pageView, SLOT(selectAll()), ac ); | 856 | m_selectAll = KStandardAction::selectAll( m_pageView, SLOT(selectAll()), ac ); | ||
848 | 857 | | |||
849 | // Setup select all action for the current page | 858 | // Setup select all action for the current page | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 942 | #endif | |||
948 | QAction *configureAnnotations = new QAction( i18n( "Configure Annotations..." ), ac ); | 957 | QAction *configureAnnotations = new QAction( i18n( "Configure Annotations..." ), ac ); | ||
949 | ac->addAction( QStringLiteral("options_configure_annotations"), configureAnnotations ); | 958 | ac->addAction( QStringLiteral("options_configure_annotations"), configureAnnotations ); | ||
950 | configureAnnotations->setIcon( QIcon::fromTheme( QStringLiteral("configure") ) ); | 959 | configureAnnotations->setIcon( QIcon::fromTheme( QStringLiteral("configure") ) ); | ||
951 | connect(configureAnnotations, &QAction::triggered, this, &Part::slotAnnotationPreferences); | 960 | connect(configureAnnotations, &QAction::triggered, this, &Part::slotAnnotationPreferences); | ||
952 | 961 | | |||
953 | QAction *playPauseAction = new QAction( i18n( "Play/Pause Presentation" ), ac ); | 962 | QAction *playPauseAction = new QAction( i18n( "Play/Pause Presentation" ), ac ); | ||
954 | ac->addAction( QStringLiteral("presentation_play_pause"), playPauseAction ); | 963 | ac->addAction( QStringLiteral("presentation_play_pause"), playPauseAction ); | ||
955 | playPauseAction->setEnabled( false ); | 964 | playPauseAction->setEnabled( false ); | ||
965 | | ||||
966 | // force the creation of the main toolbar before the annotation toolbar | ||||
967 | // to respect the default toolbar layout defined in shell.rc | ||||
968 | shell->toolBar( "mainToolBar" ); | ||||
969 | KToggleToolBarAction * showAnnotationToolBar = new KToggleToolBarAction( shell->toolBar( "annotationToolBar" ), i18n("&Annotations"), this ); | ||||
970 | showAnnotationToolBar->setIcon( QIcon::fromTheme( QStringLiteral("draw-freehand") ) ); | ||||
971 | actionCollection()->addAction( QStringLiteral("mouse_toggle_annotate"), showAnnotationToolBar ); | ||||
972 | actionCollection()->setDefaultShortcut( showAnnotationToolBar, Qt::Key_F6 ); | ||||
956 | } | 973 | } | ||
957 | 974 | | |||
958 | Part::~Part() | 975 | Part::~Part() | ||
959 | { | 976 | { | ||
960 | QDBusConnection::sessionBus().unregisterObject(m_registerDbusName); | 977 | QDBusConnection::sessionBus().unregisterObject(m_registerDbusName); | ||
961 | 978 | | |||
962 | GuiUtils::removeIconLoader( iconLoader() ); | 979 | GuiUtils::removeIconLoader( iconLoader() ); | ||
963 | m_document->removeObserver( this ); | 980 | m_document->removeObserver( this ); | ||
▲ Show 20 Lines • Show All 1309 Lines • ▼ Show 20 Line(s) | 2289 | public: | |||
2273 | GotoPageDialog(QWidget *p, int current, int max) : QDialog(p) | 2290 | GotoPageDialog(QWidget *p, int current, int max) : QDialog(p) | ||
2274 | { | 2291 | { | ||
2275 | setWindowTitle(i18n("Go to Page")); | 2292 | setWindowTitle(i18n("Go to Page")); | ||
2276 | buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | 2293 | buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | ||
2277 | connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); | 2294 | connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); | ||
2278 | connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); | 2295 | connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); | ||
2279 | 2296 | | |||
2280 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 2297 | QVBoxLayout *topLayout = new QVBoxLayout(this); | ||
2281 | topLayout->setMargin(6); | 2298 | topLayout->setContentsMargins(6, 6, 6, 6); | ||
2282 | QHBoxLayout *midLayout = new QHBoxLayout(); | 2299 | QHBoxLayout *midLayout = new QHBoxLayout(); | ||
2283 | spinbox = new QSpinBox(this); | 2300 | spinbox = new QSpinBox(this); | ||
2284 | spinbox->setRange(1, max); | 2301 | spinbox->setRange(1, max); | ||
2285 | spinbox->setValue(current); | 2302 | spinbox->setValue(current); | ||
2286 | spinbox->setFocus(); | 2303 | spinbox->setFocus(); | ||
2287 | 2304 | | |||
2288 | slider = new QSlider(Qt::Horizontal, this); | 2305 | slider = new QSlider(Qt::Horizontal, this); | ||
2289 | slider->setRange(1, max); | 2306 | slider->setRange(1, max); | ||
▲ Show 20 Lines • Show All 1430 Lines • Show Last 20 Lines |