From 18cae6b9036ab4321c724b11d4eb4b6d46358a0a Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 21 Apr 2023 16:55:05 -0500 Subject: [PATCH] GUI: Translate the tooltip for EditMode menu The tip text was extracted from the Wiki. --- src/Gui/Application.cpp | 8 ++++---- src/Gui/Application.h | 31 ++++++++++++++++++++++++------- src/Gui/ApplicationPy.cpp | 4 ++-- src/Gui/CommandStd.cpp | 9 +++++---- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 2876166ecc..df80a3f6d5 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1312,14 +1312,14 @@ int Application::getUserEditMode(const std::string &mode) const return userEditMode; } for (auto const &uem : userEditModes) { - if (uem.second == mode) { + if (uem.second.first == mode) { return uem.first; } } return -1; } -std::string Application::getUserEditModeName(int mode) const +std::pair Application::getUserEditModeUIStrings(int mode) const { if (mode == -1) { return userEditModes.at(userEditMode); @@ -1327,7 +1327,7 @@ std::string Application::getUserEditModeName(int mode) const if (userEditModes.find(mode) != userEditModes.end()) { return userEditModes.at(mode); } - return ""; + return std::make_pair(std::string(), std::string()); } bool Application::setUserEditMode(int mode) @@ -1343,7 +1343,7 @@ bool Application::setUserEditMode(int mode) bool Application::setUserEditMode(const std::string &mode) { for (auto const &uem : userEditModes) { - if (uem.second == mode) { + if (uem.second.first == mode) { return setUserEditMode(uem.first); } } diff --git a/src/Gui/Application.h b/src/Gui/Application.h index 692f95b672..ba2b46601b 100644 --- a/src/Gui/Application.h +++ b/src/Gui/Application.h @@ -248,18 +248,35 @@ protected: // the below std::map is a translation of 'EditMode' enum in ViewProvider.h // to add a new edit mode, it should first be added there // this is only used for GUI user interaction (menu, toolbar, Python API) - const std::map userEditModes { - {0, QT_TRANSLATE_NOOP("EditMode", "Default")}, - {1, QT_TRANSLATE_NOOP("EditMode", "Transform")}, - {2, QT_TRANSLATE_NOOP("EditMode", "Cutting")}, - {3, QT_TRANSLATE_NOOP("EditMode", "Color")} + const std::map> userEditModes { + {0, + std::make_pair( + QT_TRANSLATE_NOOP("EditMode", "Default"), + QT_TRANSLATE_NOOP("EditMode", + "The object will be edited using the mode defined internally to be " + "the most appropriate for the object type"))}, + {1, + std::make_pair(QT_TRANSLATE_NOOP("EditMode", "Transform"), + QT_TRANSLATE_NOOP("EditMode", + "The object will have its placement editable with the " + "Std TransformManip command"))}, + {2, + std::make_pair(QT_TRANSLATE_NOOP("EditMode", "Cutting"), + QT_TRANSLATE_NOOP("EditMode", + "This edit mode is implemented as available but " + "currently does not seem to be used by any object"))}, + {3, + std::make_pair(QT_TRANSLATE_NOOP("EditMode", "Color"), + QT_TRANSLATE_NOOP("EditMode", + "The object will have the color of its individual faces " + "editable with the Part FaceColors command"))}, }; int userEditMode = userEditModes.begin()->first; public: - std::map listUserEditModes() const { return userEditModes; } + std::map > listUserEditModes() const { return userEditModes; } int getUserEditMode(const std::string &mode = "") const; - std::string getUserEditModeName(int mode = -1) const; + std::pair getUserEditModeUIStrings(int mode = -1) const; bool setUserEditMode(int mode); bool setUserEditMode(const std::string &mode); //@} diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index 6b04456f78..82154fc7f3 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -1552,7 +1552,7 @@ PyObject* Application::sListUserEditModes(PyObject * /*self*/, PyObject *args) return nullptr; for (auto const &uem : Instance->listUserEditModes()) { - ret.append(Py::String(uem.second)); + ret.append(Py::String(uem.second.first)); } return Py::new_reference_to(ret); @@ -1563,7 +1563,7 @@ PyObject* Application::sGetUserEditMode(PyObject * /*self*/, PyObject *args) if (!PyArg_ParseTuple(args, "")) return nullptr; - return Py::new_reference_to(Py::String(Instance->getUserEditModeName())); + return Py::new_reference_to(Py::String(Instance->getUserEditModeUIStrings().first)); } PyObject* Application::sSetUserEditMode(PyObject * /*self*/, PyObject *args) diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index 92bb6b846e..37f69589e4 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -888,11 +888,12 @@ Gui::Action * StdCmdUserEditMode::createAction() for (auto const &uem : Gui::Application::Instance->listUserEditModes()) { QAction* act = pcAction->addAction(QString()); - auto modeName = QString::fromStdString(uem.second); + auto modeName = QString::fromStdString(uem.second.first); act->setCheckable(true); act->setIcon(BitmapFactory().iconFromTheme(qPrintable(QString::fromLatin1("Std_UserEditMode")+modeName))); act->setObjectName(QString::fromLatin1("Std_UserEditMode")+modeName); act->setWhatsThis(QString::fromLatin1(getWhatsThis())); + act->setToolTip(QString::fromStdString(uem.second.second)); if (uem.first == 0) { pcAction->setIcon(act->icon()); @@ -920,11 +921,11 @@ void StdCmdUserEditMode::languageChange() QList a = pcAction->actions(); for (int i = 0 ; i < a.count() ; i++) { - auto modeName = QString::fromStdString(Gui::Application::Instance->getUserEditModeName(i)); + auto modeName = Gui::Application::Instance->getUserEditModeUIStrings(i); a[i]->setText(QCoreApplication::translate( - "EditMode", qPrintable(modeName))); + "EditMode", modeName.first.c_str())); a[i]->setToolTip(QCoreApplication::translate( - "EditMode", qPrintable(modeName+QString::fromLatin1(" mode")))); + "EditMode", modeName.second.c_str())); } }