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
This commit is contained in:
luz paz
2020-11-28 13:57:01 -05:00
committed by wwmayer
parent 786d84d288
commit c93bf6cbae
12 changed files with 20 additions and 20 deletions

View File

@@ -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) {

View File

@@ -1131,7 +1131,7 @@ void StdCmdDelete::activated(int iMsg)
std::set<App::Document*> 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) {

View File

@@ -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<App::DocumentObject*,std::string>,
std::pair<App::DocumentObject*, std::vector<std::string> > > 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);

View File

@@ -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();

View File

@@ -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");

View File

@@ -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<App::DocumentObject*>::iterator it = pViews.begin(); it != pViews.end(); ++it)
alignObject(*it);
myDocument->commitCommand();

View File

@@ -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<App::DocumentObject*> 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<App::DocumentObject*>::iterator it=sel.begin();it!=sel.end();++it) {
std::map<std::string,App::Property*> props;
(*it)->getPropertyMap(props);

View File

@@ -99,7 +99,7 @@ void TransformStrategy::commitTransform(const Base::Matrix4D& mat)
std::set<App::DocumentObject*> objects = transformObjects();
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc) {
doc->openCommand("Transform");
doc->openCommand(QT_TRANSLATE_NOOP("Command", "Transform"));
for (std::set<App::DocumentObject*>::iterator it=objects.begin();it!=objects.end();++it) {
acceptDataTransform(mat, *it);
}

View File

@@ -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 *)

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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");