Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix text not getting selected when created on a normal layer

Luna Lovecrafta03e5d036720
diff --git a/libs/flake/KoShapeController.cpp b/libs/flake/KoShapeController.cpp
index 3e72cfbaad..878572a67d 100644
--- a/libs/flake/KoShapeController.cpp
+++ b/libs/flake/KoShapeController.cpp
@@ -39,7 +39,7 @@ public:
KoCanvasBase *canvas;
KoShapeControllerBase *shapeController;
- KUndo2Command* addShape(KoShape *shape, bool showDialog, KoShapeContainer *parentShape, KUndo2Command *parent) {
+ KUndo2Command* addShape(KoShape *shape, bool showDialog, KoShapeContainer **parentShape, KUndo2Command *parent) {
if (canvas) {
if (showDialog && !shape->shapeId().isEmpty()) {
@@ -87,17 +87,17 @@ public:
return addShapesDirect({shape}, parentShape, parent);
}
- KUndo2Command* addShapesDirect(const QList<KoShape*> shapes, KoShapeContainer *parentShape, KUndo2Command *parent)
+ KUndo2Command* addShapesDirect(const QList<KoShape*> shapes, KoShapeContainer **parentShape, KUndo2Command *parent)
{
KUndo2Command *resultCommand = 0;
- if (!parentShape) {
+ if (!*parentShape) {
resultCommand = new KUndo2Command(parent);
- parentShape = shapeController->createParentForShapes(shapes, false, resultCommand);
- KUndo2Command *addShapeCommand = new KoShapeCreateCommand(shapeController, shapes, parentShape, resultCommand);
+ *parentShape = shapeController->createParentForShapes(shapes, false, resultCommand);
+ KUndo2Command *addShapeCommand = new KoShapeCreateCommand(shapeController, shapes, *parentShape, resultCommand);
resultCommand->setText(addShapeCommand->text());
} else {
- resultCommand = new KoShapeCreateCommand(shapeController, shapes, parentShape, parent);
+ resultCommand = new KoShapeCreateCommand(shapeController, shapes, *parentShape, parent);
}
return resultCommand;
@@ -122,19 +122,19 @@ void KoShapeController::reset()
d->shapeController = 0;
}
-KUndo2Command* KoShapeController::addShape(KoShape *shape, KoShapeContainer *parentShape, KUndo2Command *parent)
+KUndo2Command* KoShapeController::addShape(KoShape *shape, KoShapeContainer **parentShape, KUndo2Command *parent)
{
return d->addShape(shape, true, parentShape, parent);
}
-KUndo2Command* KoShapeController::addShapeDirect(KoShape *shape, KoShapeContainer *parentShape, KUndo2Command *parent)
+KUndo2Command* KoShapeController::addShapeDirect(KoShape *shape, KoShapeContainer **parentShape, KUndo2Command *parent)
{
return d->addShapesDirect({shape}, parentShape, parent);
}
KUndo2Command *KoShapeController::addShapesDirect(const QList<KoShape *> shapes, KoShapeContainer *parentShape, KUndo2Command *parent)
{
- return d->addShapesDirect(shapes, parentShape, parent);
+ return d->addShapesDirect(shapes, &parentShape, parent);
}
KUndo2Command* KoShapeController::removeShape(KoShape *shape, KUndo2Command *parent)
diff --git a/libs/flake/KoShapeController.h b/libs/flake/KoShapeController.h
index d44271e24b..96d88a3b03 100644
--- a/libs/flake/KoShapeController.h
+++ b/libs/flake/KoShapeController.h
@@ -62,7 +62,7 @@ public:
* @return command which will insert the shape into the document or 0 if the
* insertion was cancelled. The command is not yet executed.
*/
- KUndo2Command* addShape(KoShape *shape, KoShapeContainer *parentShape, KUndo2Command *parent = 0);
+ KUndo2Command* addShape(KoShape *shape, KoShapeContainer **parentShape, KUndo2Command *parent = 0);
/**
* @brief Add a shape to the document, skipping any dialogs or other user interaction.
@@ -73,7 +73,7 @@ public:
*
* @return command which will insert the shape into the document. The command is not yet executed.
*/
- KUndo2Command* addShapeDirect(KoShape *shape, KoShapeContainer *parentShape, KUndo2Command *parent = 0);
+ KUndo2Command* addShapeDirect(KoShape *shape, KoShapeContainer **parentShape, KUndo2Command *parent = 0);
/**
* @brief Add shapes to the document, skipping any dialogs or other user interaction.
diff --git a/libs/flake/tests/TestShapePainting.cpp b/libs/flake/tests/TestShapePainting.cpp
index b58adc7405..5e51eb2ac3 100644
--- a/libs/flake/tests/TestShapePainting.cpp
+++ b/libs/flake/tests/TestShapePainting.cpp
@@ -268,7 +268,10 @@ void TestShapePainting::testGroupUngroup()
group->setName("group");
KUndo2Command groupingCommand;
- canvas.shapeController()->addShapeDirect(group, shapesFakeLayer.data(), &groupingCommand);
+
+ KoShapeContainer* parent = shapesFakeLayer.data();
+ canvas.shapeController()->addShapeDirect(group, &parent, &groupingCommand);
+
new KoShapeGroupCommand(group, groupedShapes, true, &groupingCommand);
groupingCommand.redo();
diff --git a/libs/flake/tools/KoPathTool.cpp b/libs/flake/tools/KoPathTool.cpp
index a393c0400a..e5efef92ca 100644
--- a/libs/flake/tools/KoPathTool.cpp
+++ b/libs/flake/tools/KoPathTool.cpp
@@ -323,7 +323,7 @@ void KoPathTool::convertToPath()
KoShape *outlineShape = shape->textOutline();
KoShapeContainer *parent = shape->parent();
- canvas()->shapeController()->addShapeDirect(outlineShape, parent, cmd);
+ canvas()->shapeController()->addShapeDirect(outlineShape, &parent, cmd);
newSelectedShapes << outlineShape;
}
diff --git a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
index 251f97716c..f2a737bdd1 100644
--- a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
+++ b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
@@ -1808,7 +1808,7 @@ void DefaultTool::selectionBooleanOp(int booleanOp)
newShape->setZIndex(referenceShape->zIndex());
KoShapeContainer *parent = referenceShape->parent();
- canvas()->shapeController()->addShapeDirect(newShape, parent, cmd);
+ canvas()->shapeController()->addShapeDirect(newShape, &parent, cmd);
newSelectedShapes << newShape;
}
diff --git a/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp b/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp
index 6e1e5d4514..ba4bbcebef 100644
--- a/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp
+++ b/plugins/tools/svgtexttool/SvgCreateTextStrategy.cpp
@@ -24,6 +24,7 @@
#include "commands/KoSvgTextAddRemoveShapeCommands.h"
#include "KoSvgTextPathInfoChangeCommand.h"
#include "kis_global.h"
+#include "kis_shape_layer.h"
#include "kundo2command.h"
#include <KoPathShape.h>
@@ -154,8 +155,12 @@ KUndo2Command *SvgCreateTextStrategy::createCommand()
KUndo2Command *parentCommand = new KUndo2Command();
new KoKeepShapesSelectedCommand(tool->koSelection()->selectedShapes(), {}, tool->canvas()->selectedShapesProxy(), false, parentCommand);
+ KoShapeContainer* parent = nullptr;
+
+ KUndo2Command *cmd = tool->canvas()->shapeController()->addShape(textShape, &parent, parentCommand);
+
+ KisShapeLayer *layer = dynamic_cast<KisShapeLayer *>(parent);
- KUndo2Command *cmd = tool->canvas()->shapeController()->addShape(textShape, 0, parentCommand);
parentCommand->setText(cmd->text());
if (m_flowShape) {
@@ -187,7 +192,7 @@ KUndo2Command *SvgCreateTextStrategy::createCommand()
}
}
- new KoKeepShapesSelectedCommand({}, {textShape}, tool->canvas()->selectedShapesProxy(), true, parentCommand);
+ new KoKeepShapesSelectedCommand({}, {textShape}, layer->selectedShapesProxy(), true, parentCommand);
tool->canvas()->snapGuide()->reset();
return parentCommand;
diff --git a/plugins/tools/svgtexttool/SvgTextTool.cpp b/plugins/tools/svgtexttool/SvgTextTool.cpp
index 95d89e34c5..771b0174f6 100644
--- a/plugins/tools/svgtexttool/SvgTextTool.cpp
+++ b/plugins/tools/svgtexttool/SvgTextTool.cpp
@@ -518,7 +518,8 @@ void SvgTextTool::requestStrokeEnd()
useCursor(Qt::ArrowCursor);
m_textOnPathHelper.setStrategyActive(false);
} else if (isInTextMode()) {
- canvas()->shapeManager()->selection()->deselectAll();
+ // This doesn't seem to be necessary?
+ // canvas()->selectedShapesProxy()->selection()->deselectAll();
}
}
}
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
index 7946373e0f..35046733e5 100644
--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
@@ -294,7 +294,7 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
newSelectedShapes << shape.data();
}
- tool()->canvas()->shapeController()->addShapeDirect(shape.take(), parent, cmd.data());
+ tool()->canvas()->shapeController()->addShapeDirect(shape.take(), &parent, cmd.data());
}
diff --git a/plugins/tools/tool_knife/RemoveGutterStrategy.cpp b/plugins/tools/tool_knife/RemoveGutterStrategy.cpp
index c37c2b27e8..20ba3b34ce 100644
--- a/plugins/tools/tool_knife/RemoveGutterStrategy.cpp
+++ b/plugins/tools/tool_knife/RemoveGutterStrategy.cpp
@@ -295,7 +295,7 @@ void RemoveGutterStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
KoShapeContainer *parent = referenceShape->parent();
- tool()->canvas()->shapeController()->addShapeDirect(resultShape, parent, cmd);
+ tool()->canvas()->shapeController()->addShapeDirect(resultShape, &parent, cmd);
if (isSelected[shapeOrigIndexes[0]] || isSelected[shapeOrigIndexes[1]]) { // if either is selected
resultSelectedShapes << resultShape;