From 74ab51649438461a2080a40c7ef603365ae167d8 Mon Sep 17 00:00:00 2001 From: luz paz Date: Sat, 28 Nov 2020 13:57:01 -0500 Subject: [PATCH] Gui: Issue #0004473: Expose openCommand() to translation Continuing the work to expose the undo/redo functionality to translation. This commit does so for the src/Gui code. Ticket: https://tracker.freecadweb.org/view.php?id=4473 --- src/Gui/Application.cpp | 2 +- src/Gui/CommandDoc.cpp | 4 ++-- src/Gui/CommandLink.cpp | 10 +++++----- src/Gui/CommandStd.cpp | 4 ++-- src/Gui/CommandStructure.cpp | 4 ++-- src/Gui/ManualAlignment.cpp | 2 +- src/Gui/Placement.cpp | 4 ++-- src/Gui/Transform.cpp | 2 +- src/Gui/ViewProviderAnnotation.cpp | 2 +- src/Gui/ViewProviderDragger.cpp | 2 +- src/Gui/ViewProviderLink.cpp | 2 +- src/Gui/ViewProviderMeasureDistance.cpp | 2 +- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index b108d18115..7258045a4d 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -675,7 +675,7 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch if (doc) { pendingCommand = doc->hasPendingCommand(); if (!pendingCommand) - doc->openCommand("Import"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Import")); } if (DocName) { diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index c2135aa292..88d00b609a 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -1131,7 +1131,7 @@ void StdCmdDelete::activated(int iMsg) std::set docs; try { - openCommand("Delete"); + openCommand(QT_TRANSLATE_NOOP("Command", "Delete")); if (getGuiApplication()->sendHasMsgToFocusView(getName())) { commitCommand(); return; @@ -1710,7 +1710,7 @@ protected: return; } - openCommand("Paste expressions"); + openCommand(QT_TRANSLATE_NOOP("Command", "Paste expressions")); try { for(auto &v : exprs) { for(auto &v2 : v.second) { diff --git a/src/Gui/CommandLink.cpp b/src/Gui/CommandLink.cpp index 0c28668474..5063588389 100644 --- a/src/Gui/CommandLink.cpp +++ b/src/Gui/CommandLink.cpp @@ -140,7 +140,7 @@ void StdCmdLinkMakeGroup::activated(int option) { Selection().selStackPush(); Selection().clearCompleteSelection(); - Command::openCommand("Make link group"); + Command::openCommand(QT_TRANSLATE_NOOP("Command", "Make link group")); try { std::string groupName = doc->getUniqueObjectName("LinkGroup"); Command::doCommand(Command::Doc, @@ -236,7 +236,7 @@ void StdCmdLinkMake::activated(int) { Selection().selStackPush(); Selection().clearCompleteSelection(); - Command::openCommand("Make link"); + Command::openCommand(QT_TRANSLATE_NOOP("Command", "Make link")); try { if(objs.empty()) { std::string name = doc->getUniqueObjectName("Link"); @@ -289,7 +289,7 @@ void StdCmdLinkMakeRelative::activated(int) { FC_ERR("no active document"); return; } - Command::openCommand("Make sub-link"); + Command::openCommand(QT_TRANSLATE_NOOP("Command", "Make sub-link")); try { std::map, std::pair > > linkInfo; @@ -576,7 +576,7 @@ bool StdCmdLinkImport::isActive() { } void StdCmdLinkImport::activated(int) { - Command::openCommand("Import links"); + Command::openCommand(QT_TRANSLATE_NOOP("Command", "Import links")); try { WaitCursor wc; wc.setIgnoreEvents(WaitCursor::NoEvents); @@ -617,7 +617,7 @@ bool StdCmdLinkImportAll::isActive() { } void StdCmdLinkImportAll::activated(int) { - Command::openCommand("Import all links"); + Command::openCommand(QT_TRANSLATE_NOOP("Command", "Import all links")); try { WaitCursor wc; wc.setIgnoreEvents(WaitCursor::NoEvents); diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index d4b773fe21..f350c5434d 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -724,7 +724,7 @@ void StdCmdMeasurementSimple::activated(int iMsg) name += "-"; name += Sel[1].SubName; - openCommand("Insert measurement"); + openCommand(QT_TRANSLATE_NOOP("Command", "Insert measurement")); doCommand(Doc,"_f = App.activeDocument().addObject(\"App::MeasureDistance\",\"%s\")","Measurement"); doCommand(Doc,"_f.Label ='%s'",name.c_str()); doCommand(Doc,"_f.P1 = FreeCAD.Vector(%f,%f,%f)",Sel[0].x,Sel[0].y,Sel[0].z); @@ -755,7 +755,7 @@ void StdCmdTextDocument::activated(int iMsg) { Q_UNUSED(iMsg); - openCommand("Insert text document"); + openCommand(QT_TRANSLATE_NOOP("Command", "Insert text document")); doCommand(Doc, "App.ActiveDocument.addObject(\"App::TextDocument\",\"%s\").Label=\"%s\"","Text document","Text document"); doCommand(Gui, "Gui.ActiveDocument.ActiveObject.doubleClicked()"); updateActive(); diff --git a/src/Gui/CommandStructure.cpp b/src/Gui/CommandStructure.cpp index f7b5577cfa..5b90e67510 100644 --- a/src/Gui/CommandStructure.cpp +++ b/src/Gui/CommandStructure.cpp @@ -60,7 +60,7 @@ void StdCmdPart::activated(int iMsg) { Q_UNUSED(iMsg); - openCommand("Add a part"); + openCommand(QT_TRANSLATE_NOOP("Command", "Add a part")); std::string FeatName = getUniqueObjectName("Part"); std::string PartName; @@ -101,7 +101,7 @@ void StdCmdGroup::activated(int iMsg) { Q_UNUSED(iMsg); - openCommand("Add a group"); + openCommand(QT_TRANSLATE_NOOP("Command", "Add a group")); std::string GroupName; GroupName = getUniqueObjectName("Group"); diff --git a/src/Gui/ManualAlignment.cpp b/src/Gui/ManualAlignment.cpp index 14fe025e3f..3251af8e1c 100644 --- a/src/Gui/ManualAlignment.cpp +++ b/src/Gui/ManualAlignment.cpp @@ -996,7 +996,7 @@ void ManualAlignment::align() bool ok = computeAlignment(myAlignModel.activeGroup().getPoints(), myFixedGroup.getPoints()); if (ok && myDocument) { // Align views - myDocument->openCommand("Align"); + myDocument->openCommand(QT_TRANSLATE_NOOP("Command", "Align")); for (std::vector::iterator it = pViews.begin(); it != pViews.end(); ++it) alignObject(*it); myDocument->commitCommand(); diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index cc9f336e27..04b2e6ad35 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -269,13 +269,13 @@ void Placement::applyPlacement(const QString& data, bool incremental) } catch (...) { } - document->openCommand("Placement"); + document->openCommand(QT_TRANSLATE_NOOP("Command", "Placement")); } else { std::vector sel = Gui::Selection().getObjectsOfType (App::DocumentObject::getClassTypeId(), document->getDocument()->getName()); if (!sel.empty()) { - document->openCommand("Placement"); + document->openCommand(QT_TRANSLATE_NOOP("Command", "Placement")); for (std::vector::iterator it=sel.begin();it!=sel.end();++it) { std::map props; (*it)->getPropertyMap(props); diff --git a/src/Gui/Transform.cpp b/src/Gui/Transform.cpp index cdbcea03f5..96fc420ffb 100644 --- a/src/Gui/Transform.cpp +++ b/src/Gui/Transform.cpp @@ -99,7 +99,7 @@ void TransformStrategy::commitTransform(const Base::Matrix4D& mat) std::set objects = transformObjects(); Gui::Document* doc = Gui::Application::Instance->activeDocument(); if (doc) { - doc->openCommand("Transform"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Transform")); for (std::set::iterator it=objects.begin();it!=objects.end();++it) { acceptDataTransform(mat, *it); } diff --git a/src/Gui/ViewProviderAnnotation.cpp b/src/Gui/ViewProviderAnnotation.cpp index 17825d5364..3c5c9fb41a 100644 --- a/src/Gui/ViewProviderAnnotation.cpp +++ b/src/Gui/ViewProviderAnnotation.cpp @@ -414,7 +414,7 @@ void ViewProviderAnnotationLabel::setupContextMenu(QMenu* menu, QObject* receive void ViewProviderAnnotationLabel::dragStartCallback(void *, SoDragger *) { // This is called when a manipulator is about to manipulating - Gui::Application::Instance->activeDocument()->openCommand("Transform"); + Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Transform")); } void ViewProviderAnnotationLabel::dragFinishCallback(void *, SoDragger *) diff --git a/src/Gui/ViewProviderDragger.cpp b/src/Gui/ViewProviderDragger.cpp index dbaff82b63..bf2bc001e1 100644 --- a/src/Gui/ViewProviderDragger.cpp +++ b/src/Gui/ViewProviderDragger.cpp @@ -239,7 +239,7 @@ void ViewProviderDragger::unsetEditViewer(Gui::View3DInventorViewer* viewer) void ViewProviderDragger::dragStartCallback(void *, SoDragger *) { // This is called when a manipulator is about to manipulating - Gui::Application::Instance->activeDocument()->openCommand("Transform"); + Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Transform")); } void ViewProviderDragger::dragFinishCallback(void *data, SoDragger *d) diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 52de2acea1..fcc875bbe4 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -2717,7 +2717,7 @@ void ViewProviderLink::dragStartCallback(void *data, SoDragger *) { me->dragCtx->initialPlacement = me->currentDraggingPlacement(); if(!me->callDraggerProxy("onDragStart",false)) { me->dragCtx->cmdPending = true; - me->getDocument()->openCommand("Link Transform"); + me->getDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Link Transform")); }else me->dragCtx->cmdPending = false; } diff --git a/src/Gui/ViewProviderMeasureDistance.cpp b/src/Gui/ViewProviderMeasureDistance.cpp index 5b4be8f4bb..17ecf1e554 100644 --- a/src/Gui/ViewProviderMeasureDistance.cpp +++ b/src/Gui/ViewProviderMeasureDistance.cpp @@ -265,7 +265,7 @@ int PointMarker::countPoints() const void PointMarker::customEvent(QEvent*) { Gui::Document* doc = Gui::Application::Instance->activeDocument(); - doc->openCommand("Measure distance"); + doc->openCommand(QT_TRANSLATE_NOOP("Command", "Measure distance")); App::DocumentObject* obj = doc->getDocument()->addObject (App::MeasureDistance::getClassTypeId().getName(),"Distance");