[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [krita/petrovic/text-tool-ux] /: Get text click to open editor
From:       Scott Petrovic <null () kde ! org>
Date:       2018-08-03 23:31:55
Message-ID: E1fljY3-0007Ao-Rg () code ! kde ! org
[Download RAW message or body]

Git commit 200efc0bc065bfe37a79633fd34ea7180490d901 by Scott Petrovic.
Committed on 03/08/2018 at 23:31.
Pushed by scottpetrovic into branch 'petrovic/text-tool-ux'.

Get text click to open editor

M  +10   -0    libs/flake/KoSelectedShapesProxy.cpp
M  +7    -0    libs/flake/KoSelectedShapesProxy.h
M  +28   -3    plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
M  +5    -0    plugins/tools/svgtexttool/SvgTextTool.cpp

https://commits.kde.org/krita/200efc0bc065bfe37a79633fd34ea7180490d901

diff --git a/libs/flake/KoSelectedShapesProxy.cpp \
b/libs/flake/KoSelectedShapesProxy.cpp index e5ba757ae4c..6a70ca7939e 100644
--- a/libs/flake/KoSelectedShapesProxy.cpp
+++ b/libs/flake/KoSelectedShapesProxy.cpp
@@ -23,3 +23,13 @@ KoSelectedShapesProxy::KoSelectedShapesProxy(QObject *parent)
 {
 }
 
+bool KoSelectedShapesProxy::isRequestingToBeEdited()
+{
+    return m_isRequestingEditing;
+}
+
+void KoSelectedShapesProxy::setRequestingToBeEdited(bool value)
+{
+    m_isRequestingEditing = value;
+}
+
diff --git a/libs/flake/KoSelectedShapesProxy.h b/libs/flake/KoSelectedShapesProxy.h
index 9b39dded817..b6ac138d152 100644
--- a/libs/flake/KoSelectedShapesProxy.h
+++ b/libs/flake/KoSelectedShapesProxy.h
@@ -44,6 +44,10 @@ public:
      */
     virtual KoSelection *selection() = 0;
 
+
+    bool isRequestingToBeEdited();
+    void setRequestingToBeEdited(bool value);
+
 Q_SIGNALS:
 
     // forwards a corresponding signal of KoShapeManager
@@ -54,6 +58,9 @@ Q_SIGNALS:
 
     // forwards a corresponding signal of KoSelection
     void currentLayerChanged(const KoShapeLayer *layer);
+
+private:
+    bool m_isRequestingEditing = false;
 };
 
 #endif // KOSELECTEDSHAPESPROXY_H
diff --git a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp \
b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp index \
                5f80bbe932d..4bf6b9b7bd4 100644
--- a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
+++ b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
@@ -144,7 +144,7 @@ public:
         KoShapeRubberSelectStrategy::paint(painter, converter);
     }
 
-    void finishInteraction(Qt::KeyboardModifiers modifiers) override
+    void finishInteraction(Qt::KeyboardModifiers modifiers = 0) override
     {
         Q_UNUSED(modifiers);
         DefaultTool *defaultTool = dynamic_cast<DefaultTool*>(tool());
@@ -152,6 +152,7 @@ public:
 
         KoSelection * selection = defaultTool->koSelection();
 
+
         const bool useContainedMode = currentMode() == CoveringSelection;
 
         QList<KoShape *> shapes =
@@ -743,7 +744,9 @@ void DefaultTool::mousePressEvent(KoPointerEvent *event)
 
 void DefaultTool::mouseMoveEvent(KoPointerEvent *event)
 {
+
     KoInteractionTool::mouseMoveEvent(event);
+
     if (currentStrategy() == 0 && koSelection() && koSelection()->count() > 0) {
         QRectF bound = handlesSize();
 
@@ -797,6 +800,20 @@ void DefaultTool::mouseReleaseEvent(KoPointerEvent *event)
     KoInteractionTool::mouseReleaseEvent(event);
     updateCursor();
 
+    // test to see if we are selecting button before we decide to check for a \
selection/de-selection +    const bool selectingTextEditorButton = \
isSelectingTextEditorButton(event->point); +    KoSelection *selection = \
koSelection(); +
+    canvas()->selectedShapesProxy()->setRequestingToBeEdited(selectingTextEditorButton);
 +    if (selectingTextEditorButton) {
+        // activate text tool
+        KoToolManager::instance()->switchToolRequested(KoToolManager::instance()->preferredToolForSelection(selection->selectedShapes()));
 +    }
+
+
+
+
+
     // updates the whole canvas. This makes sure the decorations that are shown are \
                refreshed
     canvas()->updateCanvas(QRectF(0,0,canvas()->canvasWidget()->width(), \
canvas()->canvasWidget()->height()));  }
@@ -926,6 +943,7 @@ KoSelection *DefaultTool::koSelection() const
 {
     Q_ASSERT(canvas());
     Q_ASSERT(canvas()->selectedShapesProxy());
+
     return canvas()->selectedShapesProxy()->selection();
 }
 
@@ -1086,6 +1104,8 @@ void DefaultTool::activate(ToolActivation activation, const \
QSet<KoShape *> &sha  repaintDecorations();
     updateActions();
 
+
+
     if (m_tabbedOptionWidget) {
         m_tabbedOptionWidget->activate();
     }
@@ -1479,7 +1499,6 @@ KoInteractionStrategy \
*DefaultTool::createStrategy(KoPointerEvent *event)  
     bool insideSelection = false;
     KoFlake::SelectionHandle handle = handleAt(event->point, &insideSelection);
-    isSelectingTextEditorButton(event->point);
 
     bool editableShape = !selection->selectedEditableShapes().isEmpty();
 
@@ -1561,7 +1580,12 @@ KoInteractionStrategy \
*DefaultTool::createStrategy(KoPointerEvent *event)  }
 
         if (!selectMultiple && !selectNextInStack) {
-            if (insideSelection) {
+
+            // move the selection if we hold and drag with the text editor button
+            // this also helps with how the click events flow to resolve this \
createStrategy +            const bool selectingTextEditorButton = \
isSelectingTextEditorButton(event->point); +
+            if (insideSelection || selectingTextEditorButton ) {
                 return new ShapeMoveStrategy(this, selection, event->point);
             }
         }
@@ -1595,6 +1619,7 @@ KoInteractionStrategy \
*DefaultTool::createStrategy(KoPointerEvent *event)  }
         return new ShapeMoveStrategy(this, selection, event->point);
     }
+
     return 0;
 }
 
diff --git a/plugins/tools/svgtexttool/SvgTextTool.cpp \
b/plugins/tools/svgtexttool/SvgTextTool.cpp index 29816d3a679..596622730c9 100644
--- a/plugins/tools/svgtexttool/SvgTextTool.cpp
+++ b/plugins/tools/svgtexttool/SvgTextTool.cpp
@@ -80,6 +80,11 @@ void SvgTextTool::activate(ToolActivation activation, const \
                QSet<KoShape *> &sha
         KoSvgTextShape *textShape = \
dynamic_cast<KoSvgTextShape*>(*shapes.constBegin());  if (!textShape) {
             koSelection()->deselectAll();
+        } else {
+            // if we are a text shape...and the proxy tells us we want to edit the \
shape. open the text editor +            if \
(canvas()->selectedShapesProxy()->isRequestingToBeEdited()) { +                \
showEditor(); +            }
         }
     } else if (shapes.size() > 1) {
         KoSvgTextShape *foundTextShape = 0;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic