From b4694100321166a4acaf6e0a848f06f8807dfbbb Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup Date: Sat, 26 Dec 2020 17:58:47 +0100 Subject: [PATCH] Fix runtime warning reg. missing argument for QString in Palettes Instead of something like the following: qsTr("%n thing(s)", "comment", n) The following was used: qsTrc("context", "%n thing(s)").arg(n) Which caused warnings like: 15:35:39.228 | WARN | main_thread | Qt | QString::arg: Argument missing: "Palettes Tree, contains %n palette(s)", 13 Because "%n" doesn't work together with `.arg`. I updated the translation functions, so that we can now use this: qsTrc("context", "%n thing(s)", "comment", n) Which works without warnings. --- src/framework/global/translation.cpp | 8 ++++---- src/framework/global/translation.h | 4 ++-- src/framework/ui/view/qmltranslation.cpp | 6 +++--- src/framework/ui/view/qmltranslation.h | 2 +- src/palette/qml/MuseScore/Palette/PaletteTree.qml | 8 ++++---- src/palette/qml/MuseScore/Palette/PalettesWidget.qml | 4 ++-- .../qml/MuseScore/Palette/PalettesWidgetHeader.qml | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/framework/global/translation.cpp b/src/framework/global/translation.cpp index 8564d0d3bb..1dc5f7887d 100644 --- a/src/framework/global/translation.cpp +++ b/src/framework/global/translation.cpp @@ -21,12 +21,12 @@ using namespace mu; -std::string mu::trc(const char* context, const char* key, const char* disambiguation) +std::string mu::trc(const char* context, const char* key, const char* disambiguation, int n) { - return QCoreApplication::translate(context, key, disambiguation).toStdString(); + return QCoreApplication::translate(context, key, disambiguation, n).toStdString(); } -QString mu::qtrc(const char* context, const char* key, const char* disambiguation) +QString mu::qtrc(const char* context, const char* key, const char* disambiguation, int n) { - return QCoreApplication::translate(context, key, disambiguation); + return QCoreApplication::translate(context, key, disambiguation, n); } diff --git a/src/framework/global/translation.h b/src/framework/global/translation.h index 05f3074166..50b6e44707 100644 --- a/src/framework/global/translation.h +++ b/src/framework/global/translation.h @@ -22,8 +22,8 @@ #include namespace mu { -std::string trc(const char* context, const char* key, const char* disambiguation = nullptr); -QString qtrc(const char* context, const char* key, const char* disambiguation = nullptr); +std::string trc(const char* context, const char* key, const char* disambiguation = nullptr, int n = -1); +QString qtrc(const char* context, const char* key, const char* disambiguation = nullptr, int n = -1); } #endif // MU_FRAMEWORK_TRANSLATION_H diff --git a/src/framework/ui/view/qmltranslation.cpp b/src/framework/ui/view/qmltranslation.cpp index 70beb3678a..5d56a6ca76 100644 --- a/src/framework/ui/view/qmltranslation.cpp +++ b/src/framework/ui/view/qmltranslation.cpp @@ -27,10 +27,10 @@ QmlTranslation::QmlTranslation(QObject* parent) { } -QString QmlTranslation::translate(const QString& context, const QString& text, const QString& disambiguation) const +QString QmlTranslation::translate(const QString& context, const QString& text, const QString& disambiguation, int n) const { return qtrc(context.toUtf8().constData(), text.toUtf8().constData(), - disambiguation.isEmpty() ? nullptr : disambiguation.toUtf8().constData() - ); + disambiguation.isEmpty() ? nullptr : disambiguation.toUtf8().constData(), + n); } diff --git a/src/framework/ui/view/qmltranslation.h b/src/framework/ui/view/qmltranslation.h index d80cb8ff64..deafc6adc2 100644 --- a/src/framework/ui/view/qmltranslation.h +++ b/src/framework/ui/view/qmltranslation.h @@ -29,7 +29,7 @@ class QmlTranslation : public QObject public: QmlTranslation(QObject* parent); - Q_INVOKABLE QString translate(const QString& context, const QString& text,const QString& disambiguation = QString()) const; + Q_INVOKABLE QString translate(const QString& context, const QString& text, const QString& disambiguation = QString(), int n = -1) const; }; } } diff --git a/src/palette/qml/MuseScore/Palette/PaletteTree.qml b/src/palette/qml/MuseScore/Palette/PaletteTree.qml index 3ed5bac2c1..1ae23739f3 100644 --- a/src/palette/qml/MuseScore/Palette/PaletteTree.qml +++ b/src/palette/qml/MuseScore/Palette/PaletteTree.qml @@ -29,7 +29,7 @@ import "utils.js" as Utils ListView { id: paletteTree - Accessible.name: qsTrc("palette", "Palettes Tree, contains %n palette(s)").arg(count) + Accessible.name: qsTrc("palette", "Palettes Tree, contains %n palette(s)", "", count) activeFocusOnTab: true // allow focus even when empty @@ -46,11 +46,11 @@ ListView { property Item currentTreeItem: currentItem // most recently focused item at any level of the tree property string filter: "" - property bool searchOpenned: false + property bool searchOpened: false - onSearchOpennedChanged: { + onSearchOpenedChanged: { if (paletteWorkspace) { - paletteWorkspace.setSearching(searchOpenned) + paletteWorkspace.setSearching(searchOpened) } } diff --git a/src/palette/qml/MuseScore/Palette/PalettesWidget.qml b/src/palette/qml/MuseScore/Palette/PalettesWidget.qml index 9f974cb5ba..4c6605e2c1 100644 --- a/src/palette/qml/MuseScore/Palette/PalettesWidget.qml +++ b/src/palette/qml/MuseScore/Palette/PalettesWidget.qml @@ -87,7 +87,7 @@ Rectangle { text: qsTrc("palette", "Start typing to search all palettes") - visible: palettesWidgetHeader.searchOpenned && !Boolean(palettesWidgetHeader.searchText) + visible: palettesWidgetHeader.searchOpened && !Boolean(palettesWidgetHeader.searchText) } PaletteTree { @@ -97,7 +97,7 @@ Rectangle { filter: palettesWidgetHeader.searchText enableAnimations: !palettesWidgetHeader.searching - searchOpenned: palettesWidgetHeader.searchOpenned + searchOpened: palettesWidgetHeader.searchOpened anchors { top: palettesWidgetHeader.bottom diff --git a/src/palette/qml/MuseScore/Palette/PalettesWidgetHeader.qml b/src/palette/qml/MuseScore/Palette/PalettesWidgetHeader.qml index 2216b769b4..708eea3773 100644 --- a/src/palette/qml/MuseScore/Palette/PalettesWidgetHeader.qml +++ b/src/palette/qml/MuseScore/Palette/PalettesWidgetHeader.qml @@ -32,7 +32,7 @@ Item { property PaletteWorkspace paletteWorkspace: null property string searchText: searchTextInput.searchText readonly property bool searching: searchTextInput.activeFocus - property bool searchOpenned: searchTextInput.visible + property bool searchOpened: searchTextInput.visible property alias popupMaxHeight: palettePopup.maxHeight