-
Notifications
You must be signed in to change notification settings - Fork 61
feat: improve tray menu and notification panel interaction #1513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. | ||
| // SPDX-FileCopyrightText: 2024-2026 UnionTech Software Technology Co., Ltd. | ||
| // | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
|
|
@@ -20,6 +20,52 @@ Item { | |
| return false | ||
| } | ||
| readonly property bool isOpened: popup.popupVisible | ||
| property var pendingTrayMenu: null | ||
| Timer { | ||
| id: trayMenuOpenTimer | ||
| interval: 150 | ||
| repeat: false | ||
| onTriggered: { | ||
| if (pendingTrayMenu) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Same autoCloseOnDeactivate restoration issue as in SurfacePopup.qml Here too, |
||
| pendingTrayMenu.open() | ||
| pendingTrayMenu = null | ||
| } | ||
| } | ||
| } | ||
| Timer { | ||
| id: restoreAutoCloseTimer | ||
| interval: 200 | ||
| repeat: false | ||
| onTriggered: { | ||
| if (pendingTrayMenu) { | ||
| pendingTrayMenu.autoCloseOnDeactivate = true | ||
| } | ||
| } | ||
| } | ||
| Connections { | ||
| target: popupMenu | ||
| function onMenuVisibleChanged() { | ||
| if (!popupMenu.menuVisible) { | ||
| MenuHelper.hasTrayMenuOpen = false | ||
| let notifyPanel = DS.applet("org.deepin.ds.notificationcenter") | ||
| if (notifyPanel) { | ||
| notifyPanel.hasTrayMenuOpen = false | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Connections { | ||
| target: popupMenu.menuWindow | ||
| function onActiveChanged() { | ||
| if (popupMenu.menuWindow && !popupMenu.menuWindow.active && !popupMenu.menuVisible) { | ||
| MenuHelper.hasTrayMenuOpen = false | ||
| let notifyPanel = DS.applet("org.deepin.ds.notificationcenter") | ||
| if (notifyPanel) { | ||
| notifyPanel.hasTrayMenuOpen = false | ||
| } | ||
| } | ||
| } | ||
| } | ||
| function closeTooltip() { | ||
| if (toolTip.toolTipVisible) { | ||
| toolTip.close() | ||
|
|
@@ -161,7 +207,18 @@ Item { | |
| var point = Qt.point(popupMenu.shellSurface.x, popupMenu.shellSurface.y) | ||
| return Qt.rect(point.x, point.y, popupMenu.width, popupMenu.height) | ||
| }) | ||
| popupMenu.open() | ||
| let notifyPanel = DS.applet("org.deepin.ds.notificationcenter") | ||
| if (notifyPanel && notifyPanel.visible) { | ||
| notifyPanel.close() | ||
| } | ||
| popupMenu.autoCloseOnDeactivate = false | ||
| MenuHelper.hasTrayMenuOpen = true | ||
| if (notifyPanel) { | ||
| notifyPanel.hasTrayMenuOpen = true | ||
| } | ||
| root.pendingTrayMenu = popupMenu | ||
| trayMenuOpenTimer.restart() | ||
| restoreAutoCloseTimer.restart() | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): autoCloseOnDeactivate is never restored because pendingTrayMenu is nulled before the restore timer runs
Because
pendingTrayMenuis set tonullimmediately afteropen(),restoreAutoCloseTimer’sif (pendingTrayMenu)check always fails andautoCloseOnDeactivateis never reset for that menu. As a result, latermenuWindow.activechanges won’t auto-close the tray menu. You’ll need to either keep a separate reference for the restore timer, delay nullingpendingTrayMenuuntil after the restore runs, or restoreautoCloseOnDeactivatein a way that doesn’t depend onpendingTrayMenubeing non-null.