handle user cancel color dialog

Currently, when user cancels line color or face color selection dialog current color gets changed to black, as opposed to retaining the status quo.  https://forum.freecadweb.org/viewtopic.php?f=3&t=29762

The fix is to test QColor.isValid(color), which returns false when the user cancels the QColor dialog.
This commit is contained in:
Mark Ganson TheMarkster
2018-07-14 14:07:36 -05:00
committed by Yorik van Havre
parent 3d09e6543a
commit 1cb114e256

View File

@@ -1315,6 +1315,8 @@ class DraftToolBar:
def getcol(self):
"opens a color picker dialog"
self.color=QtGui.QColorDialog.getColor()
if not QtGui.QColor.isValid(self.color): #user canceled
return
self.colorPix.fill(self.color)
self.colorButton.setIcon(QtGui.QIcon(self.colorPix))
if Draft.getParam("saveonexit",False):
@@ -1335,6 +1337,8 @@ class DraftToolBar:
def getfacecol(self):
"opens a color picker dialog"
self.facecolor=QtGui.QColorDialog.getColor()
if not QtGui.QColor.isValid(self.facecolor): #user canceled
return
self.facecolorPix.fill(self.facecolor)
self.facecolorButton.setIcon(QtGui.QIcon(self.facecolorPix))
r = float(self.facecolor.red()/255.0)