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++
Type Setting: Add command to remove transforms.
Wolthera van Hövell tot Westerflierbd4f047964c5
diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cppindex d0954d914a..c0d8e246ff 100644--- a/libs/flake/text/KoSvgTextShape.cpp+++ b/libs/flake/text/KoSvgTextShape.cpp@@ -1321,6 +1321,22 @@ QList<KoSvgTextCharacterInfo> KoSvgTextShape::getPositionsAndRotationsForRange(creturn infos;}+void KoSvgTextShape::removeTransformsFromRange(const int startPos, const int endPos)+{+ if ((startPos < 0 && startPos == endPos) || d->cursorPos.isEmpty()) {+ return;+ }+ const int finalPos = d->cursorPos.size()-1;+ const int startIndex = d->cursorPos.at(qBound(0, qMin(startPos, endPos), finalPos)).index;+ const int endIndex = d->cursorPos.at(qBound(0, qMax(startPos, endPos), finalPos)).index;++ d->removeTransforms(d->textData, startIndex, endIndex-startIndex);++ KoSvgTextShape::Private::cleanUp(d->textData);+ notifyChanged();+ shapeChangedPriv(ContentChanged);+}+KisForest<KoSvgTextContentElement>::child_iterator findNodeIndexForPropertyIdImpl(KisForest<KoSvgTextContentElement>::child_iterator parent, KoSvgTextProperties::PropertyId propertyId) {for (auto child = KisForestDetail::childBegin(parent); child != KisForestDetail::childEnd(parent); child++) {if (child->properties.hasProperty(propertyId)) {diff --git a/libs/flake/text/KoSvgTextShape.h b/libs/flake/text/KoSvgTextShape.hindex e9081df9c4..12c0785c63 100644--- a/libs/flake/text/KoSvgTextShape.h+++ b/libs/flake/text/KoSvgTextShape.h@@ -396,6 +396,11 @@ public:*/QList<KoSvgTextCharacterInfo> getPositionsAndRotationsForRange(const int startPos, const int endPos) const;+ /**+ * Remove local transforms from the given range.+ */+ void removeTransformsFromRange(const int startPos, const int endPos);+/****************************************************************************** KoSvgTextNodeIndex functions.*diff --git a/plugins/tools/svgtexttool/CMakeLists.txt b/plugins/tools/svgtexttool/CMakeLists.txtindex 87e0415e2d..6650debdce 100644--- a/plugins/tools/svgtexttool/CMakeLists.txt+++ b/plugins/tools/svgtexttool/CMakeLists.txt@@ -28,6 +28,7 @@ set (SvgTextTool_SRCSSvgTextToolOptionsManager.cppSvgTextChangeTransformsOnRange.cppSvgTextTypeSettingStrategy.cpp+ SvgTextRemoveTransformsFromRange.cppglyphpalette/GlyphPaletteDialog.cppglyphpalette/GlyphPaletteProxyModel.cppdiff --git a/plugins/tools/svgtexttool/SvgTextCursor.cpp b/plugins/tools/svgtexttool/SvgTextCursor.cppindex 00306875b6..fcf14ac4aa 100644--- a/plugins/tools/svgtexttool/SvgTextCursor.cpp+++ b/plugins/tools/svgtexttool/SvgTextCursor.cpp@@ -10,6 +10,7 @@#include "SvgTextInsertRichCommand.h"#include "SvgTextMergePropertiesRangeCommand.h"#include "SvgTextRemoveCommand.h"+#include "SvgTextRemoveTransformsFromRange.h"#include "SvgTextShapeManagerBlocker.h"#include "SvgTextShortCuts.h"@@ -711,6 +712,14 @@ bool SvgTextCursor::pastePlainText()return success;}+void SvgTextCursor::removeTransformsFromRange()+{+ if (d->shape) {+ KUndo2Command *cmd = new SvgTextRemoveTransformsFromRange(d->shape, d->pos, d->anchor);+ addCommandToUndoAdapter(cmd);+ }+}+void SvgTextCursor::deselectText(){setPos(d->pos, d->pos);@@ -1283,6 +1292,7 @@ void SvgTextCursor::notifyCursorPosChanged(int pos, int anchor)void SvgTextCursor::notifyMarkupChanged(){d->interface->emitSelectionChange();+ updateTypeSettingDecoration();}void SvgTextCursor::keyPressEvent(QKeyEvent *event)@@ -1564,6 +1574,10 @@ bool SvgTextCursor::registerPropertyAction(QAction *action, const QString &name)d->actions.append(action);connect(action, SIGNAL(triggered(bool)), this, SLOT(pastePlainText()));return true;+ } else if (name == "svg_remove_transforms_from_range") {+ d->actions.append(action);+ connect(action, SIGNAL(triggered(bool)), this, SLOT(removeTransformsFromRange()));+ return true;} else if (action) {d->actions.append(action);return true;diff --git a/plugins/tools/svgtexttool/SvgTextCursor.h b/plugins/tools/svgtexttool/SvgTextCursor.hindex 32ed2e456e..09810f7e47 100644--- a/plugins/tools/svgtexttool/SvgTextCursor.h+++ b/plugins/tools/svgtexttool/SvgTextCursor.h@@ -291,6 +291,8 @@ private Q_SLOTS:*/bool pastePlainText();+ void removeTransformsFromRange();+private:/**diff --git a/plugins/tools/svgtexttool/SvgTextRemoveTransformsFromRange.cpp b/plugins/tools/svgtexttool/SvgTextRemoveTransformsFromRange.cppnew file mode 100644index 0000000000..13bcee79ce--- /dev/null+++ b/plugins/tools/svgtexttool/SvgTextRemoveTransformsFromRange.cpp@@ -0,0 +1,42 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */++#include "SvgTextRemoveTransformsFromRange.h"++SvgTextRemoveTransformsFromRange::SvgTextRemoveTransformsFromRange(KoSvgTextShape *shape, int pos, int anchor, KUndo2Command *parent)+ : KUndo2Command(parent)+ , m_shape(shape)+ , m_pos(pos)+ , m_anchor(anchor)+ , m_textData(shape->getMemento())+{+ setText(kundo2_i18n("Remove Character Transforms"));+}++void SvgTextRemoveTransformsFromRange::undo()+{+ QRectF updateRect = m_shape->boundingRect();++ m_shape->setMemento(m_textData);++ updateRect |= m_shape->boundingRect();+ m_shape->notifyCursorPosChanged(m_pos, m_anchor);+ m_shape->updateAbsolute(updateRect);+}++void SvgTextRemoveTransformsFromRange::redo()+{+ QRectF updateRect = m_shape->boundingRect();++ const int indexPos = m_shape->indexForPos(m_pos);+ const int indexAnchor = m_shape->indexForPos(m_anchor);++ m_shape->removeTransformsFromRange(m_pos, m_anchor);++ updateRect |= m_shape->boundingRect();+ m_shape->notifyCursorPosChanged(m_shape->posForIndex(indexPos), m_shape->posForIndex(indexAnchor));+ m_shape->updateAbsolute(updateRect);+}diff --git a/plugins/tools/svgtexttool/SvgTextRemoveTransformsFromRange.h b/plugins/tools/svgtexttool/SvgTextRemoveTransformsFromRange.hnew file mode 100644index 0000000000..6233b7a358--- /dev/null+++ b/plugins/tools/svgtexttool/SvgTextRemoveTransformsFromRange.h@@ -0,0 +1,32 @@+/*+ * SPDX-FileCopyrightText: 2025 Wolthera van Hövell tot Westerflier <[email protected]>+ *+ * SPDX-License-Identifier: GPL-3.0-or-later+ */+#ifndef SVGTEXTREMOVETRANSFORMSFROMRANGE_H+#define SVGTEXTREMOVETRANSFORMSFROMRANGE_H++#include <kundo2command.h>+#include <KoSvgTextShape.h>++/**+ * @brief The SvgTextRemoveTransformsFromRange class+ * Removes the SVG 1.1 character transforms from the range.+ */++class SvgTextRemoveTransformsFromRange : public KUndo2Command+{+public:+ SvgTextRemoveTransformsFromRange(KoSvgTextShape *shape, int pos, int anchor, KUndo2Command *parent = nullptr);++ void undo() override;+ void redo() override;+private:++ KoSvgTextShape *m_shape;+ int m_pos;+ int m_anchor;+ KoSvgTextShapeMementoSP m_textData;+};++#endif // SVGTEXTREMOVETRANSFORMSFROMRANGE_Hdiff --git a/plugins/tools/svgtexttool/SvgTextTool.action b/plugins/tools/svgtexttool/SvgTextTool.actionindex 54c230088d..df79561044 100644--- a/plugins/tools/svgtexttool/SvgTextTool.action+++ b/plugins/tools/svgtexttool/SvgTextTool.action@@ -267,5 +267,15 @@<isCheckable>false</isCheckable></Action>+ <Action name="svg_remove_transforms_from_range">+ <iconText>Remove Character Transforms</iconText>+ <text>Remove Character Transforms</text>+ <shortcut></shortcut>+ <toolTip>Remove Character Transforms from the selection.</toolTip>+ <icon></icon>+ <whatsThis/>+ <statusTip/>+ <isCheckable>false</isCheckable>+ </Action></Actions></ActionCollection>diff --git a/plugins/tools/svgtexttool/SvgTextTool.cpp b/plugins/tools/svgtexttool/SvgTextTool.cppindex 7c1255fdc2..449e4da975 100644--- a/plugins/tools/svgtexttool/SvgTextTool.cpp+++ b/plugins/tools/svgtexttool/SvgTextTool.cpp@@ -115,7 +115,8 @@ SvgTextTool::SvgTextTool(KoCanvasBase *canvas)const QStringList extraActions = {"svg_insert_special_character","svg_paste_rich_text",- "svg_paste_plain_text"+ "svg_paste_plain_text",+ "svg_remove_transforms_from_range"};connect(&m_textCursor, SIGNAL(sigOpenGlyphPalette()), this, SLOT(showGlyphPalette()));Q_FOREACH (const QString name, extraActions) {diff --git a/plugins/tools/svgtexttool/SvgTextToolFactory.cpp b/plugins/tools/svgtexttool/SvgTextToolFactory.cppindex 7749376624..b46c0951d3 100644--- a/plugins/tools/svgtexttool/SvgTextToolFactory.cpp+++ b/plugins/tools/svgtexttool/SvgTextToolFactory.cpp@@ -51,6 +51,7 @@ QList<QAction *> SvgTextToolFactory::createActionsImpl()actions << KisActionRegistry::instance()->makeQAction("svg_type_setting_move_selection_start_up_1_px", this);actions << KisActionRegistry::instance()->makeQAction("svg_type_setting_move_selection_start_left_1_px", this);actions << KisActionRegistry::instance()->makeQAction("svg_type_setting_move_selection_start_right_1_px", this);+ actions << KisActionRegistry::instance()->makeQAction("svg_remove_transforms_from_range", this);return actions;}