-
Notifications
You must be signed in to change notification settings - Fork 37
fix: improve folder grid view navigation and focus handling #701
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
Conversation
1. Changed from onCurrentIndexChanged to onCurrentItemChanged for focus reset to ensure target page is loaded before setting focus 2. Added pendingFocusIndex property to track desired focus position when switching pages 3. Enhanced resetGridFocus function to handle focus index calculation and delayed execution via Qt.callLater 4. Added left/right key navigation for both grid view modes (icon and list) to enable cross-page navigation 5. Implemented circular navigation within pages and between pages 6. Improved model count detection to handle different model types (count property vs rowCount method) Log: Improved folder navigation with keyboard arrow keys and fixed focus issues when switching pages Influence: 1. Test left/right arrow key navigation within a folder page 2. Verify focus correctly transfers when navigating between pages using arrow keys 3. Test circular navigation when reaching page boundaries 4. Verify focus position is maintained when switching pages 5. Test with empty folders and single-page folders 6. Verify both icon view and list view modes work correctly 7. Test focus behavior when quickly switching between pages fix: 改进文件夹网格视图导航和焦点处理 1. 将焦点重置从 onCurrentIndexChanged 改为 onCurrentItemChanged,确保目 标页面加载完成后再设置焦点 2. 添加 pendingFocusIndex 属性来跟踪切换页面时所需的焦点位置 3. 增强 resetGridFocus 函数,通过 Qt.callLater 处理焦点索引计算和延迟 执行 4. 为两种网格视图模式(图标和列表)添加左右键导航功能,支持跨页面导航 5. 实现页面内和页面间的循环导航 6. 改进模型数量检测,处理不同类型的模型(count 属性 vs rowCount 方法) Log: 改进文件夹导航,支持键盘方向键导航,修复切换页面时的焦点问题 Influence: 1. 测试文件夹页面内的左右方向键导航 2. 验证使用方向键在页面间导航时焦点是否正确转移 3. 测试到达页面边界时的循环导航 4. 验证切换页面时焦点位置是否正确保持 5. 测试空文件夹和单页文件夹的情况 6. 验证图标视图和列表视图模式都能正常工作 7. 测试快速切换页面时的焦点行为 PMS: BUG-333261 BUG-333255
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.
deepin pr auto reviewGit Diff 代码审查总体评估这段代码修改了文件夹网格视图的键盘导航行为,主要实现了跨页面导航功能(在第一页按左键跳转到最后一页,在最后一页按右键跳转到第一页),并改进了焦点管理机制。代码整体逻辑清晰,但存在一些可以改进的地方。 详细审查1. 代码质量与逻辑优点:
改进建议:
2. 性能考虑
3. 安全性考虑
4. 具体改进建议4.1 提取重复代码// 在组件级别定义共享函数
function getModelCount(model) {
if (!model) return 0
if (model.count !== undefined) return model.count
if (model.rowCount !== undefined) return model.rowCount()
return 0
}
function handleKeyPress(event, direction) {
event.accepted = true
let count = getModelCount(sortProxyModel)
if (count === 0) return
let current = folderGridViewContainer.currentIndex
// 处理同一页内的导航
if (direction === "left" && current > 0) {
folderGridViewContainer.currentIndex = current - 1
return
}
if (direction === "right" && current < count - 1) {
folderGridViewContainer.currentIndex = current + 1
return
}
// 处理跨页导航
let pageCount = folderPagesView.count
if (pageCount <= 1) {
folderGridViewContainer.currentIndex = direction === "left" ? count - 1 : 0
return
}
// 设置焦点标志并切换页面
folderPagesView.pendingFocusIndex = direction === "left" ? -1 : 0
if (direction === "left") {
folderPagesView.setCurrentIndex(folderPagesView.currentIndex === 0 ? pageCount - 1 : folderPagesView.currentIndex - 1)
} else {
folderPagesView.setCurrentIndex(folderPagesView.currentIndex === pageCount - 1 ? 0 : folderPagesView.currentIndex + 1)
}
}然后在键盘事件处理中使用: Keys.onLeftPressed: function(event) {
handleKeyPress(event, "left")
}
Keys.onRightPressed: function(event) {
handleKeyPress(event, "right")
}4.2 改进
|
|
[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 |
Log: Improved folder navigation with keyboard arrow keys and fixed focus issues when switching pages
Influence:
fix: 改进文件夹网格视图导航和焦点处理
Log: 改进文件夹导航,支持键盘方向键导航,修复切换页面时的焦点问题
Influence:
PMS: BUG-333261 BUG-333255