From e3df634a20b15becb563356c73f091a4bc191023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= Date: Wed, 21 Apr 2021 16:54:21 +0200 Subject: [PATCH] Arch: Fix material color pickers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide currently set color as initial value for getColor() to enable convenient incremental changes. Do not change the colour if the Cancel buton was pressed. Signed-off-by: Ɓukasz Stelmach --- src/Mod/Arch/ArchMaterial.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Mod/Arch/ArchMaterial.py b/src/Mod/Arch/ArchMaterial.py index 1d9f536d4f..f258a781d5 100644 --- a/src/Mod/Arch/ArchMaterial.py +++ b/src/Mod/Arch/ArchMaterial.py @@ -645,18 +645,20 @@ class _ArchMaterialTaskPanel: self.material["Father"] = text def getColor(self): - "opens a color picker dialog" - color = QtGui.QColorDialog.getColor() - colorPix = QtGui.QPixmap(16,16) - colorPix.fill(color) - self.form.ButtonColor.setIcon(QtGui.QIcon(colorPix)) + self.getColorForButton(self.form.ButtonColor) def getSectionColor(self): + self.getColorForButton(self.form.ButtonSectionColor) + + def getColorForButton(self,button): "opens a color picker dialog" - color = QtGui.QColorDialog.getColor() - colorPix = QtGui.QPixmap(16,16) - colorPix.fill(color) - self.form.ButtonSectionColor.setIcon(QtGui.QIcon(colorPix)) + icon = button.icon() + pixel = icon.pixmap(16,16).toImage().pixel(0,0) + color = QtGui.QColorDialog.getColor(QtGui.QColor(pixel)) + if color.isValid(): + colorPix = QtGui.QPixmap(16,16) + colorPix.fill(color) + button.setIcon(QtGui.QIcon(colorPix)) def fillMaterialCombo(self): "fills the combo with the existing FCMat cards"