Commit b82e5756 authored by Salil Kapur's avatar Salil Kapur
Browse files

BUG: 324170

Add shortcut to undo last polygonal selection point(s)
parent ec7095b3
......@@ -27,6 +27,10 @@
#include <KoViewConverter.h>
#include "kis_tool_polyline_base.h"
#include "kis_canvas2.h"
#include <kis_view2.h>
#include <kis_action.h>
#include <kactioncollection.h>
#define SNAPPING_THRESHOLD 10
#define SNAPPING_HANDLE_RADIUS 8
......@@ -38,6 +42,12 @@ KisToolPolylineBase::KisToolPolylineBase(KoCanvasBase * canvas, KisToolPolyline
m_type(type),
m_closeSnappingActivated(false)
{
KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(this->canvas());
KAction *undo_polygon_selection = new KAction("Undo Polygon Selection Points",this);
undo_polygon_selection->setShortcut(QKeySequence(Qt::ShiftModifier + Qt::Key_Z));
kiscanvas->view()->actionCollection()->addAction("undo_polygon_selection", undo_polygon_selection);
connect(undo_polygon_selection, SIGNAL(triggered()), SLOT(undoSelection()));
}
void KisToolPolylineBase::deactivate()
......@@ -137,6 +147,24 @@ void KisToolPolylineBase::mouseDoubleClickEvent(KoPointerEvent *event)
}
}
void KisToolPolylineBase::undoSelection()
{
if(m_dragging) {
//Update canvas for drag before undo
QRectF updateRect = dragBoundingRect();
updateRect |= dragBoundingRect();
updateCanvasViewRect(updateRect);
//Update canvas for last segment
QRectF rect = pixelToView(QRectF(m_points.last(), m_points.at(m_points.size()-2)).normalized());
rect.adjust(-PREVIEW_LINE_WIDTH, -PREVIEW_LINE_WIDTH, PREVIEW_LINE_WIDTH, PREVIEW_LINE_WIDTH);
rect |= rect;
updateCanvasViewRect(rect);
m_points.pop_back();
m_dragStart = m_points.last();
}
}
void KisToolPolylineBase::paint(QPainter& gc, const KoViewConverter &converter)
{
Q_UNUSED(converter);
......
......@@ -53,6 +53,9 @@ private:
void updateArea();
QRectF dragBoundingRect();
private slots:
virtual void undoSelection();
private:
QPointF m_dragStart;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment