Skip to content

Commit

Permalink
Merge pull request #6096 from Jojo-Schmitz/barline-heavy
Browse files Browse the repository at this point in the history
fix #305676: Repeat barline tooltips in Repeats & Jumps palette are not getting translated
  • Loading branch information
anatoly-os committed May 25, 2020
2 parents 27775db + 93b4b1a commit 6362472
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 71 deletions.
18 changes: 9 additions & 9 deletions libmscore/barline.cpp
Expand Up @@ -194,14 +194,14 @@ class BarLineEditData : public ElementEditData {
//---------------------------------------------------------

const std::vector<BarLineTableItem> BarLine::barLineTable {
{ BarLineType::NORMAL, QT_TRANSLATE_NOOP("Palette", "Normal barline"), "normal" },
{ BarLineType::DOUBLE, QT_TRANSLATE_NOOP("Palette", "Double barline"), "double" },
{ BarLineType::START_REPEAT, QT_TRANSLATE_NOOP("Palette", "Start repeat barline"), "start-repeat" },
{ BarLineType::END_REPEAT, QT_TRANSLATE_NOOP("Palette", "End repeat barline"), "end-repeat" },
{ BarLineType::BROKEN, QT_TRANSLATE_NOOP("Palette", "Dashed barline"), "dashed" },
{ BarLineType::END, QT_TRANSLATE_NOOP("Palette", "Final barline"), "end" },
{ BarLineType::END_START_REPEAT, QT_TRANSLATE_NOOP("Palette", "End-start repeat barline"), "end-start-repeat" },
{ BarLineType::DOTTED, QT_TRANSLATE_NOOP("Palette", "Dotted barline"), "dotted" },
{ BarLineType::NORMAL, Sym::symUserNames[int(SymId::barlineSingle)], "normal" },
{ BarLineType::DOUBLE, Sym::symUserNames[int(SymId::barlineDouble)], "double" },
{ BarLineType::START_REPEAT, Sym::symUserNames[int(SymId::repeatLeft)], "start-repeat" },
{ BarLineType::END_REPEAT, Sym::symUserNames[int(SymId::repeatRight)], "end-repeat" },
{ BarLineType::BROKEN, Sym::symUserNames[int(SymId::barlineDashed)], "dashed" },
{ BarLineType::END, Sym::symUserNames[int(SymId::barlineFinal)], "end" },
{ BarLineType::END_START_REPEAT, Sym::symUserNames[int(SymId::repeatRightLeft)], "end-start-repeat" },
{ BarLineType::DOTTED, Sym::symUserNames[int(SymId::barlineDotted)], "dotted" },
};

//---------------------------------------------------------
Expand All @@ -223,7 +223,7 @@ QString BarLine::userTypeName(BarLineType t)
{
for (const auto& i : barLineTable) {
if (i.type == t)
return qApp->translate("Palette", i.userName);
return qApp->translate("symUserNames", i.userName);
}
return QString();
}
Expand Down
18 changes: 9 additions & 9 deletions libmscore/sym.cpp
Expand Up @@ -3274,15 +3274,15 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
QT_TRANSLATE_NOOP("symUserNames", "Unstress above"),
QT_TRANSLATE_NOOP("symUserNames", "Unstress below"),
"Augmentation dot",
"Dashed barline",
"Dotted barline",
"Double barline",
"Final barline",
"Heavy barline",
"Heavy double barline",
"Reverse final barline",
QT_TRANSLATE_NOOP("symUserNames", "Dashed barline"),
QT_TRANSLATE_NOOP("symUserNames", "Dotted barline"),
QT_TRANSLATE_NOOP("symUserNames", "Double barline"),
QT_TRANSLATE_NOOP("symUserNames", "Final barline"),
"Short barline",
"Single barline",
QT_TRANSLATE_NOOP("symUserNames", "Single barline"),
"Tick barline",
"Accel./rit. beam 1 (widest)",
"Accel./rit. beam 10",
Expand Down Expand Up @@ -3331,7 +3331,7 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
"Smooth lift, short",
QT_TRANSLATE_NOOP("symUserNames", "Muted (closed)"),
"Half-muted (half-closed)",
QT_TRANSLATE_NOOP("symUserNames", "Opened"),
QT_TRANSLATE_NOOP("symUserNames", "Open"),
"Plop",
"Scoop",
"Smear",
Expand Down Expand Up @@ -4908,9 +4908,9 @@ const std::array<const char*, int(SymId::lastSym)+1> Sym::symUserNames = { {
QT_TRANSLATE_NOOP("symUserNames", "Repeat last four bars"),
"Single repeat dot",
"Repeat dots",
"Left (start) repeat sign",
"Right (end) repeat sign",
"Right and left repeat sign",
QT_TRANSLATE_NOOP("symUserNames", "Left (start) repeat sign"),
QT_TRANSLATE_NOOP("symUserNames", "Right (end) repeat sign"),
QT_TRANSLATE_NOOP("symUserNames", "Right and left repeat sign"),
"1024th rest",
QT_TRANSLATE_NOOP("symUserNames", "128th (semihemidemisemiquaver) rest"),
QT_TRANSLATE_NOOP("symUserNames", "16th (semiquaver) rest"),
Expand Down
2 changes: 1 addition & 1 deletion mscore/inspector/inspectorBarline.cpp
Expand Up @@ -28,7 +28,7 @@ InspectorBarLine::InspectorBarLine(QWidget* parent)
b.setupUi(addWidget());

for (auto i : BarLine::barLineTable)
b.type->addItem(qApp->translate("Palette", i.userName), int(i.type));
b.type->addItem(qApp->translate("symUserName", i.userName), int(i.type));

const std::vector<InspectorItem> il = {
{ Pid::LEADING_SPACE, 1, s.leadingSpace, s.resetLeadingSpace },
Expand Down
8 changes: 4 additions & 4 deletions mscore/menus.cpp
Expand Up @@ -685,7 +685,7 @@ PalettePanel* MuseScore::newRepeatsPalettePanel()
sp->setDrawGrid(true);

RepeatMeasure* rm = new RepeatMeasure(gscore);
sp->append(rm, QT_TRANSLATE_NOOP("Palette", "Repeat measure sign"));
sp->append(rm, qApp->translate("symUserNames", Sym::symUserNames[int(SymId::repeat1Bar)]));

for (int i = 0; i < markerTypeTableSize(); i++) {
if (markerTypeTable[i].type == Marker::Type::CODETTA) //not in smufl
Expand Down Expand Up @@ -718,7 +718,7 @@ PalettePanel* MuseScore::newRepeatsPalettePanel()

BarLine* b = new BarLine(gscore);
b->setBarLineType(bti->type);
PaletteCell* cell= sp->append(b, BarLine::userTypeName(bti->type));
PaletteCell* cell = sp->append(b, BarLine::userTypeName(bti->type));
cell->drawStaff = false;
}

Expand Down Expand Up @@ -880,7 +880,7 @@ PalettePanel* MuseScore::newNoteHeadsPalettePanel()
QAction* action = s->action();
QIcon icon(action->icon());
ik->setAction("add-parentheses", icon);
sp->append(ik, QT_TRANSLATE_NOOP("action", "Add parentheses to notehead"));
sp->append(ik, s->help());
return sp;
}

Expand Down Expand Up @@ -1104,7 +1104,7 @@ PalettePanel* MuseScore::newBracketsPalettePanel()
{{ BracketType::NORMAL, QT_TRANSLATE_NOOP("Palette", "Bracket") },
{ BracketType::BRACE, QT_TRANSLATE_NOOP("Palette", "Brace") },
{ BracketType::SQUARE, QT_TRANSLATE_NOOP("Palette", "Square") },
{ BracketType::LINE, QT_TRANSLATE_NOOP("Palette", "Straight Line") }}
{ BracketType::LINE, QT_TRANSLATE_NOOP("Palette", "Line") }}
} ) {
Bracket* b1 = new Bracket(gscore);
BracketItem* bi1 = new BracketItem(gscore);
Expand Down
54 changes: 26 additions & 28 deletions mscore/timeline.cpp
Expand Up @@ -798,7 +798,7 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
std::tuple<int, qreal, Element*, Element*, bool> ri(0, 0, nullptr, nullptr, false);
_repeatInfo = ri;

static const char* leftRepeat[] = {
static const char* startRepeat[] = {
"7 14 2 1",
"# c #000000",
". c None",
Expand All @@ -818,7 +818,7 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
"##.#..."
};

static const char* rightRepeat[] = {
static const char* endRepeat[] = {
"7 14 2 1",
"# c #000000",
". c None",
Expand All @@ -838,7 +838,7 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
"...#.##"
};

static const char* finalBarline[] = {
static const char* endBarline[] = {
"7 14 2 1",
"# c #000000",
". c None",
Expand Down Expand Up @@ -878,15 +878,16 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent)
"..#.#.."
};

QPixmap* leftRepeatPixmap = new QPixmap(leftRepeat);
QPixmap* rightRepeatPixmap = new QPixmap(rightRepeat);
QPixmap* finalBarlinePixmap = new QPixmap(finalBarline);
QPixmap* startRepeatPixmap = new QPixmap(startRepeat);
QPixmap* endRepeatPixmap = new QPixmap(endRepeat);
QPixmap* endBarlinePixmap = new QPixmap(endBarline);
QPixmap* doubleBarlinePixmap = new QPixmap(doubleBarline);

_barlines["Start repeat"] = leftRepeatPixmap;
_barlines["End repeat"] = rightRepeatPixmap;
_barlines["Final barline"] = finalBarlinePixmap;
_barlines["Double barline"] = doubleBarlinePixmap;
_barlines[BarLine::userTypeName(BarLineType::START_REPEAT)] = startRepeatPixmap;
_barlines[BarLine::userTypeName(BarLineType::END_REPEAT)] = endRepeatPixmap;
_barlines[BarLine::userTypeName(BarLineType::END)] = endBarlinePixmap;
_barlines[BarLine::userTypeName(BarLineType::DOUBLE)] = doubleBarlinePixmap;

}

//---------------------------------------------------------
Expand Down Expand Up @@ -1255,20 +1256,13 @@ void Timeline::barlineMeta(Segment* seg, int* stagger, int pos)
if (barline) {
switch (barline->barLineType()) {
case BarLineType::START_REPEAT:
repeatText = QString("Start repeat");
break;
case BarLineType::END_REPEAT:
repeatText = QString("End repeat");
break;
case BarLineType::END_START_REPEAT:
// actually an end repeat followed by a start repeat, so nothing needs to be done here
break;
case BarLineType::DOUBLE:
repeatText = QString("Double barline");
break;
case BarLineType::END:
repeatText = QString("Final barline");
repeatText = BarLine::userTypeName(barline->barLineType());
break;
case BarLineType::END_START_REPEAT:
// actually an end repeat followed by a start repeat, so nothing needs to be done here
default:
break;
}
Expand Down Expand Up @@ -1454,7 +1448,7 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
textWidth = 10;
if (textWidth > _gridWidth) {
textWidth = _gridWidth;
if (metaText == QString("End repeat") && std::get<4>(_repeatInfo))
if (metaText == BarLine::userTypeName(BarLineType::END_REPEAT) && std::get<4>(_repeatInfo))
textWidth /= 2;
}
}
Expand All @@ -1463,7 +1457,11 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
textWidth = getWidth() - x;

// Adjust x for end repeats
if ((metaText == QString("End repeat") || metaText == QString("Final barline") || metaText == QString("Double barline") || std::get<2>(_repeatInfo)) && !_collapsedMeta) {
if ((metaText == BarLine::userTypeName(BarLineType::END_REPEAT) ||
metaText == BarLine::userTypeName(BarLineType::END) ||
metaText == BarLine::userTypeName(BarLineType::DOUBLE) ||
std::get<2>(_repeatInfo))
&& !_collapsedMeta) {
if (std::get<0>(_repeatInfo) > 0)
x = pos + _gridWidth - std::get<1>(_repeatInfo) + std::get<0>(_repeatInfo) * _spacing;
else {
Expand All @@ -1486,7 +1484,7 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
// Exact values required for repeat pixmap to work visually
if (textWidth != 10)
graphicsPixmapItem = new QGraphicsPixmapItem();
if (metaText == QString("Start repeat"))
if (metaText == BarLine::userTypeName(BarLineType::START_REPEAT))
std::get<4>(_repeatInfo) = true;
graphicsPixmapItem->setX(x + 2);
graphicsPixmapItem->setY(_gridHeight * row + verticalScrollBar()->value() + 3);
Expand Down Expand Up @@ -1534,10 +1532,8 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
_gridHeight);
if (tooltip != "")
graphicsRectItem->setToolTip(tooltip);
else if (partName != metaText)
else if (partName != metaText || graphicsPixmapItem)
graphicsRectItem->setToolTip(metaText);
else if (graphicsPixmapItem)
graphicsRectItem->setToolTip(tr(metaText.toLatin1().constData()));

setMetaData(graphicsRectItem, -1, elementType, measure, true, element, itemToAdd, seg);
setMetaData(itemToAdd, -1, elementType, measure, true, element, graphicsRectItem, seg);
Expand All @@ -1556,7 +1552,7 @@ bool Timeline::addMetaValue(int x, int pos, QString metaText, int row, ElementTy
_metaRows.push_back(pairTimeRect);
_metaRows.push_back(pairTimeText);

if (metaText == QString("End repeat"))
if (metaText == BarLine::userTypeName(BarLineType::END_REPEAT))
std::get<0>(_repeatInfo)++;

return true;
Expand Down Expand Up @@ -1806,7 +1802,9 @@ void Timeline::drawSelection()
staffIdx = -1;
BarLine* barline = toBarLine(element);
if (barline &&
(barline->barLineType() == BarLineType::END_REPEAT || barline->barLineType() == BarLineType::DOUBLE || barline->barLineType() == BarLineType::END) &&
(barline->barLineType() == BarLineType::END_REPEAT ||
barline->barLineType() == BarLineType::DOUBLE ||
barline->barLineType() == BarLineType::END) &&
measure != _score->lastMeasure()) {
if (measure->prevMeasure())
measure = measure->prevMeasure();
Expand Down
7 changes: 7 additions & 0 deletions mtest/mscore/palette/tst_palette.cpp
Expand Up @@ -64,6 +64,13 @@ void TestPaletteModel::testDuplicateItemNames()
qDebug("In %s workspace", qPrintable(workspaceName));
for (auto name = paletteItemNames.begin(); name != paletteItemNames.end(); ++name) {
if (name.value().size() != 1) {
// Exceptions - allowed duplicates
if (name.key().endsWith(" repeat sign") // repeat barlines in "Barlines" and "Repeats & Jumps" palette
|| name.key() == "Open" // articulations in "Articulations" and channel switch text in "Text" palette
|| name.key() == "Line" // bracket type in "Brackets" and line type in "Lines" palette
|| name.key().startsWith("Add parentheses to ") // "Noteheads" and "Accidentals" palette
)
continue;
duplicates = true;
for (auto parent : name.value())
qDebug("%s (in %s)", qPrintable(name.key()), qPrintable(parent));
Expand Down
22 changes: 11 additions & 11 deletions share/workspaces/Advanced.xml
Expand Up @@ -403,7 +403,7 @@
<Bracket type="Square">
</Bracket>
</Cell>
<Cell name="Straight Line">
<Cell name="Line">
<Bracket type="Line">
</Bracket>
</Cell>
Expand Down Expand Up @@ -640,7 +640,7 @@
<subtype>wiggleVibratoLargeSlowest</subtype>
</Articulation>
</Cell>
<Cell name="Opened">
<Cell name="Open">
<Articulation>
<subtype>brassMuteOpen</subtype>
</Articulation>
Expand Down Expand Up @@ -998,7 +998,7 @@
<name>noteShapeTriangleRoundWhite</name>
</NoteHead>
</Cell>
<Cell name="Add parentheses to notehead">
<Cell name="Add parentheses to element">
<Icon>
<subtype>22</subtype>
<action>add-parentheses</action>
Expand Down Expand Up @@ -1280,7 +1280,7 @@
<gridHeight>38</gridHeight>
<mag>0.8</mag>
<moreElements>0</moreElements>
<Cell name="Normal barline">
<Cell name="Single barline">
<staff>1</staff>
<BarLine>
</BarLine>
Expand All @@ -1291,19 +1291,19 @@
<subtype>double</subtype>
</BarLine>
</Cell>
<Cell name="Start repeat barline">
<Cell name="Left (start) repeat sign">
<staff>1</staff>
<BarLine>
<subtype>start-repeat</subtype>
</BarLine>
</Cell>
<Cell name="End repeat barline">
<Cell name="Right (end) repeat sign">
<staff>1</staff>
<BarLine>
<subtype>end-repeat</subtype>
</BarLine>
</Cell>
<Cell name="End-start repeat barline">
<Cell name="Right and left repeat sign">
<staff>1</staff>
<BarLine>
<subtype>end-start-repeat</subtype>
Expand Down Expand Up @@ -2167,7 +2167,7 @@
<mag>0.65</mag>
<grid>1</grid>
<moreElements>0</moreElements>
<Cell name="Repeat measure sign">
<Cell name="Repeat last bar">
<RepeatMeasure>
</RepeatMeasure>
</Cell>
Expand Down Expand Up @@ -2267,17 +2267,17 @@
<continueAt></continueAt>
</Jump>
</Cell>
<Cell name="Start repeat">
<Cell name="Left (start) repeat sign">
<BarLine>
<subtype>start-repeat</subtype>
</BarLine>
</Cell>
<Cell name="End repeat">
<Cell name="Right (end) repeat sign">
<BarLine>
<subtype>end-repeat</subtype>
</BarLine>
</Cell>
<Cell name="End-start repeat">
<Cell name="Right and left repeat sign">
<BarLine>
<subtype>end-start-repeat</subtype>
</BarLine>
Expand Down

0 comments on commit 6362472

Please sign in to comment.