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++

Get undos and non-text properties docker changes to call updates on the text docker.

Wolthera van Hövell tot Westerflier7f678f0e1e8c
diff --git a/libs/flake/text/KoSvgTextShape.cpp b/libs/flake/text/KoSvgTextShape.cpp
index 6beb751bcb..ce13274b60 100644
--- a/libs/flake/text/KoSvgTextShape.cpp
+++ b/libs/flake/text/KoSvgTextShape.cpp
@@ -1131,6 +1131,16 @@ void KoSvgTextShape::notifyCursorPosChanged(int pos, int anchor)
}
}
+void KoSvgTextShape::notifyMarkupChanged()
+{
+ Q_FOREACH (KoShape::ShapeChangeListener *listener, listeners()) {
+ TextCursorChangeListener *cursorListener = dynamic_cast<TextCursorChangeListener*>(listener);
+ if (cursorListener) {
+ cursorListener->notifyMarkupChanged();
+ }
+ }
+}
+
#include "KoXmlWriter.h"
bool KoSvgTextShape::saveSvg(SvgSavingContext &context)
{
@@ -1312,12 +1322,14 @@ void KoSvgTextShape::setMemento(const KoSvgTextShapeMementoSP memento)
{
setMementoImpl(memento);
notifyCursorPosChanged(0, 0);
+ notifyMarkupChanged();
}
void KoSvgTextShape::setMemento(const KoSvgTextShapeMementoSP memento, int pos, int anchor)
{
setMementoImpl(memento);
notifyCursorPosChanged(pos, anchor);
+ notifyMarkupChanged();
}
void KoSvgTextShape::debugParsing()
diff --git a/libs/flake/text/KoSvgTextShape.h b/libs/flake/text/KoSvgTextShape.h
index 1368f0106c..a2478ab87b 100644
--- a/libs/flake/text/KoSvgTextShape.h
+++ b/libs/flake/text/KoSvgTextShape.h
@@ -399,9 +399,12 @@ public:
struct KRITAFLAKE_EXPORT TextCursorChangeListener : public ShapeChangeListener {
void notifyShapeChanged(ChangeType type, KoShape *shape) override;
virtual void notifyCursorPosChanged(int pos, int anchor) = 0;
+ virtual void notifyMarkupChanged() = 0;
};
/// Notify that the cursor position has changed.
void notifyCursorPosChanged(int pos, int anchor);
+ /// Notify that the markup has changed.
+ void notifyMarkupChanged();
/*--------------- Loading / Saving ------------------*/
diff --git a/libs/ui/KisTextPropertiesManager.cpp b/libs/ui/KisTextPropertiesManager.cpp
index 9f183fafa7..f6443bc1d9 100644
--- a/libs/ui/KisTextPropertiesManager.cpp
+++ b/libs/ui/KisTextPropertiesManager.cpp
@@ -166,5 +166,4 @@ void KisTextPropertiesManager::slotTextPropertiesChanged()
if (newProps.isEmpty() && removeProperties.isEmpty()) return;
d->interface->setPropertiesOnSelected(newProps, removeProperties);
- d->lastSetTextData = textData;
}
diff --git a/plugins/tools/svgtexttool/SvgTextCursor.cpp b/plugins/tools/svgtexttool/SvgTextCursor.cpp
index 74a4912f32..cb1427a672 100644
--- a/plugins/tools/svgtexttool/SvgTextCursor.cpp
+++ b/plugins/tools/svgtexttool/SvgTextCursor.cpp
@@ -333,7 +333,7 @@ KoSvgTextProperties SvgTextCursor::currentTextProperties() const
QList<KoSvgTextProperties> SvgTextCursor::propertiesForRange() const
{
if (!d->shape) return QList<KoSvgTextProperties>();
- return d->shape->propertiesForRange(d->pos, d->anchor);
+ return d->shape->propertiesForRange(qMin(d->pos, d->anchor), qMax(d->pos, d->anchor));
}
void SvgTextCursor::mergePropertiesIntoSelection(const KoSvgTextProperties props, const QSet<KoSvgTextProperties::PropertyId> removeProperties)
@@ -925,6 +925,11 @@ void SvgTextCursor::notifyCursorPosChanged(int pos, int anchor)
updateSelection();
}
+void SvgTextCursor::notifyMarkupChanged()
+{
+ d->interface->emitSelectionChange();
+}
+
void SvgTextCursor::keyPressEvent(QKeyEvent *event)
{
KIS_SAFE_ASSERT_RECOVER_RETURN(d->shape);
diff --git a/plugins/tools/svgtexttool/SvgTextCursor.h b/plugins/tools/svgtexttool/SvgTextCursor.h
index 6b70940873..4d8b044eff 100644
--- a/plugins/tools/svgtexttool/SvgTextCursor.h
+++ b/plugins/tools/svgtexttool/SvgTextCursor.h
@@ -172,6 +172,8 @@ public:
/// to update the cursor without having the cursor owned by the command.
void notifyCursorPosChanged(int pos, int anchor) override;
+ void notifyMarkupChanged() override;
+
/// Handle the cursor-related key events.
void keyPressEvent(QKeyEvent *event);
diff --git a/plugins/tools/svgtexttool/SvgTextInsertRichCommand.cpp b/plugins/tools/svgtexttool/SvgTextInsertRichCommand.cpp
index b92f18ab0b..6353a5a67f 100644
--- a/plugins/tools/svgtexttool/SvgTextInsertRichCommand.cpp
+++ b/plugins/tools/svgtexttool/SvgTextInsertRichCommand.cpp
@@ -29,6 +29,7 @@ void SvgTextInsertRichCommand::redo()
int pos = m_shape->posForIndex(oldIndex + m_insert->plainText().size(), false, false);
m_shape->notifyCursorPosChanged(pos, pos);
+ m_shape->notifyMarkupChanged();
}
void SvgTextInsertRichCommand::undo()
diff --git a/plugins/tools/svgtexttool/SvgTextMergePropertiesRangeCommand.cpp b/plugins/tools/svgtexttool/SvgTextMergePropertiesRangeCommand.cpp
index 567dc0f5b9..3dce2a5c6f 100644
--- a/plugins/tools/svgtexttool/SvgTextMergePropertiesRangeCommand.cpp
+++ b/plugins/tools/svgtexttool/SvgTextMergePropertiesRangeCommand.cpp
@@ -34,6 +34,8 @@ void SvgTextMergePropertiesRangeCommand::redo()
QRectF updateRect = m_shape->boundingRect();
m_shape->mergePropertiesIntoRange(qMin(m_pos, m_anchor), qMax(m_pos, m_anchor), m_props, m_removeProperties);
m_shape->updateAbsolute( updateRect| m_shape->boundingRect());
+
+ m_shape->notifyMarkupChanged();
}
void SvgTextMergePropertiesRangeCommand::undo()