Skip to content

Commit

Permalink
Fix GH#18404: Transpose tool will only transpose initial key signatur…
Browse files Browse the repository at this point in the history
…e on a system if there is a key change

Backport of musescore#18530
  • Loading branch information
miiizen authored and Jojo-Schmitz committed Oct 15, 2023
1 parent 47766fe commit ad92e57
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions libmscore/keysig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,14 @@ bool KeySig::isChange() const
return staff()->currentKeyTick(keyTick) == keyTick;
}

bool KeySig::isFirstSystemKeySig()
{
System* sys = measure()->system();
if (!sys)
return false;
return tick().ticks() == sys->firstMeasure()->tick().ticks();
}

//---------------------------------------------------------
// changeKeySigEvent
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions libmscore/keysig.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class KeySig final : public Element {
bool isCustom() const { return _sig.custom(); }
bool isAtonal() const { return _sig.isAtonal(); }
bool isChange() const;
bool isFirstSystemKeySig();
KeySigEvent keySigEvent() const { return _sig; }
bool operator==(const KeySig&) const;
void changeKeySigEvent(const KeySigEvent&);
Expand Down
2 changes: 1 addition & 1 deletion libmscore/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ bool Score::transpose(TransposeMode mode, TransposeDirection direction, Key trKe
else if (e->isKeySig() && trKeys && mode != TransposeMode::DIATONICALLY) {
KeySig* ks = toKeySig(e);
Fraction tick = segment->tick();
bool startKey = tick == s1->tick();
bool startKey = tick == s1->tick() && !ks->isFirstSystemKeySig();
bool addKey = ks->isChange();
if ((startKey || addKey) && !ks->isCustom() && !ks->isAtonal()) {
Staff* staff = ks->staff();
Expand Down

0 comments on commit ad92e57

Please sign in to comment.