MCPcopy Create free account
hub / github.com/KDE/okular / AnnotationActionHandler

Method AnnotationActionHandler

part/annotationactionhandler.cpp:545–767  ·  view source on GitHub ↗

TODO: icon names should match getAnnotationInfo in gui/guiutils.cpp

Source from the content-addressed store, hash-verified

543
544// TODO: icon names should match getAnnotationInfo in gui/guiutils.cpp
545AnnotationActionHandler::AnnotationActionHandler(PageViewAnnotator *parent, KActionCollection *ac)
546 : QObject(parent)
547 , d(new AnnotationActionHandlerPrivate(this))
548{
549 d->annotator = parent;
550
551 // toolbar visibility actions
552 d->aToolBarVisibility = new KToggleAction(QIcon::fromTheme(QStringLiteral("draw-freehand")), i18n("&Annotations"), this);
553 d->aHideToolBar = new QAction(QIcon::fromTheme(QStringLiteral("dialog-close")), i18nc("@action:intoolbar Hide the toolbar", "Hide"), this);
554 d->aShowToolBar = new QAction(QIcon::fromTheme(QStringLiteral("draw-freehand")), i18nc("@action:intoolbar Show the builtin annotation toolbar", "Show more annotation tools"), this);
555
556 // Text markup actions
557 KToggleAction *aHighlighter = new KToggleAction(QIcon::fromTheme(QStringLiteral("draw-highlight")), i18nc("@action:intoolbar Annotation tool", "Highlighter"), this);
558 KToggleAction *aUnderline = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-underline")), i18nc("@action:intoolbar Annotation tool", "Underline"), this);
559 KToggleAction *aSquiggle = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-underline-squiggle")), i18nc("@action:intoolbar Annotation tool", "Squiggle"), this);
560 KToggleAction *aStrikeout = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-strikethrough")), i18nc("@action:intoolbar Annotation tool", "Strike Out"), this);
561 // Notes actions
562 KToggleAction *aTypewriter = new KToggleAction(QIcon::fromTheme(QStringLiteral("tool-text")), i18nc("@action:intoolbar Annotation tool", "Typewriter"), this);
563 KToggleAction *aInlineNote = new KToggleAction(QIcon::fromTheme(QStringLiteral("note")), i18nc("@action:intoolbar Annotation tool", "Inline Note"), this);
564 KToggleAction *aPopupNote = new KToggleAction(QIcon::fromTheme(QStringLiteral("edit-comment")), i18nc("@action:intoolbar Annotation tool", "Popup Note"), this);
565 KToggleAction *aFreehandLine = new KToggleAction(QIcon::fromTheme(QStringLiteral("draw-freehand")), i18nc("@action:intoolbar Annotation tool", "Freehand Line"), this);
566 // Geometrical shapes actions
567 KToggleAction *aStraightLine = new KToggleAction(QIcon::fromTheme(QStringLiteral("draw-line")), i18nc("@action:intoolbar Annotation tool", "Straight line"), this);
568 KToggleAction *aArrow = new KToggleAction(QIcon::fromTheme(QStringLiteral("draw-arrow")), i18nc("@action:intoolbar Annotation tool", "Arrow"), this);
569 KToggleAction *aRectangle = new KToggleAction(QIcon::fromTheme(QStringLiteral("draw-rectangle")), i18nc("@action:intoolbar Annotation tool", "Rectangle"), this);
570 KToggleAction *aEllipse = new KToggleAction(QIcon::fromTheme(QStringLiteral("draw-ellipse")), i18nc("@action:intoolbar Annotation tool", "Ellipse"), this);
571 KToggleAction *aPolygon = new KToggleAction(QIcon::fromTheme(QStringLiteral("draw-polyline")), i18nc("@action:intoolbar Annotation tool", "Polygon"), this);
572 d->aGeomShapes = new ToggleActionMenu(i18nc("@action", "Geometrical shapes"), this);
573 d->aGeomShapes->setEnabled(true); // Need to explicitly set this once, or refreshActions() in part.cpp will disable this action
574 d->aGeomShapes->setPopupMode(QToolButton::MenuButtonPopup);
575 d->aGeomShapes->addAction(aArrow);
576 d->aGeomShapes->addAction(aStraightLine);
577 d->aGeomShapes->addAction(aRectangle);
578 d->aGeomShapes->addAction(aEllipse);
579 d->aGeomShapes->addAction(aPolygon);
580 d->aGeomShapes->setDefaultAction(aArrow);
581 connect(d->aGeomShapes->menu(), &QMenu::triggered, d->aGeomShapes, &ToggleActionMenu::setDefaultAction);
582
583 // The order in which the actions are added is relevant to connect
584 // them to the correct toolId defined in tools.xml
585 d->agTools = new QActionGroup(this);
586 d->agTools->addAction(aHighlighter);
587 d->agTools->addAction(aUnderline);
588 d->agTools->addAction(aSquiggle);
589 d->agTools->addAction(aStrikeout);
590 d->agTools->addAction(aTypewriter);
591 d->agTools->addAction(aInlineNote);
592 d->agTools->addAction(aPopupNote);
593 d->agTools->addAction(aFreehandLine);
594 d->agTools->addAction(aArrow);
595 d->agTools->addAction(aStraightLine);
596 d->agTools->addAction(aRectangle);
597 d->agTools->addAction(aEllipse);
598 d->agTools->addAction(aPolygon);
599
600 d->textTools.append(aHighlighter);
601 d->textTools.append(aUnderline);
602 d->textTools.append(aSquiggle);

Callers

nothing calls this directly

Calls 15

createOpacityIconFunction · 0.85
setDefaultActionMethod · 0.80
appendMethod · 0.80
actionsMethod · 0.80
stampIconMethod · 0.80
slotStampToolSelectedMethod · 0.80
isEmptyMethod · 0.80
actionMethod · 0.80
continuousModeMethod · 0.80
colorPickerActionMethod · 0.80

Tested by

no test coverage detected