From 91f037912ec324212cea0d351fb66dee5dd58180 Mon Sep 17 00:00:00 2001 From: Roy Date: Mon, 10 Jan 2022 10:17:53 +0100 Subject: [PATCH 1/4] Draft: Fix translation issues --- src/Mod/Draft/InitGui.py | 16 ++++++++-------- .../draftguitools/gui_annotationstyleeditor.py | 4 +--- src/Mod/Draft/draftguitools/gui_arcs.py | 17 +++++------------ .../Draft/draftguitools/gui_circulararray.py | 8 +++----- src/Mod/Draft/draftguitools/gui_fillets.py | 5 ++--- src/Mod/Draft/draftguitools/gui_orthoarray.py | 8 +++----- src/Mod/Draft/draftguitools/gui_polararray.py | 8 +++----- src/Mod/Draft/draftutils/init_tools.py | 6 +++--- 8 files changed, 28 insertions(+), 44 deletions(-) diff --git a/src/Mod/Draft/InitGui.py b/src/Mod/Draft/InitGui.py index 3d90e2f0be..ca0183b59c 100644 --- a/src/Mod/Draft/InitGui.py +++ b/src/Mod/Draft/InitGui.py @@ -101,30 +101,30 @@ class DraftWorkbench(FreeCADGui.Workbench): # Set up toolbars it.init_toolbar(self, - QT_TRANSLATE_NOOP("Draft", "Draft creation tools"), + QT_TRANSLATE_NOOP("Workbench", "Draft creation tools"), self.drawing_commands) it.init_toolbar(self, - QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"), + QT_TRANSLATE_NOOP("Workbench", "Draft annotation tools"), self.annotation_commands) it.init_toolbar(self, - QT_TRANSLATE_NOOP("Draft", "Draft modification tools"), + QT_TRANSLATE_NOOP("Workbench", "Draft modification tools"), self.modification_commands) it.init_toolbar(self, - QT_TRANSLATE_NOOP("Draft", "Draft utility tools"), + QT_TRANSLATE_NOOP("Workbench", "Draft utility tools"), self.utility_commands_toolbar) # Set up menus it.init_menu(self, - [QT_TRANSLATE_NOOP("Draft", "&Drafting")], + [QT_TRANSLATE_NOOP("Workbench", "&Drafting")], self.drawing_commands) it.init_menu(self, - [QT_TRANSLATE_NOOP("Draft", "&Annotation")], + [QT_TRANSLATE_NOOP("Workbench", "&Annotation")], self.annotation_commands) it.init_menu(self, - [QT_TRANSLATE_NOOP("Draft", "&Modification")], + [QT_TRANSLATE_NOOP("Workbench", "&Modification")], self.modification_commands) it.init_menu(self, - [QT_TRANSLATE_NOOP("Draft", "&Utilities")], + [QT_TRANSLATE_NOOP("Workbench", "&Utilities")], self.utility_commands_menu) # Set up preferences pages diff --git a/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py b/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py index cc77853656..f952f26ed8 100644 --- a/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py +++ b/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py @@ -73,13 +73,11 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Manage or create annotation styles" - return {'Pixmap': ":icons/Draft_Annotation_Style.svg", 'MenuText': QT_TRANSLATE_NOOP("Draft_AnnotationStyleEditor", "Annotation styles..."), 'ToolTip': QT_TRANSLATE_NOOP("Draft_AnnotationStyleEditor", - _tip)} + "Manage or create annotation styles")} def Activated(self): """Execute when the command is called. diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index 9c4fb7334f..5650851c77 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -61,7 +61,6 @@ class Arc(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - return {'Pixmap': 'Draft_Arc', 'Accel': "A, R", 'MenuText': QT_TRANSLATE_NOOP("Draft_Arc", "Arc"), @@ -483,15 +482,10 @@ class Arc_3Points(gui_base.GuiCommandSimplest): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Arc by 3 points" - _tip = ("Creates a circular arc by picking 3 points.\n" - "CTRL to snap, SHIFT to constrain.") - - d = {'Pixmap': "Draft_Arc_3Points", - 'MenuText': QT_TRANSLATE_NOOP("Draft_Arc_3Points", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Arc_3Points", _tip), - 'Accel': 'A,T'} - return d + return {'Pixmap': "Draft_Arc_3Points", + 'Accel': "A,T"} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Arc_3Points", "Arc by 3 points"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Arc_3Points", "Creates a circular arc by picking 3 points.\nCTRL to snap, SHIFT to constrain."), def Activated(self): """Execute when the command is called.""" @@ -556,7 +550,7 @@ class Arc_3Points(gui_base.GuiCommandSimplest): Gui.Snapper.ui.setTitle(title=translate("draft", "Arc by 3 points"), icon="Draft_Arc_3Points") Gui.Snapper.ui.continueCmd.show() - + else: # If three points were already picked in the 3D view # proceed with creating the final object. @@ -604,7 +598,6 @@ class ArcGroup: def GetResources(self): """Set icon, menu and tooltip.""" - return {'MenuText': QT_TRANSLATE_NOOP("Draft_ArcTools", "Arc tools"), 'ToolTip': QT_TRANSLATE_NOOP("Draft_ArcTools", "Create various types of circular arcs.")} diff --git a/src/Mod/Draft/draftguitools/gui_circulararray.py b/src/Mod/Draft/draftguitools/gui_circulararray.py index cabd1c0ca8..71877b75c0 100644 --- a/src/Mod/Draft/draftguitools/gui_circulararray.py +++ b/src/Mod/Draft/draftguitools/gui_circulararray.py @@ -61,11 +61,9 @@ class CircularArray(gui_base.GuiCommandBase): def GetResources(self): """Set icon, menu and tooltip.""" - - d = {'Pixmap': 'Draft_CircularArray', - 'MenuText': QT_TRANSLATE_NOOP("Draft", "Circular array"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", "Creates copies of the selected object, and places the copies in a radial pattern\ncreating various circular layers.\n\nThe array can be turned into an orthogonal or a polar array by changing its type.")} - return d + return {'Pixmap': 'Draft_CircularArray', + 'MenuText': QT_TRANSLATE_NOOP("Draft_CircularArray", "Circular array"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_CircularArray", "Creates copies of the selected object, and places the copies in a radial pattern\ncreating various circular layers.\n\nThe array can be turned into an orthogonal or a polar array by changing its type.")} def Activated(self): """Execute when the command is called. diff --git a/src/Mod/Draft/draftguitools/gui_fillets.py b/src/Mod/Draft/draftguitools/gui_fillets.py index 8ce4da4239..d73e09e7a5 100644 --- a/src/Mod/Draft/draftguitools/gui_fillets.py +++ b/src/Mod/Draft/draftguitools/gui_fillets.py @@ -59,11 +59,10 @@ class Fillet(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - return {'Pixmap': 'Draft_Fillet', 'Accel':'F,I', - 'MenuText': QT_TRANSLATE_NOOP("Draft", "Fillet"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", "Creates a fillet between two selected wires or edges.")} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Fillet", "Fillet"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Fillet", "Creates a fillet between two selected wires or edges.")} def Activated(self, name="Fillet"): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_orthoarray.py b/src/Mod/Draft/draftguitools/gui_orthoarray.py index 22b1ed06df..e9fedc4c2a 100644 --- a/src/Mod/Draft/draftguitools/gui_orthoarray.py +++ b/src/Mod/Draft/draftguitools/gui_orthoarray.py @@ -61,11 +61,9 @@ class OrthoArray(gui_base.GuiCommandBase): def GetResources(self): """Set icon, menu and tooltip.""" - - d = {'Pixmap': 'Draft_Array', - 'MenuText': QT_TRANSLATE_NOOP("Draft", "Array"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", "Creates copies of the selected object, and places the copies in an orthogonal pattern,\nmeaning the copies follow the specified direction in the X, Y, Z axes.\n\nThe array can be turned into a polar or a circular array by changing its type.")} - return d + return {'Pixmap': 'Draft_Array', + 'MenuText': QT_TRANSLATE_NOOP("Draft_Array", "Array"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Array", "Creates copies of the selected object, and places the copies in an orthogonal pattern,\nmeaning the copies follow the specified direction in the X, Y, Z axes.\n\nThe array can be turned into a polar or a circular array by changing its type.")} def Activated(self): """Execute when the command is called. diff --git a/src/Mod/Draft/draftguitools/gui_polararray.py b/src/Mod/Draft/draftguitools/gui_polararray.py index 6ed9e49dae..a7f29f676f 100644 --- a/src/Mod/Draft/draftguitools/gui_polararray.py +++ b/src/Mod/Draft/draftguitools/gui_polararray.py @@ -61,11 +61,9 @@ class PolarArray(gui_base.GuiCommandBase): def GetResources(self): """Set icon, menu and tooltip.""" - - d = {'Pixmap': 'Draft_PolarArray', - 'MenuText': QT_TRANSLATE_NOOP("Draft", "Polar array"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", "Creates copies of the selected object, and places the copies in a polar pattern\ndefined by a center of rotation and its angle.\n\nThe array can be turned into an orthogonal or a circular array by changing its type.")} - return d + return {'Pixmap': 'Draft_PolarArray', + 'MenuText': QT_TRANSLATE_NOOP("Draft_PolarArray", "Polar array"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_PolarArray", "Creates copies of the selected object, and places the copies in a polar pattern\ndefined by a center of rotation and its angle.\n\nThe array can be turned into an orthogonal or a circular array by changing its type.")} def Activated(self): """Execute when the command is called. diff --git a/src/Mod/Draft/draftutils/init_tools.py b/src/Mod/Draft/draftutils/init_tools.py index b1f6fbce60..d4200b02d7 100644 --- a/src/Mod/Draft/draftutils/init_tools.py +++ b/src/Mod/Draft/draftutils/init_tools.py @@ -45,7 +45,7 @@ def get_draft_drawing_commands(): return ["Draft_Line", "Draft_Wire", "Draft_Fillet", - ([QT_TRANSLATE_NOOP("Draft", "Arc tools")], + ([QT_TRANSLATE_NOOP("Workbench", "Arc tools")], list(arc_group.GetCommands(arc_group))), # tuple len=2: submenu ("Draft_ArcTools", ), # tuple len=1: toolbar flyout "Draft_Circle", @@ -53,7 +53,7 @@ def get_draft_drawing_commands(): "Draft_Rectangle", "Draft_Polygon", "Draft_BSpline", - ([QT_TRANSLATE_NOOP("Draft", "Bezier tools")], + ([QT_TRANSLATE_NOOP("Workbench", "Bezier tools")], list(bez_group.GetCommands(bez_group))), ("Draft_BezierTools", ), "Draft_Point", @@ -84,7 +84,7 @@ def get_draft_modification_commands(): "Draft_Stretch", "Separator", "Draft_Clone", - ([QT_TRANSLATE_NOOP("Draft", "Array tools")], + ([QT_TRANSLATE_NOOP("Workbench", "Array tools")], list(arr_group.GetCommands(arr_group))), # tuple len=2: submenu ("Draft_ArrayTools", ), # tuple len=1: toolbar flyout "Separator", From cefd414f541297fa91b9cb46c1838ed85ba301fb Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Mon, 10 Jan 2022 15:12:09 +0100 Subject: [PATCH 2/4] Update gui_arrays.py --- src/Mod/Draft/draftguitools/gui_arrays.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_arrays.py b/src/Mod/Draft/draftguitools/gui_arrays.py index bda4dc9a8f..171d14d4bc 100644 --- a/src/Mod/Draft/draftguitools/gui_arrays.py +++ b/src/Mod/Draft/draftguitools/gui_arrays.py @@ -62,8 +62,8 @@ class ArrayGroup: """Set icon, menu and tooltip.""" return {'Pixmap': 'Draft_Array', - 'MenuText': QT_TRANSLATE_NOOP("Draft", "Array tools"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", "Create various types of arrays, including rectangular, polar, circular, path, and point")} + 'MenuText': QT_TRANSLATE_NOOP("Draft_ArrayTools", "Array tools"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_ArrayTools", "Create various types of arrays, including rectangular, polar, circular, path, and point")} def IsActive(self): """Return True when this command should be available.""" From 0f79fe81f90821aa9d6eef5cade2d025ce4ee982 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 11 Jan 2022 11:42:45 +0100 Subject: [PATCH 3/4] Update gui_arcs.py --- src/Mod/Draft/draftguitools/gui_arcs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index 5650851c77..05609b9f11 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -483,9 +483,9 @@ class Arc_3Points(gui_base.GuiCommandSimplest): def GetResources(self): """Set icon, menu and tooltip.""" return {'Pixmap': "Draft_Arc_3Points", - 'Accel': "A,T"} + 'Accel': "A,T", 'MenuText': QT_TRANSLATE_NOOP("Draft_Arc_3Points", "Arc by 3 points"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Arc_3Points", "Creates a circular arc by picking 3 points.\nCTRL to snap, SHIFT to constrain."), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Arc_3Points", "Creates a circular arc by picking 3 points.\nCTRL to snap, SHIFT to constrain.")} def Activated(self): """Execute when the command is called.""" From db7b37dd1ffcf72e8b14adfb2f90a24c39f0b9e3 Mon Sep 17 00:00:00 2001 From: Roy Date: Wed, 12 Jan 2022 13:43:49 +0100 Subject: [PATCH 4/4] Draft: Fix additional translation issues related to the snapping commands --- src/Mod/Draft/draftguitools/gui_snapper.py | 45 ++++++---------- .../Draft/draftutils/init_draft_statusbar.py | 54 +++++++++---------- src/Mod/Draft/draftutils/init_tools.py | 29 +++++++++- 3 files changed, 68 insertions(+), 60 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_snapper.py b/src/Mod/Draft/draftguitools/gui_snapper.py index 2236834951..19622e1e91 100644 --- a/src/Mod/Draft/draftguitools/gui_snapper.py +++ b/src/Mod/Draft/draftguitools/gui_snapper.py @@ -51,7 +51,9 @@ import DraftGeomUtils import draftguitools.gui_trackers as trackers from draftutils.init_tools import get_draft_snap_commands +from draftutils.init_tools import get_draft_snap_tooltips from draftutils.messages import _msg, _wrn +from draftutils.translate import translate __title__ = "FreeCAD Draft Snap tools" __author__ = "Yorik van Havre" @@ -1472,7 +1474,7 @@ class Snapper: self.toolbar = QtGui.QToolBar(mw) mw.addToolBar(QtCore.Qt.TopToolBarArea, self.toolbar) self.toolbar.setObjectName("Draft Snap") - self.toolbar.setWindowTitle(QtCore.QCoreApplication.translate("Workbench", "Draft Snap")) + self.toolbar.setWindowTitle(translate("Workbench", "Draft Snap")) # make snap buttons snap_gui_commands = get_draft_snap_commands() @@ -1495,27 +1497,24 @@ class Snapper: button_suffix The suffix that have to be applied to the command name to define the button name """ + tooltips_dict = get_draft_snap_tooltips() for gc in commands: if gc == "Separator": continue - if gc == "Draft_ToggleGrid": - gb = self.init_grid_button(self.toolbar) - context.addAction(gb) - QtCore.QObject.connect(gb, QtCore.SIGNAL("triggered()"), - lambda f=Gui.doCommand, - arg='Gui.runCommand("Draft_ToggleGrid")':f(arg)) - continue # setup toolbar buttons - command = 'Gui.runCommand("' + gc + '")' b = QtGui.QAction(context) - b.setIcon(QtGui.QIcon(':/icons/' + gc[6:] + '.svg')) - b.setText(QtCore.QCoreApplication.translate("Draft_Snap", "Snap " + gc[11:])) - b.setToolTip(QtCore.QCoreApplication.translate("Draft_Snap", "Snap " + gc[11:])) + if gc == "Draft_ToggleGrid": + b.setIcon(QtGui.QIcon(":/icons/Draft_Grid.svg")) + else: + b.setIcon(QtGui.QIcon(":/icons/" + gc[6:] + ".svg")) + b.setCheckable(True) + b.setChecked(True) + b.setText(tooltips_dict[gc]) + b.setToolTip(tooltips_dict[gc]) b.setObjectName(gc + button_suffix) - b.setWhatsThis("Draft_" + gc[11:].capitalize()) - b.setCheckable(True) - b.setChecked(True) + b.setWhatsThis(gc) context.addAction(b) + command = 'Gui.runCommand("' + gc + '")' QtCore.QObject.connect(b, QtCore.SIGNAL("triggered()"), lambda f=Gui.doCommand, @@ -1526,18 +1525,6 @@ class Snapper: b.setStatusTip(b.toolTip()) - def init_grid_button(self, context): - """Add grid button to the given toolbar""" - b = QtGui.QAction(context) - b.setIcon(QtGui.QIcon.fromTheme("Draft", QtGui.QIcon(":/icons/" - "Draft_Grid.svg"))) - b.setText(QtCore.QCoreApplication.translate("Draft_Snap", "Toggles Grid On/Off")) - b.setToolTip(QtCore.QCoreApplication.translate("Draft_Snap", "Toggle Draft Grid")) - b.setObjectName("Grid_Button") - b.setWhatsThis("Draft_ToggleGrid") - return b - - def restore_snap_buttons_state(self, toolbar, button_suffix): """ Restore toolbar button's checked state according to @@ -1553,10 +1540,10 @@ class Snapper: snap = action.objectName()[11:].replace(button_suffix, "") if snap in self.active_snaps: action.setChecked(True) - action.setToolTip(action.toolTip() + " (ON)") + action.setToolTip(action.toolTip() + " " + (translate("draft", "(ON)"))) elif snap in Gui.Snapper.snaps: # required: the toolbar has more children than the buttons action.setChecked(False) - action.setToolTip(action.toolTip() + " (OFF)") + action.setToolTip(action.toolTip() + " " + (translate("draft", "(OFF)"))) def get_snap_toolbar(self): diff --git a/src/Mod/Draft/draftutils/init_draft_statusbar.py b/src/Mod/Draft/draftutils/init_draft_statusbar.py index 67a700b113..c2cc538918 100644 --- a/src/Mod/Draft/draftutils/init_draft_statusbar.py +++ b/src/Mod/Draft/draftutils/init_draft_statusbar.py @@ -33,12 +33,12 @@ and is populated by various widgets, buttons and menus. # @{ import PySide.QtCore as QtCore import PySide.QtGui as QtGui -from PySide.QtCore import QT_TRANSLATE_NOOP import FreeCAD as App import FreeCADGui as Gui from draftutils.init_tools import get_draft_snap_commands +from draftutils.translate import translate #---------------------------------------------------------------------------- # SCALE WIDGET FUNCTIONS @@ -48,21 +48,21 @@ draft_scales_metrics = ["1:1000", "1:500", "1:250", "1:200", "1:100", "1:50", "1:25","1:20", "1:10", "1:5","1:2", "1:1", "2:1", "5:1", "10:1", "20:1", - QT_TRANSLATE_NOOP("draft","custom"), + translate("draft", "custom"), ] draft_scales_arch_imperial = ["1/16in=1ft", "3/32in=1ft", "1/8in=1ft", "3/16in=1ft", "1/4in=1ft","3/8in=1ft", "1/2in=1ft", "3/4in=1ft", "1in=1ft", "1.5in=1ft", "3in=1ft", - QT_TRANSLATE_NOOP("draft","custom"), + translate("draft", "custom"), ] draft_scales_eng_imperial = ["1in=10ft", "1in=20ft", "1in=30ft", "1in=40ft", "1in=50ft", "1in=60ft", "1in=70ft", "1in=80ft", "1in=90ft", "1in=100ft", - QT_TRANSLATE_NOOP("draft","custom"), + translate("draft", "custom"), ] def get_scales(unit_system = 0): @@ -135,9 +135,8 @@ def label_to_scale(label): scale = num/den return scale except Exception: - err = QT_TRANSLATE_NOOP("draft", - "Unable to convert input into a " - "scale factor") + err = translate("draft", + "Unable to convert input into a scale factor") App.Console.PrintWarning(err) return None @@ -151,13 +150,11 @@ def _set_scale(action): mw = Gui.getMainWindow() sb = mw.statusBar() scale_widget = sb.findChild(QtGui.QToolBar,"draft_status_scale_widget") - if action.text() == QT_TRANSLATE_NOOP("draft","custom"): - dialog_text = QT_TRANSLATE_NOOP("draft", - "Set custom annotation scale in " - "format x:x, x=x" - ) - custom_scale = QtGui.QInputDialog.getText(None, "Set custom scale", - dialog_text) + if action.text() == translate("draft", "custom"): + title_text = translate("draft", "Set custom scale") + dialog_text = translate("draft", + "Set custom annotation scale in format x:x, x=x") + custom_scale = QtGui.QInputDialog.getText(None, title_text, dialog_text) if custom_scale[1]: print(custom_scale[0]) scale = label_to_scale(custom_scale[0]) @@ -213,8 +210,8 @@ def init_draft_statusbar_scale(): gUnits.triggered.connect(_set_scale) scale_label = scale_to_label(draft_annotation_scale) scaleLabel.setText(scale_label) - tooltip = "Set the scale used by draft annotation tools" - scaleLabel.setToolTip(QT_TRANSLATE_NOOP("draft",tooltip)) + scaleLabel.setToolTip(translate("draft", + "Set the scale used by draft annotation tools")) scale_widget.addWidget(scaleLabel) scale_widget.scaleLabel = scaleLabel @@ -248,8 +245,7 @@ def init_draft_statusbar_snap(): gridbutton.setIcon(QtGui.QIcon.fromTheme("Draft", QtGui.QIcon(":/icons/" "Draft_Grid.svg"))) - gridbutton.setToolTip(QT_TRANSLATE_NOOP("Draft", - "Toggles Grid On/Off")) + gridbutton.setToolTip(translate("Draft", "Toggles Grid On/Off")) gridbutton.setObjectName("Grid_Statusbutton") gridbutton.setWhatsThis("Draft_ToggleGrid") gridbutton.setFlat(True) @@ -262,12 +258,11 @@ def init_draft_statusbar_snap(): snappref = param.GetString("snapModes","111111111101111")[0] snapbutton = QtGui.QPushButton(snap_widget) snapbutton.setIcon(QtGui.QIcon.fromTheme("Draft", - QtGui.QIcon(":/icons/" - "Snap_Lock.svg"))) + QtGui.QIcon(":/icons/" + "Snap_Lock.svg"))) snapbutton.setObjectName("Snap_Statusbutton") snapbutton.setWhatsThis("Draft_ToggleLockSnap") - snapbutton.setToolTip(QT_TRANSLATE_NOOP("Draft", - "Object snapping")) + snapbutton.setToolTip(translate("Draft", "Object snapping")) snapbutton.setCheckable(True) snapbutton.setChecked(bool(int(snappref))) snapbutton.setFlat(True) @@ -298,8 +293,8 @@ def init_draft_statusbar_snap(): dimbutton.setIcon(QtGui.QIcon.fromTheme("Draft", QtGui.QIcon(":/icons/" "Snap_Dimensions.svg"))) - dimbutton.setToolTip(QT_TRANSLATE_NOOP("Draft", - "Toggles Visual Aid Dimensions On/Off")) + dimbutton.setToolTip(translate("Draft", + "Toggles Visual Aid Dimensions On/Off")) dimbutton.setObjectName("Draft_Snap_Dimensions_Statusbutton") dimbutton.setWhatsThis("Draft_ToggleDimensions") dimbutton.setFlat(True) @@ -318,8 +313,7 @@ def init_draft_statusbar_snap(): "Snap_Ortho.svg"))) orthobutton.setObjectName("Draft_Snap_Ortho"+"_Statusbutton") orthobutton.setWhatsThis("Draft_ToggleOrtho") - orthobutton.setToolTip(QT_TRANSLATE_NOOP("Draft", - "Toggles Ortho On/Off")) + orthobutton.setToolTip(translate("Draft", "Toggles Ortho On/Off")) orthobutton.setFlat(True) orthobutton.setCheckable(True) orthobutton.setChecked(bool(int(ortopref))) @@ -332,12 +326,12 @@ def init_draft_statusbar_snap(): wppref = param.GetString("snapModes","111111111101111")[14] wpbutton = QtGui.QPushButton(snap_widget) wpbutton.setIcon(QtGui.QIcon.fromTheme("Draft", - QtGui.QIcon(":/icons/" - "Snap_WorkingPlane.svg"))) + QtGui.QIcon(":/icons/" + "Snap_WorkingPlane.svg"))) wpbutton.setObjectName("Draft_Snap_WorkingPlane_Statusbutton") wpbutton.setWhatsThis("Draft_ToggleWorkingPlaneSnap") - wpbutton.setToolTip(QT_TRANSLATE_NOOP("Draft", - "Toggles Constrain to Working Plane On/Off")) + wpbutton.setToolTip(translate("Draft", + "Toggles Constrain to Working Plane On/Off")) wpbutton.setFlat(True) wpbutton.setCheckable(True) wpbutton.setChecked(bool(int(wppref))) diff --git a/src/Mod/Draft/draftutils/init_tools.py b/src/Mod/Draft/draftutils/init_tools.py index d4200b02d7..ceb0f076dd 100644 --- a/src/Mod/Draft/draftutils/init_tools.py +++ b/src/Mod/Draft/draftutils/init_tools.py @@ -32,6 +32,8 @@ # @{ from PySide.QtCore import QT_TRANSLATE_NOOP +from draftutils.translate import translate + # Comment out commands that aren't ready to be used @@ -154,7 +156,32 @@ def get_draft_snap_commands(): 'Draft_Snap_Grid', 'Draft_Snap_WorkingPlane', 'Draft_Snap_Dimensions', - 'Separator', 'Draft_ToggleGrid'] + 'Separator', + 'Draft_ToggleGrid'] + + +def get_draft_snap_tooltips(): + """Return a dictionary with tooltips for the snapping commands. + + For the snapping commands in the default toolbar and in the statusbar the + tooltips from the `GetResources` functions in gui_snaps.py are not used. + """ + return {'Draft_Snap_Lock' : translate('draft', 'Snap Lock'), + 'Draft_Snap_Endpoint' : translate('draft', 'Snap Endpoint'), + 'Draft_Snap_Midpoint' : translate('draft', 'Snap Midpoint'), + 'Draft_Snap_Center' : translate('draft', 'Snap Center'), + 'Draft_Snap_Angle' : translate('draft', 'Snap Angle'), + 'Draft_Snap_Intersection' : translate('draft', 'Snap Intersection'), + 'Draft_Snap_Perpendicular': translate('draft', 'Snap Perpendicular'), + 'Draft_Snap_Extension' : translate('draft', 'Snap Extension'), + 'Draft_Snap_Parallel' : translate('draft', 'Snap Parallel'), + 'Draft_Snap_Special' : translate('draft', 'Snap Special'), + 'Draft_Snap_Near' : translate('draft', 'Snap Near'), + 'Draft_Snap_Ortho' : translate('draft', 'Snap Ortho'), + 'Draft_Snap_Grid' : translate('draft', 'Snap Grid'), + 'Draft_Snap_WorkingPlane' : translate('draft', 'Snap WorkingPlane'), + 'Draft_Snap_Dimensions' : translate('draft', 'Snap Dimensions'), + 'Draft_ToggleGrid' : translate('draft', 'Toggle Draft Grid')} def get_draft_context_commands():