From e7e27fe303086a855eb1deddf13be8837c725afa Mon Sep 17 00:00:00 2001 From: Tian Shilin Date: Sat, 7 Feb 2026 13:51:35 +0800 Subject: [PATCH] fix: Main interface does not gray out when losing focus log: In the DialogWindow, when set to WindowModal, the transientParent is automatically set to Qt.application.activeWindow. Upon display, raise() and requestActivate() are called to ensure the main window correctly enters a grayed-out state. pms: bug-336201 --- qt6/src/qml/DialogWindow.qml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/qt6/src/qml/DialogWindow.qml b/qt6/src/qml/DialogWindow.qml index 1c4f120f..c9e8818b 100644 --- a/qt6/src/qml/DialogWindow.qml +++ b/qt6/src/qml/DialogWindow.qml @@ -33,6 +33,9 @@ Window { property real leftPadding: DS.Style.dialogWindow.contentHMargin property real rightPadding: DS.Style.dialogWindow.contentHMargin + property var transientParentWindow: null + transientParent: transientParentWindow + Item { id: content palette: control.active ? D.DTK.palette : D.DTK.inactivePalette @@ -60,6 +63,24 @@ Window { } } + Component.onCompleted: { + if (control.modality === Qt.WindowModal && !transientParentWindow) + transientParentWindow = Qt.application.activeWindow + } + + onVisibleChanged: { + if (!control.visible) + return + if (control.modality !== Qt.WindowModal) + return + if (!transientParentWindow || transientParentWindow === control) + transientParentWindow = Qt.application.activeWindow + Qt.callLater(function () { + control.raise() + control.requestActivate() + }) + } + onClosing: function(close) { // close can't reset sub control's hovered state. pms Bug:168405 // if we need to close, we can add closing handler to set `close.acceped = true`