Skip to content

Commit e7e27fe

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 e7e27fe

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

qt6/src/qml/DialogWindow.qml

Lines changed: 21 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,24 @@ 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+
transientParentWindow = Qt.application.activeWindow
78+
Qt.callLater(function () {
79+
control.raise()
80+
control.requestActivate()
81+
})
82+
}
83+
6384
onClosing: function(close) {
6485
// close can't reset sub control's hovered state. pms Bug:168405
6586
// if we need to close, we can add closing handler to set `close.acceped = true`

0 commit comments

Comments
 (0)