From 823baefcbf141e8541cf6cc3c37b775fdea3aeaf Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Tue, 16 Jun 2026 21:02:10 +0800 Subject: [PATCH] fix(osd): re-establish selectIndex binding in onVisibleChanged for reactive sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the imperative selectIndex assignment in update() with a declarative Qt.binding() in onVisibleChanged when the OSD becomes visible. This re-establishes the selectIndex binding that was broken by the cyclic switch, and applies the QML idiom of restoring bindings at the visibility lifecycle boundary rather than inside the type-matching update() function. The else branch in update() is no longer needed. Per review suggestion: ensure the selectIndex binding is restored when the panel becomes visible, so it reactively tracks Applet.effectType. 将 update() 中的命令式 selectIndex 赋值迁移到 onVisibleChanged 的 visible=true 分支,使用 Qt.binding() 声明式恢复绑定。原先循环切换 操作会破坏 selectIndex 的属性绑定,现在 OSD 每次显示时自动重建绑定, 确保选中项始终与 Applet.effectType 保持响应式同步。update() 中的 else 分支已删除,由 onVisibleChanged 替代。 PMS: BUG-365207 --- panels/notification/osd/windoweffect/package/main.qml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/panels/notification/osd/windoweffect/package/main.qml b/panels/notification/osd/windoweffect/package/main.qml index d2670c72e..f5788e309 100644 --- a/panels/notification/osd/windoweffect/package/main.qml +++ b/panels/notification/osd/windoweffect/package/main.qml @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -32,7 +32,14 @@ AppletItem { enabled: match(control.Panel.osdType) function onVisibleChanged() { if (!control.Panel.visible) { + // OSD hidden: write selected effect type back Applet.effectType = effectModel.get(selectIndex).value + } else { + // OSD shown: re-establish selectIndex binding to track current effect type. + // This handles the case where the binding was broken by a cyclic switch. + control.selectIndex = Qt.binding(function() { + return indexByValue(Applet.effectType) + }) } } }