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

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

View File

@@ -129,7 +129,7 @@ void CmdTechDrawPageDefault::activated(int iMsg)
QFileInfo tfi(templateFileName);
if (tfi.isReadable()) {
Gui::WaitCursor wc;
openCommand("Drawing create page");
openCommand(QT_TRANSLATE_NOOP("Command", "Drawing create page"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawPage','%s')",PageName.c_str());
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawSVGTemplate','%s')",TemplateName.c_str());
@@ -199,7 +199,7 @@ void CmdTechDrawPageTemplate::activated(int iMsg)
QFileInfo tfi(templateFileName);
if (tfi.isReadable()) {
Gui::WaitCursor wc;
openCommand("Drawing create page");
openCommand(QT_TRANSLATE_NOOP("Command", "Drawing create page"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawPage','%s')",PageName.c_str());
// Create the Template Object to attach to the page
@@ -353,7 +353,7 @@ void CmdTechDrawView::activated(int iMsg)
Base::Vector3d projDir;
Gui::WaitCursor wc;
openCommand("Create view");
openCommand(QT_TRANSLATE_NOOP("Command", "Create view"));
std::string FeatName = getUniqueObjectName("View");
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewPart','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
@@ -606,7 +606,7 @@ void CmdTechDrawProjectionGroup::activated(int iMsg)
Base::Vector3d projDir;
Gui::WaitCursor wc;
openCommand("Create Projection Group");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Projection Group"));
std::string multiViewName = getUniqueObjectName("ProjGroup");
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawProjGroup','%s')",
@@ -697,7 +697,7 @@ bool CmdTechDrawProjectionGroup::isActive(void)
// Gui::WaitCursor wc;
// openCommand("Create view");
// openCommand(QT_TRANSLATE_NOOP("Command", "Create view"));
// std::string FeatName = getUniqueObjectName("MultiView");
// doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewMulti','%s')",FeatName.c_str());
// App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
@@ -828,7 +828,7 @@ void CmdTechDrawClipGroup::activated(int iMsg)
std::string PageName = page->getNameInDocument();
std::string FeatName = getUniqueObjectName("Clip");
openCommand("Create Clip");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Clip"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewClip','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
updateActive();
@@ -901,7 +901,7 @@ void CmdTechDrawClipGroupAdd::activated(int iMsg)
std::string ClipName = clip->getNameInDocument();
std::string ViewName = view->getNameInDocument();
openCommand("ClipGroupAdd");
openCommand(QT_TRANSLATE_NOOP("Command", "ClipGroupAdd"));
doCommand(Doc,"App.activeDocument().%s.ViewObject.Visibility = False",ViewName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",ClipName.c_str(),ViewName.c_str());
doCommand(Doc,"App.activeDocument().%s.ViewObject.Visibility = True",ViewName.c_str());
@@ -974,7 +974,7 @@ void CmdTechDrawClipGroupRemove::activated(int iMsg)
std::string ClipName = clip->getNameInDocument();
std::string ViewName = view->getNameInDocument();
openCommand("ClipGroupRemove");
openCommand(QT_TRANSLATE_NOOP("Command", "ClipGroupRemove"));
doCommand(Doc,"App.activeDocument().%s.ViewObject.Visibility = False",ViewName.c_str());
doCommand(Doc,"App.activeDocument().%s.removeView(App.activeDocument().%s)",ClipName.c_str(),ViewName.c_str());
doCommand(Doc,"App.activeDocument().%s.ViewObject.Visibility = True",ViewName.c_str());
@@ -1035,7 +1035,7 @@ void CmdTechDrawSymbol::activated(int iMsg)
{
std::string FeatName = getUniqueObjectName("Symbol");
filename = Base::Tools::escapeEncodeFilename(filename);
openCommand("Create Symbol");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Symbol"));
#if PY_MAJOR_VERSION < 3
doCommand(Doc,"f = open(unicode(\"%s\",'utf-8'),'r')",(const char*)filename.toUtf8());
#else
@@ -1099,7 +1099,7 @@ void CmdTechDrawDraftView::activated(int iMsg)
draftItemsFound++;
std::string FeatName = getUniqueObjectName("DraftView");
std::string SourceName = (*it)->getNameInDocument();
openCommand("Create DraftView");
openCommand(QT_TRANSLATE_NOOP("Command", "Create DraftView"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDraft','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",
FeatName.c_str(),SourceName.c_str());
@@ -1174,7 +1174,7 @@ void CmdTechDrawArchView::activated(int iMsg)
std::string FeatName = getUniqueObjectName("ArchView");
std::string SourceName = archObject->getNameInDocument();
openCommand("Create ArchView");
openCommand(QT_TRANSLATE_NOOP("Command", "Create ArchView"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewArch','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),SourceName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
@@ -1222,7 +1222,7 @@ void CmdTechDrawSpreadsheetView::activated(int iMsg)
}
std::string PageName = page->getNameInDocument();
openCommand("Create spreadsheet view");
openCommand(QT_TRANSLATE_NOOP("Command", "Create spreadsheet view"));
std::string FeatName = getUniqueObjectName("Sheet");
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewSpreadsheet','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",FeatName.c_str(),SpreadName.c_str());
@@ -1343,7 +1343,7 @@ void CmdTechDrawExportPageDXF::activated(int iMsg)
}
std::string PageName = page->getNameInDocument();
openCommand("Save page to dxf");
openCommand(QT_TRANSLATE_NOOP("Command", "Save page to dxf"));
doCommand(Doc,"import TechDraw");
fileName = Base::Tools::escapeEncodeFilename(fileName);
doCommand(Doc,"TechDraw.writeDXFPage(App.activeDocument().%s,u\"%s\")",PageName.c_str(),(const char*)fileName.toUtf8());

View File

@@ -548,7 +548,7 @@ void CmdTechDrawAnnotation::activated(int iMsg)
std::string PageName = page->getNameInDocument();
std::string FeatName = getUniqueObjectName("Annotation");
openCommand("Create Annotation");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Annotation"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewAnnotation','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
updateActive();

View File

@@ -210,7 +210,7 @@ void CmdTechDrawDimension::activated(int iMsg)
// return;
// }
// openCommand("Create Dimension");
// openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension"));
// doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
// doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
// ,dimType.c_str());
@@ -330,7 +330,7 @@ void CmdTechDrawRadiusDimension::activated(int iMsg)
return;
}
openCommand("Create Dimension");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"Radius");
@@ -452,7 +452,7 @@ void CmdTechDrawDiameterDimension::activated(int iMsg)
return;
}
openCommand("Create Dimension");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"Diameter");
@@ -549,7 +549,7 @@ void CmdTechDrawLengthDimension::activated(int iMsg)
return;
}
openCommand("Create Dimension");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'", FeatName.c_str()
, "Distance");
@@ -650,7 +650,7 @@ void CmdTechDrawHorizontalDimension::activated(int iMsg)
return;
}
openCommand("Create Dimension");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"DistanceX");
@@ -752,7 +752,7 @@ void CmdTechDrawVerticalDimension::activated(int iMsg)
return;
}
openCommand("Create Dimension");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"DistanceY");
@@ -843,7 +843,7 @@ void CmdTechDrawAngleDimension::activated(int iMsg)
return;
}
openCommand("Create Dimension");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"Angle");
@@ -932,7 +932,7 @@ void CmdTechDraw3PtAngleDimension::activated(int iMsg)
return;
}
openCommand("Create Dimension");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str()
,"Angle3Pt");
@@ -1359,7 +1359,7 @@ void CmdTechDrawLandmarkDimension::activated(int iMsg)
TechDraw::LandmarkDimension *dim = 0;
std::string FeatName = getUniqueObjectName("LandmarkDim");
openCommand("Create Dimension");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::LandmarkDimension','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
if (objects.size() == 2) {

View File

@@ -248,7 +248,7 @@ void CmdTechDrawHatch::activated(int iMsg)
}
}
openCommand("Create Hatch");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Hatch"));
if (removeOld) {
std::vector<std::pair< int, TechDraw::DrawHatch*> > toRemove;
for (auto& h: hatchObjs) { //all the hatch objects for selected DVP
@@ -351,7 +351,7 @@ void CmdTechDrawGeometricHatch::activated(int iMsg)
std::stringstream featLabel;
featLabel << FeatName << "FX" << TechDraw::DrawUtil::getIndexFromName(subNames.at(0));
openCommand("Create GeomHatch");
openCommand(QT_TRANSLATE_NOOP("Command", "Create GeomHatch"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawGeomHatch','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Label = '%s'",FeatName.c_str(),featLabel.str().c_str());
@@ -419,7 +419,7 @@ void CmdTechDrawImage::activated(int iMsg)
{
std::string FeatName = getUniqueObjectName("Image");
fileName = Base::Tools::escapeEncodeFilename(fileName);
openCommand("Create Image");
openCommand(QT_TRANSLATE_NOOP("Command", "Create Image"));
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewImage','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.ImageFile = '%s'",FeatName.c_str(),fileName.toUtf8().constData());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());

View File

@@ -933,7 +933,7 @@ void MDIViewPage::saveDXF(std::string fileName)
TechDraw::DrawPage* page = m_vpPage->getDrawPage();
std::string PageName = page->getNameInDocument();
fileName = Base::Tools::escapeEncodeFilename(fileName);
Gui::Command::openCommand("Save page to dxf");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Save page to dxf"));
Gui::Command::doCommand(Gui::Command::Doc,"import TechDraw");
Gui::Command::doCommand(Gui::Command::Doc,"TechDraw.writeDXFPage(App.activeDocument().%s,u\"%s\")",
PageName.c_str(),(const char*)fileName.c_str());

View File

@@ -484,7 +484,7 @@ void QGIViewBalloon::balloonLabelDragged(bool ctrl)
//set feature position (x,y) from graphic position
double x = Rez::appX(balloonLabel->X() / scale),
y = Rez::appX(balloonLabel->Y() / scale);
Gui::Command::openCommand("Drag Balloon");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Drag Balloon"));
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.X = %f", dvb->getNameInDocument(), x);
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Y = %f", dvb->getNameInDocument(), -y);
//if origin is also moving, calc new origin and update feature

View File

@@ -671,7 +671,7 @@ void QGIViewDimension::datumLabelDragFinished()
double x = Rez::appX(datumLabel->X()),
y = Rez::appX(datumLabel->Y());
Gui::Command::openCommand("Drag Dimension");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Drag Dimension"));
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.X = %f", dim->getNameInDocument(), x);
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Y = %f", dim->getNameInDocument(), -y);
Gui::Command::commitCommand();

View File

@@ -1194,10 +1194,10 @@ void QGVPage::mouseReleaseEvent(QMouseEvent *event)
std::string FeatName = getDrawPage()->getDocument()->getUniqueObjectName("Balloon");
std::string PageName = getDrawPage()->getNameInDocument();
Gui::Command::openCommand("Create Balloon");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Balloon"));
TechDraw::DrawViewBalloon *balloon = 0;
Gui::Command::openCommand("Create Balloon");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Balloon"));
Command::doCommand(Command::Doc,"App.activeDocument().addObject('TechDraw::DrawViewBalloon','%s')",FeatName.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());

View File

@@ -193,7 +193,7 @@ void TaskActiveView::enableTaskButtons(bool b)
bool TaskActiveView::accept()
{
// Base::Console().Message("TAV::accept()\n");
Gui::Command::openCommand("Create ActiveView");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create ActiveView"));
m_symbolFeat = createActiveView();
// m_symbolFeat->requestPaint();
m_symbolFeat->recomputeFeature();

View File

@@ -344,7 +344,7 @@ void TaskCenterLine::onFlipChanged()
void TaskCenterLine::createCenterLine(void)
{
// Base::Console().Message("TCL::createCenterLine() - m_type: %d\n", m_type);
Gui::Command::openCommand("Create CenterLine");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create CenterLine"));
// bool vertical = false;
double hShift = ui->qsbHorizShift->rawValue();
double vShift = ui->qsbVertShift->rawValue();
@@ -389,7 +389,7 @@ void TaskCenterLine::createCenterLine(void)
void TaskCenterLine::updateCenterLine(void)
{
// Base::Console().Message("TCL::updateCenterLine()\n");
Gui::Command::openCommand("Edit CenterLine");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit CenterLine"));
m_cl->m_format.m_color.setValue<QColor>(ui->cpLineColor->color() );
m_cl->m_format.m_weight = ui->dsbWeight->value().getValue();
m_cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1;

View File

@@ -269,7 +269,7 @@ bool TaskCosmeticLine::accept()
m_partFeat->requestPaint();
} else {
//update mode
Gui::Command::openCommand("Update CosmeticLine");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Update CosmeticLine"));
updateCosmeticLine();
m_partFeat->refreshCEGeoms();
m_partFeat->requestPaint();

View File

@@ -470,7 +470,7 @@ void TaskDetail::enableTaskButtons(bool b)
void TaskDetail::createDetail()
{
// Base::Console().Message("TD::createDetail()\n");
Gui::Command::openCommand("Create Detail View");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Detail View"));
m_detailName = m_doc->getUniqueObjectName("Detail");
@@ -507,7 +507,7 @@ void TaskDetail::updateDetail()
{
// Base::Console().Message("TD::updateDetail()\n");
try {
Gui::Command::openCommand("Update Detail");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Update Detail"));
double x = ui->qsbX->rawValue();
double y = ui->qsbY->rawValue();
Base::Vector3d temp(x, y, 0.0);

View File

@@ -398,7 +398,7 @@ void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
std::string PageName = m_basePage->getNameInDocument();
Gui::Command::openCommand("Create Leader");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Leader"));
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
m_leaderType.c_str(),m_leaderName.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",
@@ -452,7 +452,7 @@ void TaskLeaderLine::createLeaderFeature(std::vector<Base::Vector3d> converted)
void TaskLeaderLine::updateLeaderFeature(void)
{
// Base::Console().Message("TTL::updateLeaderFeature()\n");
Gui::Command::openCommand("Edit Leader");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit Leader"));
//waypoints & x,y are updated by QGILeaderLine (for edits only!)
commonFeatureUpdate();
App::Color ac;

View File

@@ -355,7 +355,7 @@ void TaskRichAnno::createAnnoFeature()
std::string PageName = m_basePage->getNameInDocument();
Gui::Command::openCommand("Create Anno");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Anno"));
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
annoType.c_str(),annoName.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",
@@ -414,7 +414,7 @@ void TaskRichAnno::createAnnoFeature()
void TaskRichAnno::updateAnnoFeature()
{
// Base::Console().Message("TRA::updateAnnoFeature()\n");
Gui::Command::openCommand("Edit Anno");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit Anno"));
commonFeatureUpdate();
App::Color ac;
ac.setValue<QColor>(ui->cpFrameColor->color());

View File

@@ -352,7 +352,7 @@ bool TaskSectionView::apply(void)
void TaskSectionView::applyQuick(std::string dir)
{
// Base::Console().Message("TSV::applyQuick(%s)\n", dir.c_str());
Gui::Command::openCommand("Apply Quick");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Apply Quick"));
m_dirName = dir;
if (m_section == nullptr) {
createSectionView();
@@ -378,7 +378,7 @@ void TaskSectionView::applyQuick(std::string dir)
void TaskSectionView::applyAligned(void)
{
Base::Console().Message("TSV::applyAligned() - not implemented yet\n");
Gui::Command::openCommand("Apply Aligned");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Apply Aligned"));
m_dirName = "Aligned";
//fiddle with directions here
@@ -401,7 +401,7 @@ void TaskSectionView::createSectionView(void)
std::string baseName = m_base->getNameInDocument();
double baseScale = m_base->getScale();
Gui::Command::openCommand("Create SectionView");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create SectionView"));
if (m_section == nullptr) {
m_sectionName = m_base->getDocument()->getUniqueObjectName("SectionView");
std::string sectionType = "TechDraw::DrawViewSection";

View File

@@ -650,7 +650,7 @@ bool TaskWeldingSymbol::accept()
{
// Base::Console().Message("TWS::accept()\n");
if (m_createMode) {
Gui::Command::openCommand("Create WeldSymbol");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create WeldSymbol"));
m_weldFeat = createWeldingSymbol();
updateTiles();
Gui::Command::updateActive();
@@ -658,7 +658,7 @@ bool TaskWeldingSymbol::accept()
m_weldFeat->recomputeFeature();
// m_weldFeat->requestPaint(); //not a dv!
} else {
Gui::Command::openCommand("Edit WeldSymbol");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit WeldSymbol"));
try {
updateWeldingSymbol();
updateTiles();