Skip to content

Commit 4851ea9

Browse files
committed
Changes to custom text behaviour
1 parent 9fb44d0 commit 4851ea9

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

src/engraving/dom/barline.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,10 @@ PropertyValue BarLine::propertyDefault(Pid propertyId) const
956956
case Pid::PLAY_COUNT_TEXT_SETTING:
957957
return AutoCustomHide::AUTO;
958958

959-
case Pid::PLAY_COUNT_TEXT:
960-
return String();
959+
case Pid::PLAY_COUNT_TEXT: {
960+
double repeatCount = measure() ? measure()->repeatCount() : 2;
961+
return TConv::translatedUserName(style().styleV(Sid::repeatPlayCountPreset).value<RepeatPlayCountPreset>()).arg(repeatCount);
962+
}
961963

962964
default:
963965
break;

src/engraving/dom/edit.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5526,7 +5526,8 @@ void Score::undoResetPlayCountTextSettings(BarLine* bl)
55265526
continue;
55275527
}
55285528

5529-
curBl->undoChangeProperty(Pid::PLAY_COUNT_TEXT_SETTING, AutoCustomHide::AUTO);
5529+
curBl->undoResetProperty(Pid::PLAY_COUNT_TEXT_SETTING);
5530+
curBl->undoResetProperty(Pid::PLAY_COUNT_TEXT);
55305531
}
55315532
}
55325533

src/engraving/dom/playcounttext.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include "barline.h"
2626
#include "dom/score.h"
27+
#include "dom/textedit.h"
28+
#include "dom/undo.h"
2729

2830
using namespace mu;
2931
using namespace mu::engraving;
@@ -39,19 +41,18 @@ PlayCountText::PlayCountText(BarLine* parent, TextStyleType tid)
3941
initElementStyle(&playCountStyle);
4042
}
4143

42-
void PlayCountText::startEdit(EditData& ed)
43-
{
44-
score()->startCmd(TranslatableString("undoableAction", "Set play count text setting to custom"));
45-
barline()->undoChangeProperty(Pid::PLAY_COUNT_TEXT_SETTING, AutoCustomHide::CUSTOM);
46-
score()->endCmd();
47-
TextBase::startEdit(ed);
48-
}
49-
5044
void PlayCountText::endEdit(EditData& ed)
5145
{
52-
score()->startCmd(TranslatableString("undoableAction", "Update play count text"));
53-
barline()->undoChangeProperty(Pid::PLAY_COUNT_TEXT, xmlText());
54-
score()->endCmd();
46+
UndoStack* undo = score()->undoStack();
47+
TextEditData* ted = static_cast<TextEditData*>(ed.getData(this).get());
48+
const bool textWasEdited = undo->currentIndex() > ted->startUndoIdx;
49+
50+
if (textWasEdited) {
51+
score()->startCmd(TranslatableString("undoableAction", "Update play count text"));
52+
barline()->undoChangeProperty(Pid::PLAY_COUNT_TEXT, xmlText());
53+
barline()->undoChangeProperty(Pid::PLAY_COUNT_TEXT_SETTING, AutoCustomHide::CUSTOM);
54+
score()->endCmd();
55+
}
5556
TextBase::endEdit(ed);
5657
}
5758

src/engraving/dom/playcounttext.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class PlayCountText final : public TextBase
3636
BarLine* barline() const { return toBarLine(parent()); }
3737

3838
bool isEditable() const override { return true; }
39-
void startEdit(EditData&) override;
4039
void endEdit(EditData&) override;
4140

4241
EngravingItem* propertyDelegate(Pid) override;

0 commit comments

Comments
 (0)