fix #9837: don't ignore PropertiesFlags. Otherwise the text style will be reset to the default value after changing style settings in the style dialog

This commit is contained in:
Roman Pudashkin 2021-11-30 19:52:38 +02:00
parent 5399075ec5
commit 67bb89bd44
3 changed files with 7 additions and 3 deletions

View file

@ -3665,7 +3665,7 @@ void TextBase::undoChangeProperty(Pid id, const PropertyValue& v, PropertyFlags
}
if (id == Pid::FONT_STYLE || id == Pid::FONT_FACE || id == Pid::FONT_SIZE || id == Pid::TEXT_SCRIPT_ALIGN) {
// can't use standard change property as Undo might set to "undefined"
score()->undo(new ChangeTextProperties(_cursor, id, v));
score()->undo(new ChangeTextProperties(_cursor, id, v, ps));
} else {
EngravingItem::undoChangeProperty(id, v, ps);
}

View file

@ -845,11 +845,12 @@ void ChangeTextProperties::restoreSelection()
tc.text()->cursor()->setColumn(tc.column());
}
ChangeTextProperties::ChangeTextProperties(const TextCursor* tc, Ms::Pid propId, const PropertyValue& propVal)
ChangeTextProperties::ChangeTextProperties(const TextCursor* tc, Ms::Pid propId, const PropertyValue& propVal, PropertyFlags flags_)
: TextEditUndoCommand(*tc)
{
propertyId = propId;
propertyVal = propVal;
flags = flags_;
if (propertyId == Pid::FONT_STYLE) {
existingStyle = static_cast<FontStyle>(cursor().text()->getProperty(propId).toInt());
}
@ -867,6 +868,8 @@ void ChangeTextProperties::redo(EditData*)
{
xmlText = cursor().text()->xmlText();
restoreSelection();
cursor().text()->setPropertyFlags(propertyId, flags);
if (propertyId == Pid::FONT_STYLE) {
FontStyle setStyle = static_cast<FontStyle>(propertyVal.toInt());
TextCursor* tc = cursor().text()->cursor();

View file

@ -82,11 +82,12 @@ class ChangeTextProperties : public TextEditUndoCommand
Pid propertyId;
mu::engraving::PropertyValue propertyVal;
FontStyle existingStyle;
PropertyFlags flags;
void restoreSelection();
public:
ChangeTextProperties(const TextCursor* tc, Ms::Pid propId, const mu::engraving::PropertyValue& propVal);
ChangeTextProperties(const TextCursor* tc, Ms::Pid propId, const mu::engraving::PropertyValue& propVal, PropertyFlags flags);
void undo(EditData*) override;
void redo(EditData*) override;
};