diff --git a/src/Mod/BIM/bimcommands/BimClassification.py b/src/Mod/BIM/bimcommands/BimClassification.py index 04be60432d..aa452120f0 100644 --- a/src/Mod/BIM/bimcommands/BimClassification.py +++ b/src/Mod/BIM/bimcommands/BimClassification.py @@ -159,7 +159,7 @@ class BIM_Classification: self.form.buttonRename.clicked.connect(self.rename) self.form.search.textEdited.connect(self.updateClasses) self.form.buttonBox.accepted.connect(self.accept) - self.form.buttonBox.rejected.connect(self.reject) + self.form.rejected.connect(self.reject) # also triggered by self.form.buttonBox.rejected self.form.groupMode.currentIndexChanged.connect(self.updateObjects) self.form.treeClass.itemDoubleClicked.connect(self.apply) self.form.search.up.connect(self.onUpArrow) @@ -604,8 +604,7 @@ class BIM_Classification: # Close the form if user has pressed Enter and did not # select anything if len(self.form.treeClass.selectedItems()) < 1: - self.form.close() - return + return self.reject() code = self.form.treeClass.selectedItems()[0].text(0) pl = self.isEditing.PropertiesList @@ -630,7 +629,6 @@ class BIM_Classification: p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM") p.SetInt("BimClassificationDialogWidth", self.form.width()) p.SetInt("BimClassificationDialogHeight", self.form.height()) - self.form.hide() return self.reject() def reject(self): diff --git a/src/Mod/BIM/bimcommands/BimIfcElements.py b/src/Mod/BIM/bimcommands/BimIfcElements.py index 18e1a13c00..c63e38c758 100644 --- a/src/Mod/BIM/bimcommands/BimIfcElements.py +++ b/src/Mod/BIM/bimcommands/BimIfcElements.py @@ -102,7 +102,7 @@ class BIM_IfcElements: else: # Qt version < 6.7.0 self.form.onlyVisible.stateChanged.connect(self.update) self.form.buttonBox.accepted.connect(self.accept) - self.form.buttonBox.rejected.connect(self.reject) + self.form.rejected.connect(self.reject) # also triggered by self.form.buttonBox.rejected self.form.globalMode.currentIndexChanged.connect(self.onObjectTypeChanged) self.form.globalMaterial.currentIndexChanged.connect(self.onMaterialChanged) @@ -442,41 +442,43 @@ class BIM_IfcElements: import Draft from PySide import QtCore, QtGui + if getattr(self, "form", None) is None: + return if FreeCADGui.Control.activeDialog(): QtCore.QTimer.singleShot(500, self.checkMatChanged) - else: - mats = [ - o.Name - for o in FreeCAD.ActiveDocument.Objects - if (o.isDerivedFrom("App::MaterialObject") or (Draft.getType(o) == "MultiMaterial")) - ] - if len(mats) != len(self.materials): - newmats = [m for m in mats if not m in self.materials] - self.materials = mats - self.form.globalMaterial.clear() - self.form.globalMaterial.addItem(" ") - self.form.globalMaterial.addItem(translate("BIM", "Create new material")) - self.form.globalMaterial.addItem(translate("BIM", "Create new multi-material")) - for m in self.materials: - o = FreeCAD.ActiveDocument.getObject(m) - if o: - self.form.globalMaterial.addItem( - o.Label, QtGui.QIcon(":/icons/Arch_Material.svg") - ) - changed = False - sel = self.form.tree.selectedIndexes() - for index in sel: - if index.column() == 2: - for mat in newmats: - mobj = FreeCAD.ActiveDocument.getObject(mat) - if mobj: - item = self.model.itemFromIndex(index) - if item.toolTip() != mat: - item.setText(mobj.Label) - item.setToolTip(mat) - changed = True - if changed: - self.update() + return + mats = [ + o.Name + for o in FreeCAD.ActiveDocument.Objects + if (o.isDerivedFrom("App::MaterialObject") or (Draft.getType(o) == "MultiMaterial")) + ] + if len(mats) != len(self.materials): + newmats = [m for m in mats if not m in self.materials] + self.materials = mats + self.form.globalMaterial.clear() + self.form.globalMaterial.addItem(" ") + self.form.globalMaterial.addItem(translate("BIM", "Create new material")) + self.form.globalMaterial.addItem(translate("BIM", "Create new multi-material")) + for m in self.materials: + o = FreeCAD.ActiveDocument.getObject(m) + if o: + self.form.globalMaterial.addItem( + o.Label, QtGui.QIcon(":/icons/Arch_Material.svg") + ) + changed = False + sel = self.form.tree.selectedIndexes() + for index in sel: + if index.column() == 2: + for mat in newmats: + mobj = FreeCAD.ActiveDocument.getObject(mat) + if mobj: + item = self.model.itemFromIndex(index) + if item.toolTip() != mat: + item.setText(mobj.Label) + item.setToolTip(mat) + changed = True + if changed: + self.update() def accept(self): # get current state of tree diff --git a/src/Mod/BIM/bimcommands/BimIfcProperties.py b/src/Mod/BIM/bimcommands/BimIfcProperties.py index 9d814578ee..9947f7a711 100644 --- a/src/Mod/BIM/bimcommands/BimIfcProperties.py +++ b/src/Mod/BIM/bimcommands/BimIfcProperties.py @@ -146,7 +146,7 @@ class BIM_IfcProperties: self.form.onlySelected.stateChanged.connect(self.onSelected) self.form.onlyMatches.stateChanged.connect(self.update) self.form.buttonBox.accepted.connect(self.accept) - self.form.buttonBox.rejected.connect(self.reject) + self.form.rejected.connect(self.reject) # also triggered by self.form.buttonBox.rejected self.form.searchField.currentIndexChanged.connect(self.update) self.form.searchField.editTextChanged.connect(self.update) self.form.comboProperty.currentIndexChanged.connect(self.addProperty) diff --git a/src/Mod/BIM/bimcommands/BimIfcQuantities.py b/src/Mod/BIM/bimcommands/BimIfcQuantities.py index f5ea094058..92f58bb382 100644 --- a/src/Mod/BIM/bimcommands/BimIfcQuantities.py +++ b/src/Mod/BIM/bimcommands/BimIfcQuantities.py @@ -125,7 +125,7 @@ class BIM_IfcQuantities: self.form.quantities.setItemDelegate(QtGui.QStyledItemDelegate()) self.qmodel.dataChanged.connect(self.setChecked) self.form.buttonBox.accepted.connect(self.accept) - self.form.buttonBox.rejected.connect(self.reject) + self.form.rejected.connect(self.reject) # also triggered by self.form.buttonBox.rejected self.form.quantities.clicked.connect(self.onClickTree) if hasattr(self.form.onlyVisible, "checkStateChanged"): # Qt version >= 6.7.0 self.form.onlyVisible.checkStateChanged.connect(self.update) diff --git a/src/Mod/BIM/bimcommands/BimProjectManager.py b/src/Mod/BIM/bimcommands/BimProjectManager.py index 576b29d4f5..98dd3e9999 100644 --- a/src/Mod/BIM/bimcommands/BimProjectManager.py +++ b/src/Mod/BIM/bimcommands/BimProjectManager.py @@ -75,6 +75,7 @@ class BIM_ProjectManager: self.form.presets.currentIndexChanged.connect(self.getPreset) self.form.buttonOK.clicked.connect(self.accept) self.form.buttonCancel.clicked.connect(self.reject) + self.form.rejected.connect(self.reject) self.fillPresets() # Detect existing objects