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

111 : QObject(parent),
112 d(new KoToolProxyPrivate(this))
113{
114 KoToolManager::instance()->priv()->registerToolProxy(this, canvas);
115
116 connect(&d->scrollTimer, SIGNAL(timeout()), this, SLOT(timeout()));
117}
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 119 of file KoToolProxy.cpp.

120{
121 delete d;
122}

References d.

Member Function Documentation

◆ canvas()

KoCanvasBase * KoToolProxy::canvas ( ) const
protected

Definition at line 134 of file KoToolProxy.cpp.

135{
136 return d->controller->canvas();
137}
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 456 of file KoToolProxy.cpp.

457{
458 if (d->activeTool)
459 d->activeTool->copy();
460}
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 139 of file KoToolProxy.cpp.

140{
141 QPointF globalPoint = ev->globalPos();
142
143 if (d->multiClickSource != eventType) {
144 d->multiClickCount = 0;
145 }
146
147 if (d->multiClickGlobalPoint != globalPoint) {
148 if (qAbs(globalPoint.x() - d->multiClickGlobalPoint.x()) > 5||
149 qAbs(globalPoint.y() - d->multiClickGlobalPoint.y()) > 5) {
150 d->multiClickCount = 0;
151 }
152 d->multiClickGlobalPoint = globalPoint;
153 }
154
155 if (d->multiClickCount && d->multiClickTimeStamp.elapsed() < QApplication::doubleClickInterval()) {
156 // One more multiclick;
158 } else {
159 d->multiClickTimeStamp.start();
160 d->multiClickCount = 1;
161 d->multiClickSource = QEvent::Type(eventType);
162 }
163
164 if (d->activeTool) {
165 switch (d->multiClickCount) {
166 case 0:
167 case 1:
169 break;
170 case 2:
172 break;
173 case 3:
174 default:
176 break;
177 }
178 } else {
179 d->multiClickCount = 0;
180 ev->ignore();
181 }
182
183}
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 450 of file KoToolProxy.cpp.

451{
453 d->activeTool->cut();
454}
virtual void cut()

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

◆ deleteSelection()

void KoToolProxy::deleteSelection ( )

Forwarded to the current KoToolBase.

Definition at line 508 of file KoToolProxy.cpp.

509{
510 if (d->activeTool)
512}
virtual void deleteSelection()

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

◆ deselect()

void KoToolProxy::deselect ( )

Forwarded to the current KoToolBase.

Definition at line 484 of file KoToolProxy.cpp.

485{
486 if (d->activeTool)
488}
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 496 of file KoToolProxy.cpp.

497{
498 if (d->activeTool)
499 d->activeTool->dragLeaveEvent(event);
500}
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 490 of file KoToolProxy.cpp.

491{
492 if (d->activeTool)
493 d->activeTool->dragMoveEvent(event, point);
494}
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 502 of file KoToolProxy.cpp.

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

332{
333 if (d->activeTool) {
335 }
336}
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 350 of file KoToolProxy.cpp.

351{
352 if (d->activeTool) d->activeTool->focusInEvent(event);
353}
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 355 of file KoToolProxy.cpp.

356{
357 if (d->activeTool) d->activeTool->focusOutEvent(event);
358}
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 445 of file KoToolProxy.cpp.

446{
447 return d->activeTool ? d->activeTool->hasSelection() : false;
448}
virtual bool hasSelection()

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

◆ inputMethodEvent()

void KoToolProxy::inputMethodEvent ( QInputMethodEvent * event)

Forwarded to the current KoToolBase.

Definition at line 345 of file KoToolProxy.cpp.

346{
348}
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 338 of file KoToolProxy.cpp.

339{
340 if (d->activeTool)
341 return d->activeTool->inputMethodQuery(query);
342 return QVariant();
343}
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 313 of file KoToolProxy.cpp.

314{
315 if (d->activeTool)
316 d->activeTool->keyPressEvent(event);
317 else
318 event->ignore();
319}
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 321 of file KoToolProxy.cpp.

322{
323 if (d->activeTool)
325 else
326 event->ignore();
327
328 d->isToolPressed = false;
329}
virtual void keyReleaseEvent(QKeyEvent *event)

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

◆ lastDeliveredPointerEvent()

KoPointerEvent * KoToolProxy::lastDeliveredPointerEvent ( ) const

Definition at line 430 of file KoToolProxy.cpp.

431{
432 return d->lastPointerEvent ? &(d->lastPointerEvent->event) : 0;
433}
boost::optional< KoPointerEventWrapper > lastPointerEvent

References d, and KoToolProxyPrivate::lastPointerEvent.

◆ mouseDoubleClickEvent() [1/2]

void KoToolProxy::mouseDoubleClickEvent ( KoPointerEvent * event)

Definition at line 259 of file KoToolProxy.cpp.

260{
261 // let us handle it as any other mousepress (where we then detect multi clicks
262 mousePressEvent(event);
263}
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 252 of file KoToolProxy.cpp.

253{
254 KoPointerEvent ev(event, point);
256 d->lastPointerEvent = ev.deepCopyEvent();
257}
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 272 of file KoToolProxy.cpp.

273{
274 if (d->mouseLeaveWorkaround) {
275 d->mouseLeaveWorkaround = false;
276 return;
277 }
278 KoInputDevice id;
279 KoToolManager::instance()->priv()->switchInputDevice(id);
280 if (d->activeTool == 0) {
281 event->ignore();
282 return;
283 }
284
285 d->activeTool->mouseMoveEvent(event);
286
287 d->checkAutoScroll(*event);
288}
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 265 of file KoToolProxy.cpp.

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

218{
219 d->mouseLeaveWorkaround = false;
220 KoInputDevice id;
221 KoToolManager::instance()->priv()->switchInputDevice(id);
222 d->mouseDownPoint = ev->pos();
223
224
225 // this tries to make sure another mouse press event doesn't happen
226 // before a release event happens
227 if (d->isToolPressed) {
229 d->scrollTimer.stop();
230
231 if (d->activeTool) {
233 }
234
235 d->isToolPressed = false;
236
237 return;
238 }
239
240 countMultiClick(ev, QEvent::MouseButtonPress);
241
242 d->isToolPressed = true;
243}
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 245 of file KoToolProxy.cpp.

246{
247 KoPointerEvent ev(event, point);
248 mousePressEvent(&ev);
249 d->lastPointerEvent = ev.deepCopyEvent();
250}

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

◆ mouseReleaseEvent() [1/2]

void KoToolProxy::mouseReleaseEvent ( KoPointerEvent * event)

Definition at line 297 of file KoToolProxy.cpp.

298{
299 d->mouseLeaveWorkaround = false;
300 KoInputDevice id;
301 KoToolManager::instance()->priv()->switchInputDevice(id);
302 d->scrollTimer.stop();
303
304 if (d->activeTool) {
306 } else {
307 event->ignore();
308 }
309
310 d->isToolPressed = false;
311}

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

291{
292 KoPointerEvent ev(event, point);
294 d->lastPointerEvent = ev.deepCopyEvent();
295}

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

125{
126 if (d->activeTool) d->activeTool->paint(painter, converter);
127}
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 462 of file KoToolProxy.cpp.

463{
464 bool success = false;
465
466 if (d->activeTool && d->isActiveLayerEditable()) {
467 success = d->activeTool->paste();
468 }
469
470 return success;
471}
virtual bool paste()

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

◆ popupActionsMenu()

QMenu * KoToolProxy::popupActionsMenu ( )

Forwarded to the current KoToolBase.

Definition at line 360 of file KoToolProxy.cpp.

361{
362 return d->activeTool ? d->activeTool->popupActionsMenu() : 0;
363}
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 365 of file KoToolProxy.cpp.

366{
367 return d->activeTool ? d->activeTool->popupWidget() : nullptr;
368}
virtual KisPopupWidgetInterface * popupWidget()
Definition KoToolBase.h:340

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

◆ priv()

KoToolProxyPrivate * KoToolProxy::priv ( )

Definition at line 559 of file KoToolProxy.cpp.

560{
561 return d;
562}

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

515{
516 if(e->type()==QEvent::ShortcutOverride
517 && d->activeTool
519 && (static_cast<QKeyEvent*>(e)->modifiers()==Qt::NoModifier ||
520 static_cast<QKeyEvent*>(e)->modifiers()==Qt::ShiftModifier
521#ifdef Q_OS_WIN
522 // we should disallow AltGr shortcuts if a text box is in focus
523 || (static_cast<QKeyEvent*>(e)->modifiers()==(Qt::AltModifier | Qt::ControlModifier) &&
524 static_cast<QKeyEvent*>(e)->key() < Qt::Key_Escape)
525#endif
526 )) {
527 e->accept();
528 }
529}
bool isInTextMode() const

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

◆ repaintDecorations()

void KoToolProxy::repaintDecorations ( )

Forwarded to the current KoToolBase.

Definition at line 129 of file KoToolProxy.cpp.

130{
132}
virtual void repaintDecorations()

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

◆ requestRedoDuringStroke

void KoToolProxy::requestRedoDuringStroke ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 538 of file KoToolProxy.cpp.

539{
540 if (d->activeTool) {
542 }
543}
virtual void requestRedoDuringStroke()

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

◆ requestStrokeCancellation

void KoToolProxy::requestStrokeCancellation ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 545 of file KoToolProxy.cpp.

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

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

◆ requestStrokeEnd

void KoToolProxy::requestStrokeEnd ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 552 of file KoToolProxy.cpp.

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

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

◆ requestUndoDuringStroke

void KoToolProxy::requestUndoDuringStroke ( )
protectedslot

Forwarded to the current KoToolBase.

Definition at line 531 of file KoToolProxy.cpp.

532{
533 if (d->activeTool) {
535 }
536}
virtual void requestUndoDuringStroke()

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

◆ selectAll()

bool KoToolProxy::selectAll ( )

Forwarded to the current KoToolBase.

Definition at line 473 of file KoToolProxy.cpp.

474{
475 bool success = false;
476
477 if (d->activeTool && d->isActiveLayerEditable()) {
478 success = d->activeTool->selectAll();
479 }
480
481 return success;
482}
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 370 of file KoToolProxy.cpp.

371{
372 if (d->activeTool) {
373 disconnect(d->activeTool, SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
374 d->toolPriorityShortcuts.clear();
375 }
376
377 d->activeTool = tool;
378
379 if (tool) {
382 if (collection) {
383 Q_FOREACH(QAction *action, collection->actions()) {
384
385 const QVariant prop = action->property("tool_action");
386
387 if (prop.isValid()) {
388 const QStringList tools = prop.toStringList();
389
390 if (tools.contains(d->activeTool->toolId())) {
391 const QList<QKeySequence> shortcuts = action->shortcuts();
392 std::copy(shortcuts.begin(), shortcuts.end(),
393 std::back_inserter(d->toolPriorityShortcuts));
394 }
395 }
396 }
397 }
398
399 connect(d->activeTool, SIGNAL(selectionChanged(bool)), this, SLOT(selectionChanged(bool)));
401 Q_EMIT toolChanged(tool->toolId());
402 }
403}
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 185 of file KoToolProxy.cpp.

186{
187 // We get these events exclusively from KisToolProxy - accept them
188 event->accept();
189
191 KoInputDevice::convertPointerType(event), event->uniqueId());
192 KoToolManager::instance()->priv()->switchInputDevice(id);
193
194 KoPointerEvent ev(event, point);
195
196 switch (event->type()) {
197 case QEvent::TabletPress:
198 countMultiClick(&ev, event->type());
199 break;
200 case QEvent::TabletRelease:
201 d->scrollTimer.stop();
202 if (d->activeTool)
204 break;
205 case QEvent::TabletMove:
206 if (d->activeTool)
208 d->checkAutoScroll(ev);
209 default:
210 ; // ignore the rest.
211 }
212
213 d->mouseLeaveWorkaround = true;
214 d->lastPointerEvent = ev.deepCopyEvent();
215}
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 435 of file KoToolProxy.cpp.

436{
437 return d->toolPriorityShortcuts;
438}

References d, and KoToolProxyPrivate::toolPriorityShortcuts.

◆ touchEvent()

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

Definition at line 405 of file KoToolProxy.cpp.

406{
407 // only one "touchpoint" events should be here
408 KoPointerEvent ev(event, point);
409
410 if (!d->activeTool) return;
411
412 switch (event->touchPointStates())
413 {
414 case Qt::TouchPointPressed:
415 countMultiClick(&ev, QEvent::TouchBegin);
416 break;
417 case Qt::TouchPointMoved:
419 break;
420 case Qt::TouchPointReleased:
422 break;
423 default: // don't care
424 ;
425 }
426
427 d->lastPointerEvent = ev.deepCopyEvent();
428}

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: