diff --git a/UM/Qt/QtApplication.py b/UM/Qt/QtApplication.py index cb72d1822..9bbec9879 100644 --- a/UM/Qt/QtApplication.py +++ b/UM/Qt/QtApplication.py @@ -457,6 +457,7 @@ def isShuttingDown(self) -> bool: return self._is_shutting_down def registerObjects(self, engine) -> None: #type: ignore #Don't type engine, because the type depends on the platform you're running on so it always gives an error somewhere. + engine.rootContext().setContextProperty("QtApplication", self) engine.rootContext().setContextProperty("PluginRegistry", PluginRegistry.getInstance()) def makeRenderer(self) -> QtRenderer: @@ -468,8 +469,6 @@ def getRenderer(self) -> QtRenderer: return cast(QtRenderer, self._renderer) - mainWindowChanged = Signal() - def getMainWindow(self) -> Optional[MainWindow]: return self._main_window @@ -483,6 +482,9 @@ def setMainWindow(self, window: MainWindow) -> None: self._main_window.windowStateChanged.connect(self._onMainWindowStateChanged) self.mainWindowChanged.emit() + mainWindowChanged = Signal() + mainWindow = pyqtProperty(QQuickWindow, fget=getMainWindow, constant=True) + def setVisible(self, visible: bool) -> None: if self._main_window is not None: self._main_window.visible = visible @@ -614,7 +616,6 @@ def createQmlSubWindow(self, qml_file_path: str, context_properties: Dict[str, " Create a QML window from a QML file. This method uses createQmlComponent internally, but adds a few specific features for windows management: * The created object is a QQuickWindow instance - * The transient parent of the window is explicitly set to be the main window * The window ownership is handled and it will be destroyed as soon as it's no longer visible, so the caller should not keep a reference to it :param qml_file_path: The absolute file path to the root qml file. @@ -626,9 +627,7 @@ def createQmlSubWindow(self, qml_file_path: str, context_properties: Dict[str, " if result is None: return None - result.setTransientParent(self._main_window) - - # Keep a link to the window so that it is not garbage-collected, then register it for destruction + # Keep a link to the window so that it is not garbage-collected, then register it for destruction. self._sub_windows.append(result) result.visibleChanged.connect(self._onWindowVisibleChange, Qt.ConnectionType.QueuedConnection) diff --git a/UM/Qt/qml/UM/Dialog.qml b/UM/Qt/qml/UM/Dialog.qml index 465905230..13d9374fd 100644 --- a/UM/Qt/qml/UM/Dialog.qml +++ b/UM/Qt/qml/UM/Dialog.qml @@ -20,12 +20,13 @@ Window minimumHeight: screenScaleFactor * 480; width: minimumWidth height: minimumHeight + transientParent: QtApplication.mainWindow property int margin: UM.Theme.getSize("default_margin").width property bool closeOnAccept: true; // Automatically close the window when the window is "accepted" (eg using the return key) property bool selfDestroy: false; // Automatically destroys the dialog when it has been hidden, useful if it has been created with component.createObject - default property alias contents: contentItem.children; + default property alias contents: contentItem.data; property alias loader: contentLoader diff --git a/conandata.yml b/conandata.yml index 29ece110b..3dcbf38cb 100644 --- a/conandata.yml +++ b/conandata.yml @@ -411,10 +411,12 @@ pip_requirements_core: pip_requirements_dev: any_os: - pytest: {} + pytest: + version: "9.1.1" twisted: version: "21.2.0" - pytest-benchmark: {} + pytest-benchmark: + version: "5.3.0" sip: {} python_translation_source_folders: