Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_tool_pan.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Victor Wåhlström <victor.wahlstrom@initiali.se>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#include <QKeyEvent>
8
9#include "kis_tool_pan.h"
10
11#include "kis_action_registry.h"
12#include "kis_cursor.h"
13#include "kis_canvas2.h"
14
15#include <KoCanvasController.h>
16
17#include <KoIcon.h>
18#include <klocalizedstring.h>
19
20
22 : KisTool(canvas, KisCursor::openHandCursor())
23{
24}
25
29
30void KisToolPan::activate(const QSet<KoShape*> &shapes)
31{
32 Q_UNUSED(shapes);
33
34 m_actionConnections.addConnection(action("movetool-move-up"),
35 &QAction::triggered, this, [this] () {
37 });
38
39 m_actionConnections.addConnection(action("movetool-move-down"),
40 &QAction::triggered, this, [this] () {
42 });
43
44 m_actionConnections.addConnection(action("movetool-move-left"),
45 &QAction::triggered, this, [this] () {
47 });
48
49 m_actionConnections.addConnection(action("movetool-move-right"),
50 &QAction::triggered, this, [this] () {
52 });
53}
54
60
66
68{
69 QPoint pos = event->pos();
70 QPoint delta = m_lastPosition - pos;
71 canvas()->canvasController()->pan(delta);
72 m_lastPosition = pos;
73}
74
80
81void KisToolPan::paint(QPainter &painter, const KoViewConverter &converter)
82{
83 Q_UNUSED(painter);
84 Q_UNUSED(converter);
85}
86
88{
89 return false;
90}
91
101
105
107{
110
111 actions << actionRegistry->makeQAction("movetool-move-up", this);
112 actions << actionRegistry->makeQAction("movetool-move-down", this);
113 actions << actionRegistry->makeQAction("movetool-move-left", this);
114 actions << actionRegistry->makeQAction("movetool-move-right", this);
115
116 return actions;
117}
118
QAction * makeQAction(const QString &name, QObject *parent=0)
static KisActionRegistry * instance()
static QCursor openHandCursor()
static QCursor closedHandCursor()
void addConnection(Sender sender, Signal signal, Receiver receiver, Method method, Qt::ConnectionType type=Qt::AutoConnection)
KoToolBase * createTool(KoCanvasBase *canvas) override
QList< QAction * > createActionsImpl() override
createActionsImpl should be reimplemented if the tool needs any actions. The actions should have a va...
~KisToolPanFactory() override
void continuePrimaryAction(KoPointerEvent *event) override
QPoint m_lastPosition
bool wantsAutoScroll() const override
~KisToolPan() override
void deactivate() override
KisSignalAutoConnectionsStore m_actionConnections
void activate(const QSet< KoShape * > &shapes) override
KisToolPan(KoCanvasBase *canvas)
void paint(QPainter &painter, const KoViewConverter &converter) override
void beginPrimaryAction(KoPointerEvent *event) override
void endPrimaryAction(KoPointerEvent *event) override
KoCanvasController * canvasController() const
virtual void panLeft()=0
virtual void panRight()=0
virtual void pan(const QPoint &distance)=0
virtual void panDown()=0
virtual void panUp()=0
void useCursor(const QCursor &cursor)
QAction * action(const QString &name) const
void setSection(const QString &section)
void setActivationShapeId(const QString &activationShapeId)
void setIconName(const char *iconName)
void setToolTip(const QString &tooltip)
virtual QList< QAction * > createActionsImpl()
createActionsImpl should be reimplemented if the tool needs any actions. The actions should have a va...
void setPriority(int newPriority)
#define koIconNameCStr(name)
Definition kis_icon.h:28
static const QString KRITA_TOOL_ACTIVATION_ID
Definition kis_tool.h:37
static const QString Navigation
Tools that affect the canvas: pan, zoom, etc.
void deactivate() override
Definition kis_tool.cc:131
KisCanvas2 * canvas