fix: correct ActiveRole and AttentionRole data retrieval for active#1570
fix: correct ActiveRole and AttentionRole data retrieval for active#1570deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
app model
1. Added case handling for `TaskManager::ActiveRole` and
`TaskManager::AttentionRole` in the `data()` method of
`DockGlobalElementModel`
2. Fixed issue where these roles returned incorrect values when queried
from the active app model (`m_activeAppModel`)
3. Previously, these roles were not explicitly handled, potentially
falling through to a default behavior that could return wrong data
4. Now correctly delegates to the underlying model's data method for the
specified roles when the model is the active app model
5. Returns `false` for other models (e.g., window group model) as these
concepts don't apply there
Log: Fixed incorrect active state and attention state display for dock
app icons
Influence:
1. Verify that active dock app icons properly reflect their active state
2. Test attention-requesting apps show correct visual feedback (e.g.,
blinking)
3. Check that window group icons do not incorrectly display active/
attention states
4. Regression test on app launching and window switching scenarios
5. Test with multiple workspaces and virtual desktops
fix: 修复活跃应用模型的 ActiveRole 和 AttentionRole 数据获取
1. 在 `DockGlobalElementModel` 的 `data()` 方法中增加了
`TaskManager::ActiveRole` 和 `TaskManager::AttentionRole` 的处理分支
2. 修复了从活跃应用模型查询这些角色时返回错误值的问题
3. 现在对于活跃应用模型会正确委托到底层模型的数据方法
4. 其他模型(如窗口组模型)返回 `false`,因为这些概念不适用
Log: 修复任务栏应用图标活跃状态和提醒状态显示异常
Influence:
1. 验证任务栏中活跃应用的图标是否正确显示活跃状态
2. 测试请求关注的应用是否能显示正确的视觉反馈(如闪烁)
3. 确保窗口组图标不会错误显示活跃/关注状态
4. 回归测试应用启动和窗口切换场景
5. 测试多工作区和虚拟桌面下的表现
此问题主要是处理
拆分模式下,关闭某个驻留应用窗口时(有焦点的窗口),他的背景不会消失,问题在于:属性绑定机制里,如果绑定的数据源返回了
undefined(对应 C++ 的空的/无效的 QVariant),QML
会选择不更新此属性,保留上一次的旧值!
因此 默认default返回的是一个 return {}; 会导致 保留了上次值,导致问题。
deepin pr auto review这段. 语法逻辑审查:
改进后的代码示例: case TaskManager::ActiveRole:
case TaskManager::AttentionRole: {
if (!model) {
return QVariant(false);
}
if (model == m_activeAppModel) {
return model->index(row, 0).data(role);
}
return QVariant(false);
}
|
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds explicit handling of TaskManager::ActiveRole and TaskManager::AttentionRole in DockGlobalElementModel::data() so that active/attention state is correctly delegated to the active app model and returns false for non-app models, fixing incorrect dock icon active/attention visuals. Sequence diagram for ActiveRole and AttentionRole data retrievalsequenceDiagram
actor User
participant QMLBinding
participant DockGlobalElementModel
participant ActiveAppModel
User->>QMLBinding: triggers icon state update
QMLBinding->>DockGlobalElementModel: data(index, ActiveRole)
DockGlobalElementModel->>DockGlobalElementModel: determine model and row
alt model is m_activeAppModel
DockGlobalElementModel->>ActiveAppModel: index(row, 0)
ActiveAppModel-->>DockGlobalElementModel: QModelIndex
DockGlobalElementModel->>ActiveAppModel: data(ActiveRole)
ActiveAppModel-->>DockGlobalElementModel: QVariant(bool)
DockGlobalElementModel-->>QMLBinding: QVariant(bool)
else model is not m_activeAppModel
DockGlobalElementModel-->>QMLBinding: QVariant(false)
end
QMLBinding-->>User: icon reflects correct active state
User->>QMLBinding: attention state change
QMLBinding->>DockGlobalElementModel: data(index, AttentionRole)
DockGlobalElementModel->>DockGlobalElementModel: determine model and row
alt model is m_activeAppModel
DockGlobalElementModel->>ActiveAppModel: index(row, 0)
ActiveAppModel-->>DockGlobalElementModel: QModelIndex
DockGlobalElementModel->>ActiveAppModel: data(AttentionRole)
ActiveAppModel-->>DockGlobalElementModel: QVariant(bool)
DockGlobalElementModel-->>QMLBinding: QVariant(bool)
else model is not m_activeAppModel
DockGlobalElementModel-->>QMLBinding: QVariant(false)
end
QMLBinding-->>User: icon shows correct attention feedback
Class diagram for updated DockGlobalElementModel data handlingclassDiagram
class DockGlobalElementModel {
+QVariant data(QModelIndex index, int role)
-QAbstractItemModel* m_activeAppModel
-QAbstractItemModel* model
}
class QAbstractItemModel {
+QModelIndex index(int row, int column)
+QVariant data(int role)
}
class TaskManagerRoles {
<<enumeration>>
+int WindowsRole
+int ActiveRole
+int AttentionRole
+int MenusRole
}
DockGlobalElementModel --> QAbstractItemModel : uses
DockGlobalElementModel --> TaskManagerRoles : uses
class DataFlowForActiveAndAttentionRoles {
+QVariant handleActiveRole(QModelIndex index)
+QVariant handleAttentionRole(QModelIndex index)
+QVariant delegateToActiveAppModel(QModelIndex index, int role)
+QVariant returnFalseForNonAppModels()
}
DockGlobalElementModel ..> DataFlowForActiveAndAttentionRoles : implements
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider adding a brief comment above the
ActiveRole/AttentionRolebranch to explain whyfalseis returned instead of an invalidQVariant(to force QML property updates), since this is non-obvious behavior that future maintainers might otherwise “fix” back. - If
ActiveRole/AttentionRoleare conceptually "not applicable" for non-active models rather than explicitlyfalse, it might be worth clarifying this choice (e.g., via naming or comments) so consumers don’t confuse the two states.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider adding a brief comment above the `ActiveRole`/`AttentionRole` branch to explain why `false` is returned instead of an invalid `QVariant` (to force QML property updates), since this is non-obvious behavior that future maintainers might otherwise “fix” back.
- If `ActiveRole`/`AttentionRole` are conceptually "not applicable" for non-active models rather than explicitly `false`, it might be worth clarifying this choice (e.g., via naming or comments) so consumers don’t confuse the two states.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
app model
TaskManager::ActiveRoleandTaskManager::AttentionRolein thedata()method ofDockGlobalElementModelm_activeAppModel)falsefor other models (e.g., window group model) as these concepts don't apply thereLog: Fixed incorrect active state and attention state display for dock app icons
Influence:
fix: 修复活跃应用模型的 ActiveRole 和 AttentionRole 数据获取
DockGlobalElementModel的data()方法中增加了TaskManager::ActiveRole和TaskManager::AttentionRole的处理分支false,因为这些概念不适用Log: 修复任务栏应用图标活跃状态和提醒状态显示异常
Influence:
此问题主要是处理
拆分模式下,关闭某个驻留应用窗口时(有焦点的窗口),他的背景不会消失,问题在于:属性绑定机制里,如果绑定的数据源返回了 undefined(对应 C++ 的空的/无效的 QVariant),QML
会选择不更新此属性,保留上一次的旧值!
因此 默认default返回的是一个 return {}; 会导致 保留了上次值,导致问题。
Summary by Sourcery
Fix active and attention state data retrieval for dock app entries in the global element model.
Bug Fixes: