Changeset View
Changeset View
Standalone View
Standalone View
ui/pageview.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | 44 | | |||
45 | #include <qaction.h> | 45 | #include <qaction.h> | ||
46 | #include <kactionmenu.h> | 46 | #include <kactionmenu.h> | ||
47 | #include <kstandardaction.h> | 47 | #include <kstandardaction.h> | ||
48 | #include <kactioncollection.h> | 48 | #include <kactioncollection.h> | ||
49 | #include <KLocalizedString> | 49 | #include <KLocalizedString> | ||
50 | #include <kselectaction.h> | 50 | #include <kselectaction.h> | ||
51 | #include <ktoggleaction.h> | 51 | #include <ktoggleaction.h> | ||
52 | #include <ktoggletoolbaraction.h> | ||||
52 | #include <QDebug> | 53 | #include <QDebug> | ||
53 | #include <kmessagebox.h> | 54 | #include <kmessagebox.h> | ||
54 | #include <QIcon> | 55 | #include <QIcon> | ||
55 | #include <kurifilter.h> | 56 | #include <kurifilter.h> | ||
56 | #include <kstringhandler.h> | 57 | #include <kstringhandler.h> | ||
57 | #include <ktoolinvocation.h> | 58 | #include <ktoolinvocation.h> | ||
58 | #include <krun.h> | 59 | #include <krun.h> | ||
59 | 60 | | |||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Line(s) | 192 | #endif | |||
214 | KActionMenu * aTrimMode; | 215 | KActionMenu * aTrimMode; | ||
215 | KToggleAction * aTrimMargins; | 216 | KToggleAction * aTrimMargins; | ||
216 | QAction * aMouseNormal; | 217 | QAction * aMouseNormal; | ||
217 | QAction * aMouseSelect; | 218 | QAction * aMouseSelect; | ||
218 | QAction * aMouseTextSelect; | 219 | QAction * aMouseTextSelect; | ||
219 | QAction * aMouseTableSelect; | 220 | QAction * aMouseTableSelect; | ||
220 | QAction * aMouseMagnifier; | 221 | QAction * aMouseMagnifier; | ||
221 | KToggleAction * aTrimToSelection; | 222 | KToggleAction * aTrimToSelection; | ||
222 | KToggleAction * aToggleAnnotator; | | |||
223 | KSelectAction * aZoom; | 223 | KSelectAction * aZoom; | ||
224 | QAction * aZoomIn; | 224 | QAction * aZoomIn; | ||
225 | QAction * aZoomOut; | 225 | QAction * aZoomOut; | ||
226 | QAction * aZoomActual; | 226 | QAction * aZoomActual; | ||
227 | KToggleAction * aZoomFitWidth; | 227 | KToggleAction * aZoomFitWidth; | ||
228 | KToggleAction * aZoomFitPage; | 228 | KToggleAction * aZoomFitPage; | ||
229 | KToggleAction * aZoomAutoFit; | 229 | KToggleAction * aZoomAutoFit; | ||
230 | KActionMenu * aViewMode; | 230 | KActionMenu * aViewMode; | ||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | 336 | #endif | |||
340 | d->aRotateOriginal = nullptr; | 340 | d->aRotateOriginal = nullptr; | ||
341 | d->aPageSizes = nullptr; | 341 | d->aPageSizes = nullptr; | ||
342 | d->aTrimMode = nullptr; | 342 | d->aTrimMode = nullptr; | ||
343 | d->aTrimMargins = nullptr; | 343 | d->aTrimMargins = nullptr; | ||
344 | d->aTrimToSelection = nullptr; | 344 | d->aTrimToSelection = nullptr; | ||
345 | d->aMouseNormal = nullptr; | 345 | d->aMouseNormal = nullptr; | ||
346 | d->aMouseSelect = nullptr; | 346 | d->aMouseSelect = nullptr; | ||
347 | d->aMouseTextSelect = nullptr; | 347 | d->aMouseTextSelect = nullptr; | ||
348 | d->aToggleAnnotator = nullptr; | | |||
349 | d->aZoomFitWidth = nullptr; | 348 | d->aZoomFitWidth = nullptr; | ||
350 | d->aZoomFitPage = nullptr; | 349 | d->aZoomFitPage = nullptr; | ||
351 | d->aZoomAutoFit = nullptr; | 350 | d->aZoomAutoFit = nullptr; | ||
352 | d->aViewMode = nullptr; | 351 | d->aViewMode = nullptr; | ||
353 | d->aViewContinuous = nullptr; | 352 | d->aViewContinuous = nullptr; | ||
354 | d->aPrevAction = nullptr; | 353 | d->aPrevAction = nullptr; | ||
355 | d->aToggleForms = nullptr; | 354 | d->aToggleForms = nullptr; | ||
356 | d->aSpeakDoc = nullptr; | 355 | d->aSpeakDoc = nullptr; | ||
▲ Show 20 Lines • Show All 231 Lines • ▼ Show 20 Line(s) | 583 | #undef ADD_VIEWMODE_ACTION | |||
588 | connect( d->aViewContinuous, &QAction::toggled, this, &PageView::slotContinuousToggled ); | 587 | connect( d->aViewContinuous, &QAction::toggled, this, &PageView::slotContinuousToggled ); | ||
589 | d->aViewContinuous->setChecked( Okular::Settings::viewContinuous() ); | 588 | d->aViewContinuous->setChecked( Okular::Settings::viewContinuous() ); | ||
590 | 589 | | |||
591 | // Mouse mode actions for viewer mode | 590 | // Mouse mode actions for viewer mode | ||
592 | d->mouseModeActionGroup = new QActionGroup( this ); | 591 | d->mouseModeActionGroup = new QActionGroup( this ); | ||
593 | d->mouseModeActionGroup->setExclusive( true ); | 592 | d->mouseModeActionGroup->setExclusive( true ); | ||
594 | d->aMouseNormal = new QAction( QIcon::fromTheme( QStringLiteral("transform-browse") ), i18n( "&Browse" ), this ); | 593 | d->aMouseNormal = new QAction( QIcon::fromTheme( QStringLiteral("transform-browse") ), i18n( "&Browse" ), this ); | ||
595 | ac->addAction(QStringLiteral("mouse_drag"), d->aMouseNormal ); | 594 | ac->addAction(QStringLiteral("mouse_drag"), d->aMouseNormal ); | ||
596 | connect( d->aMouseNormal, &QAction::triggered, this, &PageView::slotSetMouseNormal ); | 595 | connect( d->aMouseNormal, &QAction::triggered, this, &PageView::slotMouseNormalToggled ); | ||
597 | d->aMouseNormal->setCheckable( true ); | 596 | d->aMouseNormal->setCheckable( true ); | ||
598 | ac->setDefaultShortcut(d->aMouseNormal, QKeySequence(Qt::CTRL + Qt::Key_1)); | 597 | ac->setDefaultShortcut(d->aMouseNormal, QKeySequence(Qt::CTRL + Qt::Key_1)); | ||
599 | d->aMouseNormal->setActionGroup( d->mouseModeActionGroup ); | 598 | d->aMouseNormal->setActionGroup( d->mouseModeActionGroup ); | ||
600 | d->aMouseNormal->setChecked( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::Browse ); | 599 | d->aMouseNormal->setChecked( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::Browse ); | ||
601 | 600 | | |||
602 | QAction * mz = new QAction(QIcon::fromTheme( QStringLiteral("page-zoom") ), i18n("&Zoom"), this); | 601 | QAction * mz = new QAction(QIcon::fromTheme( QStringLiteral("page-zoom") ), i18n("&Zoom"), this); | ||
603 | ac->addAction(QStringLiteral("mouse_zoom"), mz ); | 602 | ac->addAction(QStringLiteral("mouse_zoom"), mz ); | ||
604 | connect( mz, &QAction::triggered, this, &PageView::slotSetMouseZoom ); | 603 | connect( mz, &QAction::triggered, this, &PageView::slotSetMouseZoom ); | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 616 | { | |||
648 | 647 | | |||
649 | d->aMouseMagnifier = new QAction(QIcon::fromTheme( QStringLiteral("document-preview") ), i18n("&Magnifier"), this); | 648 | d->aMouseMagnifier = new QAction(QIcon::fromTheme( QStringLiteral("document-preview") ), i18n("&Magnifier"), this); | ||
650 | ac->addAction(QStringLiteral("mouse_magnifier"), d->aMouseMagnifier ); | 649 | ac->addAction(QStringLiteral("mouse_magnifier"), d->aMouseMagnifier ); | ||
651 | connect( d->aMouseMagnifier, &QAction::triggered, this, &PageView::slotSetMouseMagnifier ); | 650 | connect( d->aMouseMagnifier, &QAction::triggered, this, &PageView::slotSetMouseMagnifier ); | ||
652 | d->aMouseMagnifier->setCheckable( true ); | 651 | d->aMouseMagnifier->setCheckable( true ); | ||
653 | ac->setDefaultShortcut(d->aMouseMagnifier, Qt::CTRL + Qt::Key_6); | 652 | ac->setDefaultShortcut(d->aMouseMagnifier, Qt::CTRL + Qt::Key_6); | ||
654 | d->aMouseMagnifier->setActionGroup( d->mouseModeActionGroup ); | 653 | d->aMouseMagnifier->setActionGroup( d->mouseModeActionGroup ); | ||
655 | d->aMouseMagnifier->setChecked( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::Magnifier ); | 654 | d->aMouseMagnifier->setChecked( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::Magnifier ); | ||
656 | 655 | | |||
657 | d->aToggleAnnotator = new KToggleAction(QIcon::fromTheme( QStringLiteral("draw-freehand") ), i18n("&Review"), this); | | |||
658 | ac->addAction(QStringLiteral("mouse_toggle_annotate"), d->aToggleAnnotator ); | | |||
659 | d->aToggleAnnotator->setCheckable( true ); | | |||
660 | connect( d->aToggleAnnotator, &QAction::toggled, this, &PageView::slotToggleAnnotator ); | | |||
661 | ac->setDefaultShortcut(d->aToggleAnnotator, Qt::Key_F6); | | |||
662 | | ||||
663 | ToolAction *ta = new ToolAction( this ); | 656 | ToolAction *ta = new ToolAction( this ); | ||
simgunz: Anyone knows how KToggleToolBarAction is supposed to work?
Currently it does nothing. | |||||
aacid: You're right, it seems it never has. Can you use the other one? | |||||
Is it there a clean way to obtain a reference to the toolbar from within this class? simgunz: Is it there a clean way to obtain a reference to the toolbar from within this class?
I guess… | |||||
right, that's actually a tricky question. I'll try to figure it out, but you may want to play with stuff and not wait for me, a close friend of mine is getting married so don't expect anything from me until monday/tuesday aacid: right, that's actually a tricky question.
I'll try to figure it out, but you may want to play… | |||||
Your help is appreciated. No rush, I can work on other things in the meanwhile. What I tried so far: Calling this in setupActions of PageViewAnnotator: qDebug() << KMainWindow::memberList(); qDebug() << KMainWindow::memberList().count(); qDebug() << KMainWindow::memberList()[0]->toolBars().count(); I get (Shell(0x55c3e0f80fc0, name="okular::Shell#")) 1 0 So it seems that the toolbars have not been created yet at this point. I'll keep experimenting. simgunz: Your help is appreciated. No rush, I can work on other things in the meanwhile.
What I tried… | |||||
664 | ac->addAction( QStringLiteral("mouse_selecttools"), ta ); | 657 | ac->addAction( QStringLiteral("mouse_selecttools"), ta ); | ||
665 | ta->addAction( d->aMouseTextSelect ); | 658 | ta->addAction( d->aMouseTextSelect ); | ||
666 | ta->addAction( d->aMouseSelect ); | 659 | ta->addAction( d->aMouseSelect ); | ||
667 | ta->addAction( d->aMouseTableSelect ); | 660 | ta->addAction( d->aMouseTableSelect ); | ||
668 | 661 | | |||
669 | // speak actions | 662 | // speak actions | ||
670 | #ifdef HAVE_SPEECH | 663 | #ifdef HAVE_SPEECH | ||
671 | d->aSpeakDoc = new QAction( QIcon::fromTheme( QStringLiteral("text-speak") ), i18n( "Speak Whole Document" ), this ); | 664 | d->aSpeakDoc = new QAction( QIcon::fromTheme( QStringLiteral("text-speak") ), i18n( "Speak Whole Document" ), this ); | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 682 | #endif | |||
721 | 714 | | |||
722 | // Setup undo and redo actions | 715 | // Setup undo and redo actions | ||
723 | QAction *kundo = KStandardAction::create( KStandardAction::Undo, d->document, SLOT(undo()), ac ); | 716 | QAction *kundo = KStandardAction::create( KStandardAction::Undo, d->document, SLOT(undo()), ac ); | ||
724 | QAction *kredo = KStandardAction::create( KStandardAction::Redo, d->document, SLOT(redo()), ac ); | 717 | QAction *kredo = KStandardAction::create( KStandardAction::Redo, d->document, SLOT(redo()), ac ); | ||
725 | connect(d->document, &Okular::Document::canUndoChanged, kundo, &QAction::setEnabled); | 718 | connect(d->document, &Okular::Document::canUndoChanged, kundo, &QAction::setEnabled); | ||
726 | connect(d->document, &Okular::Document::canRedoChanged, kredo, &QAction::setEnabled); | 719 | connect(d->document, &Okular::Document::canRedoChanged, kredo, &QAction::setEnabled); | ||
727 | kundo->setEnabled(false); | 720 | kundo->setEnabled(false); | ||
728 | kredo->setEnabled(false); | 721 | kredo->setEnabled(false); | ||
722 | | ||||
723 | if( !d->annotator ) { | ||||
724 | d->annotator = new PageViewAnnotator( this, d->document ); | ||||
725 | connect( d->annotator, &PageViewAnnotator::toolSelected, d->aMouseNormal , &QAction::trigger ); | ||||
726 | } | ||||
727 | d->annotator->setupActions( ac ); | ||||
729 | } | 728 | } | ||
730 | 729 | | |||
731 | bool PageView::canFitPageWidth() const | 730 | bool PageView::canFitPageWidth() const | ||
732 | { | 731 | { | ||
733 | return Okular::Settings::viewMode() != Okular::Settings::EnumViewMode::Single || d->zoomMode != ZoomFitWidth; | 732 | return Okular::Settings::viewMode() != Okular::Settings::EnumViewMode::Single || d->zoomMode != ZoomFitWidth; | ||
734 | } | 733 | } | ||
735 | 734 | | |||
736 | void PageView::fitPageWidth( int page ) | 735 | void PageView::fitPageWidth( int page ) | ||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 816 | { | |||
836 | { | 835 | { | ||
837 | d->rtl_Mode = Okular::Settings::rtlReadingDirection(); | 836 | d->rtl_Mode = Okular::Settings::rtlReadingDirection(); | ||
838 | slotRelayoutPages(); | 837 | slotRelayoutPages(); | ||
839 | } | 838 | } | ||
840 | 839 | | |||
841 | updatePageStep(); | 840 | updatePageStep(); | ||
842 | 841 | | |||
843 | if ( d->annotator ) | 842 | if ( d->annotator ) | ||
844 | { | | |||
845 | d->annotator->setEnabled( false ); | | |||
846 | d->annotator->reparseConfig(); | 843 | d->annotator->reparseConfig(); | ||
847 | if ( d->aToggleAnnotator->isChecked() ) | | |||
848 | slotToggleAnnotator( true ); | | |||
849 | } | | |||
850 | 844 | | |||
851 | // Something like invert colors may have changed | 845 | // Something like invert colors may have changed | ||
852 | // As we don't have a way to find out the old value | 846 | // As we don't have a way to find out the old value | ||
853 | // We just update the viewport, this shouldn't be that bad | 847 | // We just update the viewport, this shouldn't be that bad | ||
854 | // since it's just a repaint of pixmaps we already have | 848 | // since it's just a repaint of pixmaps we already have | ||
855 | viewport()->update(); | 849 | viewport()->update(); | ||
856 | } | 850 | } | ||
857 | 851 | | |||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 943 | { | |||
974 | } | 968 | } | ||
975 | } | 969 | } | ||
976 | } | 970 | } | ||
977 | 971 | | |||
978 | //BEGIN DocumentObserver inherited methods | 972 | //BEGIN DocumentObserver inherited methods | ||
979 | void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setupFlags ) | 973 | void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, int setupFlags ) | ||
980 | { | 974 | { | ||
981 | bool documentChanged = setupFlags & Okular::DocumentObserver::DocumentChanged; | 975 | bool documentChanged = setupFlags & Okular::DocumentObserver::DocumentChanged; | ||
982 | const bool allownotes = d->document->isAllowed( Okular::AllowNotes ); | | |||
983 | const bool allowfillforms = d->document->isAllowed( Okular::AllowFillForms ); | 976 | const bool allowfillforms = d->document->isAllowed( Okular::AllowFillForms ); | ||
984 | 977 | | |||
985 | // allownotes may have changed | | |||
986 | if ( d->aToggleAnnotator ) | | |||
987 | d->aToggleAnnotator->setEnabled( allownotes ); | | |||
988 | | ||||
989 | // reuse current pages if nothing new | 978 | // reuse current pages if nothing new | ||
990 | if ( ( pageSet.count() == d->items.count() ) && !documentChanged && !( setupFlags & Okular::DocumentObserver::NewLayoutForPages ) ) | 979 | if ( ( pageSet.count() == d->items.count() ) && !documentChanged && !( setupFlags & Okular::DocumentObserver::NewLayoutForPages ) ) | ||
991 | { | 980 | { | ||
992 | int count = pageSet.count(); | 981 | int count = pageSet.count(); | ||
993 | for ( int i = 0; (i < count) && !documentChanged; i++ ) | 982 | for ( int i = 0; (i < count) && !documentChanged; i++ ) | ||
994 | { | 983 | { | ||
995 | if ( (int)pageSet[i]->number() != d->items[i]->pageNumber() ) | 984 | if ( (int)pageSet[i]->number() != d->items[i]->pageNumber() ) | ||
996 | { | 985 | { | ||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Line(s) | 1140 | { | |||
1211 | } | 1200 | } | ||
1212 | bool allowAnnotations = d->document->isAllowed( Okular::AllowNotes ); | 1201 | bool allowAnnotations = d->document->isAllowed( Okular::AllowNotes ); | ||
1213 | if ( d->annotator ) | 1202 | if ( d->annotator ) | ||
1214 | { | 1203 | { | ||
1215 | bool allowTools = haspages && allowAnnotations; | 1204 | bool allowTools = haspages && allowAnnotations; | ||
1216 | d->annotator->setToolsEnabled( allowTools ); | 1205 | d->annotator->setToolsEnabled( allowTools ); | ||
1217 | d->annotator->setTextToolsEnabled( allowTools && d->document->supportsSearching() ); | 1206 | d->annotator->setTextToolsEnabled( allowTools && d->document->supportsSearching() ); | ||
1218 | } | 1207 | } | ||
1219 | if ( d->aToggleAnnotator ) | | |||
1220 | { | | |||
1221 | if ( !allowAnnotations && d->aToggleAnnotator->isChecked() ) | | |||
1222 | { | | |||
1223 | d->aToggleAnnotator->trigger(); | | |||
1224 | } | | |||
1225 | d->aToggleAnnotator->setEnabled( allowAnnotations ); | | |||
1226 | } | | |||
1227 | #ifdef HAVE_SPEECH | 1208 | #ifdef HAVE_SPEECH | ||
1228 | if ( d->aSpeakDoc ) | 1209 | if ( d->aSpeakDoc ) | ||
1229 | { | 1210 | { | ||
1230 | const bool enablettsactions = haspages ? Okular::Settings::useTTS() : false; | 1211 | const bool enablettsactions = haspages ? Okular::Settings::useTTS() : false; | ||
1231 | d->aSpeakDoc->setEnabled( enablettsactions ); | 1212 | d->aSpeakDoc->setEnabled( enablettsactions ); | ||
1232 | d->aSpeakPage->setEnabled( enablettsactions ); | 1213 | d->aSpeakPage->setEnabled( enablettsactions ); | ||
1233 | } | 1214 | } | ||
1234 | #endif | 1215 | #endif | ||
▲ Show 20 Lines • Show All 3824 Lines • ▼ Show 20 Line(s) | 5038 | { | |||
5059 | { | 5040 | { | ||
5060 | Okular::Settings::setViewContinuous( on ); | 5041 | Okular::Settings::setViewContinuous( on ); | ||
5061 | Okular::Settings::self()->save(); | 5042 | Okular::Settings::self()->save(); | ||
5062 | if ( d->document->pages() > 0 ) | 5043 | if ( d->document->pages() > 0 ) | ||
5063 | slotRelayoutPages(); | 5044 | slotRelayoutPages(); | ||
5064 | } | 5045 | } | ||
5065 | } | 5046 | } | ||
5066 | 5047 | | |||
5067 | void PageView::slotSetMouseNormal() | 5048 | void PageView::slotMouseNormalToggled( bool checked ) | ||
5068 | { | 5049 | { | ||
5050 | if( checked ) { | ||||
5069 | d->mouseMode = Okular::Settings::EnumMouseMode::Browse; | 5051 | d->mouseMode = Okular::Settings::EnumMouseMode::Browse; | ||
5070 | Okular::Settings::setMouseMode( d->mouseMode ); | 5052 | Okular::Settings::setMouseMode( d->mouseMode ); | ||
5071 | // hide the messageWindow | 5053 | // hide the messageWindow | ||
5072 | d->messageWindow->hide(); | 5054 | d->messageWindow->hide(); | ||
5073 | // reshow the annotator toolbar if hiding was forced (and if it is not already visible) | | |||
5074 | if ( d->annotator && d->annotator->hidingWasForced() && d->aToggleAnnotator && !d->aToggleAnnotator->isChecked() ) | | |||
5075 | d->aToggleAnnotator->trigger(); | | |||
5076 | // force an update of the cursor | 5055 | // force an update of the cursor | ||
5077 | updateCursor(); | 5056 | updateCursor(); | ||
5078 | Okular::Settings::self()->save(); | 5057 | Okular::Settings::self()->save(); | ||
5058 | } else { | ||||
5059 | d->annotator->detachAnnotation(); | ||||
5060 | } | ||||
5079 | } | 5061 | } | ||
5080 | 5062 | | |||
5081 | void PageView::slotSetMouseZoom() | 5063 | void PageView::slotSetMouseZoom() | ||
5082 | { | 5064 | { | ||
5083 | d->mouseMode = Okular::Settings::EnumMouseMode::Zoom; | 5065 | d->mouseMode = Okular::Settings::EnumMouseMode::Zoom; | ||
5084 | Okular::Settings::setMouseMode( d->mouseMode ); | 5066 | Okular::Settings::setMouseMode( d->mouseMode ); | ||
5085 | // change the text in messageWindow (and show it if hidden) | 5067 | // change the text in messageWindow (and show it if hidden) | ||
5086 | d->messageWindow->display( i18n( "Select zooming area. Right-click to zoom out." ), QString(), PageViewMessage::Info, -1 ); | 5068 | d->messageWindow->display( i18n( "Select zooming area. Right-click to zoom out." ), QString(), PageViewMessage::Info, -1 ); | ||
5087 | // force hiding of annotator toolbar | | |||
5088 | if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) | | |||
5089 | { | | |||
5090 | d->aToggleAnnotator->trigger(); | | |||
5091 | d->annotator->setHidingForced( true ); | | |||
5092 | } | | |||
5093 | // force an update of the cursor | 5069 | // force an update of the cursor | ||
5094 | updateCursor(); | 5070 | updateCursor(); | ||
5095 | Okular::Settings::self()->save(); | 5071 | Okular::Settings::self()->save(); | ||
5096 | } | 5072 | } | ||
5097 | 5073 | | |||
5098 | void PageView::slotSetMouseMagnifier() | 5074 | void PageView::slotSetMouseMagnifier() | ||
5099 | { | 5075 | { | ||
5100 | d->mouseMode = Okular::Settings::EnumMouseMode::Magnifier; | 5076 | d->mouseMode = Okular::Settings::EnumMouseMode::Magnifier; | ||
5101 | Okular::Settings::setMouseMode( d->mouseMode ); | 5077 | Okular::Settings::setMouseMode( d->mouseMode ); | ||
5102 | d->messageWindow->display( i18n( "Click to see the magnified view." ), QString() ); | 5078 | d->messageWindow->display( i18n( "Click to see the magnified view." ), QString() ); | ||
5103 | 5079 | | |||
5104 | // force an update of the cursor | 5080 | // force an update of the cursor | ||
5105 | updateCursor(); | 5081 | updateCursor(); | ||
5106 | Okular::Settings::self()->save(); | 5082 | Okular::Settings::self()->save(); | ||
5107 | } | 5083 | } | ||
5108 | 5084 | | |||
5109 | void PageView::slotSetMouseSelect() | 5085 | void PageView::slotSetMouseSelect() | ||
5110 | { | 5086 | { | ||
5111 | d->mouseMode = Okular::Settings::EnumMouseMode::RectSelect; | 5087 | d->mouseMode = Okular::Settings::EnumMouseMode::RectSelect; | ||
5112 | Okular::Settings::setMouseMode( d->mouseMode ); | 5088 | Okular::Settings::setMouseMode( d->mouseMode ); | ||
5113 | // change the text in messageWindow (and show it if hidden) | 5089 | // change the text in messageWindow (and show it if hidden) | ||
5114 | d->messageWindow->display( i18n( "Draw a rectangle around the text/graphics to copy." ), QString(), PageViewMessage::Info, -1 ); | 5090 | d->messageWindow->display( i18n( "Draw a rectangle around the text/graphics to copy." ), QString(), PageViewMessage::Info, -1 ); | ||
5115 | // force hiding of annotator toolbar | | |||
5116 | if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) | | |||
5117 | { | | |||
5118 | d->aToggleAnnotator->trigger(); | | |||
5119 | d->annotator->setHidingForced( true ); | | |||
5120 | } | | |||
5121 | // force an update of the cursor | 5091 | // force an update of the cursor | ||
5122 | updateCursor(); | 5092 | updateCursor(); | ||
5123 | Okular::Settings::self()->save(); | 5093 | Okular::Settings::self()->save(); | ||
5124 | } | 5094 | } | ||
5125 | 5095 | | |||
5126 | void PageView::slotSetMouseTextSelect() | 5096 | void PageView::slotSetMouseTextSelect() | ||
5127 | { | 5097 | { | ||
5128 | d->mouseMode = Okular::Settings::EnumMouseMode::TextSelect; | 5098 | d->mouseMode = Okular::Settings::EnumMouseMode::TextSelect; | ||
5129 | Okular::Settings::setMouseMode( d->mouseMode ); | 5099 | Okular::Settings::setMouseMode( d->mouseMode ); | ||
5130 | // change the text in messageWindow (and show it if hidden) | 5100 | // change the text in messageWindow (and show it if hidden) | ||
5131 | d->messageWindow->display( i18n( "Select text" ), QString(), PageViewMessage::Info, -1 ); | 5101 | d->messageWindow->display( i18n( "Select text" ), QString(), PageViewMessage::Info, -1 ); | ||
5132 | // force hiding of annotator toolbar | | |||
5133 | if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) | | |||
5134 | { | | |||
5135 | d->aToggleAnnotator->trigger(); | | |||
5136 | d->annotator->setHidingForced( true ); | | |||
5137 | } | | |||
5138 | // force an update of the cursor | 5102 | // force an update of the cursor | ||
5139 | updateCursor(); | 5103 | updateCursor(); | ||
5140 | Okular::Settings::self()->save(); | 5104 | Okular::Settings::self()->save(); | ||
5141 | } | 5105 | } | ||
5142 | 5106 | | |||
5143 | void PageView::slotSetMouseTableSelect() | 5107 | void PageView::slotSetMouseTableSelect() | ||
5144 | { | 5108 | { | ||
5145 | d->mouseMode = Okular::Settings::EnumMouseMode::TableSelect; | 5109 | d->mouseMode = Okular::Settings::EnumMouseMode::TableSelect; | ||
5146 | Okular::Settings::setMouseMode( d->mouseMode ); | 5110 | Okular::Settings::setMouseMode( d->mouseMode ); | ||
5147 | // change the text in messageWindow (and show it if hidden) | 5111 | // change the text in messageWindow (and show it if hidden) | ||
5148 | d->messageWindow->display( i18n( | 5112 | d->messageWindow->display( i18n( | ||
5149 | "Draw a rectangle around the table, then click near edges to divide up; press Esc to clear." | 5113 | "Draw a rectangle around the table, then click near edges to divide up; press Esc to clear." | ||
5150 | ), QString(), PageViewMessage::Info, -1 ); | 5114 | ), QString(), PageViewMessage::Info, -1 ); | ||
5151 | // force hiding of annotator toolbar | | |||
5152 | if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) | | |||
5153 | { | | |||
5154 | d->aToggleAnnotator->trigger(); | | |||
5155 | d->annotator->setHidingForced( true ); | | |||
5156 | } | | |||
5157 | // force an update of the cursor | 5115 | // force an update of the cursor | ||
5158 | updateCursor(); | 5116 | updateCursor(); | ||
5159 | Okular::Settings::self()->save(); | 5117 | Okular::Settings::self()->save(); | ||
5160 | } | 5118 | } | ||
5161 | 5119 | | |||
5162 | void PageView::slotToggleAnnotator( bool on ) | | |||
5163 | { | | |||
5164 | // the 'inHere' trick is needed as the slotSetMouseZoom() calls this | | |||
5165 | static bool inHere = false; | | |||
5166 | if ( inHere ) | | |||
5167 | return; | | |||
5168 | inHere = true; | | |||
5169 | | ||||
5170 | // the annotator can be used in normal mouse mode only, so if asked for it, | | |||
5171 | // switch to normal mode | | |||
5172 | if ( on && d->mouseMode != Okular::Settings::EnumMouseMode::Browse ) | | |||
5173 | d->aMouseNormal->trigger(); | | |||
5174 | | ||||
5175 | // ask for Author's name if not already set | | |||
5176 | if ( Okular::Settings::identityAuthor().isEmpty() ) | | |||
5177 | { | | |||
5178 | // get default username from the kdelibs/kdecore/KUser | | |||
5179 | KUser currentUser; | | |||
5180 | QString userName = currentUser.property( KUser::FullName ).toString(); | | |||
5181 | // ask the user for confirmation/change | | |||
5182 | if ( userName.isEmpty() ) | | |||
5183 | { | | |||
5184 | bool ok = false; | | |||
5185 | userName = QInputDialog::getText(nullptr, | | |||
5186 | i18n( "Annotations author" ), | | |||
5187 | i18n( "Please insert your name or initials:" ), | | |||
5188 | QLineEdit::Normal, | | |||
5189 | QString(), | | |||
5190 | &ok ); | | |||
5191 | | ||||
5192 | if ( !ok ) | | |||
5193 | { | | |||
5194 | d->aToggleAnnotator->trigger(); | | |||
5195 | inHere = false; | | |||
5196 | return; | | |||
5197 | } | | |||
5198 | } | | |||
5199 | // save the name | | |||
5200 | Okular::Settings::setIdentityAuthor( userName ); | | |||
5201 | Okular::Settings::self()->save(); | | |||
5202 | } | | |||
5203 | | ||||
5204 | // create the annotator object if not present | | |||
5205 | if ( !d->annotator ) | | |||
5206 | { | | |||
5207 | d->annotator = new PageViewAnnotator( this, d->document ); | | |||
5208 | bool allowTools = d->document->pages() > 0 && d->document->isAllowed( Okular::AllowNotes ); | | |||
5209 | d->annotator->setToolsEnabled( allowTools ); | | |||
5210 | d->annotator->setTextToolsEnabled( allowTools && d->document->supportsSearching() ); | | |||
5211 | } | | |||
5212 | | ||||
5213 | // initialize/reset annotator (and show/hide toolbar) | | |||
5214 | d->annotator->setEnabled( on ); | | |||
5215 | d->annotator->setHidingForced( false ); | | |||
5216 | | ||||
5217 | inHere = false; | | |||
5218 | } | | |||
5219 | | ||||
5220 | void PageView::slotAutoScrollUp() | 5120 | void PageView::slotAutoScrollUp() | ||
5221 | { | 5121 | { | ||
5222 | if ( d->scrollIncrement < -9 ) | 5122 | if ( d->scrollIncrement < -9 ) | ||
5223 | return; | 5123 | return; | ||
5224 | d->scrollIncrement--; | 5124 | d->scrollIncrement--; | ||
5225 | slotAutoScroll(); | 5125 | slotAutoScroll(); | ||
5226 | setFocus(); | 5126 | setFocus(); | ||
5227 | } | 5127 | } | ||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | |||||
5351 | void PageView::slotTrimToSelectionToggled( bool on ) | 5251 | void PageView::slotTrimToSelectionToggled( bool on ) | ||
5352 | { | 5252 | { | ||
5353 | if ( on ) { // Turn off any other Trim modes | 5253 | if ( on ) { // Turn off any other Trim modes | ||
5354 | updateTrimMode(d->aTrimToSelection->data().toInt()); | 5254 | updateTrimMode(d->aTrimToSelection->data().toInt()); | ||
5355 | 5255 | | |||
5356 | d->mouseMode = Okular::Settings::EnumMouseMode::TrimSelect; | 5256 | d->mouseMode = Okular::Settings::EnumMouseMode::TrimSelect; | ||
5357 | // change the text in messageWindow (and show it if hidden) | 5257 | // change the text in messageWindow (and show it if hidden) | ||
5358 | d->messageWindow->display( i18n( "Draw a rectangle around the page area you wish to keep visible" ), QString(), PageViewMessage::Info, -1 ); | 5258 | d->messageWindow->display( i18n( "Draw a rectangle around the page area you wish to keep visible" ), QString(), PageViewMessage::Info, -1 ); | ||
5359 | // force hiding of annotator toolbar | | |||
5360 | if ( d->aToggleAnnotator && d->aToggleAnnotator->isChecked() ) | | |||
5361 | { | | |||
5362 | d->aToggleAnnotator->trigger(); | | |||
5363 | d->annotator->setHidingForced( true ); | | |||
5364 | } | | |||
5365 | // force an update of the cursor | 5259 | // force an update of the cursor | ||
5366 | updateCursor(); | 5260 | updateCursor(); | ||
5367 | } else { | 5261 | } else { | ||
5368 | 5262 | | |||
5369 | // toggled off while making selection | 5263 | // toggled off while making selection | ||
5370 | if ( Okular::Settings::EnumMouseMode::TrimSelect == d->mouseMode ) { | 5264 | if ( Okular::Settings::EnumMouseMode::TrimSelect == d->mouseMode ) { | ||
5371 | // clear widget selection and invalidate rect | 5265 | // clear widget selection and invalidate rect | ||
5372 | selectionClear(); | 5266 | selectionClear(); | ||
▲ Show 20 Lines • Show All 257 Lines • Show Last 20 Lines |
Anyone knows how KToggleToolBarAction is supposed to work?
Currently it does nothing.
Reading the code, it seems that the constructor where the toolbar is specified by name does nothing, unless there is some other magic going on.
https://api.kde.org/frameworks/kxmlgui/html/ktoggletoolbaraction_8cpp_source.html#l00061