-
Notifications
You must be signed in to change notification settings - Fork 55
fix: Fix the tab switching focus order #1345
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
base: master
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR introduces a new rebuildDelegates method in NotifyModel to reset the model and force QML ListView delegate recreation, and invokes it after notification group expand/collapse operations to correct the tab focus order to match the visual order. Sequence diagram for tab focus order update after expand/collapsesequenceDiagram
participant User
participant NotifyModel
participant QML_ListView
User->>NotifyModel: Expand or collapse notification group
NotifyModel->>NotifyModel: expandApp()/collapseApp()
NotifyModel->>NotifyModel: rebuildDelegates()
NotifyModel->>QML_ListView: beginResetModel()
NotifyModel->>QML_ListView: endResetModel()
QML_ListView->>QML_ListView: Destroy and recreate delegates
QML_ListView->>User: Tab focus order matches visual order
Class diagram for updated NotifyModelclassDiagram
class NotifyModel {
+void expandApp(int row)
+void collapseApp(int row)
+void rebuildDelegates()
QList<AppNotifyItem *> m_appNotifies
}
NotifyModel : rebuildDelegates()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
1353f90 to
6c1bf67
Compare
|
TAG Bot New tag: 2.0.18 |
| { | ||
| // 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(); |
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.
这个这样直接reset,可能会影响动画的,
为什么要让它重新生成呀,之前的代码是特意不让它重新生成的,焦点问题是不是可以按照当前应该的index,主动在界面上用listview的接口设置,让它特定的Item获得焦点,类似这样https://github.com/linuxdeepin/dde-shell/blob/master/panels/notification/center/NotifyView.qml#L32
|
TAG Bot New tag: 2.0.19 |
Fix the tab switching focus order Log: Fix the tab switching focus order pms: BUG-339891
6c1bf67 to
4601671
Compare
deepin pr auto review我来对这段代码变更进行审查:
可改进之处:
改进建议: void NotifyModel::rebuildDelegates()
{
// 只在有可见项时才重置模型
if (rowCount() == 0) {
return;
}
// 记录当前滚动位置
emit saveScrollPosition();
beginResetModel();
endResetModel();
// 恢复滚动位置
emit restoreScrollPosition();
}同时,可以考虑以下优化方案:
private:
bool m_needsDelegateRebuild = false;
void NotifyModel::setNeedsDelegateRebuild(bool needs)
{
if (m_needsDelegateRebuild != needs) {
m_needsDelegateRebuild = needs;
if (needs) {
QMetaObject::invokeMethod(this, [this]() {
if (m_needsDelegateRebuild) {
rebuildDelegates();
m_needsDelegateRebuild = false;
}
}, Qt::QueuedConnection);
}
}
}这样可以:
|
Fix the tab switching focus order
Log: Fix the tab switching focus order
pms: BUG-339891
Summary by Sourcery
Bug Fixes: