Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transpose keysigs in parts after changing instrument #22940

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/notation/internal/masternotationparts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,20 @@ void MasterNotationParts::replaceInstrument(const InstrumentKey& instrumentKey,

startGlobalEdit();

const Part* part = partModifiable(instrumentKey.partId);
Part* part = partModifiable(instrumentKey.partId);
bool isMainInstrument = part && isMainInstrumentForPart(instrumentKey, part);

mu::engraving::Interval oldTranspose = part ? part->instrument()->transpose() : mu::engraving::Interval(0, 0);

NotationParts::replaceInstrument(instrumentKey, newInstrument);

for (INotationPartsPtr parts : excerptsParts()) {
parts->replaceInstrument(instrumentKey, newInstrument);
}

// this also transposes all linked parts
score()->transpositionChanged(part, Part::MAIN_INSTRUMENT_TICK, oldTranspose);

if (isMainInstrument) {
if (mu::engraving::Excerpt* excerpt = findExcerpt(part->id())) {
StringList allExcerptLowerNames;
Expand Down
6 changes: 0 additions & 6 deletions src/notation/internal/notationparts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,14 +574,8 @@ void NotationParts::replaceInstrument(const InstrumentKey& instrumentKey, const
startEdit();

if (isMainInstrumentForPart(instrumentKey, part)) {
mu::engraving::Interval oldTranspose = part->instrument()->transpose();

QString newInstrumentPartName = formatInstrumentTitle(newInstrument.trackName(), newInstrument.trait());
score()->undo(new mu::engraving::ChangePart(part, new mu::engraving::Instrument(newInstrument), newInstrumentPartName));
if (score()->isMaster()) {
// this also transposes all linked parts
score()->transpositionChanged(part, Part::MAIN_INSTRUMENT_TICK, oldTranspose);
}

// Update clefs
for (staff_idx_t staffIdx = 0; staffIdx < part->nstaves(); ++staffIdx) {
Expand Down
Loading