fix #4954 Change staff instrument changes default clef. See PR #3158

This commit is contained in:
lasconic 2017-05-27 17:53:08 +02:00
parent 04a0219336
commit 3d280f21f7
3 changed files with 10 additions and 4 deletions

View file

@ -1219,11 +1219,12 @@ void ChangePatch::flip(EditData*)
// ChangeStaff
//---------------------------------------------------------
ChangeStaff::ChangeStaff(Staff* _staff, bool _invisible,
ChangeStaff::ChangeStaff(Staff* _staff, bool _invisible, ClefTypeList _clefType,
qreal _userDist, Staff::HideMode _hideMode, bool _showIfEmpty, bool _cutaway, bool hide)
{
staff = _staff;
invisible = _invisible;
clefType = _clefType;
userDist = _userDist;
hideMode = _hideMode;
showIfEmpty = _showIfEmpty;
@ -1238,7 +1239,7 @@ ChangeStaff::ChangeStaff(Staff* _staff, bool _invisible,
void ChangeStaff::flip(EditData*)
{
bool invisibleChanged = staff->invisible() != invisible;
ClefTypeList oldClefType = staff->defaultClefType();
bool oldInvisible = staff->invisible();
qreal oldUserDist = staff->userDist();
Staff::HideMode oldHideMode = staff->hideWhenEmpty();
@ -1247,6 +1248,7 @@ void ChangeStaff::flip(EditData*)
bool hide = staff->hideSystemBarLine();
staff->setInvisible(invisible);
staff->setDefaultClefType(clefType);
staff->setUserDist(userDist);
staff->setHideWhenEmpty(hideMode);
staff->setShowIfEmpty(showIfEmpty);
@ -1254,6 +1256,7 @@ void ChangeStaff::flip(EditData*)
staff->setHideSystemBarLine(hideSystemBarLine);
invisible = oldInvisible;
clefType = oldClefType;
userDist = oldUserDist;
hideMode = oldHideMode;
showIfEmpty = oldShowIfEmpty;

View file

@ -561,6 +561,7 @@ class ChangePatch : public UndoCommand {
class ChangeStaff : public UndoCommand {
Staff* staff;
bool invisible;
ClefTypeList clefType;
qreal userDist;
Staff::HideMode hideMode;
bool showIfEmpty;
@ -570,7 +571,7 @@ class ChangeStaff : public UndoCommand {
void flip(EditData*) override;
public:
ChangeStaff(Staff*, bool invisible, qreal userDist, Staff::HideMode _hideMode,
ChangeStaff(Staff*, bool invisible, ClefTypeList _clefType, qreal userDist, Staff::HideMode _hideMode,
bool _showIfEmpty, bool _cutaway, bool hide);
UNDO_NAME("ChangeStaff")
};

View file

@ -336,6 +336,7 @@ void EditStaff::apply()
instrument.setLongName(ln);
bool inv = invisible->isChecked();
ClefTypeList clefType = instrument.clefType(orgStaff->rstaff());
qreal userDist = spinExtraDistance->value();
bool ifEmpty = showIfEmpty->isChecked();
bool hideSystemBL = hideSystemBarLine->isChecked();
@ -359,13 +360,14 @@ void EditStaff::apply()
orgStaff->undoChangeProperty(P_ID::SMALL, small->isChecked());
if (inv != orgStaff->invisible()
|| clefType != orgStaff->defaultClefType()
|| userDist != orgStaff->userDist()
|| cutAway != orgStaff->cutaway()
|| hideEmpty != orgStaff->hideWhenEmpty()
|| ifEmpty != orgStaff->showIfEmpty()
|| hideSystemBL != orgStaff->hideSystemBarLine()
) {
score->undo(new ChangeStaff(orgStaff, inv, userDist * score->spatium(), hideEmpty, ifEmpty, cutAway, hideSystemBL));
score->undo(new ChangeStaff(orgStaff, inv, clefType, userDist * score->spatium(), hideEmpty, ifEmpty, cutAway, hideSystemBL));
}
if ( !(*orgStaff->staffType(0) == *staff->staffType(0)) ) {