PKGBUILDs/extra/freecad/fixups-with-qt6-enums.patch
2024-04-30 00:08:16 +00:00

446 lines
17 KiB
Diff

diff --git a/src/Gui/PythonWrapper.cpp b/src/Gui/PythonWrapper.cpp
index 79bc20d47..0452966f7 100644
--- a/src/Gui/PythonWrapper.cpp
+++ b/src/Gui/PythonWrapper.cpp
@@ -550,6 +550,36 @@ QObject* PythonWrapper::toQObject(const Py::Object& pyobject)
return nullptr;
}
+qsizetype PythonWrapper::toEnum(PyObject* pyPtr)
+{
+#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
+ return Shiboken::Enum::getValue(pyPtr);
+#else
+ return toEnum(Py::Object(pyPtr));
+#endif
+}
+
+qsizetype PythonWrapper::toEnum(const Py::Object& pyobject)
+{
+#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
+ return toEnum(pyobject.ptr());
+#else
+ try {
+ Py::Int ret;
+ if (pyobject.hasAttr(std::string("value"))) {
+ ret = pyobject.getAttr(std::string("value"));
+ } else {
+ ret = Py::Int(pyobject);
+ }
+ return (qsizetype)ret;
+ }
+ catch (Py::Exception&) {
+ Base::PyException e; // extract the Python error text
+ e.ReportException();
+ }
+#endif
+}
+
QGraphicsItem* PythonWrapper::toQGraphicsItem(PyObject* pyPtr)
{
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
diff --git a/src/Gui/PythonWrapper.h b/src/Gui/PythonWrapper.h
index c31f30e47..eada6607f 100644
--- a/src/Gui/PythonWrapper.h
+++ b/src/Gui/PythonWrapper.h
@@ -52,6 +52,8 @@ public:
bool toCString(const Py::Object&, std::string&);
QObject* toQObject(const Py::Object&);
+ qsizetype toEnum(PyObject* pyPtr);
+ qsizetype toEnum(const Py::Object& pyobject);
QGraphicsItem* toQGraphicsItem(PyObject* ptr);
QGraphicsItem* toQGraphicsItem(const Py::Object& pyObject);
QGraphicsObject* toQGraphicsObject(PyObject* pyPtr);
diff --git a/src/Gui/TaskView/TaskDialogPython.cpp b/src/Gui/TaskView/TaskDialogPython.cpp
index 795b7cf43..52476f7d8 100644
--- a/src/Gui/TaskView/TaskDialogPython.cpp
+++ b/src/Gui/TaskView/TaskDialogPython.cpp
@@ -740,9 +740,10 @@ QDialogButtonBox::StandardButtons TaskDialogPython::getStandardButtons() const
if (dlg.hasAttr(std::string("getStandardButtons"))) {
Py::Callable method(dlg.getAttr(std::string("getStandardButtons")));
Py::Tuple args;
- Py::Int ret(method.apply(args));
- int value = (int)ret;
- return QDialogButtonBox::StandardButtons(value);
+ Gui::PythonWrapper wrap;
+ wrap.loadWidgetsModule();
+ qsizetype value(wrap.toEnum(method.apply(args)));
+ return QDialogButtonBox::StandardButtons((int)value);
}
}
catch (Py::Exception&) {
diff --git a/src/Mod/Arch/ArchAxis.py b/src/Mod/Arch/ArchAxis.py
index ecda27a76..406f094f5 100644
--- a/src/Mod/Arch/ArchAxis.py
+++ b/src/Mod/Arch/ArchAxis.py
@@ -723,7 +723,7 @@ class _AxisTaskPanel:
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def update(self):
diff --git a/src/Mod/Arch/ArchAxisSystem.py b/src/Mod/Arch/ArchAxisSystem.py
index a896a98a5..241dcf36b 100644
--- a/src/Mod/Arch/ArchAxisSystem.py
+++ b/src/Mod/Arch/ArchAxisSystem.py
@@ -313,7 +313,7 @@ class AxisSystemTaskPanel:
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Ok)
+ return QtGui.QDialogButtonBox.Ok
def getIcon(self,obj):
diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py
index 114ab6034..143641784 100644
--- a/src/Mod/Arch/ArchCommands.py
+++ b/src/Mod/Arch/ArchCommands.py
@@ -1023,7 +1023,7 @@ class SurveyTaskPanel:
return True
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def reject(self):
if hasattr(FreeCAD,"SurveyObserver"):
diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py
index 36bb3a4d3..3e33b5a45 100644
--- a/src/Mod/Arch/ArchComponent.py
+++ b/src/Mod/Arch/ArchComponent.py
@@ -1660,7 +1660,7 @@ class SelectionTaskPanel:
def getStandardButtons(self):
"""Adds the cancel button."""
- return int(QtGui.QDialogButtonBox.Cancel)
+ return QtGui.QDialogButtonBox.Cancel
def reject(self):
"""The method run when the user selects the cancel button."""
@@ -1766,7 +1766,7 @@ class ComponentTaskPanel:
def getStandardButtons(self):
"""Add the standard ok button."""
- return int(QtGui.QDialogButtonBox.Ok)
+ return QtGui.QDialogButtonBox.Ok
def check(self,wid,col):
"""This method is run as the callback when the user selects an item in the tree.
diff --git a/src/Mod/Arch/ArchCutPlane.py b/src/Mod/Arch/ArchCutPlane.py
index 3aa5e1ce0..ba103f38d 100644
--- a/src/Mod/Arch/ArchCutPlane.py
+++ b/src/Mod/Arch/ArchCutPlane.py
@@ -168,7 +168,7 @@ class _CutPlaneTaskPanel:
return True
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel)
+ return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel
def previewCutVolume(self, i):
cutVolume = ArchCommands.getCutVolume(self.plan,FreeCADGui.Selection.getSelectionEx()[0].Object.Shape)
diff --git a/src/Mod/Arch/ArchRoof.py b/src/Mod/Arch/ArchRoof.py
index 74ec30b5b..f9333d81a 100644
--- a/src/Mod/Arch/ArchRoof.py
+++ b/src/Mod/Arch/ArchRoof.py
@@ -949,7 +949,7 @@ class _RoofTaskPanel:
return True
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def update(self):
'''fills the treewidget'''
diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py
index 8e6177dfc..bede32334 100644
--- a/src/Mod/Arch/ArchSectionPlane.py
+++ b/src/Mod/Arch/ArchSectionPlane.py
@@ -1265,7 +1265,7 @@ class SectionPlaneTaskPanel:
return True
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Ok)
+ return QtGui.QDialogButtonBox.Ok
def getIcon(self,obj):
if hasattr(obj.ViewObject,"Proxy"):
diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py
index c3cc10c60..b5e72ee2e 100644
--- a/src/Mod/Arch/ArchWindow.py
+++ b/src/Mod/Arch/ArchWindow.py
@@ -1496,7 +1496,7 @@ class _ArchWindowTaskPanel:
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def check(self,wid,col):
diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py
index b19101e9c..3bba18795 100644
--- a/src/Mod/Draft/DraftGui.py
+++ b/src/Mod/Draft/DraftGui.py
@@ -217,7 +217,7 @@ class DraftTaskPanel:
else:
self.form = widget
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def accept(self):
if hasattr(FreeCADGui,"draftToolBar"):
return FreeCADGui.draftToolBar.validatePoint()
@@ -1031,7 +1031,7 @@ class DraftToolBar:
self.form = [extra]
self.callback = callback
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def reject(self):
if self.callback:
self.callback()
@@ -1766,7 +1766,7 @@ class FacebinderTaskPanel:
return True
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Ok)
+ return QtGui.QDialogButtonBox.Ok
def update(self):
"""fills the treewidget"""
diff --git a/src/Mod/Draft/drafttaskpanels/task_selectplane.py b/src/Mod/Draft/drafttaskpanels/task_selectplane.py
index 7eba90f0e..a8ba3139d 100644
--- a/src/Mod/Draft/drafttaskpanels/task_selectplane.py
+++ b/src/Mod/Draft/drafttaskpanels/task_selectplane.py
@@ -40,6 +40,7 @@ to be more similar to OrthoArray and the new tools.
## \addtogroup drafttaskpanels
# @{
import FreeCADGui as Gui
+from PySide import QtWidgets
class SelectPlaneTaskPanel:
@@ -50,6 +51,6 @@ class SelectPlaneTaskPanel:
def getStandardButtons(self):
"""Execute to set the standard buttons."""
- return 2097152 # int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
## @}
diff --git a/src/Mod/Fem/femsolver/solver_taskpanel.py b/src/Mod/Fem/femsolver/solver_taskpanel.py
index 90c622ad7..5d3817bef 100644
--- a/src/Mod/Fem/femsolver/solver_taskpanel.py
+++ b/src/Mod/Fem/femsolver/solver_taskpanel.py
@@ -156,7 +156,7 @@ class ControlTaskPanel(QtCore.QObject):
femsolver.report.display(machine.report, _REPORT_TITLE, text)
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def reject(self):
Gui.ActiveDocument.resetEdit()
diff --git a/src/Mod/Fem/femtaskpanels/task_mesh_gmsh.py b/src/Mod/Fem/femtaskpanels/task_mesh_gmsh.py
index 2aa2fbf24..770620c08 100644
--- a/src/Mod/Fem/femtaskpanels/task_mesh_gmsh.py
+++ b/src/Mod/Fem/femtaskpanels/task_mesh_gmsh.py
@@ -106,9 +106,7 @@ class _TaskPanel:
self.update()
def getStandardButtons(self):
- button_value = int(
- QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel
- )
+ button_value = QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel
return button_value
# show a OK, a apply and a Cancel button
# def reject() is called on Cancel button
diff --git a/src/Mod/Fem/femtaskpanels/task_result_mechanical.py b/src/Mod/Fem/femtaskpanels/task_result_mechanical.py
index 266670a54..f0ec4e9d7 100644
--- a/src/Mod/Fem/femtaskpanels/task_result_mechanical.py
+++ b/src/Mod/Fem/femtaskpanels/task_result_mechanical.py
@@ -265,7 +265,7 @@ class _TaskPanel:
self.result_widget.sb_displacement_factor_max.setValue(100.) # init non standard values
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def get_result_stats(self, type_name):
return resulttools.get_stats(self.result_obj, type_name)
diff --git a/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py b/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py
index fd4607f94..a39eb47d7 100644
--- a/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py
+++ b/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py
@@ -159,7 +159,7 @@ class _TaskPanel:
def getStandardButtons(self):
# only show a close button
# def accept() in no longer needed, since there is no OK button
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def reject(self):
FreeCADGui.ActiveDocument.resetEdit()
diff --git a/src/Mod/OpenSCAD/OpenSCADCommands.py b/src/Mod/OpenSCAD/OpenSCADCommands.py
index 3ee3737b5..10b45d5f0 100644
--- a/src/Mod/OpenSCAD/OpenSCADCommands.py
+++ b/src/Mod/OpenSCAD/OpenSCADCommands.py
@@ -379,7 +379,7 @@ class AddSCADTask:
self.form.buttonrefresh.clicked.connect(self.refreshelement)
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def isAllowedAlterSelection(self):
return True
@@ -492,7 +492,7 @@ class OpenSCADMeshBooleanTask:
self.form.buttonadd.clicked.connect(self.doboolean)
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Close)
+ return QtGui.QDialogButtonBox.Close
def isAllowedAlterSelection(self):
return False
diff --git a/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py b/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py
index bf79827a2..fb3607797 100644
--- a/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py
+++ b/src/Mod/Part/AttachmentEditor/TaskAttachmentEditor.py
@@ -306,7 +306,7 @@ class AttachmentEditorTaskPanel(FrozenClass):
# task dialog handling
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Ok) | int(QtGui.QDialogButtonBox.Cancel)| int(QtGui.QDialogButtonBox.Apply)
+ return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Apply
def clicked(self,button):
if button == QtGui.QDialogButtonBox.Apply:
diff --git a/src/Mod/PartDesign/InvoluteGearFeature.py b/src/Mod/PartDesign/InvoluteGearFeature.py
index bd91d495b..bca795851 100644
--- a/src/Mod/PartDesign/InvoluteGearFeature.py
+++ b/src/Mod/PartDesign/InvoluteGearFeature.py
@@ -258,7 +258,7 @@ class _InvoluteGearTaskPanel:
self.form.doubleSpinBox_ProfileShift.setValue(self.obj.ProfileShiftCoefficient)
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Ok) | int(QtGui.QDialogButtonBox.Cancel)| int(QtGui.QDialogButtonBox.Apply)
+ return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Apply
def clicked(self,button):
if button == QtGui.QDialogButtonBox.Apply:
diff --git a/src/Mod/PartDesign/SprocketFeature.py b/src/Mod/PartDesign/SprocketFeature.py
index c63cbe0fe..53270b093 100644
--- a/src/Mod/PartDesign/SprocketFeature.py
+++ b/src/Mod/PartDesign/SprocketFeature.py
@@ -253,7 +253,7 @@ class SprocketTaskPanel:
self.obj.Proxy.execute(self.obj)
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Ok) | int(QtGui.QDialogButtonBox.Cancel)| int(QtGui.QDialogButtonBox.Apply)
+ return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Apply
def clicked(self,button):
if button == QtGui.QDialogButtonBox.Apply:
diff --git a/src/Mod/PartDesign/WizardShaft/WizardShaft.py b/src/Mod/PartDesign/WizardShaft/WizardShaft.py
index 850da098c..096468d1e 100644
--- a/src/Mod/PartDesign/WizardShaft/WizardShaft.py
+++ b/src/Mod/PartDesign/WizardShaft/WizardShaft.py
@@ -155,7 +155,7 @@ class TaskWizardShaft:
self.updateButton(row, col, flag)
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Ok)
+ return QtGui.QDialogButtonBox.Ok
def accept(self):
if self.table:
diff --git a/src/Mod/Path/Path/Dressup/Gui/Boundary.py b/src/Mod/Path/Path/Dressup/Gui/Boundary.py
index e27c0169e..9064a3de1 100644
--- a/src/Mod/Path/Path/Dressup/Gui/Boundary.py
+++ b/src/Mod/Path/Path/Dressup/Gui/Boundary.py
@@ -59,11 +59,7 @@ class TaskPanel(object):
self.stockEdit = None
def getStandardButtons(self):
- return int(
- QtGui.QDialogButtonBox.Ok
- | QtGui.QDialogButtonBox.Apply
- | QtGui.QDialogButtonBox.Cancel
- )
+ return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel
def modifyStandardButtons(self, buttonBox):
self.buttonBox = buttonBox
diff --git a/src/Mod/Path/Path/Dressup/Gui/Tags.py b/src/Mod/Path/Path/Dressup/Gui/Tags.py
index b0c4d2aff..6b3a62a82 100644
--- a/src/Mod/Path/Path/Dressup/Gui/Tags.py
+++ b/src/Mod/Path/Path/Dressup/Gui/Tags.py
@@ -75,11 +75,7 @@ class PathDressupTagTaskPanel:
self.editItem = None
def getStandardButtons(self):
- return int(
- QtGui.QDialogButtonBox.Ok
- | QtGui.QDialogButtonBox.Apply
- | QtGui.QDialogButtonBox.Cancel
- )
+ return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel
def clicked(self, button):
if button == QtGui.QDialogButtonBox.Apply:
diff --git a/src/Mod/Path/Path/Op/Gui/Base.py b/src/Mod/Path/Path/Op/Gui/Base.py
index 0de7699b4..3faec0533 100644
--- a/src/Mod/Path/Path/Op/Gui/Base.py
+++ b/src/Mod/Path/Path/Op/Gui/Base.py
@@ -1274,11 +1274,7 @@ class TaskPanel(object):
def getStandardButtons(self):
"""getStandardButtons() ... returns the Buttons for the task panel."""
- return int(
- QtGui.QDialogButtonBox.Ok
- | QtGui.QDialogButtonBox.Apply
- | QtGui.QDialogButtonBox.Cancel
- )
+ return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel
def setupUi(self):
"""setupUi() ... internal function to initialise all pages."""
diff --git a/src/Mod/Path/PathPythonGui/simple_edit_panel.py b/src/Mod/Path/PathPythonGui/simple_edit_panel.py
index 0de9345bf..75d635f75 100644
--- a/src/Mod/Path/PathPythonGui/simple_edit_panel.py
+++ b/src/Mod/Path/PathPythonGui/simple_edit_panel.py
@@ -88,11 +88,7 @@ class SimpleEditPanel:
)
def getStandardButtons(self):
- return int(
- QtGui.QDialogButtonBox.Ok
- | QtGui.QDialogButtonBox.Apply
- | QtGui.QDialogButtonBox.Cancel
- )
+ return QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Cancel
def clicked(self, button):
# callback for standard buttons
diff --git a/src/Mod/TemplatePyMod/TaskPanel.py b/src/Mod/TemplatePyMod/TaskPanel.py
index ef07e9b24..cc8e301aa 100644
--- a/src/Mod/TemplatePyMod/TaskPanel.py
+++ b/src/Mod/TemplatePyMod/TaskPanel.py
@@ -61,7 +61,7 @@ class TaskPanel:
return True
def getStandardButtons(self):
- return int(QtGui.QDialogButtonBox.Ok)
+ return QtGui.QDialogButtonBox.Ok
def helpRequested(self):
pass