fix: Fixed issue where the focus did not start from the current page when entering the secondary interface#3005
Conversation
Reviewer's GuideIntroduces a new DccApp flag and QML focus handling changes so that when entering the secondary interface, keyboard focus starts at the correct page instead of the first right‑panel item, with a special case for the system page. Sequence diagram for secondary interface focus handlingsequenceDiagram
actor User
participant SecondPage
participant DccApp
participant DccRightView
participant DccItem
User->>SecondPage: navigateToSecondaryInterface(activeObj)
SecondPage->>SecondPage: ensure activeObj.page
SecondPage->>DccApp: setSkipRightViewFocus(activeObj.name == system)
DccApp-->>SecondPage: skipRightViewFocusChanged(skip)
SecondPage->>DccRightView: rightView.replace(mainView, dccObj, animationMode)
activate DccRightView
DccRightView->>DccRightView: Component.onCompleted
DccRightView->>DccRightView: showScrollBarTimer.start()
DccRightView->>DccApp: read skipRightViewFocus
alt skipRightViewFocus is false
DccRightView->>DccRightView: control.forceActiveFocus()
DccRightView-->>User: keyboard focus on rightView root
DccRightView->>DccItem: item receives focus via navigation
else skipRightViewFocus is true (system page)
DccRightView-->>User: focus remains on current page context
end
Updated class diagram for DccApp focus management flagclassDiagram
class DccApp {
+QVector~DccObject*~ currentObjects
+QVector~DccObject*~ triggeredObjects
+AnimationMode m_animationMode
+bool m_skipRightViewFocus
+int width()
+int height()
+int sidebarWidth()
+void setSidebarWidth(int width)
+AnimationMode animationMode()
+void setAnimationMode(AnimationMode mode)
+bool skipRightViewFocus()
+void setSkipRightViewFocus(bool skip)
+void currentObjectsChanged(QVector~DccObject*~ currentObjects)
+void triggeredObjectsChanged(QVector~DccObject*~ triggeredObjects)
+void activeItemChanged(QQuickItem* item)
+void animationModeChanged(AnimationMode mode)
+void skipRightViewFocusChanged(bool skipRightViewFocus)
}
class DccObject
class QQuickItem
DccApp --> DccObject : uses
DccApp --> QQuickItem : activeItemChanged parameter
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:
- The
Component.onCompletedblock inDccRightView.qmlonly checksDccApp.skipRightViewFocusonce on creation; if this flag changes later (e.g. when switching between different secondary pages), the focus behavior will not update—consider reacting toskipRightViewFocusChangedor binding focus logic to the property instead of a one-shot check. - Using the literal string
"system"inSecondPage.qmlto decide whether to skip right view focus makes the behavior fragile; consider basing this on a typed property/flag ofactiveObjor a central enum-like definition instead of a magic string.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `Component.onCompleted` block in `DccRightView.qml` only checks `DccApp.skipRightViewFocus` once on creation; if this flag changes later (e.g. when switching between different secondary pages), the focus behavior will not update—consider reacting to `skipRightViewFocusChanged` or binding focus logic to the property instead of a one-shot check.
- Using the literal string `"system"` in `SecondPage.qml` to decide whether to skip right view focus makes the behavior fragile; consider basing this on a typed property/flag of `activeObj` or a central enum-like definition instead of a magic string.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if (activeObj.page === null) { | ||
| activeObj.page = rightLayout | ||
| } | ||
| DccApp.skipRightViewFocus = (activeObj.name === "system") |
There was a problem hiding this comment.
如果tab点了个性化,再点回系统,岂不是系统的一级页面的焦点就不会自动跳转了
There was a problem hiding this comment.
如果tab点了个性化,再点回系统,岂不是系统的一级页面的焦点就不会自动跳转了
是的,系统界面的焦点从主窗口开始,其他的界面焦点从右侧区域开始
…when entering the secondary interface Fixed issue where the focus did not start from the current page when entering the secondary interface Log: Fixed issue where the focus did not start from the current page when entering the secondary interface pms: BUG-311355
deepin pr auto review这段代码变更主要涉及两个QML文件的修改,主要目的是调整焦点管理行为。以下是针对语法逻辑、代码质量、代码性能和代码安全的详细审查意见: 1. 语法逻辑DccItem.qml 修改: - activeFocusOnTab: true
+ activeFocusOnTab: false
SecondPage.qml 修改: + if (activeObj.name !== "system") {
+ list.forceActiveFocus()
+ }
2. 代码质量
3. 代码性能
4. 代码安全
综合改进建议
总结这段代码的修改主要是调整焦点管理逻辑,但存在以下潜在问题:
建议添加注释、优化条件判断逻辑,并确保键盘导航的完整性。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, pengfeixx 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) |
Fixed issue where the focus did not start from the current page when entering the secondary interface
Log: Fixed issue where the focus did not start from the current page when entering the secondary interface
pms: BUG-311355
Summary by Sourcery
Adjust focus behavior when entering secondary pages so the right view focus can be optionally skipped for specific pages.
Bug Fixes:
Enhancements: