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
 
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 KoToolManager::instance()->priv()->registerToolProxy(this, canvas);
124
125 connect(&d->scrollTimer, SIGNAL(timeout()), this, SLOT(timeout()));
126}
KoToolManager::Private * priv()
static KoToolManager * instance()
Return the toolmanager singleton.
KoToolProxyPrivate *const d
KoCanvasBase * canvas() const
friend class KoToolProxyPrivate

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

◆ ~KoToolProxy()

KoToolProxy::~KoToolProxy ( )
override

Definition at line 128 of file KoToolProxy.cpp.

129{
130 delete d;
131}

References d.

Member Function Documentation

◆ canvas()

KoCanvasBase * KoToolProxy::canvas ( ) const
protected

Definition at line 143 of file KoToolProxy.cpp.

144{
145 return d->controller->canvas();
146}
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 470 of file KoToolProxy.cpp.

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

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

465{
467 d->activeTool->cut();
468}
virtual void cut()

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

◆ deleteSelection()

void KoToolProxy::deleteSelection ( )

Forwarded to the current KoToolBase.

Definition at line 522 of file KoToolProxy.cpp.

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

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

◆ deselect()

void KoToolProxy::deselect ( )

Forwarded to the current KoToolBase.

Definition at line 498 of file KoToolProxy.cpp.

499{
500 if (d->activeTool)
502}
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 510 of file KoToolProxy.cpp.

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

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

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

346{
347 if (d->activeTool) {
349 }
350}
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 364 of file KoToolProxy.cpp.

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

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

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

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

◆ inputMethodEvent()

void KoToolProxy::inputMethodEvent ( QInputMethodEvent * event)

Forwarded to the current KoToolBase.

Definition at line 359 of file KoToolProxy.cpp.

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

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

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

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

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

◆ lastDeliveredPointerEvent()

KoPointerEvent * KoToolProxy::lastDeliveredPointerEvent ( ) const

Definition at line 444 of file KoToolProxy.cpp.

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

References d, and KoToolProxyPrivate::lastPointerEvent.

◆ mouseDoubleClickEvent() [1/2]

void KoToolProxy::mouseDoubleClickEvent ( KoPointerEvent * event)

Definition at line 273 of file KoToolProxy.cpp.

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

267{
268 KoPointerEvent ev(event, point);
270 d->lastPointerEvent = ev.deepCopyEvent();
271}
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 286 of file KoToolProxy.cpp.

287{
288 if (d->mouseLeaveWorkaround) {
289 d->mouseLeaveWorkaround = false;
290 return;
291 }
292 KoInputDevice id;
293 KoToolManager::instance()->priv()->switchInputDevice(id);
294 if (d->activeTool == 0) {
295 event->ignore();
296 return;
297 }
298
299 d->activeTool->mouseMoveEvent(event);
300
301 d->checkAutoScroll(*event);
302}
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 279 of file KoToolProxy.cpp.

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

232{
233 d->mouseLeaveWorkaround = false;
234 KoInputDevice id;
235 KoToolManager::instance()->priv()->switchInputDevice(id);
236 d->mouseDownPoint = ev->pos();
237
238
239 // this tries to make sure another mouse press event doesn't happen
240 // before a release event happens
241 if (d->isToolPressed) {
243 d->scrollTimer.stop();
244
245 if (d->activeTool) {
247 }
248
249 d->isToolPressed = false;
250
251 return;
252 }
253
254 countMultiClick(ev, QEvent::MouseButtonPress);
255
256 d->isToolPressed = true;
257}
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 259 of file KoToolProxy.cpp.

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

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

◆ mouseReleaseEvent() [1/2]

void KoToolProxy::mouseReleaseEvent ( KoPointerEvent * event)

Definition at line 311 of file KoToolProxy.cpp.

312{
313 d->mouseLeaveWorkaround = false;
314 KoInputDevice id;
315 KoToolManager::instance()->priv()->switchInputDevice(id);
316 d->scrollTimer.stop();
317
318 if (d->activeTool) {
320 } else {
321 event->ignore();
322 }
323
324 d->isToolPressed = false;
325}

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

305{
306 KoPointerEvent ev(event, point);
308 d->lastPointerEvent = ev.deepCopyEvent();
309}

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

◆ multiClickCount()

int KoToolProxy::multiClickCount ( ) const
protected

Definition at line 148 of file KoToolProxy.cpp.

149{
150 return d->multiClickCount;
151}

References d, and KoToolProxyPrivate::multiClickCount.

◆ paint()

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

Forwarded to the current KoToolBase.

Definition at line 133 of file KoToolProxy.cpp.

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

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

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

◆ popupActionsMenu()

QMenu * KoToolProxy::popupActionsMenu ( )

Forwarded to the current KoToolBase.

Definition at line 374 of file KoToolProxy.cpp.

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

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

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

◆ priv()

KoToolProxyPrivate * KoToolProxy::priv ( )

Definition at line 573 of file KoToolProxy.cpp.

574{
575 return d;
576}

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

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

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

◆ repaintDecorations()

void KoToolProxy::repaintDecorations ( )

Forwarded to the current KoToolBase.

Definition at line 138 of file KoToolProxy.cpp.

139{
141}
virtual void repaintDecorations()

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

◆ requestRedoDuringStroke

void KoToolProxy::requestRedoDuringStroke ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 552 of file KoToolProxy.cpp.

553{
554 if (d->activeTool) {
556 }
557}
virtual void requestRedoDuringStroke()

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

◆ requestStrokeCancellation

void KoToolProxy::requestStrokeCancellation ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 559 of file KoToolProxy.cpp.

560{
561 if (d->activeTool) {
563 }
564}
virtual void requestStrokeCancellation()

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

◆ requestStrokeEnd

void KoToolProxy::requestStrokeEnd ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 566 of file KoToolProxy.cpp.

567{
568 if (d->activeTool) {
570 }
571}
virtual void requestStrokeEnd()

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

◆ requestUndoDuringStroke

void KoToolProxy::requestUndoDuringStroke ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 545 of file KoToolProxy.cpp.

546{
547 if (d->activeTool) {
549 }
550}
virtual void requestUndoDuringStroke()

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

◆ selectAll()

bool KoToolProxy::selectAll ( )

Forwarded to the current KoToolBase.

Definition at line 487 of file KoToolProxy.cpp.

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

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

200{
201 // We get these events exclusively from KisToolProxy - accept them
202 event->accept();
203
205 KoInputDevice::convertPointerType(event), event->uniqueId());
206 KoToolManager::instance()->priv()->switchInputDevice(id);
207
208 KoPointerEvent ev(event, point);
209
210 switch (event->type()) {
211 case QEvent::TabletPress:
212 countMultiClick(&ev, event->type());
213 break;
214 case QEvent::TabletRelease:
215 d->scrollTimer.stop();
216 if (d->activeTool)
218 break;
219 case QEvent::TabletMove:
220 if (d->activeTool)
222 d->checkAutoScroll(ev);
223 default:
224 ; // ignore the rest.
225 }
226
227 d->mouseLeaveWorkaround = true;
228 d->lastPointerEvent = ev.deepCopyEvent();
229}
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 449 of file KoToolProxy.cpp.

450{
451 return d->toolPriorityShortcuts;
452}

References d, and KoToolProxyPrivate::toolPriorityShortcuts.

◆ touchEvent()

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

Definition at line 419 of file KoToolProxy.cpp.

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

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: