Skip to content

Commit

Permalink
Fix #18404: Transpose tool will only transpose initial key signature …
Browse files Browse the repository at this point in the history
…on a system if there is a key change
  • Loading branch information
miiizen committed Oct 17, 2023
1 parent 7091ae6 commit 3a56014
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/engraving/dom/keysig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "masterscore.h"
#include "score.h"
#include "segment.h"
#include "system.h"
#include "staff.h"
#include "part.h"

Expand Down Expand Up @@ -156,6 +157,15 @@ 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 src/engraving/dom/keysig.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class KeySig final : public EngravingItem
bool isAtonal() const { return m_sig.isAtonal(); }
bool isChange() const;
const KeySigEvent& keySigEvent() const { return m_sig; }
bool isFirstSystemKeySig();
bool operator==(const KeySig&) const;
void changeKeySigEvent(const KeySigEvent&);
void setKeySigEvent(const KeySigEvent& e) { m_sig = e; }
Expand Down
2 changes: 1 addition & 1 deletion src/engraving/dom/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,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->isAtonal()) {
Staff* staff = ks->staff();
Expand Down

0 comments on commit 3a56014

Please sign in to comment.