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++
Make character properties return nothing when there's only paragraph properties.
Wolthera van Hövell tot Westerflier1cb9204ed7bb
diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cppindex 862880b939..5d0c1007d5 100644--- a/libs/flake/text/KoSvgTextShape.cpp+++ b/libs/flake/text/KoSvgTextShape.cpp@@ -1593,6 +1593,12 @@ KoSvgText::WritingMode KoSvgTextShape::writingMode() constreturn KoSvgText::WritingMode(this->textProperties().propertyOrDefault(KoSvgTextProperties::WritingModeId).toInt());}+bool KoSvgTextShape::singleNode() const+{+ if (d->textData.empty()) return false;+ return (KisForestDetail::size(d->textData) == 1);+}+void KoSvgTextShape::notifyCursorPosChanged(int pos, int anchor){if (d->isLoading) {diff --git a/libs/flake/text/KoSvgTextShape.h b/libs/flake/text/KoSvgTextShape.hindex df4eb6b5e2..9e31e80d19 100644--- a/libs/flake/text/KoSvgTextShape.h+++ b/libs/flake/text/KoSvgTextShape.h@@ -563,6 +563,14 @@ public:*/KoSvgText::WritingMode writingMode() const;+ /**+ * @brief singleNode+ * Sometimes it is useful to know whether there's only a single text node+ * for UX purposes.+ * @return whether there's only a single root node, or there's a full fledged tree.+ */+ bool singleNode() const;+/// ShapeChangeListener so we can inform any text cursors that the cursor needs updating.struct KRITAFLAKE_EXPORT TextCursorChangeListener : public ShapeChangeListener {void notifyShapeChanged(ChangeType type, KoShape *shape) override;diff --git a/plugins/tools/svgtexttool/SvgTextCursor.cpp b/plugins/tools/svgtexttool/SvgTextCursor.cppindex 24a9a3508a..a917478b55 100644--- a/plugins/tools/svgtexttool/SvgTextCursor.cpp+++ b/plugins/tools/svgtexttool/SvgTextCursor.cpp@@ -1975,6 +1975,11 @@ QList<KoSvgTextProperties> SvgTextCursorPropertyInterface::getSelectedPropertiesQList<KoSvgTextProperties> SvgTextCursorPropertyInterface::getCharacterProperties(){+ // When there's only a single node, its best to only return empty properties, as paragraph properties handle that single node.+ if (!d->parent->shape()) return QList<KoSvgTextProperties>();+ if (d->parent->shape()->singleNode()) {+ return {KoSvgTextProperties()};+ }return d->parent->propertiesForRange();}