Changeset View
Changeset View
Standalone View
Standalone View
libs/basicflakes/tools/KoCreatePathTool.cpp
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | 117 | if (pathShape.stroke()) { | |||
---|---|---|---|---|---|
120 | painter.restore(); | 120 | painter.restore(); | ||
121 | } | 121 | } | ||
122 | } | 122 | } | ||
123 | 123 | | |||
124 | void KoCreatePathTool::mousePressEvent(KoPointerEvent *event) | 124 | void KoCreatePathTool::mousePressEvent(KoPointerEvent *event) | ||
125 | { | 125 | { | ||
126 | Q_D(KoCreatePathTool); | 126 | Q_D(KoCreatePathTool); | ||
127 | 127 | | |||
128 | //Right click removes last point | ||||
129 | if (event->button() == Qt::RightButton) { | ||||
130 | removeLastPoint(); | ||||
131 | return; | ||||
132 | } | ||||
133 | | ||||
128 | const bool isOverFirstPoint = d->shape && | 134 | const bool isOverFirstPoint = d->shape && | ||
129 | handleGrabRect(d->firstPoint->point()).contains(event->point); | 135 | handleGrabRect(d->firstPoint->point()).contains(event->point); | ||
130 | bool haveCloseModifier = (listeningToModifiers() && (event->modifiers() & Qt::ShiftModifier)); | 136 | bool haveCloseModifier = (listeningToModifiers() && (event->modifiers() & Qt::ShiftModifier)); | ||
131 | 137 | | |||
132 | if ((event->button() == Qt::RightButton) || ((event->button() == Qt::LeftButton) && haveCloseModifier && !isOverFirstPoint)) { | 138 | if ((event->button() == Qt::LeftButton) && haveCloseModifier && !isOverFirstPoint) { | ||
133 | endPathWithoutLastPoint(); | 139 | endPathWithoutLastPoint(); | ||
134 | return; | 140 | return; | ||
135 | } | 141 | } | ||
136 | 142 | | |||
137 | d->finishAfterThisPoint = false; | 143 | d->finishAfterThisPoint = false; | ||
138 | 144 | | |||
139 | if (pathStarted()) { | 145 | if (pathStarted()) { | ||
140 | if (isOverFirstPoint) { | 146 | if (isOverFirstPoint) { | ||
▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Line(s) | 356 | if (d->shape) { | |||
351 | canvas()->updateCanvas(handlePaintRect(d->firstPoint->point())); | 357 | canvas()->updateCanvas(handlePaintRect(d->firstPoint->point())); | ||
352 | canvas()->updateCanvas(d->shape->boundingRect()); | 358 | canvas()->updateCanvas(d->shape->boundingRect()); | ||
353 | d->firstPoint = 0; | 359 | d->firstPoint = 0; | ||
354 | d->activePoint = 0; | 360 | d->activePoint = 0; | ||
355 | } | 361 | } | ||
356 | d->cleanUp(); | 362 | d->cleanUp(); | ||
357 | } | 363 | } | ||
358 | 364 | | |||
365 | void KoCreatePathTool::removeLastPoint() | ||||
366 | { | ||||
367 | Q_D(KoCreatePathTool); | ||||
368 | | ||||
369 | if ((d->shape)) { | ||||
370 | KoPathPointIndex lastPointIndex = d->shape->pathPointIndex(d->activePoint); | ||||
371 | | ||||
372 | if (lastPointIndex.second > 1) { | ||||
373 | lastPointIndex.second--; | ||||
374 | delete d->shape->removePoint(lastPointIndex); | ||||
375 | | ||||
376 | d->hoveredPoint = 0; | ||||
377 | | ||||
378 | d->repaintActivePoint(); | ||||
379 | canvas()->updateCanvas(d->shape->boundingRect()); | ||||
380 | } | ||||
381 | } | ||||
382 | } | ||||
383 | | ||||
359 | void KoCreatePathTool::activate(ToolActivation, const QSet<KoShape*> &) | 384 | void KoCreatePathTool::activate(ToolActivation, const QSet<KoShape*> &) | ||
360 | { | 385 | { | ||
361 | Q_D(KoCreatePathTool); | 386 | Q_D(KoCreatePathTool); | ||
362 | useCursor(Qt::ArrowCursor); | 387 | useCursor(Qt::ArrowCursor); | ||
363 | 388 | | |||
364 | // retrieve the actual global handle radius | 389 | // retrieve the actual global handle radius | ||
365 | d->handleRadius = handleRadius(); | 390 | d->handleRadius = handleRadius(); | ||
366 | 391 | | |||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |