Skip to content

Commit bf74e47

Browse files
committed
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
1 parent 95a2c37 commit bf74e47

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

qt6/src/qml/DialogWindow.qml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Window {
3333
property real leftPadding: DS.Style.dialogWindow.contentHMargin
3434
property real rightPadding: DS.Style.dialogWindow.contentHMargin
3535

36+
property var transientParentWindow: null
37+
transientParent: transientParentWindow
38+
3639
Item {
3740
id: content
3841
palette: control.active ? D.DTK.palette : D.DTK.inactivePalette
@@ -60,6 +63,27 @@ Window {
6063
}
6164
}
6265

66+
Component.onCompleted: {
67+
if (control.modality === Qt.WindowModal && !transientParentWindow)
68+
transientParentWindow = Qt.application.activeWindow
69+
}
70+
71+
onVisibleChanged: {
72+
if (!control.visible)
73+
return
74+
if (control.modality !== Qt.WindowModal)
75+
return
76+
if (!transientParentWindow || transientParentWindow === control) {
77+
var candidate = Qt.application.activeWindow
78+
if (candidate && candidate !== control)
79+
transientParentWindow = candidate
80+
}
81+
Qt.callLater(function () {
82+
control.raise()
83+
control.requestActivate()
84+
})
85+
}
86+
6387
onClosing: function(close) {
6488
// close can't reset sub control's hovered state. pms Bug:168405
6589
// if we need to close, we can add closing handler to set `close.acceped = true`

0 commit comments

Comments
 (0)