-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fix Instrument change text should show full instrument name #32821
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,8 @@ | |
|
|
||
| #include "instrument.h" | ||
|
|
||
| #include "translation.h" | ||
|
|
||
| #include "drumset.h" | ||
| #include "instrtemplate.h" | ||
| #include "masterscore.h" | ||
|
|
@@ -1066,6 +1068,14 @@ String Instrument::trackName() const | |
| return m_trackName; | ||
| } | ||
|
|
||
| String Instrument::trackNameWithTrait() const | ||
| { | ||
| if (m_trait.type == TraitType::Transposition && !m_trait.isHiddenOnScore) { | ||
| return muse::mtrc("engraving", "%1 in %2").arg(m_trackName, m_trait.name); | ||
| } | ||
| return m_trackName; | ||
| } | ||
|
Comment on lines
+1071
to
+1077
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Use a single shared formatter for instrument display names across contexts. This method introduces another formatting path for transposition naming. To prevent drift between score text, mixer, and Staff/Part properties, prefer one canonical formatter and route all UI/display callers through it. |
||
|
|
||
| void Instrument::setTrackName(const String& s) | ||
| { | ||
| m_trackName = s; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,19 +48,6 @@ using namespace mu::engraving; | |
|
|
||
| static const mu::engraving::Fraction DEFAULT_TICK = mu::engraving::Fraction(0, 1); | ||
|
|
||
| static String formatInstrumentTitleOnScore(const String& instrumentName, const Trait& trait) | ||
| { | ||
| // Comments for translators start with //: | ||
|
|
||
| if (trait.type == TraitType::Transposition && !trait.isHiddenOnScore) { | ||
| //: %1=name ("Horn"), %2=transposition ("C alto"). Example: "Horn in C alto" | ||
| return muse::qtrc("notation", "%1 in %2", "Transposing instrument displayed in the score") | ||
| .arg(instrumentName, trait.name); | ||
| } | ||
|
|
||
| return instrumentName; // Example: "Flute" | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See also my #32771, which also removes this apparently unused method |
||
| NotationParts::NotationParts(IGetScore* getScore, INotationInteractionPtr interaction, INotationUndoStackPtr undoStack) | ||
| : m_getScore(getScore), m_undoStack(undoStack), m_interaction(interaction) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard against empty transposition trait names in formatted output.
If
m_trait.nameis empty, Line 1074 can yield a user-visible string like"Piccolo in ". Add a validity check before formatting.💡 Proposed fix
String Instrument::trackNameWithTrait() const { - if (m_trait.type == TraitType::Transposition && !m_trait.isHiddenOnScore) { + if (m_trait.type == TraitType::Transposition && !m_trait.isHiddenOnScore && m_trait.isValid()) { return muse::mtrc("engraving", "%1 in %2").arg(m_trackName, m_trait.name); } return m_trackName; }