From d989acaae8b405e544b42703be0f877bde7071d5 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 29 Dec 2015 12:10:22 -0200 Subject: [PATCH] Draft: Added a grid toggle button to the snap toolbar --- src/Mod/Draft/DraftSnap.py | 13 ++ src/Mod/Draft/DraftTools.py | 2 +- src/Mod/Draft/Resources/Draft.qrc | 1 + src/Mod/Draft/Resources/icons/Draft_Grid.svg | 129 +++++++++++++++++++ 4 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 src/Mod/Draft/Resources/icons/Draft_Grid.svg diff --git a/src/Mod/Draft/DraftSnap.py b/src/Mod/Draft/DraftSnap.py index 6f721418d..66590b9e8 100644 --- a/src/Mod/Draft/DraftSnap.py +++ b/src/Mod/Draft/DraftSnap.py @@ -1074,6 +1074,16 @@ class Snapper: self.toolbar.setObjectName("Draft Snap") self.toolbar.setWindowTitle(QtCore.QCoreApplication.translate("Workbench", "Draft Snap")) self.toolbarButtons = [] + # grid button + gridbutton = QtGui.QPushButton(None) + gridbutton.setIcon(QtGui.QIcon(":/icons/Draft_Grid.svg")) + gridbutton.setIconSize(QtCore.QSize(isize, isize)) + gridbutton.setMaximumSize(QtCore.QSize(bsize,bsize)) + gridbutton.setToolTip(QtCore.QCoreApplication.translate("Draft_ToggleGrid","Toggles the Draft grid on/off")) + gridbutton.setObjectName("GridButton") + QtCore.QObject.connect(gridbutton,QtCore.SIGNAL("clicked()"),self.toggleGrid) + self.toolbar.addWidget(gridbutton) + # master button self.masterbutton = QtGui.QPushButton(None) self.masterbutton.setIcon(QtGui.QIcon(":/icons/Snap_Lock.svg")) self.masterbutton.setIconSize(QtCore.QSize(isize, isize)) @@ -1123,6 +1133,9 @@ class Snapper: c += 1 if not Draft.getParam("showSnapBar",True): self.toolbar.hide() + + def toggleGrid(self): + FreeCADGui.runCommand("Draft_ToggleGrid") def saveSnapModes(self): "saves the snap modes for next sessions" diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index c71380075..694b7e520 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -4319,7 +4319,7 @@ class ToggleGrid(): "The Draft ToggleGrid command definition" def GetResources(self): - return {'Pixmap' : 'Snap_Grid', + return {'Pixmap' : 'Draft_Grid', 'Accel' : "G,R", 'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_ToggleGrid", "Toggle Grid"), 'ToolTip' : QtCore.QT_TRANSLATE_NOOP("Draft_ToggleGrid", "Toggles the Draft grid on/off")} diff --git a/src/Mod/Draft/Resources/Draft.qrc b/src/Mod/Draft/Resources/Draft.qrc index d2edc859f..e4f9c7253 100644 --- a/src/Mod/Draft/Resources/Draft.qrc +++ b/src/Mod/Draft/Resources/Draft.qrc @@ -67,6 +67,7 @@ icons/Draft_Facebinder.svg icons/Draft_FlipDimension.svg icons/Draft_Mirror.svg + icons/Draft_Grid.svg patterns/concrete.svg patterns/cross.svg patterns/line.svg diff --git a/src/Mod/Draft/Resources/icons/Draft_Grid.svg b/src/Mod/Draft/Resources/icons/Draft_Grid.svg new file mode 100644 index 000000000..7be9b83cb --- /dev/null +++ b/src/Mod/Draft/Resources/icons/Draft_Grid.svg @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + +