Fix Instrument change text should show full instrument name#32821
Fix Instrument change text should show full instrument name#32821CubikingChill wants to merge 1 commit intomusescore:masterfrom
Conversation
ea4b092 to
c9d48dd
Compare
|
|
||
| return instrumentName; // Example: "Flute" | ||
| } | ||
|
|
There was a problem hiding this comment.
See also my #32771, which also removes this apparently unused method
|
Do you think in future we should only keep 1 format-name method in the whole codebase? Currently my PR creates a non-QT method while some other parts of the UI use this |
2026-03-30.20-29-05.-.Trim.mp4 |
c9d48dd to
6305669
Compare
📝 WalkthroughWalkthroughThis change refactors instrument name formatting by introducing a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0253b09c-5f16-4927-820a-bde311309f9f
📒 Files selected for processing (4)
src/engraving/dom/instrchange.cppsrc/engraving/dom/instrument.cppsrc/engraving/dom/instrument.hsrc/notation/internal/notationparts.cpp
💤 Files with no reviewable changes (1)
- src/notation/internal/notationparts.cpp
| 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; | ||
| } |
There was a problem hiding this comment.
🛠️ 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.
| if (m_trait.type == TraitType::Transposition && !m_trait.isHiddenOnScore) { | ||
| return muse::mtrc("engraving", "%1 in %2").arg(m_trackName, m_trait.name); | ||
| } |
There was a problem hiding this comment.
Guard against empty transposition trait names in formatted output.
If m_trait.name is 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;
}
Resolves: #32588
Summary by CodeRabbit