Changeset View
Changeset View
Standalone View
Standalone View
ui/pageview.cpp
Show First 20 Lines • Show All 651 Lines • ▼ Show 20 Line(s) | 616 | { | |||
---|---|---|---|---|---|
652 | ac->addAction(QStringLiteral("mouse_magnifier"), d->aMouseMagnifier ); | 652 | ac->addAction(QStringLiteral("mouse_magnifier"), d->aMouseMagnifier ); | ||
653 | connect( d->aMouseMagnifier, &QAction::triggered, this, &PageView::slotSetMouseMagnifier ); | 653 | connect( d->aMouseMagnifier, &QAction::triggered, this, &PageView::slotSetMouseMagnifier ); | ||
654 | d->aMouseMagnifier->setIconText( i18nc( "Magnifier Tool", "Magnifier" ) ); | 654 | d->aMouseMagnifier->setIconText( i18nc( "Magnifier Tool", "Magnifier" ) ); | ||
655 | d->aMouseMagnifier->setCheckable( true ); | 655 | d->aMouseMagnifier->setCheckable( true ); | ||
656 | ac->setDefaultShortcut(d->aMouseMagnifier, Qt::CTRL + Qt::Key_6); | 656 | ac->setDefaultShortcut(d->aMouseMagnifier, Qt::CTRL + Qt::Key_6); | ||
657 | d->aMouseMagnifier->setActionGroup( d->mouseModeActionGroup ); | 657 | d->aMouseMagnifier->setActionGroup( d->mouseModeActionGroup ); | ||
658 | d->aMouseMagnifier->setChecked( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::Magnifier ); | 658 | d->aMouseMagnifier->setChecked( Okular::Settings::mouseMode() == Okular::Settings::EnumMouseMode::Magnifier ); | ||
659 | 659 | | |||
660 | d->aToggleAnnotator = new KToggleAction(QIcon::fromTheme( QStringLiteral("draw-freehand") ), i18n("&Review"), this); | 660 | d->aToggleAnnotator = new KToggleAction(QIcon::fromTheme( QStringLiteral("draw-freehand") ), i18n("&Review"), 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… | |||||
661 | ac->addAction(QStringLiteral("mouse_toggle_annotate"), d->aToggleAnnotator ); | 661 | ac->addAction(QStringLiteral("mouse_toggle_annotate"), d->aToggleAnnotator ); | ||
662 | d->aToggleAnnotator->setCheckable( true ); | 662 | d->aToggleAnnotator->setCheckable( true ); | ||
663 | connect( d->aToggleAnnotator, &QAction::toggled, this, &PageView::slotToggleAnnotator ); | 663 | connect( d->aToggleAnnotator, &QAction::toggled, this, &PageView::slotToggleAnnotator ); | ||
664 | ac->setDefaultShortcut(d->aToggleAnnotator, Qt::Key_F6); | 664 | ac->setDefaultShortcut(d->aToggleAnnotator, Qt::Key_F6); | ||
665 | 665 | | |||
666 | ToolAction *ta = new ToolAction( this ); | 666 | ToolAction *ta = new ToolAction( this ); | ||
667 | ac->addAction( QStringLiteral("mouse_selecttools"), ta ); | 667 | ac->addAction( QStringLiteral("mouse_selecttools"), ta ); | ||
668 | ta->addAction( d->aMouseSelect ); | 668 | ta->addAction( d->aMouseSelect ); | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 692 | #endif | |||
724 | 724 | | |||
725 | // Setup undo and redo actions | 725 | // Setup undo and redo actions | ||
726 | QAction *kundo = KStandardAction::create( KStandardAction::Undo, d->document, SLOT(undo()), ac ); | 726 | QAction *kundo = KStandardAction::create( KStandardAction::Undo, d->document, SLOT(undo()), ac ); | ||
727 | QAction *kredo = KStandardAction::create( KStandardAction::Redo, d->document, SLOT(redo()), ac ); | 727 | QAction *kredo = KStandardAction::create( KStandardAction::Redo, d->document, SLOT(redo()), ac ); | ||
728 | connect(d->document, &Okular::Document::canUndoChanged, kundo, &QAction::setEnabled); | 728 | connect(d->document, &Okular::Document::canUndoChanged, kundo, &QAction::setEnabled); | ||
729 | connect(d->document, &Okular::Document::canRedoChanged, kredo, &QAction::setEnabled); | 729 | connect(d->document, &Okular::Document::canRedoChanged, kredo, &QAction::setEnabled); | ||
730 | kundo->setEnabled(false); | 730 | kundo->setEnabled(false); | ||
731 | kredo->setEnabled(false); | 731 | kredo->setEnabled(false); | ||
732 | | ||||
733 | slotToggleAnnotator( true); | ||||
734 | d->annotator->setupActions( ac ); | ||||
732 | } | 735 | } | ||
733 | 736 | | |||
734 | bool PageView::canFitPageWidth() const | 737 | bool PageView::canFitPageWidth() const | ||
735 | { | 738 | { | ||
736 | return Okular::Settings::viewMode() != Okular::Settings::EnumViewMode::Single || d->zoomMode != ZoomFitWidth; | 739 | return Okular::Settings::viewMode() != Okular::Settings::EnumViewMode::Single || d->zoomMode != ZoomFitWidth; | ||
737 | } | 740 | } | ||
738 | 741 | | |||
739 | void PageView::fitPageWidth( int page ) | 742 | void PageView::fitPageWidth( int page ) | ||
▲ Show 20 Lines • Show All 4804 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