From 4601671fce2573b295d89737362d717efc3ab40f Mon Sep 17 00:00:00 2001 From: xiepengfei Date: Thu, 13 Nov 2025 11:47:50 +0800 Subject: [PATCH] fix: Fix the tab switching focus order Fix the tab switching focus order Log: Fix the tab switching focus order pms: BUG-339891 --- panels/notification/center/notifymodel.cpp | 14 ++++++++++++++ panels/notification/center/notifymodel.h | 1 + 2 files changed, 15 insertions(+) diff --git a/panels/notification/center/notifymodel.cpp b/panels/notification/center/notifymodel.cpp index 5ea4ea34a..bd6732ebb 100644 --- a/panels/notification/center/notifymodel.cpp +++ b/panels/notification/center/notifymodel.cpp @@ -81,6 +81,9 @@ void NotifyModel::expandApp(int row) } endInsertRows(); } + + // Rebuild all delegates to ensure Tab focus order matches visual order + rebuildDelegates(); } void NotifyModel::collapseApp(int row) @@ -129,6 +132,9 @@ void NotifyModel::collapseApp(int row) m_appNotifies.insert(row, overlap); endInsertRows(); } + + // Rebuild all delegates to ensure Tab focus order matches visual order + rebuildDelegates(); } void NotifyModel::close() @@ -361,6 +367,14 @@ void NotifyModel::sortNotifies() sort(0, Qt::DescendingOrder); } +void NotifyModel::rebuildDelegates() +{ + // Force a model reset so that QML ListView delegates are destroyed and recreated + // in the current order, which helps synchronize Tab focus order with visual order. + beginResetModel(); + endResetModel(); +} + void NotifyModel::trayUpdateGroupLastEntity(const NotifyEntity &entity) { if (const auto index = firstNotifyIndex(entity.appName(), NotifyType::Group); index >= 0) { diff --git a/panels/notification/center/notifymodel.h b/panels/notification/center/notifymodel.h index 6e2960cce..72539ab32 100644 --- a/panels/notification/center/notifymodel.h +++ b/panels/notification/center/notifymodel.h @@ -96,6 +96,7 @@ private slots: void trayUpdateGroupLastEntity(const QString &appName); void updateCollapseStatus(); void updateContentRowCount(int rowCount); + void rebuildDelegates(); private: QList m_appNotifies;