Krita Source Code Documentation
Loading...
Searching...
No Matches
KoZoomTool Class Reference

#include <KoZoomTool.h>

+ Inheritance diagram for KoZoomTool:

Public Member Functions

void activate (const QSet< KoShape * > &shapes) override
 
void keyPressEvent (QKeyEvent *event) override
 
void keyReleaseEvent (QKeyEvent *event) override
 
 KoZoomTool (KoCanvasBase *canvas)
 
void mouseDoubleClickEvent (KoPointerEvent *event) override
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
void setCanvasController (KoCanvasController *controller)
 
void setZoomInMode (bool zoomIn)
 
- Public Member Functions inherited from KoInteractionTool
 KoInteractionTool (KoCanvasBase *canvas)
 
void mousePressEvent (KoPointerEvent *event) override
 
void paint (QPainter &painter, const KoViewConverter &converter) override
 
 ~KoInteractionTool () override
 
- Public Member Functions inherited from KoToolBase
QAction * action (const QString &name) const
 
KoCanvasBasecanvas () const
 Returns the canvas the tool is working on.
 
virtual void copy () const
 
QCursor cursor () const
 return the last emitted cursor
 
virtual void customMoveEvent (KoPointerEvent *event)
 
virtual void customPressEvent (KoPointerEvent *event)
 
virtual void customReleaseEvent (KoPointerEvent *event)
 
virtual void cut ()
 
virtual QRectF decorationsRect () const
 
int decorationThickness () const
 decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen magnification, thus the HiDPI settings. Note: to use this effectively, also set the pen to isCosmetic(true);
 
virtual void deleteSelection ()
 
virtual void deselect ()
 deselect the tool should clear the selection if it has one.
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event, const QPointF &point)
 
virtual void dropEvent (QDropEvent *event, const QPointF &point)
 
virtual void explicitUserStrokeEndRequest ()
 explicitUserStrokeEndRequest is called by the input manager when the user presses Enter key or any equivalent. This callback comes before requestStrokeEnd(), which comes from a different source.
 
KoToolFactoryBasefactory () const
 
virtual void focusInEvent (QFocusEvent *event)
 
virtual void focusOutEvent (QFocusEvent *event)
 
virtual bool hasSelection ()
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
bool isInTextMode () const
 
bool isOpacityPresetMode () const
 
 KoToolBase (KoCanvasBase *canvas)
 
bool maskSyntheticEvents () const
 
virtual void mouseTripleClickEvent (KoPointerEvent *event)
 
QList< QPointer< QWidget > > optionWidgets ()
 
virtual bool paste ()
 
virtual QMenu * popupActionsMenu ()
 
virtual KisPopupWidgetInterfacepopupWidget ()
 
virtual bool selectAll ()
 selectAll select all data the tool can select.
 
virtual KoToolSelectionselection ()
 
Q_INVOKABLE QString toolId () const
 
virtual bool wantsAutoScroll () const
 
 ~KoToolBase () override
 

Protected Member Functions

QWidget * createOptionWidget () override
 
- Protected Member Functions inherited from KoInteractionTool
void addInteractionFactory (KoInteractionStrategyFactory *factory)
 
void cancelCurrentStrategy ()
 Cancels the current strategy and deletes it.
 
KoInteractionStrategycreateStrategyBase (KoPointerEvent *event)
 
KoInteractionStrategycurrentStrategy ()
 
bool hasInteractionFactory (const QString &id)
 
 KoInteractionTool (KoInteractionToolPrivate &dd)
 
void removeInteractionFactory (const QString &id)
 
bool tryUseCustomCursor ()
 
- Protected Member Functions inherited from KoToolBase
virtual QList< QPointer< QWidget > > createOptionWidgets ()
 
int grabSensitivity () const
 Convenience function to get the current grab sensitivity.
 
qreal handleDocRadius () const
 
QRectF handleGrabRect (const QPointF &position) const
 
QRectF handlePaintRect (const QPointF &position) const
 
int handleRadius () const
 Convenience function to get the current handle radius.
 
bool isActivated () const
 
 KoToolBase (KoToolBasePrivate &dd)
 
KoPointerEventlastDeliveredPointerEvent () const
 
void setAbstractResource (KoAbstractCanvasResourceInterfaceSP abstractResource)
 
void setConverter (KoDerivedResourceConverterSP converter)
 
void setIsOpacityPresetMode (bool value)
 
void setMaskSyntheticEvents (bool value)
 
void setTextMode (bool value)
 
QHash< int, KoAbstractCanvasResourceInterfaceSPtoolAbstractResources ()
 
QHash< int, KoDerivedResourceConverterSPtoolConverters ()
 
void useCursor (const QCursor &cursor)
 

Private Member Functions

KoInteractionStrategycreateStrategy (KoPointerEvent *event) override
 
void updateCursor (bool swap)
 

Private Attributes

KoCanvasControllerm_controller
 
QCursor m_inCursor
 
QCursor m_outCursor
 
bool m_zoomInMode
 

Additional Inherited Members

- Public Slots inherited from KoToolBase
virtual void canvasResourceChanged (int key, const QVariant &res)
 
virtual void deactivate ()
 
virtual void documentResourceChanged (int key, const QVariant &res)
 
virtual void repaintDecorations ()
 
virtual void requestRedoDuringStroke ()
 
virtual void requestStrokeCancellation ()
 
virtual void requestStrokeEnd ()
 
virtual void requestUndoDuringStroke ()
 
void setStatusText (const QString &statusText)
 
void updateOptionsWidgetIcons ()
 
- Signals inherited from KoToolBase
void activateTool (const QString &id)
 
void cursorChanged (const QCursor &cursor)
 
void selectionChanged (bool hasSelection)
 
void statusTextChanged (const QString &statusText)
 
void textModeChanged (bool inTextMode)
 
- Protected Attributes inherited from KoToolBase
KoToolBasePrivated_ptr
 

Detailed Description

Definition at line 20 of file KoZoomTool.h.

Constructor & Destructor Documentation

◆ KoZoomTool()

KoZoomTool::KoZoomTool ( KoCanvasBase * canvas)
explicit

Create a new tool; typically not called by applications, only by the KoToolManager

Parameters
canvasthe canvas this tool works for.

Definition at line 21 of file KoZoomTool.cpp.

23 , m_controller(nullptr)
24 , m_zoomInMode(true)
25{
26 QPixmap inPixmap, outPixmap;
27 inPixmap.load(":/zoom_in_cursor.png");
28 outPixmap.load(":/zoom_out_cursor.png");
29 m_inCursor = QCursor(inPixmap, 4, 4);
30 m_outCursor = QCursor(outPixmap, 4, 4);
31}
KoInteractionTool(KoCanvasBase *canvas)
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
KoCanvasController * m_controller
Definition KoZoomTool.h:49
QCursor m_outCursor
Definition KoZoomTool.h:51
QCursor m_inCursor
Definition KoZoomTool.h:50
bool m_zoomInMode
Definition KoZoomTool.h:52

References m_inCursor, and m_outCursor.

Member Function Documentation

◆ activate()

void KoZoomTool::activate ( const QSet< KoShape * > & shapes)
overridevirtual

This method is called when this tool instance is activated. For any main window there is only one tool active at a time, which then gets all user input. Switching between tools will call deactivate on one and activate on the new tool allowing the tool to flush items (like a selection) when it is not in use.

Parameters
shapesthe set of shapes that are selected or suggested for editing by a selected shape for the tool to work on. Not all shapes will be meant for this tool.
See also
deactivate()

Reimplemented from KoToolBase.

Definition at line 61 of file KoZoomTool.cpp.

62{
63 updateCursor(false);
64}
void updateCursor(bool swap)

References updateCursor().

◆ createOptionWidget()

QWidget * KoZoomTool::createOptionWidget ( )
overrideprotectedvirtual

Reimplement this if your tool actually has an option widget. Sets the option widget to 0 by default.

Reimplemented from KoToolBase.

Definition at line 88 of file KoZoomTool.cpp.

89{
90 return new KoZoomToolWidget(this);
91}

◆ createStrategy()

KoInteractionStrategy * KoZoomTool::createStrategy ( KoPointerEvent * event)
overrideprivatevirtual

Implements KoInteractionTool.

Definition at line 71 of file KoZoomTool.cpp.

72{
73 KoZoomStrategy *zs = new KoZoomStrategy(this, m_controller, event->point);
74 bool shouldZoomIn = m_zoomInMode;
75 if (event->button() == Qt::RightButton ||
76 event->modifiers() == Qt::ControlModifier) {
77 shouldZoomIn = !shouldZoomIn;
78 }
79
80 if (shouldZoomIn) {
81 zs->forceZoomIn();
82 } else {
83 zs->forceZoomOut();
84 }
85 return zs;
86}
Qt::MouseButton button() const
return button pressed (see QMouseEvent::button());
Qt::KeyboardModifiers modifiers() const
QPointF point
The point in document coordinates.

References KoPointerEvent::button(), KoZoomStrategy::forceZoomIn(), KoZoomStrategy::forceZoomOut(), m_controller, m_zoomInMode, KoPointerEvent::modifiers(), and KoPointerEvent::point.

◆ keyPressEvent()

void KoZoomTool::keyPressEvent ( QKeyEvent * event)
overridevirtual

Called when a key is pressed. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this key press

Reimplemented from KoInteractionTool.

Definition at line 45 of file KoZoomTool.cpp.

46{
47 event->ignore();
48 updateCursor(event->modifiers() & Qt::ControlModifier);
49
51}
void keyPressEvent(QKeyEvent *event) override

References KoInteractionTool::keyPressEvent(), and updateCursor().

◆ keyReleaseEvent()

void KoZoomTool::keyReleaseEvent ( QKeyEvent * event)
overridevirtual

Called when a key is released Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this key release

Reimplemented from KoInteractionTool.

Definition at line 53 of file KoZoomTool.cpp.

54{
55 event->ignore();
56 updateCursor(event->modifiers() & Qt::ControlModifier);
57
59}
void keyReleaseEvent(QKeyEvent *event) override

References KoInteractionTool::keyReleaseEvent(), and updateCursor().

◆ mouseDoubleClickEvent()

void KoZoomTool::mouseDoubleClickEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is double clicked. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this mouse or stylus press

Reimplemented from KoToolBase.

Definition at line 66 of file KoZoomTool.cpp.

67{
68 mousePressEvent(event);
69}
void mousePressEvent(KoPointerEvent *event) override

References KoInteractionTool::mousePressEvent().

◆ mouseMoveEvent()

void KoZoomTool::mouseMoveEvent ( KoPointerEvent * event)
overridevirtual

Called when the mouse or stylus moved over the canvas. Implementors should call event->ignore() if they do not actually use the event.

Parameters
eventstate and reason of this mouse or stylus move

Reimplemented from KoInteractionTool.

Definition at line 38 of file KoZoomTool.cpp.

39{
40 updateCursor(event->modifiers() & Qt::ControlModifier);
41
43}
void mouseMoveEvent(KoPointerEvent *event) override

References KoPointerEvent::modifiers(), KoInteractionTool::mouseMoveEvent(), and updateCursor().

◆ mouseReleaseEvent()

void KoZoomTool::mouseReleaseEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is released. Implementors should call event->ignore() if they do not actually use the event.

Parameters
eventstate and reason of this mouse or stylus release

Reimplemented from KoInteractionTool.

Definition at line 33 of file KoZoomTool.cpp.

34{
36}
void mouseReleaseEvent(KoPointerEvent *event) override

References KoInteractionTool::mouseReleaseEvent().

◆ setCanvasController()

void KoZoomTool::setCanvasController ( KoCanvasController * controller)
inline

Definition at line 35 of file KoZoomTool.h.

35 {
36 m_controller = controller;
37 }

References m_controller.

◆ setZoomInMode()

void KoZoomTool::setZoomInMode ( bool zoomIn)

Definition at line 93 of file KoZoomTool.cpp.

94{
96 updateCursor(false);
97}
QAction * zoomIn(const QObject *recvr, const char *slot, QObject *parent)

References m_zoomInMode, and updateCursor().

◆ updateCursor()

void KoZoomTool::updateCursor ( bool swap)
private

Definition at line 99 of file KoZoomTool.cpp.

100{
101 bool setZoomInCursor = m_zoomInMode;
102 if (swap) {
103 setZoomInCursor = !setZoomInCursor;
104 }
105
106 if (setZoomInCursor) {
108 } else {
110 }
111}
void useCursor(const QCursor &cursor)

References m_inCursor, m_outCursor, m_zoomInMode, and KoToolBase::useCursor().

Member Data Documentation

◆ m_controller

KoCanvasController* KoZoomTool::m_controller
private

Definition at line 49 of file KoZoomTool.h.

◆ m_inCursor

QCursor KoZoomTool::m_inCursor
private

Definition at line 50 of file KoZoomTool.h.

◆ m_outCursor

QCursor KoZoomTool::m_outCursor
private

Definition at line 51 of file KoZoomTool.h.

◆ m_zoomInMode

bool KoZoomTool::m_zoomInMode
private

Definition at line 52 of file KoZoomTool.h.


The documentation for this class was generated from the following files: