diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py
index aa09b61dbf..1dfc605f99 100644
--- a/src/Mod/Draft/DraftGui.py
+++ b/src/Mod/Draft/DraftGui.py
@@ -435,7 +435,10 @@ class DraftToolBar:
if hide:
button.hide()
if icon:
- button.setIcon(QtGui.QIcon.fromTheme(icon, QtGui.QIcon(':/icons/'+icon+'.svg')))
+ if icon.endswith(".svg"):
+ button.setIcon(QtGui.QIcon(icon))
+ else:
+ button.setIcon(QtGui.QIcon.fromTheme(icon, QtGui.QIcon(':/icons/'+icon+'.svg')))
#button.setIconSize(QtCore.QSize(isize, isize))
if checkable:
button.setCheckable(True)
@@ -772,9 +775,10 @@ class DraftToolBar:
self.widthButton = self._spinbox("widthButton", self.bottomtray, val=self.linewidth,hide=False,size=(bsize * 2,bsize))
self.widthButton.setSuffix("px")
self.fontsizeButton = self._spinbox("fontsizeButton",self.bottomtray, val=self.fontsize,vmax=999, hide=False,double=True,size=(bsize * 4,bsize))
- self.applyButton = self._pushbutton("applyButton", self.toptray, hide=False, icon='Draft_Apply',square=True)
- self.autoGroupButton = self._pushbutton("autoGroup",self.bottomtray,icon="Draft_AutoGroup_off",hide=False,width=120)
+ self.autoGroupButton = self._pushbutton("autoGroup",self.bottomtray,icon=":/icons/button_invalid.svg",hide=False,width=120)
self.autoGroupButton.setText("None")
+ self.autoGroupButton.setFlat(True)
+ self.applyButton = self._pushbutton("applyButton", self.toptray, hide=False, icon='Draft_Apply',square=True)
QtCore.QObject.connect(self.wplabel,QtCore.SIGNAL("pressed()"),self.selectplane)
QtCore.QObject.connect(self.colorButton,QtCore.SIGNAL("pressed()"),self.getcol)
@@ -2022,15 +2026,21 @@ class DraftToolBar:
def selectplane(self):
FreeCADGui.runCommand("Draft_SelectPlane")
- def popupMenu(self,mlist):
+ def popupMenu(self,llist,ilist=None):
"pops up a menu filled with the given list"
self.groupmenu = QtGui.QMenu()
- for i in mlist:
- self.groupmenu.addAction(i)
+ for i,l in enumerate(llist):
+ if ilist:
+ self.groupmenu.addAction(ilist[i],l)
+ else:
+ self.groupmenu.addAction(l)
pos = FreeCADGui.getMainWindow().cursor().pos()
self.groupmenu.popup(pos)
QtCore.QObject.connect(self.groupmenu,QtCore.SIGNAL("triggered(QAction *)"),self.popupTriggered)
+ def getIcon(self,iconpath):
+ return QtGui.QIcon(iconpath)
+
def popupTriggered(self,action):
self.sourceCmd.proceed(str(action.text()))
@@ -2093,7 +2103,7 @@ class DraftToolBar:
self.autogroup = None
self.autoGroupButton.setText("None")
self.autoGroupButton.setIcon(QtGui.QIcon.fromTheme('Draft_AutoGroup_off',
- QtGui.QIcon(':/icons/Draft_AutoGroup_off.svg')))
+ QtGui.QIcon(':/icons/button_invalid.svg')))
self.autoGroupButton.setToolTip(translate("draft", "Autogroup off"))
self.autoGroupButton.setDown(False)
else:
@@ -2101,15 +2111,14 @@ class DraftToolBar:
if obj:
self.autogroup = value
self.autoGroupButton.setText(obj.Label)
- self.autoGroupButton.setIcon(QtGui.QIcon.fromTheme('Draft_AutoGroup_on',
- QtGui.QIcon(':/icons/Draft_AutoGroup_on.svg')))
+ self.autoGroupButton.setIcon(obj.ViewObject.Icon)
self.autoGroupButton.setToolTip(translate("draft", "Autogroup: ")+obj.Label)
self.autoGroupButton.setDown(False)
else:
self.autogroup = None
self.autoGroupButton.setText("None")
self.autoGroupButton.setIcon(QtGui.QIcon.fromTheme('Draft_AutoGroup_off',
- QtGui.QIcon(':/icons/Draft_AutoGroup_off.svg')))
+ QtGui.QIcon(':/icons/button_invalid.svg')))
self.autoGroupButton.setToolTip(translate("draft", "Autogroup off"))
self.autoGroupButton.setDown(False)
diff --git a/src/Mod/Draft/DraftLayer.py b/src/Mod/Draft/DraftLayer.py
index abc6fd42c5..268df6f591 100644
--- a/src/Mod/Draft/DraftLayer.py
+++ b/src/Mod/Draft/DraftLayer.py
@@ -277,6 +277,20 @@ class ViewProviderLayer:
parent.Group = g
FreeCAD.ActiveDocument.recompute()
+ def setupContextMenu(self,vobj,menu):
+
+ from PySide import QtCore,QtGui
+ action1 = QtGui.QAction(QtGui.QIcon(":/icons/button_right.svg"),translate("draft","Activate this layer"),menu)
+ action1.triggered.connect(self.activate)
+ menu.addAction(action1)
+
+ def activate(self):
+
+ if hasattr(self,"Object"):
+ FreeCADGui.Selection.clearSelection()
+ FreeCADGui.Selection.addSelection(self.Object)
+ FreeCADGui.runCommand("Draft_AutoGroup")
+
class LayerContainer:
@@ -289,7 +303,9 @@ class LayerContainer:
def execute(self,obj):
- return
+ g = obj.Group
+ g.sort(key=lambda o: o.Label)
+ obj.Group = g
def __getstate__(self):
diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py
index 0d563237cd..c1a0ad2ca6 100644
--- a/src/Mod/Draft/DraftTools.py
+++ b/src/Mod/Draft/DraftTools.py
@@ -5303,20 +5303,26 @@ class SetAutoGroup():
self.ui = FreeCADGui.draftToolBar
s = FreeCADGui.Selection.getSelection()
if len(s) == 1:
- if s[0].isDerivedFrom("App::DocumentObjectGroup") or (Draft.getType(s[0]) in ["Site","Building","Floor"]):
+ if (Draft.getType(s[0]) == "Layer") or \
+ ( FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").GetBool("AutogroupAddGroups",False) and \
+ (s[0].isDerivedFrom("App::DocumentObjectGroup") or (Draft.getType(s[0]) in ["Site","Building","Floor","BuildingPart",]))):
self.ui.setAutoGroup(s[0].Name)
return
self.groups = ["None"]
- gn = Draft.getGroupNames()
+ gn = [o.Name for o in FreeCAD.ActiveDocument.Objects if Draft.getType(o) == "Layer"]
+ if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").GetBool("AutogroupAddGroups",False):
+ gn.extend(Draft.getGroupNames())
if gn:
self.groups.extend(gn)
self.labels = ["None"]
+ self.icons = [self.ui.getIcon(":/icons/button_invalid.svg")]
for g in gn:
o = FreeCAD.ActiveDocument.getObject(g)
if o:
self.labels.append(o.Label)
+ self.icons.append(o.ViewObject.Icon)
self.ui.sourceCmd = self
- self.ui.popupMenu(self.labels)
+ self.ui.popupMenu(self.labels,self.icons)
def proceed(self,labelname):
self.ui.sourceCmd = None
diff --git a/src/Mod/Draft/Resources/ui/preferences-draft.ui b/src/Mod/Draft/Resources/ui/preferences-draft.ui
index 8967cc26dc..99af017bb8 100755
--- a/src/Mod/Draft/Resources/ui/preferences-draft.ui
+++ b/src/Mod/Draft/Resources/ui/preferences-draft.ui
@@ -7,7 +7,7 @@
0
0
486
- 758
+ 781
@@ -17,16 +17,7 @@
6
-
- 9
-
-
- 9
-
-
- 9
-
-
+
9
-
@@ -373,6 +364,25 @@ Values with differences below this value will be treated as same. This value wil
+ -
+
+
+ If this option is checked, the layers drop-down list will also show groups, allowing you to automatically add objects to groups too.
+
+
+ Show groups in layers list drop-down button
+
+
+ false
+
+
+ AutogroupAddGroups
+
+
+ Mod/Draft
+
+
+
@@ -442,7 +452,7 @@ Values with differences below this value will be treated as same. This value wil
This is the default color for objects being drawn while in construction mode.
-
+
44
125
@@ -505,14 +515,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutRelative
Mod/Draft
-
- inCommandShortcutRelative
+
+ false
@@ -555,14 +565,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutContinue
Mod/Draft
-
- inCommandShortcutContinue
+
+ false
@@ -605,14 +615,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutClose
Mod/Draft
-
- inCommandShortcutClose
+
+ false
@@ -657,14 +667,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutCopy
Mod/Draft
-
- inCommandShortcutCopy
+
+ false
@@ -705,14 +715,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutSubelementMode
Mod/Draft
-
- inCommandShortcutSubelementMode
+
+ false
@@ -753,14 +763,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutFill
Mod/Draft
-
- inCommandShortcutFill
+
+ false
@@ -805,14 +815,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutExit
Mod/Draft
-
- inCommandShortcutExit
+
+ false
@@ -853,14 +863,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutSelectEdge
Mod/Draft
-
- inCommandShortcutSelectEdge
+
+ false
@@ -901,14 +911,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutAddHold
Mod/Draft
-
- inCommandShortcutAddHold
+
+ false
@@ -953,14 +963,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutLength
Mod/Draft
-
- inCommandShortcutLength
+
+ false
@@ -1001,14 +1011,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutWipe
Mod/Draft
-
- inCommandShortcutWipe
+
+ false
@@ -1049,14 +1059,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutSetWP
Mod/Draft
-
- inCommandShortcutSetWP
+
+ false
@@ -1101,14 +1111,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutCycleSnap
Mod/Draft
-
- inCommandShortcutCycleSnap
+
+ false
@@ -1159,14 +1169,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutSnap
Mod/Draft
-
- inCommandShortcutSnap
+
+ false
@@ -1207,14 +1217,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutIncreaseRadius
Mod/Draft
-
- inCommandShortcutIncreaseRadius
+
+ false
@@ -1255,14 +1265,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutDecreaseRadius
Mod/Draft
-
- inCommandShortcutDecreaseRadius
+
+ false
@@ -1307,14 +1317,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutRestrictX
Mod/Draft
-
- inCommandShortcutRestrictX
+
+ false
@@ -1355,14 +1365,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ inCommandShortcutRestrictY
Mod/Draft
-
- inCommandShortcutRestrictY
+
+ false
@@ -1403,14 +1413,14 @@ Values with differences below this value will be treated as same. This value wil
-
- false
+
+ RestrictZ
Mod/Draft
-
- RestrictZ
+
+ false
@@ -1439,11 +1449,21 @@ Values with differences below this value will be treated as same. This value wil
qPixmapFromMimeSource
+
+ Gui::ColorButton
+ QPushButton
+
+
Gui::PrefSpinBox
QSpinBox
+
+ Gui::PrefColorButton
+ Gui::ColorButton
+
+
Gui::PrefCheckBox
QCheckBox
@@ -1454,26 +1474,16 @@ Values with differences below this value will be treated as same. This value wil
QComboBox
-
- Gui::PrefDoubleSpinBox
- QDoubleSpinBox
-
-
-
- Gui::ColorButton
- QPushButton
-
-
-
- Gui::PrefColorButton
- Gui::ColorButton
-
-
Gui::PrefLineEdit
QLineEdit
+
+ Gui::PrefDoubleSpinBox
+ QDoubleSpinBox
+
+
diff --git a/src/Mod/Draft/Resources/ui/preferences-draftvisual.ui b/src/Mod/Draft/Resources/ui/preferences-draftvisual.ui
index 8a3e4e7c2d..e7424daadf 100644
--- a/src/Mod/Draft/Resources/ui/preferences-draftvisual.ui
+++ b/src/Mod/Draft/Resources/ui/preferences-draftvisual.ui
@@ -6,8 +6,8 @@
0
0
- 532
- 484
+ 531
+ 552
@@ -26,90 +26,6 @@
Visual Settings
- -
-
-
-
-
-
- Default line color
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- The default color for new objects
-
-
-
- 0
- 0
- 0
-
-
-
- color
-
-
- Mod/Draft
-
-
-
-
-
- -
-
-
-
-
-
- Default line width
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
-
-
- The default linewidth for new objects
-
-
- 2
-
-
- linewidth
-
-
- Mod/Draft
-
-
-
-
-
-
-