[krita] /: Connect David Revoy's selection mode cursors to actual tools

Dmitry Kazakov null at kde.org
Wed Sep 5 17:15:29 BST 2018


Git commit a1dc9ad7494156cf79b225086bd0f941864baab7 by Dmitry Kazakov.
Committed on 05/09/2018 at 16:15.
Pushed by dkazakov into branch 'master'.

Connect David Revoy's selection mode cursors to actual tools

After three(!) years! :)

CC:kimageshop at kde.org

M  +2    -0    libs/ui/tool/kis_selection_tool_config_widget_helper.cpp
M  +1    -0    libs/ui/tool/kis_tool_select_base.h
M  +11   -0    plugins/tools/selectiontools/kis_tool_select_contiguous.cc
M  +1    -0    plugins/tools/selectiontools/kis_tool_select_contiguous.h
M  +12   -0    plugins/tools/selectiontools/kis_tool_select_elliptical.cc
M  +1    -0    plugins/tools/selectiontools/kis_tool_select_elliptical.h
M  +12   -0    plugins/tools/selectiontools/kis_tool_select_outline.cc
M  +1    -0    plugins/tools/selectiontools/kis_tool_select_outline.h
M  +11   -0    plugins/tools/selectiontools/kis_tool_select_path.cc
M  +1    -0    plugins/tools/selectiontools/kis_tool_select_path.h
M  +12   -0    plugins/tools/selectiontools/kis_tool_select_polygonal.cc
M  +1    -0    plugins/tools/selectiontools/kis_tool_select_polygonal.h
M  +11   -0    plugins/tools/selectiontools/kis_tool_select_rectangular.cc
M  +3    -3    plugins/tools/selectiontools/kis_tool_select_rectangular.h
M  +11   -0    plugins/tools/selectiontools/kis_tool_select_similar.cc
M  +2    -1    plugins/tools/selectiontools/kis_tool_select_similar.h

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

diff --git a/libs/ui/tool/kis_selection_tool_config_widget_helper.cpp b/libs/ui/tool/kis_selection_tool_config_widget_helper.cpp
index 94a3b95a2b5..e415d3940e2 100644
--- a/libs/ui/tool/kis_selection_tool_config_widget_helper.cpp
+++ b/libs/ui/tool/kis_selection_tool_config_widget_helper.cpp
@@ -81,6 +81,8 @@ void KisSelectionToolConfigWidgetHelper::slotWidgetActionChanged(int action)
 
         KConfigGroup cfg = KSharedConfig::openConfig()->group("KisToolSelectBase");
         cfg.writeEntry("selectionAction", action);
+
+        emit selectionActionChanged(action);
     }
 }
 
diff --git a/libs/ui/tool/kis_tool_select_base.h b/libs/ui/tool/kis_tool_select_base.h
index 06027631ee8..39d13463b08 100644
--- a/libs/ui/tool/kis_tool_select_base.h
+++ b/libs/ui/tool/kis_tool_select_base.h
@@ -178,6 +178,7 @@ public:
 
         m_widgetHelper.createOptionWidget(canvas, this->toolId());
         this->connect(this, SIGNAL(isActiveChanged(bool)), &m_widgetHelper, SLOT(slotToolActivatedChanged(bool)));
+        this->connect(&m_widgetHelper, SIGNAL(selectionActionChanged(int)), this, SLOT(resetCursorStyle()));
 
         updateActionShortcutToolTips();
 
diff --git a/plugins/tools/selectiontools/kis_tool_select_contiguous.cc b/plugins/tools/selectiontools/kis_tool_select_contiguous.cc
index 1343ad5ecd8..ccd09870106 100644
--- a/plugins/tools/selectiontools/kis_tool_select_contiguous.cc
+++ b/plugins/tools/selectiontools/kis_tool_select_contiguous.cc
@@ -252,3 +252,14 @@ QMenu* KisToolSelectContiguous::popupActionsMenu()
 
     return KisSelectionToolHelper::getSelectionContextMenu(kisCanvas);
 }
+
+void KisToolSelectContiguous::resetCursorStyle()
+{
+    if (selectionAction() == SELECTION_ADD) {
+        useCursor(KisCursor::load("tool_contiguous_selection_cursor_add.png", 6, 6));
+    } else if (selectionAction() == SELECTION_SUBTRACT) {
+        useCursor(KisCursor::load("tool_contiguous_selection_cursor_sub.png", 6, 6));
+    } else {
+        KisToolSelect::resetCursorStyle();
+    }
+}
diff --git a/plugins/tools/selectiontools/kis_tool_select_contiguous.h b/plugins/tools/selectiontools/kis_tool_select_contiguous.h
index 717cbbd2846..2b51188a00d 100644
--- a/plugins/tools/selectiontools/kis_tool_select_contiguous.h
+++ b/plugins/tools/selectiontools/kis_tool_select_contiguous.h
@@ -48,6 +48,7 @@ public:
     void beginPrimaryAction(KoPointerEvent *event) override;
 
     QMenu* popupActionsMenu() override;
+    void resetCursorStyle();
 
 protected:
 
diff --git a/plugins/tools/selectiontools/kis_tool_select_elliptical.cc b/plugins/tools/selectiontools/kis_tool_select_elliptical.cc
index 30e1ea1e438..ea7a000b0ab 100644
--- a/plugins/tools/selectiontools/kis_tool_select_elliptical.cc
+++ b/plugins/tools/selectiontools/kis_tool_select_elliptical.cc
@@ -106,3 +106,15 @@ QMenu* KisToolSelectElliptical::popupActionsMenu()
 
     return KisSelectionToolHelper::getSelectionContextMenu(kisCanvas);
 }
+
+void KisToolSelectElliptical::resetCursorStyle()
+{
+    if (selectionAction() == SELECTION_ADD) {
+        useCursor(KisCursor::load("tool_elliptical_selection_cursor_add.png", 6, 6));
+    } else if (selectionAction() == SELECTION_SUBTRACT) {
+        useCursor(KisCursor::load("tool_elliptical_selection_cursor_sub.png", 6, 6));
+    } else {
+        KisToolSelectBase<__KisToolSelectEllipticalLocal>::resetCursorStyle();
+    }
+}
+
diff --git a/plugins/tools/selectiontools/kis_tool_select_elliptical.h b/plugins/tools/selectiontools/kis_tool_select_elliptical.h
index ed425e90dfb..b23efa89e69 100644
--- a/plugins/tools/selectiontools/kis_tool_select_elliptical.h
+++ b/plugins/tools/selectiontools/kis_tool_select_elliptical.h
@@ -63,6 +63,7 @@ class KisToolSelectElliptical : public KisToolSelectEllipticalTemplate
 public:
     KisToolSelectElliptical(KoCanvasBase* canvas);
     QMenu* popupActionsMenu() override;
+    void resetCursorStyle();
 
 public Q_SLOTS:
     void setSelectionAction(int);
diff --git a/plugins/tools/selectiontools/kis_tool_select_outline.cc b/plugins/tools/selectiontools/kis_tool_select_outline.cc
index 3b3f62d942e..fd68997fd11 100644
--- a/plugins/tools/selectiontools/kis_tool_select_outline.cc
+++ b/plugins/tools/selectiontools/kis_tool_select_outline.cc
@@ -278,3 +278,15 @@ QMenu* KisToolSelectOutline::popupActionsMenu()
 
     return KisSelectionToolHelper::getSelectionContextMenu(kisCanvas);
 }
+
+void KisToolSelectOutline::resetCursorStyle()
+{
+    if (selectionAction() == SELECTION_ADD) {
+        useCursor(KisCursor::load("tool_outline_selection_cursor_add.png", 6, 6));
+    } else if (selectionAction() == SELECTION_SUBTRACT) {
+        useCursor(KisCursor::load("tool_outline_selection_cursor_sub.png", 6, 6));
+    } else {
+        KisToolSelect::resetCursorStyle();
+    }
+}
+
diff --git a/plugins/tools/selectiontools/kis_tool_select_outline.h b/plugins/tools/selectiontools/kis_tool_select_outline.h
index 799bf691a2b..e5938fadcb1 100644
--- a/plugins/tools/selectiontools/kis_tool_select_outline.h
+++ b/plugins/tools/selectiontools/kis_tool_select_outline.h
@@ -49,6 +49,7 @@ public:
     void mouseMoveEvent(KoPointerEvent *event) override;
 
     QMenu* popupActionsMenu() override;
+    void resetCursorStyle();
 
 public Q_SLOTS:
     void deactivate() override;
diff --git a/plugins/tools/selectiontools/kis_tool_select_path.cc b/plugins/tools/selectiontools/kis_tool_select_path.cc
index e647891a65f..0ace61079de 100644
--- a/plugins/tools/selectiontools/kis_tool_select_path.cc
+++ b/plugins/tools/selectiontools/kis_tool_select_path.cc
@@ -173,4 +173,15 @@ void __KisToolSelectPathLocalTool::addPathShape(KoPathShape* pathShape)
     }
 }
 
+void KisToolSelectPath::resetCursorStyle()
+{
+    if (selectionAction() == SELECTION_ADD) {
+        useCursor(KisCursor::load("tool_polygonal_selection_cursor_add.png", 6, 6));
+    } else if (selectionAction() == SELECTION_SUBTRACT) {
+        useCursor(KisCursor::load("tool_polygonal_selection_cursor_sub.png", 6, 6));
+    } else {
+        KisToolSelectBase<KisDelegatedSelectPathWrapper>::resetCursorStyle();
+    }
+}
+
 
diff --git a/plugins/tools/selectiontools/kis_tool_select_path.h b/plugins/tools/selectiontools/kis_tool_select_path.h
index 6b811c3cdcc..43822995456 100644
--- a/plugins/tools/selectiontools/kis_tool_select_path.h
+++ b/plugins/tools/selectiontools/kis_tool_select_path.h
@@ -75,6 +75,7 @@ public:
     KisToolSelectPath(KoCanvasBase * canvas);
     void mousePressEvent(KoPointerEvent* event) override;
     bool eventFilter(QObject *obj, QEvent *event) override;
+    void resetCursorStyle();
 
 protected:
     void requestStrokeCancellation() override;
diff --git a/plugins/tools/selectiontools/kis_tool_select_polygonal.cc b/plugins/tools/selectiontools/kis_tool_select_polygonal.cc
index ea79b6e03eb..5aaab21f8aa 100644
--- a/plugins/tools/selectiontools/kis_tool_select_polygonal.cc
+++ b/plugins/tools/selectiontools/kis_tool_select_polygonal.cc
@@ -110,3 +110,15 @@ QMenu* KisToolSelectPolygonal::popupActionsMenu()
     return KisSelectionToolHelper::getSelectionContextMenu(kisCanvas);
 }
 
+
+void KisToolSelectPolygonal::resetCursorStyle()
+{
+    if (selectionAction() == SELECTION_ADD) {
+        useCursor(KisCursor::load("tool_polygonal_selection_cursor_add.png", 6, 6));
+    } else if (selectionAction() == SELECTION_SUBTRACT) {
+        useCursor(KisCursor::load("tool_polygonal_selection_cursor_sub.png", 6, 6));
+    } else {
+        KisToolSelectBase<__KisToolSelectPolygonalLocal>::resetCursorStyle();
+    }
+}
+
diff --git a/plugins/tools/selectiontools/kis_tool_select_polygonal.h b/plugins/tools/selectiontools/kis_tool_select_polygonal.h
index 7cb6359ad4a..f47afb3cc42 100644
--- a/plugins/tools/selectiontools/kis_tool_select_polygonal.h
+++ b/plugins/tools/selectiontools/kis_tool_select_polygonal.h
@@ -50,6 +50,7 @@ class KisToolSelectPolygonal : public KisToolSelectBase<__KisToolSelectPolygonal
 public:
     KisToolSelectPolygonal(KoCanvasBase* canvas);
     QMenu* popupActionsMenu() override;
+    void resetCursorStyle();
 
 public Q_SLOTS:
     void setSelectionAction(int);
diff --git a/plugins/tools/selectiontools/kis_tool_select_rectangular.cc b/plugins/tools/selectiontools/kis_tool_select_rectangular.cc
index c6b703cb516..0007ff26361 100644
--- a/plugins/tools/selectiontools/kis_tool_select_rectangular.cc
+++ b/plugins/tools/selectiontools/kis_tool_select_rectangular.cc
@@ -123,3 +123,14 @@ QMenu* KisToolSelectRectangular::popupActionsMenu()
     return KisSelectionToolHelper::getSelectionContextMenu(kisCanvas);
 }
 
+void KisToolSelectRectangular::resetCursorStyle()
+{
+    if (selectionAction() == SELECTION_ADD) {
+        useCursor(KisCursor::load("tool_rectangular_selection_cursor_add.png", 6, 6));
+    } else if (selectionAction() == SELECTION_SUBTRACT) {
+        useCursor(KisCursor::load("tool_rectangular_selection_cursor_sub.png", 6, 6));
+    } else {
+        KisToolSelectBase<__KisToolSelectRectangularLocal>::resetCursorStyle();
+    }
+}
+
diff --git a/plugins/tools/selectiontools/kis_tool_select_rectangular.h b/plugins/tools/selectiontools/kis_tool_select_rectangular.h
index 987a9fb7dcf..88e604b8afa 100644
--- a/plugins/tools/selectiontools/kis_tool_select_rectangular.h
+++ b/plugins/tools/selectiontools/kis_tool_select_rectangular.h
@@ -38,9 +38,7 @@ class __KisToolSelectRectangularLocal : public KisToolRectangleBase
 public:
     __KisToolSelectRectangularLocal(KoCanvasBase * canvas);
 
-    bool hasUserInteractionRunning() const
-;
-
+    bool hasUserInteractionRunning() const;
 
 protected:
     virtual SelectionMode selectionMode() const = 0;
@@ -58,6 +56,8 @@ public:
     KisToolSelectRectangular(KoCanvasBase* canvas);
     QMenu* popupActionsMenu() override;
 
+    void resetCursorStyle();
+
 public Q_SLOTS:
     void setSelectionAction(int);
 };
diff --git a/plugins/tools/selectiontools/kis_tool_select_similar.cc b/plugins/tools/selectiontools/kis_tool_select_similar.cc
index a2278998789..7d5b005b0f8 100644
--- a/plugins/tools/selectiontools/kis_tool_select_similar.cc
+++ b/plugins/tools/selectiontools/kis_tool_select_similar.cc
@@ -187,3 +187,14 @@ QMenu* KisToolSelectSimilar::popupActionsMenu()
 
     return KisSelectionToolHelper::getSelectionContextMenu(kisCanvas);
 }
+
+void KisToolSelectSimilar::resetCursorStyle()
+{
+    if (selectionAction() == SELECTION_ADD) {
+        useCursor(KisCursor::load("tool_similar_selection_cursor_add.png", 6, 6));
+    } else if (selectionAction() == SELECTION_SUBTRACT) {
+        useCursor(KisCursor::load("tool_similar_selection_cursor_sub.png", 6, 6));
+    } else {
+        KisToolSelect::resetCursorStyle();
+    }
+}
diff --git a/plugins/tools/selectiontools/kis_tool_select_similar.h b/plugins/tools/selectiontools/kis_tool_select_similar.h
index 67068260f5c..a8ec8747e80 100644
--- a/plugins/tools/selectiontools/kis_tool_select_similar.h
+++ b/plugins/tools/selectiontools/kis_tool_select_similar.h
@@ -38,8 +38,9 @@ public:
     void paint(QPainter&, const KoViewConverter &) override {}
     QWidget* createOptionWidget() override;
     QMenu* popupActionsMenu() override;
+    void resetCursorStyle();
 
-    public Q_SLOTS:
+public Q_SLOTS:
     void activate(ToolActivation toolActivation, const QSet<KoShape*> &shapes) override;
     void slotSetFuzziness(int);
     void setSelectionAction(int);



More information about the kimageshop mailing list