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)
 
KoPointerEvent * lastDeliveredPointerEvent () 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.
 
KisPopupWidgetInterface * popupWidget ()
 Forwarded to the current KoToolBase.
 
KoToolProxyPrivate * priv ()
 
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

KoCanvasBase * canvas () const
 
virtual QPointF documentToWidget (const QPointF &documentPoint) const =0
 
int multiClickCount () const
 
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 119 of file KoToolProxy.cpp.

120 : QObject(parent),
121 d(new KoToolProxyPrivate(this))
122{
123 connect(&d->scrollTimer, SIGNAL(timeout()), this, SLOT(timeout()));
124}
KoToolProxyPrivate *const d
friend class KoToolProxyPrivate

References d, and KoToolProxyPrivate::scrollTimer.

◆ ~KoToolProxy()

KoToolProxy::~KoToolProxy ( )
override

Definition at line 126 of file KoToolProxy.cpp.

127{
128 delete d;
129}

References d.

Member Function Documentation

◆ canvas()

KoCanvasBase * KoToolProxy::canvas ( ) const
protected

Definition at line 141 of file KoToolProxy.cpp.

142{
143 return d->controller->canvas();
144}
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 468 of file KoToolProxy.cpp.

469{
470 if (d->activeTool)
471 d->activeTool->copy();
472}
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 151 of file KoToolProxy.cpp.

152{
153 QPointF globalPoint = ev->globalPos();
154
155 if (d->multiClickSource != eventType) {
156 d->multiClickCount = 0;
157 }
158
159 if (d->multiClickGlobalPoint != globalPoint) {
160 if (qAbs(globalPoint.x() - d->multiClickGlobalPoint.x()) > 5||
161 qAbs(globalPoint.y() - d->multiClickGlobalPoint.y()) > 5) {
162 d->multiClickCount = 0;
163 }
164 d->multiClickGlobalPoint = globalPoint;
165 }
166
167 if (d->multiClickCount && d->multiClickTimeStamp.elapsed() < QApplication::doubleClickInterval()) {
168 // One more multiclick;
170 } else {
171 d->multiClickTimeStamp.start();
172 d->multiClickCount = 1;
173 d->multiClickSource = QEvent::Type(eventType);
174 }
175
176 if (d->activeTool) {
177 switch (d->multiClickCount) {
178 case 0:
179 case 1:
181 break;
182 case 2:
184 break;
185 case 3:
186 default:
188 break;
189 }
190 } else {
191 d->multiClickCount = 0;
192 ev->ignore();
193 }
194
195}
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 462 of file KoToolProxy.cpp.

463{
465 d->activeTool->cut();
466}
virtual void cut()

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

◆ deleteSelection()

void KoToolProxy::deleteSelection ( )

Forwarded to the current KoToolBase.

Definition at line 520 of file KoToolProxy.cpp.

521{
522 if (d->activeTool)
524}
virtual void deleteSelection()

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

◆ deselect()

void KoToolProxy::deselect ( )

Forwarded to the current KoToolBase.

Definition at line 496 of file KoToolProxy.cpp.

497{
498 if (d->activeTool)
500}
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 508 of file KoToolProxy.cpp.

509{
510 if (d->activeTool)
511 d->activeTool->dragLeaveEvent(event);
512}
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 502 of file KoToolProxy.cpp.

503{
504 if (d->activeTool)
505 d->activeTool->dragMoveEvent(event, point);
506}
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 514 of file KoToolProxy.cpp.

515{
516 if (d->activeTool)
517 d->activeTool->dropEvent(event, point);
518}
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 343 of file KoToolProxy.cpp.

344{
345 if (d->activeTool) {
347 }
348}
virtual void explicitUserStrokeEndRequest()
explicitUserStrokeEndRequest is called by the input manager when the user presses the Enter key or an...

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

◆ focusInEvent()

void KoToolProxy::focusInEvent ( QFocusEvent * event)

Forwarded to the current KoToolBase.

Definition at line 362 of file KoToolProxy.cpp.

363{
364 if (d->activeTool) d->activeTool->focusInEvent(event);
365}
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 367 of file KoToolProxy.cpp.

368{
369 if (d->activeTool) d->activeTool->focusOutEvent(event);
370}
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 457 of file KoToolProxy.cpp.

458{
459 return d->activeTool ? d->activeTool->hasSelection() : false;
460}
virtual bool hasSelection()

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

◆ inputMethodEvent()

void KoToolProxy::inputMethodEvent ( QInputMethodEvent * event)

Forwarded to the current KoToolBase.

Definition at line 357 of file KoToolProxy.cpp.

358{
360}
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 350 of file KoToolProxy.cpp.

351{
352 if (d->activeTool)
353 return d->activeTool->inputMethodQuery(query);
354 return QVariant();
355}
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 325 of file KoToolProxy.cpp.

326{
327 if (d->activeTool)
328 d->activeTool->keyPressEvent(event);
329 else
330 event->ignore();
331}
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 333 of file KoToolProxy.cpp.

334{
335 if (d->activeTool)
337 else
338 event->ignore();
339
340 d->isToolPressed = false;
341}
virtual void keyReleaseEvent(QKeyEvent *event)

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

◆ lastDeliveredPointerEvent()

KoPointerEvent * KoToolProxy::lastDeliveredPointerEvent ( ) const

Definition at line 442 of file KoToolProxy.cpp.

443{
444 return d->lastPointerEvent ? &(d->lastPointerEvent->event) : 0;
445}
boost::optional< KoPointerEventWrapper > lastPointerEvent

References d, and KoToolProxyPrivate::lastPointerEvent.

◆ mouseDoubleClickEvent() [1/2]

void KoToolProxy::mouseDoubleClickEvent ( KoPointerEvent * event)

Definition at line 271 of file KoToolProxy.cpp.

272{
273 // let us handle it as any other mousepress (where we then detect multi clicks
274 mousePressEvent(event);
275}
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 264 of file KoToolProxy.cpp.

265{
266 KoPointerEvent ev(event, point);
268 d->lastPointerEvent = ev.deepCopyEvent();
269}
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 284 of file KoToolProxy.cpp.

285{
286 if (d->mouseLeaveWorkaround) {
287 d->mouseLeaveWorkaround = false;
288 return;
289 }
290 KoInputDevice id;
291 d->controller->toolManager()->priv()->switchInputDevice(id);
292 if (d->activeTool == 0) {
293 event->ignore();
294 return;
295 }
296
297 d->activeTool->mouseMoveEvent(event);
298
299 d->checkAutoScroll(*event);
300}
QPointer< KoToolManager > toolManager
virtual void mouseMoveEvent(KoPointerEvent *event)=0
void checkAutoScroll(const KoPointerEvent &event)

References KoToolProxyPrivate::activeTool, KoToolProxyPrivate::checkAutoScroll(), KoToolProxyPrivate::controller, d, KoToolProxyPrivate::mouseLeaveWorkaround, KoToolBase::mouseMoveEvent(), and KoCanvasController::toolManager.

◆ mouseMoveEvent() [2/2]

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

Forwarded to the current KoToolBase.

Definition at line 277 of file KoToolProxy.cpp.

278{
279 KoPointerEvent ev(event, point);
280 mouseMoveEvent(&ev);
281 d->lastPointerEvent = ev.deepCopyEvent();
282}
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 229 of file KoToolProxy.cpp.

230{
231 d->mouseLeaveWorkaround = false;
232 KoInputDevice id;
233 d->controller->toolManager()->priv()->switchInputDevice(id);
234 d->mouseDownPoint = ev->pos();
235
236
237 // this tries to make sure another mouse press event doesn't happen
238 // before a release event happens
239 if (d->isToolPressed) {
241 d->scrollTimer.stop();
242
243 if (d->activeTool) {
245 }
246
247 d->isToolPressed = false;
248
249 return;
250 }
251
252 countMultiClick(ev, QEvent::MouseButtonPress);
253
254 d->isToolPressed = true;
255}
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, KoToolProxyPrivate::controller, countMultiClick(), d, KoToolProxyPrivate::isToolPressed, KoToolProxyPrivate::mouseDownPoint, KoToolProxyPrivate::mouseLeaveWorkaround, KoToolBase::mouseReleaseEvent(), mouseReleaseEvent(), KoPointerEvent::pos(), KoToolProxyPrivate::scrollTimer, and KoCanvasController::toolManager.

◆ mousePressEvent() [2/2]

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

Forwarded to the current KoToolBase.

Definition at line 257 of file KoToolProxy.cpp.

258{
259 KoPointerEvent ev(event, point);
260 mousePressEvent(&ev);
261 d->lastPointerEvent = ev.deepCopyEvent();
262}

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

◆ mouseReleaseEvent() [1/2]

void KoToolProxy::mouseReleaseEvent ( KoPointerEvent * event)

Definition at line 309 of file KoToolProxy.cpp.

310{
311 d->mouseLeaveWorkaround = false;
312 KoInputDevice id;
313 d->controller->toolManager()->priv()->switchInputDevice(id);
314 d->scrollTimer.stop();
315
316 if (d->activeTool) {
318 } else {
319 event->ignore();
320 }
321
322 d->isToolPressed = false;
323}

References KoToolProxyPrivate::activeTool, KoToolProxyPrivate::controller, d, KoToolProxyPrivate::isToolPressed, KoToolProxyPrivate::mouseLeaveWorkaround, KoToolBase::mouseReleaseEvent(), KoToolProxyPrivate::scrollTimer, and KoCanvasController::toolManager.

◆ mouseReleaseEvent() [2/2]

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

Forwarded to the current KoToolBase.

Definition at line 302 of file KoToolProxy.cpp.

303{
304 KoPointerEvent ev(event, point);
306 d->lastPointerEvent = ev.deepCopyEvent();
307}

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

◆ multiClickCount()

int KoToolProxy::multiClickCount ( ) const
protected

Definition at line 146 of file KoToolProxy.cpp.

147{
148 return d->multiClickCount;
149}

References d, and KoToolProxyPrivate::multiClickCount.

◆ paint()

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

Forwarded to the current KoToolBase.

Definition at line 131 of file KoToolProxy.cpp.

132{
133 if (d->activeTool) d->activeTool->paint(painter, converter);
134}
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 474 of file KoToolProxy.cpp.

475{
476 bool success = false;
477
478 if (d->activeTool && d->isActiveLayerEditable()) {
479 success = d->activeTool->paste();
480 }
481
482 return success;
483}
virtual bool paste()

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

◆ popupActionsMenu()

QMenu * KoToolProxy::popupActionsMenu ( )

Forwarded to the current KoToolBase.

Definition at line 372 of file KoToolProxy.cpp.

373{
374 return d->activeTool ? d->activeTool->popupActionsMenu() : 0;
375}
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 377 of file KoToolProxy.cpp.

378{
379 return d->activeTool ? d->activeTool->popupWidget() : nullptr;
380}
virtual KisPopupWidgetInterface * popupWidget()
Definition KoToolBase.h:340

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

◆ priv()

KoToolProxyPrivate * KoToolProxy::priv ( )

Definition at line 571 of file KoToolProxy.cpp.

572{
573 return d;
574}

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 526 of file KoToolProxy.cpp.

527{
528 if(e->type()==QEvent::ShortcutOverride
529 && d->activeTool
531 && (static_cast<QKeyEvent*>(e)->modifiers()==Qt::NoModifier ||
532 static_cast<QKeyEvent*>(e)->modifiers()==Qt::ShiftModifier
533#ifdef Q_OS_WIN
534 // we should disallow AltGr shortcuts if a text box is in focus
535 || (static_cast<QKeyEvent*>(e)->modifiers()==(Qt::AltModifier | Qt::ControlModifier) &&
536 static_cast<QKeyEvent*>(e)->key() < Qt::Key_Escape)
537#endif
538 )) {
539 e->accept();
540 }
541}
bool isInTextMode() const

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

◆ repaintDecorations()

void KoToolProxy::repaintDecorations ( )

Forwarded to the current KoToolBase.

Definition at line 136 of file KoToolProxy.cpp.

137{
139}
virtual void repaintDecorations()

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

◆ requestRedoDuringStroke

void KoToolProxy::requestRedoDuringStroke ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 550 of file KoToolProxy.cpp.

551{
552 if (d->activeTool) {
554 }
555}
virtual void requestRedoDuringStroke()

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

◆ requestStrokeCancellation

void KoToolProxy::requestStrokeCancellation ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 557 of file KoToolProxy.cpp.

558{
559 if (d->activeTool) {
561 }
562}
virtual void requestStrokeCancellation()

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

◆ requestStrokeEnd

void KoToolProxy::requestStrokeEnd ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 564 of file KoToolProxy.cpp.

565{
566 if (d->activeTool) {
568 }
569}
virtual void requestStrokeEnd()

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

◆ requestUndoDuringStroke

void KoToolProxy::requestUndoDuringStroke ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 543 of file KoToolProxy.cpp.

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

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

◆ selectAll()

bool KoToolProxy::selectAll ( )

Forwarded to the current KoToolBase.

Definition at line 485 of file KoToolProxy.cpp.

486{
487 bool success = false;
488
489 if (d->activeTool && d->isActiveLayerEditable()) {
490 success = d->activeTool->selectAll();
491 }
492
493 return success;
494}
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 382 of file KoToolProxy.cpp.

383{
384 if (d->activeTool) {
385 disconnect(d->activeTool, SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
386 d->toolPriorityShortcuts.clear();
387 }
388
389 d->activeTool = tool;
390
391 if (tool) {
394 if (collection) {
395 Q_FOREACH(QAction *action, collection->actions()) {
396
397 const QVariant prop = action->property("tool_action");
398
399 if (prop.isValid()) {
400 const QStringList tools = prop.toStringList();
401
402 if (tools.contains(d->activeTool->toolId())) {
403 const QList<QKeySequence> shortcuts = action->shortcuts();
404 std::copy(shortcuts.begin(), shortcuts.end(),
405 std::back_inserter(d->toolPriorityShortcuts));
406 }
407 }
408 }
409 }
410
411 connect(d->activeTool, SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
413 Q_EMIT toolChanged(tool->toolId());
414 }
415}
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, 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 197 of file KoToolProxy.cpp.

198{
199 // We get these events exclusively from KisToolProxy - accept them
200 event->accept();
201
203 KoInputDevice::convertPointerType(event), event->uniqueId());
204 d->controller->toolManager()->priv()->switchInputDevice(id);
205
206 KoPointerEvent ev(event, point);
207
208 switch (event->type()) {
209 case QEvent::TabletPress:
210 countMultiClick(&ev, event->type());
211 break;
212 case QEvent::TabletRelease:
213 d->scrollTimer.stop();
214 if (d->activeTool)
216 break;
217 case QEvent::TabletMove:
218 if (d->activeTool)
220 d->checkAutoScroll(ev);
221 default:
222 ; // ignore the rest.
223 }
224
225 d->mouseLeaveWorkaround = true;
226 d->lastPointerEvent = ev.deepCopyEvent();
227}
static InputDevice convertDeviceType(QTabletEvent *event)
static Pointer convertPointerType(QTabletEvent *event)

References KoToolProxyPrivate::activeTool, KoToolProxyPrivate::checkAutoScroll(), KoToolProxyPrivate::controller, KoInputDevice::convertDeviceType(), KoInputDevice::convertPointerType(), countMultiClick(), d, KoPointerEvent::deepCopyEvent(), KoToolProxyPrivate::lastPointerEvent, KoToolProxyPrivate::mouseLeaveWorkaround, KoToolBase::mouseMoveEvent(), KoToolBase::mouseReleaseEvent(), KoToolProxyPrivate::scrollTimer, and KoCanvasController::toolManager.

◆ 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 447 of file KoToolProxy.cpp.

448{
449 return d->toolPriorityShortcuts;
450}

References d, and KoToolProxyPrivate::toolPriorityShortcuts.

◆ touchEvent()

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

Definition at line 417 of file KoToolProxy.cpp.

418{
419 // only one "touchpoint" events should be here
420 KoPointerEvent ev(event, point);
421
422 if (!d->activeTool) return;
423
424 switch (event->touchPointStates())
425 {
426 case Qt::TouchPointPressed:
427 countMultiClick(&ev, QEvent::TouchBegin);
428 break;
429 case Qt::TouchPointMoved:
431 break;
432 case Qt::TouchPointReleased:
434 break;
435 default: // don't care
436 ;
437 }
438
439 d->lastPointerEvent = ev.deepCopyEvent();
440}

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: