From 93b4b1ae292646b01a0d5864911193cd521a99d7 Mon Sep 17 00:00:00 2001 From: Joachim Schmitz Date: Mon, 25 May 2020 16:20:07 +0200 Subject: [PATCH] fix #305676: Repeat barline tooltips in Repeats & Jumps palette are not getting translated by fixing the mtest to allow certain duplicates and reverting some earlier changes to make those textx different --- libmscore/barline.cpp | 18 ++++----- libmscore/sym.cpp | 18 ++++----- mscore/inspector/inspectorBarline.cpp | 2 +- mscore/menus.cpp | 8 ++-- mscore/timeline.cpp | 54 +++++++++++++-------------- mtest/mscore/palette/tst_palette.cpp | 7 ++++ share/workspaces/Advanced.xml | 22 +++++------ share/workspaces/Basic.xml | 18 ++++----- 8 files changed, 76 insertions(+), 71 deletions(-) diff --git a/libmscore/barline.cpp b/libmscore/barline.cpp index ed2617b0667d..34d6b9c65d7e 100644 --- a/libmscore/barline.cpp +++ b/libmscore/barline.cpp @@ -194,14 +194,14 @@ class BarLineEditData : public ElementEditData { //--------------------------------------------------------- const std::vector 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" }, }; //--------------------------------------------------------- @@ -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(); } diff --git a/libmscore/sym.cpp b/libmscore/sym.cpp index d3a0a3c99a86..9a95767f2460 100644 --- a/libmscore/sym.cpp +++ b/libmscore/sym.cpp @@ -3274,15 +3274,15 @@ const std::array 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", @@ -3331,7 +3331,7 @@ const std::array 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", @@ -4908,9 +4908,9 @@ const std::array 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"), diff --git a/mscore/inspector/inspectorBarline.cpp b/mscore/inspector/inspectorBarline.cpp index d8f29ad57982..2983d2054ec8 100644 --- a/mscore/inspector/inspectorBarline.cpp +++ b/mscore/inspector/inspectorBarline.cpp @@ -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 il = { { Pid::LEADING_SPACE, 1, s.leadingSpace, s.resetLeadingSpace }, diff --git a/mscore/menus.cpp b/mscore/menus.cpp index f41a8bbd8f24..a06dcf5ad629 100644 --- a/mscore/menus.cpp +++ b/mscore/menus.cpp @@ -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 @@ -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; } @@ -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; } @@ -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); diff --git a/mscore/timeline.cpp b/mscore/timeline.cpp index 5a1933366c9f..dbeaca292b6d 100644 --- a/mscore/timeline.cpp +++ b/mscore/timeline.cpp @@ -798,7 +798,7 @@ Timeline::Timeline(TDockWidget* dockWidget, QWidget* parent) std::tuple ri(0, 0, nullptr, nullptr, false); _repeatInfo = ri; - static const char* leftRepeat[] = { + static const char* startRepeat[] = { "7 14 2 1", "# c #000000", ". c None", @@ -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", @@ -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", @@ -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; + } //--------------------------------------------------------- @@ -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; } @@ -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; } } @@ -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 { @@ -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); @@ -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); @@ -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; @@ -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(); diff --git a/mtest/mscore/palette/tst_palette.cpp b/mtest/mscore/palette/tst_palette.cpp index aa7a50ff0b9b..e1f74b8a0b4e 100644 --- a/mtest/mscore/palette/tst_palette.cpp +++ b/mtest/mscore/palette/tst_palette.cpp @@ -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)); diff --git a/share/workspaces/Advanced.xml b/share/workspaces/Advanced.xml index 641c16f55432..b848eb00b1b0 100644 --- a/share/workspaces/Advanced.xml +++ b/share/workspaces/Advanced.xml @@ -403,7 +403,7 @@ - + @@ -640,7 +640,7 @@ wiggleVibratoLargeSlowest - + brassMuteOpen @@ -998,7 +998,7 @@ noteShapeTriangleRoundWhite - + 22 add-parentheses @@ -1280,7 +1280,7 @@ 38 0.8 0 - + 1 @@ -1291,19 +1291,19 @@ double - + 1 start-repeat - + 1 end-repeat - + 1 end-start-repeat @@ -2167,7 +2167,7 @@ 0.65 1 0 - + @@ -2267,17 +2267,17 @@ - + start-repeat - + end-repeat - + end-start-repeat diff --git a/share/workspaces/Basic.xml b/share/workspaces/Basic.xml index 0763d29e4fe5..d5e5f182d0da 100644 --- a/share/workspaces/Basic.xml +++ b/share/workspaces/Basic.xml @@ -256,7 +256,7 @@ add-brackets - + 22 add-parentheses @@ -453,7 +453,7 @@ 38 0.8 1 - + 1 @@ -464,19 +464,19 @@ double - + 1 start-repeat - + 1 end-repeat - + 1 end-start-repeat @@ -693,7 +693,7 @@ 0.65 1 0 - + @@ -793,17 +793,17 @@ - + start-repeat - + end-repeat - + end-start-repeat