Part: Issue #0004473: Expose openCommand() to translation

Continuing the work to expose the undo/redo functionality to translation. This commit does so for the Part Wb.  
Ticket: https://tracker.freecadweb.org/view.php?id=4473
This commit is contained in:
luz paz
2020-11-27 20:51:47 -05:00
committed by wwmayer
parent 2befcd9502
commit 5aff8cdd0b
8 changed files with 31 additions and 31 deletions

View File

@@ -144,7 +144,7 @@ CmdPartBox2::CmdPartBox2()
void CmdPartBox2::activated(int iMsg)
{
Q_UNUSED(iMsg);
openCommand("Part Box Create");
openCommand(QT_TRANSLATE_NOOP("Command", "Part Box Create"));
doCommand(Doc,"from FreeCAD import Base");
doCommand(Doc,"import Part");
doCommand(Doc,"__fb__ = App.ActiveDocument.addObject(\"Part::Box\",\"PartBox\")");
@@ -185,7 +185,7 @@ CmdPartBox3::CmdPartBox3()
void CmdPartBox3::activated(int iMsg)
{
Q_UNUSED(iMsg);
openCommand("Part Box Create");
openCommand(QT_TRANSLATE_NOOP("Command", "Part Box Create"));
doCommand(Doc,"from FreeCAD import Base");
doCommand(Doc,"import Part");
doCommand(Doc,"__fb__ = App.ActiveDocument.addObject(\"Part::Box\",\"PartBox\")");
@@ -304,7 +304,7 @@ void CmdPartCut::activated(int iMsg)
std::string FeatName = getUniqueObjectName("Cut");
openCommand("Part Cut");
openCommand(QT_TRANSLATE_NOOP("Command", "Part Cut"));
doCommand(Doc,"App.activeDocument().addObject(\"Part::Cut\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),Sel[0].getFeatName());
doCommand(Doc,"App.activeDocument().%s.Tool = App.activeDocument().%s",FeatName.c_str(),Sel[1].getFeatName());
@@ -405,7 +405,7 @@ void CmdPartCommon::activated(int iMsg)
}
str << "]";
openCommand("Common");
openCommand(QT_TRANSLATE_NOOP("Command", "Common"));
doCommand(Doc,"App.activeDocument().addObject(\"Part::MultiCommon\",\"%s\")",FeatName.c_str());
runCommand(Doc,str.str().c_str());
@@ -505,7 +505,7 @@ void CmdPartFuse::activated(int iMsg)
}
str << "]";
openCommand("Fusion");
openCommand(QT_TRANSLATE_NOOP("Command", "Fusion"));
doCommand(Doc,"App.activeDocument().addObject(\"Part::MultiFuse\",\"%s\")",FeatName.c_str());
runCommand(Doc,str.str().c_str());
@@ -918,7 +918,7 @@ void CmdPartCompound::activated(int iMsg)
}
str << "]";
openCommand("Compound");
openCommand(QT_TRANSLATE_NOOP("Command", "Compound"));
doCommand(Doc,"App.activeDocument().addObject(\"Part::Compound\",\"%s\")",FeatName.c_str());
runCommand(Doc,str.str().c_str());
updateActive();
@@ -963,7 +963,7 @@ void CmdPartSection::activated(int iMsg)
std::string BaseName = Sel[0].getFeatName();
std::string ToolName = Sel[1].getFeatName();
openCommand("Section");
openCommand(QT_TRANSLATE_NOOP("Command", "Section"));
doCommand(Doc,"App.activeDocument().addObject(\"Part::Section\",\"%s\")",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),BaseName.c_str());
doCommand(Doc,"App.activeDocument().%s.Tool = App.activeDocument().%s",FeatName.c_str(),ToolName.c_str());
@@ -1014,7 +1014,7 @@ void CmdPartImport::activated(int iMsg)
if (!pDoc) return; // no document
fn = Base::Tools::escapeEncodeFilename(fn);
openCommand("Import Part");
openCommand(QT_TRANSLATE_NOOP("Command", "Import Part"));
if (select == filter[1] ||
select == filter[3]) {
doCommand(Doc, "import ImportGui");
@@ -1120,7 +1120,7 @@ void CmdPartImportCurveNet::activated(int iMsg)
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")));
if (!fn.isEmpty()) {
QFileInfo fi; fi.setFile(fn);
openCommand("Part Import Curve Net");
openCommand(QT_TRANSLATE_NOOP("Command", "Part Import Curve Net"));
doCommand(Doc,"f = App.activeDocument().addObject(\"Part::CurveNet\",\"%s\")", (const char*)fi.baseName().toLatin1());
doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toLatin1());
commitCommand();
@@ -1236,7 +1236,7 @@ void CmdPartReverseShape::activated(int iMsg)
Q_UNUSED(iMsg);
std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType
(Part::Feature::getClassTypeId());
openCommand("Reverse");
openCommand(QT_TRANSLATE_NOOP("Command", "Reverse"));
for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) {
const TopoDS_Shape& shape = Part::Feature::getShape(*it);
if (!shape.IsNull()) {
@@ -1358,7 +1358,7 @@ void CmdPartMakeFace::activated(int iMsg)
auto sketches = Gui::Selection().getObjectsOfType(App::DocumentObject::getClassTypeId(),0,3);
if(sketches.empty())
return;
openCommand("Make face");
openCommand(QT_TRANSLATE_NOOP("Command", "Make face"));
try {
App::DocumentT doc(sketches.front()->getDocument());
@@ -1652,7 +1652,7 @@ void CmdPartOffset::activated(int iMsg)
App::DocumentObject* shape = shapes.front();
std::string offset = getUniqueObjectName("Offset");
openCommand("Make Offset");
openCommand(QT_TRANSLATE_NOOP("Command", "Make Offset"));
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Offset\",\"%s\")",offset.c_str());
doCommand(Doc,"App.ActiveDocument.%s.Source = App.ActiveDocument.%s" ,offset.c_str(), shape->getNameInDocument());
doCommand(Doc,"App.ActiveDocument.%s.Value = 1.0",offset.c_str());
@@ -1704,7 +1704,7 @@ void CmdPartOffset2D::activated(int iMsg)
App::DocumentObject* shape = shapes.front();
std::string offset = getUniqueObjectName("Offset2D");
openCommand("Make 2D Offset");
openCommand(QT_TRANSLATE_NOOP("Command", "Make 2D Offset"));
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Offset2D\",\"%s\")",offset.c_str());
doCommand(Doc,"App.ActiveDocument.%s.Source = App.ActiveDocument.%s" ,offset.c_str(), shape->getNameInDocument());
doCommand(Doc,"App.ActiveDocument.%s.Value = 1.0",offset.c_str());
@@ -1872,7 +1872,7 @@ void CmdPartThickness::activated(int iMsg)
std::string thick = getUniqueObjectName("Thickness");
openCommand("Make Thickness");
openCommand(QT_TRANSLATE_NOOP("Command", "Make Thickness"));
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Thickness\",\"%s\")",thick.c_str());
doCommand(Doc,"App.ActiveDocument.%s.Faces = %s" ,thick.c_str(), selection.c_str());
doCommand(Doc,"App.ActiveDocument.%s.Value = 1.0",thick.c_str());
@@ -2097,7 +2097,7 @@ void CmdPartRuledSurface::activated(int iMsg)
return;
}
openCommand("Create ruled surface");
openCommand(QT_TRANSLATE_NOOP("Command", "Create ruled surface"));
doCommand(Doc, "FreeCAD.ActiveDocument.addObject('Part::RuledSurface', 'Ruled Surface')");
doCommand(Doc, "FreeCAD.ActiveDocument.ActiveObject.Curve1=(FreeCAD.ActiveDocument.%s,['%s'])"
,obj1.c_str(), link1.c_str());

View File

@@ -69,7 +69,7 @@ void CmdPartSimpleCylinder::activated(int iMsg)
if (dlg.exec()== QDialog::Accepted) {
Base::Vector3d dir = dlg.getDirection();
Base::Vector3d pos = dlg.getPosition();
openCommand("Create Part Cylinder");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Part Cylinder"));
doCommand(Doc,"from FreeCAD import Base");
doCommand(Doc,"import Part");
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Feature\",\"Cylinder\")"
@@ -134,7 +134,7 @@ void CmdPartShapeFromMesh::activated(int iMsg)
meshes = Gui::Selection().getObjectsOfType(meshid);
Gui::WaitCursor wc;
std::vector<App::DocumentObject*>::iterator it;
openCommand("Convert mesh");
openCommand(QT_TRANSLATE_NOOP("Command", "Convert mesh"));
for (it = meshes.begin(); it != meshes.end(); ++it) {
App::Document* doc = (*it)->getDocument();
std::string mesh = (*it)->getNameInDocument();
@@ -193,7 +193,7 @@ void CmdPartPointsFromMesh::activated(int iMsg)
meshes = Gui::Selection().getObjectsOfType(meshid);
Gui::WaitCursor wc;
std::vector<App::DocumentObject*>::iterator it;
openCommand("Points from mesh");
openCommand(QT_TRANSLATE_NOOP("Command", "Points from mesh"));
for (it = meshes.begin(); it != meshes.end(); ++it) {
App::Document* doc = (*it)->getDocument();
@@ -370,7 +370,7 @@ void CmdPartRefineShape::activated(int iMsg)
Gui::WaitCursor wc;
Base::Type partid = Base::Type::fromName("Part::Feature");
std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType(partid);
openCommand("Refine shape");
openCommand(QT_TRANSLATE_NOOP("Command", "Refine shape"));
std::for_each(objs.begin(), objs.end(), [](App::DocumentObject* obj) {
try {
doCommand(Doc,"App.ActiveDocument.addObject('Part::Refine','%s').Source="
@@ -427,7 +427,7 @@ void CmdPartDefeaturing::activated(int iMsg)
Gui::WaitCursor wc;
Base::Type partid = Base::Type::fromName("Part::Feature");
std::vector<Gui::SelectionObject> objs = Gui::Selection().getSelectionEx(0, partid);
openCommand("Defeaturing");
openCommand(QT_TRANSLATE_NOOP("Command", "Defeaturing"));
for (std::vector<Gui::SelectionObject>::iterator it = objs.begin(); it != objs.end(); ++it) {
try {
std::string shape;

View File

@@ -1054,7 +1054,7 @@ TaskDlgAttacher::~TaskDlgAttacher()
void TaskDlgAttacher::open()
{
Gui::Document* document = Gui::Application::Instance->getDocument(ViewProvider->getObject()->getDocument());
document->openCommand("Edit attachment");
document->openCommand(QT_TRANSLATE_NOOP("Command", "Edit attachment"));
}
void TaskDlgAttacher::clicked(int)

View File

@@ -429,7 +429,7 @@ void FaceColors::updatePanel()
void FaceColors::open()
{
Gui::Document* doc = Gui::Application::Instance->getDocument(d->vp->getObject()->getDocument());
doc->openCommand("Change face colors");
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Change face colors"));
}
bool FaceColors::accept()

View File

@@ -199,7 +199,7 @@ bool LoftWidget::accept()
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
if (!doc)
throw Base::RuntimeError("Document doesn't exist anymore");
doc->openCommand("Loft");
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Loft"));
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
doc->getDocument()->recompute();
App::DocumentObject* obj = doc->getDocument()->getActiveObject();

View File

@@ -237,7 +237,7 @@ void ShapeBuilderWidget::createEdgeFromVertex()
).arg(elements[0]).arg(elements[1]);
try {
Gui::Application::Instance->activeDocument()->openCommand("Edge");
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Edge"));
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
Gui::Application::Instance->activeDocument()->commitCommand();
}
@@ -278,7 +278,7 @@ void ShapeBuilderWidget::createWireFromEdge()
"del _\n"
).arg(list);
try {
Gui::Application::Instance->activeDocument()->openCommand("Wire");
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Wire"));
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
Gui::Application::Instance->activeDocument()->commitCommand();
}
@@ -330,7 +330,7 @@ void ShapeBuilderWidget::createFaceFromVertex()
}
try {
Gui::Application::Instance->activeDocument()->openCommand("Face");
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Face"));
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
Gui::Application::Instance->activeDocument()->commitCommand();
}
@@ -382,7 +382,7 @@ void ShapeBuilderWidget::createFaceFromEdge()
}
try {
Gui::Application::Instance->activeDocument()->openCommand("Face");
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Face"));
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
Gui::Application::Instance->activeDocument()->commitCommand();
}
@@ -445,7 +445,7 @@ void ShapeBuilderWidget::createShellFromFace()
}
try {
Gui::Application::Instance->activeDocument()->openCommand("Shell");
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Shell"));
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
Gui::Application::Instance->activeDocument()->commitCommand();
}
@@ -497,7 +497,7 @@ void ShapeBuilderWidget::createSolidFromShell()
}
try {
Gui::Application::Instance->activeDocument()->openCommand("Solid");
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Solid"));
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
Gui::Application::Instance->activeDocument()->commitCommand();
}

View File

@@ -339,7 +339,7 @@ bool SweepWidget::accept()
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
if (!doc)
throw Base::RuntimeError("Document doesn't exist anymore");
doc->openCommand("Sweep");
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Sweep"));
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
doc->getDocument()->recompute();
App::DocumentObject* obj = doc->getDocument()->getActiveObject();

View File

@@ -196,7 +196,7 @@ bool ViewProviderMirror::onDelete(const std::vector<std::string> &)
void ViewProviderMirror::dragStartCallback(void *, SoDragger *)
{
// This is called when a manipulator is about to manipulating
Gui::Application::Instance->activeDocument()->openCommand("Edit Mirror");
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Edit Mirror"));
}
void ViewProviderMirror::dragFinishCallback(void *, SoDragger *)