[krita/kazakov/svg-loading] /: Make the shortcuts in Edit Tool be consistent with Selection Tool

Dmitry Kazakov null at kde.org
Fri Feb 17 19:21:41 UTC 2017


Git commit baa9d8fcaba476677d8def3fb5f411f6478cd649 by Dmitry Kazakov.
Committed on 17/02/2017 at 14:19.
Pushed by dkazakov into branch 'kazakov/svg-loading'.

Make the shortcuts in Edit Tool be consistent with Selection Tool

Shift + click, Shift + drag --- multiselection
Ctrl + Click on point --- changle point type: corner, smooth, symmetric


CC:kimageshop at kde.org

M  +13   -2    libs/flake/tools/KoPathPointRubberSelectStrategy.cpp
M  +3    -1    libs/flake/tools/KoPathPointRubberSelectStrategy.h
M  +13   -28   libs/flake/tools/KoPathTool.cpp
M  +2    -2    libs/flake/tools/KoPathToolHandle.cpp
M  +1    -1    plugins/flake/textshape/TextToolFactory.cpp

https://commits.kde.org/krita/baa9d8fcaba476677d8def3fb5f411f6478cd649

diff --git a/libs/flake/tools/KoPathPointRubberSelectStrategy.cpp b/libs/flake/tools/KoPathPointRubberSelectStrategy.cpp
index d58f6b0650e..05d6dff98a2 100644
--- a/libs/flake/tools/KoPathPointRubberSelectStrategy.cpp
+++ b/libs/flake/tools/KoPathPointRubberSelectStrategy.cpp
@@ -31,14 +31,25 @@ KoPathPointRubberSelectStrategy::KoPathPointRubberSelectStrategy(KoPathTool *too
 {
 }
 
+void KoPathPointRubberSelectStrategy::handleMouseMove(const QPointF &p, Qt::KeyboardModifiers modifiers)
+{
+    KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
+    if (selection && !(modifiers & Qt::ShiftModifier)) {
+        selection->clear();
+    }
+
+    KoShapeRubberSelectStrategy::handleMouseMove(p, modifiers);
+}
+
 void KoPathPointRubberSelectStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
 {
     Q_D(KoShapeRubberSelectStrategy);
     KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
-    if (! selection)
+    if (!selection) {
         return;
+    }
 
-    selection->selectPoints(d->selectedRect(), !(modifiers & Qt::ControlModifier));
+    selection->selectPoints(d->selectedRect(), !(modifiers & Qt::ShiftModifier));
     m_tool->canvas()->updateCanvas(d->selectedRect().normalized());
     selection->repaint();
 }
diff --git a/libs/flake/tools/KoPathPointRubberSelectStrategy.h b/libs/flake/tools/KoPathPointRubberSelectStrategy.h
index 87b04f7e2a2..9817c8c4d11 100644
--- a/libs/flake/tools/KoPathPointRubberSelectStrategy.h
+++ b/libs/flake/tools/KoPathPointRubberSelectStrategy.h
@@ -33,7 +33,9 @@ class KoPathPointRubberSelectStrategy : public KoShapeRubberSelectStrategy
 public:
     KoPathPointRubberSelectStrategy(KoPathTool *tool, const QPointF &clicked);
     virtual ~KoPathPointRubberSelectStrategy() {}
-    virtual void finishInteraction(Qt::KeyboardModifiers modifiers);
+
+    void handleMouseMove(const QPointF &p, Qt::KeyboardModifiers modifiers) override;
+    void finishInteraction(Qt::KeyboardModifiers modifiers) override;
 
 private:
     /// pointer to the path tool
diff --git a/libs/flake/tools/KoPathTool.cpp b/libs/flake/tools/KoPathTool.cpp
index c90fe3c0748..8a7bc209d62 100644
--- a/libs/flake/tools/KoPathTool.cpp
+++ b/libs/flake/tools/KoPathTool.cpp
@@ -491,10 +491,6 @@ void KoPathTool::mousePressEvent(KoPointerEvent *event)
                 delete m_activeSegment;
                 m_activeSegment = 0;
             } else {
-                if ((event->modifiers() & Qt::ControlModifier) == 0) {
-                    m_pointSelection.clear();
-                }
-                // start rubberband selection
                 Q_ASSERT(m_currentStrategy == 0);
                 m_currentStrategy = new KoPathPointRubberSelectStrategy(this, event->point);
                 event->accept();
@@ -514,8 +510,10 @@ void KoPathTool::mouseMoveEvent(KoPointerEvent *event)
 
         // repaint new handle positions
         m_pointSelection.repaint();
-        if (m_activeHandle)
+        if (m_activeHandle) {
             m_activeHandle->repaint();
+        }
+
         return;
     }
 
@@ -612,8 +610,11 @@ void KoPathTool::mouseMoveEvent(KoPointerEvent *event)
     }
 
     useCursor(m_selectCursor);
-    if (m_activeHandle)
+
+    if (m_activeHandle) {
         m_activeHandle->repaint();
+    }
+
     delete m_activeHandle;
     m_activeHandle = 0;
 
@@ -681,17 +682,6 @@ void KoPathTool::keyPressEvent(QKeyEvent *event)
         }
     } else {
         switch (event->key()) {
-// TODO move these to the actions in the constructor.
-        case Qt::Key_I: {
-            KoDocumentResourceManager *rm = d->canvas->shapeController()->resourceManager();
-            int handleRadius = rm->handleRadius();
-            if (event->modifiers() & Qt::ControlModifier)
-                handleRadius--;
-            else
-                handleRadius++;
-            rm->setHandleRadius(handleRadius);
-            break;
-        }
 #ifndef NDEBUG
         case Qt::Key_D:
             if (m_pointSelection.objectCount() == 1) {
@@ -740,14 +730,11 @@ void KoPathTool::mouseDoubleClickEvent(KoPointerEvent *event)
     event->ignore();
 
     // check if we are doing something else at the moment
-    if (m_currentStrategy)
-        return;
+    if (m_currentStrategy) return;
 
-    PathSegment *s = segmentAtPoint(event->point);
-    if (!s)
-        return;
+    QScopedPointer<PathSegment> s(segmentAtPoint(event->point));
 
-    if (s->isValid()) {
+    if (s && s->isValid()) {
         QList<KoPathPointData> segments;
         segments.append(KoPathPointData(s->path, s->path->pathPointIndex(s->segmentStart)));
         KoPathPointInsertCommand *cmd = new KoPathPointInsertCommand(segments, s->positionOnSegment);
@@ -759,7 +746,6 @@ void KoPathTool::mouseDoubleClickEvent(KoPointerEvent *event)
         updateActions();
         event->accept();
     }
-    delete s;
 }
 
 KoPathTool::PathSegment* KoPathTool::segmentAtPoint(const QPointF &point)
@@ -772,7 +758,7 @@ KoPathTool::PathSegment* KoPathTool::segmentAtPoint(const QPointF &point)
     // the max allowed distance from a segment
     const qreal maxSquaredDistance = clickOffset.x()*clickOffset.x();
 
-    PathSegment *segment = new PathSegment;
+    QScopedPointer<PathSegment> segment(new PathSegment);
 
     Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
         KoParameterShape * parameterShape = dynamic_cast<KoParameterShape*>(shape);
@@ -805,11 +791,10 @@ KoPathTool::PathSegment* KoPathTool::segmentAtPoint(const QPointF &point)
     }
 
     if (!segment->isValid()) {
-        delete segment;
-        segment = 0;
+        segment.reset();
     }
 
-    return segment;
+    return segment.take();
 }
 
 void KoPathTool::activate(ToolActivation toolActivation, const QSet<KoShape*> &shapes)
diff --git a/libs/flake/tools/KoPathToolHandle.cpp b/libs/flake/tools/KoPathToolHandle.cpp
index 3c0fe0fdd77..89e44b70b9c 100644
--- a/libs/flake/tools/KoPathToolHandle.cpp
+++ b/libs/flake/tools/KoPathToolHandle.cpp
@@ -89,11 +89,11 @@ KoInteractionStrategy * PointHandle::handleMousePress(KoPointerEvent *event)
 {
     if ((event->button() & Qt::LeftButton) == 0)
         return 0;
-    if ((event->modifiers() & Qt::ShiftModifier) == 0) { // no shift pressed.
+    if ((event->modifiers() & Qt::ControlModifier) == 0) { // no shift pressed.
         KoPathToolSelection * selection = dynamic_cast<KoPathToolSelection*>(m_tool->selection());
 
         // control select adds/removes points to/from the selection
-        if (event->modifiers() & Qt::ControlModifier) {
+        if (event->modifiers() & Qt::ShiftModifier) {
             if (selection->contains(m_activePoint)) {
                 selection->remove(m_activePoint);
             } else {
diff --git a/plugins/flake/textshape/TextToolFactory.cpp b/plugins/flake/textshape/TextToolFactory.cpp
index 0be037e0d7a..d032de3f640 100644
--- a/plugins/flake/textshape/TextToolFactory.cpp
+++ b/plugins/flake/textshape/TextToolFactory.cpp
@@ -31,7 +31,7 @@ TextToolFactory::TextToolFactory()
     setToolTip(i18n("Text editing"));
     setSection(dynamicToolType() + ",calligrawords,calligraauthor");
     setIconName(koIconNameCStr("tool-text"));
-    setPriority(0);
+    setPriority(2);
     setActivationShapeId(TextShape_SHAPEID "," AnnotationShape_SHAPEID);
 }
 



More information about the kimageshop mailing list