From 29cc754cfdd51974d382c5f7f1be6a96dbf9be3c Mon Sep 17 00:00:00 2001 From: Kuzemko Alexsandr Date: Sun, 5 Jun 2022 10:04:07 +0300 Subject: [PATCH] [TD] Add ability to translate for some tooltip text. Fix incorrect use of tr(variable). --- src/Mod/TechDraw/Gui/CommandAnnotate.cpp | 16 +++--- src/Mod/TechDraw/Gui/CommandCreateDims.cpp | 50 ++++++++++--------- .../Gui/DlgPrefsTechDrawAnnotationImp.cpp | 16 +++--- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp index abd757589c..3626198ba9 100644 --- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp +++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp @@ -1509,11 +1509,9 @@ std::vector getSelectedSubElements(Gui::Command* cmd, } } if (dvp == nullptr) { - std::stringstream edgeMsg; - edgeMsg << "No Part View in Selection"; - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), - QObject::tr(edgeMsg.str().c_str())); - return selectedSubs; + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), + QObject::tr("No Part View in Selection")); + return selectedSubs; } for (auto& s: subNames) { @@ -1523,10 +1521,10 @@ std::vector getSelectedSubElements(Gui::Command* cmd, } if (selectedSubs.empty()) { - std::stringstream edgeMsg; - edgeMsg << "No " << subType << " in Selection"; - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), - QObject::tr(edgeMsg.str().c_str())); + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Wrong Selection"), + QObject::tr("No %1 in Selection") + .arg(QString::fromStdString(subType))); return selectedSubs; } diff --git a/src/Mod/TechDraw/Gui/CommandCreateDims.cpp b/src/Mod/TechDraw/Gui/CommandCreateDims.cpp index aa88bd4913..81252efc6f 100644 --- a/src/Mod/TechDraw/Gui/CommandCreateDims.cpp +++ b/src/Mod/TechDraw/Gui/CommandCreateDims.cpp @@ -326,10 +326,11 @@ void CmdTechDrawRadiusDimension::activated(int iMsg) return; } } else { - std::stringstream edgeMsg; - edgeMsg << "Selection for Radius does not contain a circular edge (edge type: " << _edgeTypeToText(edgeType) << ")"; - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"), - QObject::tr(edgeMsg.str().c_str())); + QMessageBox::warning( + Gui::getMainWindow(), QObject::tr("Incorrect Selection"), + QObject::tr("Selection for Radius does not contain a circular edge " + "(edge type: %1)") + .arg(QString::fromStdString(_edgeTypeToText(edgeType)))); return; } @@ -448,11 +449,12 @@ void CmdTechDrawDiameterDimension::activated(int iMsg) return; } } else { - std::stringstream edgeMsg; - edgeMsg << "Selection for Diameter does not contain a circular edge (edge type: " << _edgeTypeToText(edgeType) << ")"; - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"), - QObject::tr(edgeMsg.str().c_str())); - return; + QMessageBox::warning( + Gui::getMainWindow(), QObject::tr("Incorrect Selection"), + QObject::tr("Selection for Diameter does not contain a circular edge " + "(edge type: %1)") + .arg(QString::fromStdString(_edgeTypeToText(edgeType)))); + return; } openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); @@ -545,11 +547,11 @@ void CmdTechDrawLengthDimension::activated(int iMsg) subs.push_back(SubNames[0]); subs.push_back(SubNames[1]); } else { - std::stringstream edgeMsg; - edgeMsg << "Need 2 Vertexes, 2 Edges or 1 Vertex and 1 Edge for Distance Dimension"; - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"), - QObject::tr(edgeMsg.str().c_str())); - return; + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Incorrect Selection"), + QObject::tr("Need 2 Vertexes, 2 Edges or 1 Vertex " + "and 1 Edge for Distance Dimension")); + return; } openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); @@ -648,11 +650,11 @@ void CmdTechDrawHorizontalDimension::activated(int iMsg) subs.push_back(SubNames[0]); subs.push_back(SubNames[1]); } else { - std::stringstream edgeMsg; - edgeMsg << "Need 2 Vertexes, 2 Edges or 1 Vertex and 1 Edge for Horizontal Dimension"; - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"), - QObject::tr(edgeMsg.str().c_str())); - return; + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Incorrect Selection"), + QObject::tr("Need 2 Vertexes, 2 Edges or 1 Vertex " + "and 1 Edge for Horizontal Dimension")); + return; } openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); @@ -751,11 +753,11 @@ void CmdTechDrawVerticalDimension::activated(int iMsg) subs.push_back(SubNames[0]); subs.push_back(SubNames[1]); } else { - std::stringstream edgeMsg; - edgeMsg << "Need 2 Vertexes, 2 Edges or 1 Vertex and 1 Edge for Vertical Dimension"; - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"), - QObject::tr(edgeMsg.str().c_str())); - return; + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("Incorrect Selection"), + QObject::tr("Need 2 Vertexes, 2 Edges or 1 Vertex " + "and 1 Edge for Vertical Dimension")); + return; } openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp index f2ff3269fa..6f9a5e6265 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp @@ -144,7 +144,7 @@ int DlgPrefsTechDrawAnnotationImp::prefBalloonArrow(void) const void DlgPrefsTechDrawAnnotationImp::onLineGroupChanged(int index) { if (index == -1) { // there is no valid index yet - ui->pcbLineGroup->setToolTip(QString::fromStdString("Please select a Line Group")); + ui->pcbLineGroup->setToolTip(QObject::tr("Please select a Line Group")); return; } // get the definition the the selected LineGroup (includes the name) @@ -154,13 +154,13 @@ void DlgPrefsTechDrawAnnotationImp::onLineGroupChanged(int index) while (std::getline(ss, lgRecord, ',')) { lgNames.push_back(lgRecord); } - // format the tooltip - std::stringstream TooltipText; - TooltipText << lgNames.at(0).substr(1) << " defines these line widths:\n" - << "thin: " << lgNames.at(1) << "\n" - << "graphic: " << lgNames.at(2) << "\n" - << "thick: " << lgNames.at(3); - ui->pcbLineGroup->setToolTip(QString::fromStdString(TooltipText.str())); + ui->pcbLineGroup->setToolTip( + QObject::tr("%1 defines these line widths:\n thin: %2\n graphic: %3\n " + "thick: %4") + .arg(QString::fromStdString(lgNames.at(0).substr(1)), + QString::fromStdString(lgNames.at(1)), + QString::fromStdString(lgNames.at(2)), + QString::fromStdString(lgNames.at(3)))); } #include