Krita Source Code Documentation
Loading...
Searching...
No Matches
KoToolProxy Class Referenceabstract

#include <KoToolProxy.h>

+ Inheritance diagram for KoToolProxy:

Signals

void selectionChanged (bool hasSelection)
 
void toolChanged (const QString &toolId)
 

Public Member Functions

void copy () const
 Forwarded to the current KoToolBase.
 
void cut ()
 Forwarded to the current KoToolBase.
 
void deleteSelection ()
 Forwarded to the current KoToolBase.
 
void deselect ()
 Forwarded to the current KoToolBase.
 
void dragLeaveEvent (QDragLeaveEvent *event)
 Forwarded to the current KoToolBase.
 
void dragMoveEvent (QDragMoveEvent *event, const QPointF &point)
 Forwarded to the current KoToolBase.
 
void dropEvent (QDropEvent *event, const QPointF &point)
 Forwarded to the current KoToolBase.
 
void explicitUserStrokeEndRequest ()
 Forwarded to the current KoToolBase.
 
void focusInEvent (QFocusEvent *event)
 Forwarded to the current KoToolBase.
 
void focusOutEvent (QFocusEvent *event)
 Forwarded to the current KoToolBase.
 
bool hasSelection () const
 returns true if the current tool holds a selection
 
void inputMethodEvent (QInputMethodEvent *event)
 Forwarded to the current KoToolBase.
 
QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 Forwarded to the current KoToolBase.
 
void keyPressEvent (QKeyEvent *event)
 Forwarded to the current KoToolBase.
 
void keyReleaseEvent (QKeyEvent *event)
 Forwarded to the current KoToolBase.
 
 KoToolProxy (KoCanvasBase *canvas, QObject *parent=0)
 
KoPointerEventlastDeliveredPointerEvent () const
 
void mouseDoubleClickEvent (KoPointerEvent *event)
 
void mouseDoubleClickEvent (QMouseEvent *event, const QPointF &point)
 Forwarded to the current KoToolBase.
 
void mouseMoveEvent (KoPointerEvent *event)
 
void mouseMoveEvent (QMouseEvent *event, const QPointF &point)
 Forwarded to the current KoToolBase.
 
void mousePressEvent (KoPointerEvent *event)
 
void mousePressEvent (QMouseEvent *event, const QPointF &point)
 Forwarded to the current KoToolBase.
 
void mouseReleaseEvent (KoPointerEvent *event)
 
void mouseReleaseEvent (QMouseEvent *event, const QPointF &point)
 Forwarded to the current KoToolBase.
 
void paint (QPainter &painter, const KoViewConverter &converter)
 Forwarded to the current KoToolBase.
 
bool paste ()
 Forwarded to the current KoToolBase.
 
QMenu * popupActionsMenu ()
 Forwarded to the current KoToolBase.
 
KisPopupWidgetInterfacepopupWidget ()
 Forwarded to the current KoToolBase.
 
KoToolProxyPrivatepriv ()
 
void processEvent (QEvent *) const
 
void repaintDecorations ()
 Forwarded to the current KoToolBase.
 
bool selectAll ()
 Forwarded to the current KoToolBase.
 
virtual void setActiveTool (KoToolBase *tool)
 Set the new active tool.
 
void tabletEvent (QTabletEvent *event, const QPointF &point)
 Forwarded to the current KoToolBase.
 
QVector< QKeySequence > toolPriorityShortcuts () const
 
void touchEvent (QTouchEvent *event, const QPointF &point)
 
 ~KoToolProxy () override
 

Protected Slots

void requestRedoDuringStroke ()
 Forwarded to the current KoToolBase.
 
void requestStrokeCancellation ()
 Forwarded to the current KoToolBase.
 
void requestStrokeEnd ()
 Forwarded to the current KoToolBase.
 
void requestUndoDuringStroke ()
 Forwarded to the current KoToolBase.
 

Protected Member Functions

KoCanvasBasecanvas () const
 
virtual QPointF documentToWidget (const QPointF &documentPoint) const =0
 
virtual QPointF widgetToDocument (const QPointF &widgetPoint) const =0
 

Private Member Functions

void countMultiClick (KoPointerEvent *ev, int eventType)
 

Private Attributes

KoToolProxyPrivate *const d
 

Friends

class KoToolProxyPrivate
 

Detailed Description

Tool proxy object which allows an application to address the current tool.

Applications typically have a canvas and a canvas requires a tool for the user to do anything. Since the flake system is responsible for handling tools and also to change the active tool when needed we provide one class that can be used by an application canvas to route all the native events too which will transparently be routed to the active tool. Without the application having to bother about which tool is active.

Definition at line 47 of file KoToolProxy.h.

Constructor & Destructor Documentation

◆ KoToolProxy()

KoToolProxy::KoToolProxy ( KoCanvasBase * canvas,
QObject * parent = 0 )
explicit

Constructor

Parameters
canvasEach canvas has 1 toolProxy. Pass the parent here.
parenta parent QObject for memory management purposes.

Definition at line 101 of file KoToolProxy.cpp.

102 : QObject(parent),
103 d(new KoToolProxyPrivate(this))
104{
105 KoToolManager::instance()->priv()->registerToolProxy(this, canvas);
106
107 connect(&d->scrollTimer, SIGNAL(timeout()), this, SLOT(timeout()));
108}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KoToolManager::Private * priv()
static KoToolManager * instance()
Return the toolmanager singleton.
KoToolProxyPrivate *const d
KoCanvasBase * canvas() const
friend class KoToolProxyPrivate

References canvas(), connect(), d, KoToolManager::instance(), KoToolManager::priv(), and KoToolProxyPrivate::scrollTimer.

◆ ~KoToolProxy()

KoToolProxy::~KoToolProxy ( )
override

Definition at line 110 of file KoToolProxy.cpp.

111{
112 delete d;
113}

References d.

Member Function Documentation

◆ canvas()

KoCanvasBase * KoToolProxy::canvas ( ) const
protected

Definition at line 125 of file KoToolProxy.cpp.

126{
127 return d->controller->canvas();
128}
virtual KoCanvasBase * canvas() const
KoCanvasController * controller

References KoCanvasController::canvas(), KoToolProxyPrivate::controller, and d.

◆ copy()

void KoToolProxy::copy ( ) const

Forwarded to the current KoToolBase.

Definition at line 447 of file KoToolProxy.cpp.

448{
449 if (d->activeTool)
450 d->activeTool->copy();
451}
virtual void copy() const
KoToolBase * activeTool

References KoToolProxyPrivate::activeTool, KoToolBase::copy(), and d.

◆ countMultiClick()

void KoToolProxy::countMultiClick ( KoPointerEvent * ev,
int eventType )
private

Definition at line 130 of file KoToolProxy.cpp.

131{
132 QPointF globalPoint = ev->globalPos();
133
134 if (d->multiClickSource != eventType) {
135 d->multiClickCount = 0;
136 }
137
138 if (d->multiClickGlobalPoint != globalPoint) {
139 if (qAbs(globalPoint.x() - d->multiClickGlobalPoint.x()) > 5||
140 qAbs(globalPoint.y() - d->multiClickGlobalPoint.y()) > 5) {
141 d->multiClickCount = 0;
142 }
143 d->multiClickGlobalPoint = globalPoint;
144 }
145
146 if (d->multiClickCount && d->multiClickTimeStamp.elapsed() < QApplication::doubleClickInterval()) {
147 // One more multiclick;
149 } else {
150 d->multiClickTimeStamp.start();
151 d->multiClickCount = 1;
152 d->multiClickSource = QEvent::Type(eventType);
153 }
154
155 if (d->activeTool) {
156 switch (d->multiClickCount) {
157 case 0:
158 case 1:
160 break;
161 case 2:
163 break;
164 case 3:
165 default:
167 break;
168 }
169 } else {
170 d->multiClickCount = 0;
171 ev->ignore();
172 }
173
174}
QPoint globalPos() const
Return the position screen coordinates.
virtual void mouseTripleClickEvent(KoPointerEvent *event)
virtual void mousePressEvent(KoPointerEvent *event)=0
virtual void mouseDoubleClickEvent(KoPointerEvent *event)
QEvent::Type multiClickSource
QElapsedTimer multiClickTimeStamp
QPointF multiClickGlobalPoint

References KoToolProxyPrivate::activeTool, d, KoPointerEvent::globalPos(), KoPointerEvent::ignore(), KoToolBase::mouseDoubleClickEvent(), KoToolBase::mousePressEvent(), KoToolBase::mouseTripleClickEvent(), KoToolProxyPrivate::multiClickCount, KoToolProxyPrivate::multiClickGlobalPoint, KoToolProxyPrivate::multiClickSource, and KoToolProxyPrivate::multiClickTimeStamp.

◆ cut()

void KoToolProxy::cut ( )

Forwarded to the current KoToolBase.

Definition at line 441 of file KoToolProxy.cpp.

442{
444 d->activeTool->cut();
445}
virtual void cut()

References KoToolProxyPrivate::activeTool, KoToolBase::cut(), d, and KoToolProxyPrivate::isActiveLayerEditable().

◆ deleteSelection()

void KoToolProxy::deleteSelection ( )

Forwarded to the current KoToolBase.

Definition at line 499 of file KoToolProxy.cpp.

500{
501 if (d->activeTool)
503}
virtual void deleteSelection()

References KoToolProxyPrivate::activeTool, d, and KoToolBase::deleteSelection().

◆ deselect()

void KoToolProxy::deselect ( )

Forwarded to the current KoToolBase.

Definition at line 475 of file KoToolProxy.cpp.

476{
477 if (d->activeTool)
479}
virtual void deselect()
deselect the tool should clear the selection if it has one.

References KoToolProxyPrivate::activeTool, d, and KoToolBase::deselect().

◆ documentToWidget()

virtual QPointF KoToolProxy::documentToWidget ( const QPointF & documentPoint) const
protectedpure virtual

Implemented in KisToolProxy.

◆ dragLeaveEvent()

void KoToolProxy::dragLeaveEvent ( QDragLeaveEvent * event)

Forwarded to the current KoToolBase.

Definition at line 487 of file KoToolProxy.cpp.

488{
489 if (d->activeTool)
490 d->activeTool->dragLeaveEvent(event);
491}
virtual void dragLeaveEvent(QDragLeaveEvent *event)

References KoToolProxyPrivate::activeTool, d, and KoToolBase::dragLeaveEvent().

◆ dragMoveEvent()

void KoToolProxy::dragMoveEvent ( QDragMoveEvent * event,
const QPointF & point )

Forwarded to the current KoToolBase.

Definition at line 481 of file KoToolProxy.cpp.

482{
483 if (d->activeTool)
484 d->activeTool->dragMoveEvent(event, point);
485}
virtual void dragMoveEvent(QDragMoveEvent *event, const QPointF &point)

References KoToolProxyPrivate::activeTool, d, and KoToolBase::dragMoveEvent().

◆ dropEvent()

void KoToolProxy::dropEvent ( QDropEvent * event,
const QPointF & point )

Forwarded to the current KoToolBase.

Definition at line 493 of file KoToolProxy.cpp.

494{
495 if (d->activeTool)
496 d->activeTool->dropEvent(event, point);
497}
virtual void dropEvent(QDropEvent *event, const QPointF &point)

References KoToolProxyPrivate::activeTool, d, and KoToolBase::dropEvent().

◆ explicitUserStrokeEndRequest()

void KoToolProxy::explicitUserStrokeEndRequest ( )

Forwarded to the current KoToolBase.

Definition at line 322 of file KoToolProxy.cpp.

323{
324 if (d->activeTool) {
326 }
327}
virtual void explicitUserStrokeEndRequest()
explicitUserStrokeEndRequest is called by the input manager when the user presses Enter key or any eq...

References KoToolProxyPrivate::activeTool, d, and KoToolBase::explicitUserStrokeEndRequest().

◆ focusInEvent()

void KoToolProxy::focusInEvent ( QFocusEvent * event)

Forwarded to the current KoToolBase.

Definition at line 341 of file KoToolProxy.cpp.

342{
343 if (d->activeTool) d->activeTool->focusInEvent(event);
344}
virtual void focusInEvent(QFocusEvent *event)

References KoToolProxyPrivate::activeTool, d, and KoToolBase::focusInEvent().

◆ focusOutEvent()

void KoToolProxy::focusOutEvent ( QFocusEvent * event)

Forwarded to the current KoToolBase.

Definition at line 346 of file KoToolProxy.cpp.

347{
348 if (d->activeTool) d->activeTool->focusOutEvent(event);
349}
virtual void focusOutEvent(QFocusEvent *event)

References KoToolProxyPrivate::activeTool, d, and KoToolBase::focusOutEvent().

◆ hasSelection()

bool KoToolProxy::hasSelection ( ) const

returns true if the current tool holds a selection

Definition at line 436 of file KoToolProxy.cpp.

437{
438 return d->activeTool ? d->activeTool->hasSelection() : false;
439}
virtual bool hasSelection()

References KoToolProxyPrivate::activeTool, d, and KoToolBase::hasSelection().

◆ inputMethodEvent()

void KoToolProxy::inputMethodEvent ( QInputMethodEvent * event)

Forwarded to the current KoToolBase.

Definition at line 336 of file KoToolProxy.cpp.

337{
339}
virtual void inputMethodEvent(QInputMethodEvent *event)

References KoToolProxyPrivate::activeTool, d, and KoToolBase::inputMethodEvent().

◆ inputMethodQuery()

QVariant KoToolProxy::inputMethodQuery ( Qt::InputMethodQuery query) const

Forwarded to the current KoToolBase.

Definition at line 329 of file KoToolProxy.cpp.

330{
331 if (d->activeTool)
332 return d->activeTool->inputMethodQuery(query);
333 return QVariant();
334}
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const

References KoToolProxyPrivate::activeTool, d, and KoToolBase::inputMethodQuery().

◆ keyPressEvent()

void KoToolProxy::keyPressEvent ( QKeyEvent * event)

Forwarded to the current KoToolBase.

Definition at line 304 of file KoToolProxy.cpp.

305{
306 if (d->activeTool)
307 d->activeTool->keyPressEvent(event);
308 else
309 event->ignore();
310}
virtual void keyPressEvent(QKeyEvent *event)

References KoToolProxyPrivate::activeTool, d, and KoToolBase::keyPressEvent().

◆ keyReleaseEvent()

void KoToolProxy::keyReleaseEvent ( QKeyEvent * event)

Forwarded to the current KoToolBase.

Definition at line 312 of file KoToolProxy.cpp.

313{
314 if (d->activeTool)
316 else
317 event->ignore();
318
319 d->isToolPressed = false;
320}
virtual void keyReleaseEvent(QKeyEvent *event)

References KoToolProxyPrivate::activeTool, d, KoToolProxyPrivate::isToolPressed, and KoToolBase::keyReleaseEvent().

◆ lastDeliveredPointerEvent()

KoPointerEvent * KoToolProxy::lastDeliveredPointerEvent ( ) const

Definition at line 421 of file KoToolProxy.cpp.

422{
423 return d->lastPointerEvent ? &(d->lastPointerEvent->event) : 0;
424}
boost::optional< KoPointerEventWrapper > lastPointerEvent

References d, and KoToolProxyPrivate::lastPointerEvent.

◆ mouseDoubleClickEvent() [1/2]

void KoToolProxy::mouseDoubleClickEvent ( KoPointerEvent * event)

Definition at line 250 of file KoToolProxy.cpp.

251{
252 // let us handle it as any other mousepress (where we then detect multi clicks
253 mousePressEvent(event);
254}
void mousePressEvent(QMouseEvent *event, const QPointF &point)
Forwarded to the current KoToolBase.

References mousePressEvent().

◆ mouseDoubleClickEvent() [2/2]

void KoToolProxy::mouseDoubleClickEvent ( QMouseEvent * event,
const QPointF & point )

Forwarded to the current KoToolBase.

Definition at line 243 of file KoToolProxy.cpp.

244{
245 KoPointerEvent ev(event, point);
247 d->lastPointerEvent = ev.deepCopyEvent();
248}
void mouseDoubleClickEvent(QMouseEvent *event, const QPointF &point)
Forwarded to the current KoToolBase.

References d, KoPointerEvent::deepCopyEvent(), KoToolProxyPrivate::lastPointerEvent, and mouseDoubleClickEvent().

◆ mouseMoveEvent() [1/2]

void KoToolProxy::mouseMoveEvent ( KoPointerEvent * event)

Definition at line 263 of file KoToolProxy.cpp.

264{
265 if (d->mouseLeaveWorkaround) {
266 d->mouseLeaveWorkaround = false;
267 return;
268 }
269 KoInputDevice id;
270 KoToolManager::instance()->priv()->switchInputDevice(id);
271 if (d->activeTool == 0) {
272 event->ignore();
273 return;
274 }
275
276 d->activeTool->mouseMoveEvent(event);
277
278 d->checkAutoScroll(*event);
279}
virtual void mouseMoveEvent(KoPointerEvent *event)=0
void checkAutoScroll(const KoPointerEvent &event)

References KoToolProxyPrivate::activeTool, KoToolProxyPrivate::checkAutoScroll(), d, KoToolManager::instance(), KoToolProxyPrivate::mouseLeaveWorkaround, KoToolBase::mouseMoveEvent(), and KoToolManager::priv().

◆ mouseMoveEvent() [2/2]

void KoToolProxy::mouseMoveEvent ( QMouseEvent * event,
const QPointF & point )

Forwarded to the current KoToolBase.

Definition at line 256 of file KoToolProxy.cpp.

257{
258 KoPointerEvent ev(event, point);
259 mouseMoveEvent(&ev);
260 d->lastPointerEvent = ev.deepCopyEvent();
261}
void mouseMoveEvent(QMouseEvent *event, const QPointF &point)
Forwarded to the current KoToolBase.

References d, KoPointerEvent::deepCopyEvent(), KoToolProxyPrivate::lastPointerEvent, and mouseMoveEvent().

◆ mousePressEvent() [1/2]

void KoToolProxy::mousePressEvent ( KoPointerEvent * event)

Definition at line 208 of file KoToolProxy.cpp.

209{
210 d->mouseLeaveWorkaround = false;
211 KoInputDevice id;
212 KoToolManager::instance()->priv()->switchInputDevice(id);
213 d->mouseDownPoint = ev->pos();
214
215
216 // this tries to make sure another mouse press event doesn't happen
217 // before a release event happens
218 if (d->isToolPressed) {
220 d->scrollTimer.stop();
221
222 if (d->activeTool) {
224 }
225
226 d->isToolPressed = false;
227
228 return;
229 }
230
231 countMultiClick(ev, QEvent::MouseButtonPress);
232
233 d->isToolPressed = true;
234}
virtual void mouseReleaseEvent(KoPointerEvent *event)=0
void countMultiClick(KoPointerEvent *ev, int eventType)
void mouseReleaseEvent(QMouseEvent *event, const QPointF &point)
Forwarded to the current KoToolBase.

References KoToolProxyPrivate::activeTool, countMultiClick(), d, KoToolManager::instance(), KoToolProxyPrivate::isToolPressed, KoToolProxyPrivate::mouseDownPoint, KoToolProxyPrivate::mouseLeaveWorkaround, KoToolBase::mouseReleaseEvent(), mouseReleaseEvent(), KoPointerEvent::pos(), KoToolManager::priv(), and KoToolProxyPrivate::scrollTimer.

◆ mousePressEvent() [2/2]

void KoToolProxy::mousePressEvent ( QMouseEvent * event,
const QPointF & point )

Forwarded to the current KoToolBase.

Definition at line 236 of file KoToolProxy.cpp.

237{
238 KoPointerEvent ev(event, point);
239 mousePressEvent(&ev);
240 d->lastPointerEvent = ev.deepCopyEvent();
241}

References d, KoPointerEvent::deepCopyEvent(), KoToolProxyPrivate::lastPointerEvent, and mousePressEvent().

◆ mouseReleaseEvent() [1/2]

void KoToolProxy::mouseReleaseEvent ( KoPointerEvent * event)

Definition at line 288 of file KoToolProxy.cpp.

289{
290 d->mouseLeaveWorkaround = false;
291 KoInputDevice id;
292 KoToolManager::instance()->priv()->switchInputDevice(id);
293 d->scrollTimer.stop();
294
295 if (d->activeTool) {
297 } else {
298 event->ignore();
299 }
300
301 d->isToolPressed = false;
302}

References KoToolProxyPrivate::activeTool, d, KoToolManager::instance(), KoToolProxyPrivate::isToolPressed, KoToolProxyPrivate::mouseLeaveWorkaround, KoToolBase::mouseReleaseEvent(), KoToolManager::priv(), and KoToolProxyPrivate::scrollTimer.

◆ mouseReleaseEvent() [2/2]

void KoToolProxy::mouseReleaseEvent ( QMouseEvent * event,
const QPointF & point )

Forwarded to the current KoToolBase.

Definition at line 281 of file KoToolProxy.cpp.

282{
283 KoPointerEvent ev(event, point);
285 d->lastPointerEvent = ev.deepCopyEvent();
286}

References d, KoPointerEvent::deepCopyEvent(), KoToolProxyPrivate::lastPointerEvent, and mouseReleaseEvent().

◆ paint()

void KoToolProxy::paint ( QPainter & painter,
const KoViewConverter & converter )

Forwarded to the current KoToolBase.

Definition at line 115 of file KoToolProxy.cpp.

116{
117 if (d->activeTool) d->activeTool->paint(painter, converter);
118}
virtual void paint(QPainter &painter, const KoViewConverter &converter)=0

References KoToolProxyPrivate::activeTool, d, and KoToolBase::paint().

◆ paste()

bool KoToolProxy::paste ( )

Forwarded to the current KoToolBase.

Definition at line 453 of file KoToolProxy.cpp.

454{
455 bool success = false;
456
457 if (d->activeTool && d->isActiveLayerEditable()) {
458 success = d->activeTool->paste();
459 }
460
461 return success;
462}
virtual bool paste()

References KoToolProxyPrivate::activeTool, d, KoToolProxyPrivate::isActiveLayerEditable(), and KoToolBase::paste().

◆ popupActionsMenu()

QMenu * KoToolProxy::popupActionsMenu ( )

Forwarded to the current KoToolBase.

Definition at line 351 of file KoToolProxy.cpp.

352{
353 return d->activeTool ? d->activeTool->popupActionsMenu() : 0;
354}
virtual QMenu * popupActionsMenu()
Definition KoToolBase.h:334

References KoToolProxyPrivate::activeTool, d, and KoToolBase::popupActionsMenu().

◆ popupWidget()

KisPopupWidgetInterface * KoToolProxy::popupWidget ( )

Forwarded to the current KoToolBase.

Definition at line 356 of file KoToolProxy.cpp.

357{
358 return d->activeTool ? d->activeTool->popupWidget() : nullptr;
359}
virtual KisPopupWidgetInterface * popupWidget()
Definition KoToolBase.h:340

References KoToolProxyPrivate::activeTool, d, and KoToolBase::popupWidget().

◆ priv()

KoToolProxyPrivate * KoToolProxy::priv ( )

Definition at line 550 of file KoToolProxy.cpp.

551{
552 return d;
553}

References d.

◆ processEvent()

void KoToolProxy::processEvent ( QEvent * e) const

This method gives the proxy a chance to do things. for example it is need to have working singlekey shortcuts. call it from the canvas' event function and forward it to QWidget::event() later.

Definition at line 505 of file KoToolProxy.cpp.

506{
507 if(e->type()==QEvent::ShortcutOverride
508 && d->activeTool
510 && (static_cast<QKeyEvent*>(e)->modifiers()==Qt::NoModifier ||
511 static_cast<QKeyEvent*>(e)->modifiers()==Qt::ShiftModifier
512#ifdef Q_OS_WIN
513 // we should disallow AltGr shortcuts if a text box is in focus
514 || (static_cast<QKeyEvent*>(e)->modifiers()==(Qt::AltModifier | Qt::ControlModifier) &&
515 static_cast<QKeyEvent*>(e)->key() < Qt::Key_Escape)
516#endif
517 )) {
518 e->accept();
519 }
520}
bool isInTextMode() const

References KoToolProxyPrivate::activeTool, d, and KoToolBase::isInTextMode().

◆ repaintDecorations()

void KoToolProxy::repaintDecorations ( )

Forwarded to the current KoToolBase.

Definition at line 120 of file KoToolProxy.cpp.

121{
123}
virtual void repaintDecorations()

References KoToolProxyPrivate::activeTool, d, and KoToolBase::repaintDecorations().

◆ requestRedoDuringStroke

void KoToolProxy::requestRedoDuringStroke ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 529 of file KoToolProxy.cpp.

530{
531 if (d->activeTool) {
533 }
534}
virtual void requestRedoDuringStroke()

References KoToolProxyPrivate::activeTool, d, and KoToolBase::requestRedoDuringStroke().

◆ requestStrokeCancellation

void KoToolProxy::requestStrokeCancellation ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 536 of file KoToolProxy.cpp.

537{
538 if (d->activeTool) {
540 }
541}
virtual void requestStrokeCancellation()

References KoToolProxyPrivate::activeTool, d, and KoToolBase::requestStrokeCancellation().

◆ requestStrokeEnd

void KoToolProxy::requestStrokeEnd ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 543 of file KoToolProxy.cpp.

544{
545 if (d->activeTool) {
547 }
548}
virtual void requestStrokeEnd()

References KoToolProxyPrivate::activeTool, d, and KoToolBase::requestStrokeEnd().

◆ requestUndoDuringStroke

void KoToolProxy::requestUndoDuringStroke ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 522 of file KoToolProxy.cpp.

523{
524 if (d->activeTool) {
526 }
527}
virtual void requestUndoDuringStroke()

References KoToolProxyPrivate::activeTool, d, and KoToolBase::requestUndoDuringStroke().

◆ selectAll()

bool KoToolProxy::selectAll ( )

Forwarded to the current KoToolBase.

Definition at line 464 of file KoToolProxy.cpp.

465{
466 bool success = false;
467
468 if (d->activeTool && d->isActiveLayerEditable()) {
469 success = d->activeTool->selectAll();
470 }
471
472 return success;
473}
virtual bool selectAll()
selectAll select all data the tool can select.

References KoToolProxyPrivate::activeTool, d, KoToolProxyPrivate::isActiveLayerEditable(), and KoToolBase::selectAll().

◆ selectionChanged

void KoToolProxy::selectionChanged ( bool hasSelection)
signal

A tool can have a selection that is copy-able, this signal is emitted when that status changes.

Parameters
hasSelectionis true when the tool holds selected data.

◆ setActiveTool()

void KoToolProxy::setActiveTool ( KoToolBase * tool)
virtual

Set the new active tool.

Reimplemented in KisToolProxy.

Definition at line 361 of file KoToolProxy.cpp.

362{
363 if (d->activeTool) {
364 disconnect(d->activeTool, SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
365 d->toolPriorityShortcuts.clear();
366 }
367
368 d->activeTool = tool;
369
370 if (tool) {
373 if (collection) {
374 Q_FOREACH(QAction *action, collection->actions()) {
375
376 const QVariant prop = action->property("tool_action");
377
378 if (prop.isValid()) {
379 const QStringList tools = prop.toStringList();
380
381 if (tools.contains(d->activeTool->toolId())) {
382 const QList<QKeySequence> shortcuts = action->shortcuts();
383 std::copy(shortcuts.begin(), shortcuts.end(),
384 std::back_inserter(d->toolPriorityShortcuts));
385 }
386 }
387 }
388 }
389
390 connect(d->activeTool, SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
392 Q_EMIT toolChanged(tool->toolId());
393 }
394}
A container for a set of QAction objects.
QList< QAction * > actions() const
KisKActionCollection * actionCollection
Q_INVOKABLE QString toolId() const
void selectionChanged(bool newSelection)
QVector< QKeySequence > toolPriorityShortcuts
bool hasSelection() const
returns true if the current tool holds a selection
void toolChanged(const QString &toolId)
void selectionChanged(bool hasSelection)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KoCanvasController::actionCollection, KisKActionCollection::actions(), KoToolProxyPrivate::activeTool, connect(), KoToolProxyPrivate::controller, d, hasSelection(), KIS_SAFE_ASSERT_RECOVER_NOOP, selectionChanged(), KoToolProxyPrivate::selectionChanged(), toolChanged(), KoToolBase::toolId(), and KoToolProxyPrivate::toolPriorityShortcuts.

◆ tabletEvent()

void KoToolProxy::tabletEvent ( QTabletEvent * event,
const QPointF & point )

Forwarded to the current KoToolBase.

Definition at line 176 of file KoToolProxy.cpp.

177{
178 // We get these events exclusively from KisToolProxy - accept them
179 event->accept();
180
182 KoInputDevice::convertPointerType(event), event->uniqueId());
183 KoToolManager::instance()->priv()->switchInputDevice(id);
184
185 KoPointerEvent ev(event, point);
186
187 switch (event->type()) {
188 case QEvent::TabletPress:
189 countMultiClick(&ev, event->type());
190 break;
191 case QEvent::TabletRelease:
192 d->scrollTimer.stop();
193 if (d->activeTool)
195 break;
196 case QEvent::TabletMove:
197 if (d->activeTool)
199 d->checkAutoScroll(ev);
200 default:
201 ; // ignore the rest.
202 }
203
204 d->mouseLeaveWorkaround = true;
205 d->lastPointerEvent = ev.deepCopyEvent();
206}
static InputDevice convertDeviceType(QTabletEvent *event)
static Pointer convertPointerType(QTabletEvent *event)

References KoToolProxyPrivate::activeTool, KoToolProxyPrivate::checkAutoScroll(), KoInputDevice::convertDeviceType(), KoInputDevice::convertPointerType(), countMultiClick(), d, KoPointerEvent::deepCopyEvent(), KoToolManager::instance(), KoToolProxyPrivate::lastPointerEvent, KoToolProxyPrivate::mouseLeaveWorkaround, KoToolBase::mouseMoveEvent(), KoToolBase::mouseReleaseEvent(), KoToolManager::priv(), and KoToolProxyPrivate::scrollTimer.

◆ toolChanged

void KoToolProxy::toolChanged ( const QString & toolId)
signal

Emitted every time a tool is changed.

Parameters
toolIdthe id of the tool.
See also
KoToolBase::toolId()

◆ toolPriorityShortcuts()

QVector< QKeySequence > KoToolProxy::toolPriorityShortcuts ( ) const

Definition at line 426 of file KoToolProxy.cpp.

427{
428 return d->toolPriorityShortcuts;
429}

References d, and KoToolProxyPrivate::toolPriorityShortcuts.

◆ touchEvent()

void KoToolProxy::touchEvent ( QTouchEvent * event,
const QPointF & point )

Definition at line 396 of file KoToolProxy.cpp.

397{
398 // only one "touchpoint" events should be here
399 KoPointerEvent ev(event, point);
400
401 if (!d->activeTool) return;
402
403 switch (event->touchPointStates())
404 {
405 case Qt::TouchPointPressed:
406 countMultiClick(&ev, QEvent::TouchBegin);
407 break;
408 case Qt::TouchPointMoved:
410 break;
411 case Qt::TouchPointReleased:
413 break;
414 default: // don't care
415 ;
416 }
417
418 d->lastPointerEvent = ev.deepCopyEvent();
419}

References KoToolProxyPrivate::activeTool, countMultiClick(), d, KoPointerEvent::deepCopyEvent(), KoToolProxyPrivate::lastPointerEvent, KoToolBase::mouseMoveEvent(), and KoToolBase::mouseReleaseEvent().

◆ widgetToDocument()

virtual QPointF KoToolProxy::widgetToDocument ( const QPointF & widgetPoint) const
protectedpure virtual

Implemented in KisToolProxy.

Friends And Related Symbol Documentation

◆ KoToolProxyPrivate

friend class KoToolProxyPrivate
friend

Definition at line 196 of file KoToolProxy.h.

Member Data Documentation

◆ d

KoToolProxyPrivate* const KoToolProxy::d
private

Definition at line 197 of file KoToolProxy.h.


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