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 31, 2023
1 parent 02224ef commit a3cdccd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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() && !isFirstSystemKeySig(ks);
bool addKey = ks->isChange();
if ((startKey || addKey) && !ks->isCustom() && !ks->isAtonal()) {
Staff* staff = ks->staff();
Expand Down
11 changes: 11 additions & 0 deletions libmscore/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "page.h"
#include "segment.h"
#include "clef.h"
#include "keysig.h"
#include "utils.h"
#include "system.h"
#include "measure.h"
Expand Down Expand Up @@ -1070,5 +1071,15 @@ double yStaffDifference(const System* system1, int staffIdx1, const System* syst
return 0.0;
return staff1->y() - staff2->y();
}

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

3 changes: 3 additions & 0 deletions libmscore/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

namespace Ms {

class KeySig;

enum class Key;

//---------------------------------------------------------
Expand Down Expand Up @@ -92,6 +94,7 @@ extern Fraction actualTicks(Fraction duration, Tuplet* tuplet, Fraction timeStre


extern double yStaffDifference(const System* system1, int staffIdx1, const System* system2, int staffIdx2);
extern bool isFirstSystemKeySig(const KeySig* ks);
} // namespace Ms
#endif

0 comments on commit a3cdccd

Please sign in to comment.