Skip to content

Commit c6598bd

Browse files
committed
feat: improve grid navigation with circular behavior
Enhanced keyboard navigation in fullscreen grid view to provide circular navigation behavior: 1. Added proper handling for empty grid scenarios 2. Implemented circular navigation within current page (wraps around when reaching edges) 3. Added proper page switching logic with circular behavior between pages 4. Fixed the previousIndex tracking for proper page transition state management 5. Ensured consistent event handling by always accepting key events The changes improve user experience by making navigation more intuitive and preventing users from getting stuck at grid boundaries. The navigation now seamlessly wraps around both within a page and between pages. Log: Improved keyboard navigation in fullscreen grid view with circular behavior Influence: 1. Test left/right arrow key navigation in empty grid 2. Verify circular navigation within a single page 3. Test page switching behavior when reaching grid boundaries 4. Verify navigation between multiple pages with circular behavior 5. Check that previousIndex is properly set for page transitions 6. Test that key events are properly accepted and handled feat: 改进网格导航实现循环行为 增强了全屏网格视图中的键盘导航功能,提供循环导航行为: 1. 添加了对空网格场景的适当处理 2. 在当前页面内实现了循环导航(到达边缘时自动环绕) 3. 添加了适当的页面切换逻辑,支持页面间的循环行为 4. 修复了previousIndex跟踪,确保正确的页面过渡状态管理 5. 通过始终接受按键事件确保一致的事件处理 这些改进通过使导航更加直观并防止用户在网格边界处卡住,提升了用户体验。导 航现在可以在页面内和页面间无缝环绕。 Log: 改进了全屏网格视图中的键盘导航,支持循环行为 Influence: 1. 在空网格中测试左右方向键导航 2. 验证单个页面内的循环导航 3. 测试到达网格边界时的页面切换行为 4. 验证多页面间的循环导航行为 5. 检查previousIndex是否正确设置用于页面过渡 6. 测试按键事件是否被正确接受和处理 PMS: BUG-339605 BUG-337493 BUG-324419
1 parent 6168166 commit c6598bd

1 file changed

Lines changed: 49 additions & 7 deletions

File tree

qml/FullscreenFrame.qml

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -421,23 +421,65 @@ InputEventItem {
421421
listviewPage.previousIndex = listviewPage.currentIndex
422422
})
423423
}
424-
425424
Keys.onLeftPressed: function(event) {
426-
if (listItem.viewIndex === 0 && itemPageModel.rowCount() > 1) {
425+
event.accepted = true
426+
427+
let count = proxyModel.count
428+
if (count === 0) {
429+
return
430+
}
431+
432+
let current = gridViewContainer.currentIndex
433+
if (current > 0) {
434+
gridViewContainer.currentIndex = current - 1
435+
return
436+
}
437+
438+
let pageCount = itemPageModel.rowCount()
439+
if (pageCount <= 1) {
440+
gridViewContainer.currentIndex = count - 1
441+
return
442+
}
443+
444+
if (listItem.viewIndex === 0) {
427445
// is the 1st page, go to last page
428-
listviewPage.setCurrentIndex(itemPageModel.rowCount() - 1)
446+
listviewPage.setCurrentIndex(pageCount - 1)
429447
} else {
430448
// not the 1st page, simply use SwipeView default behavior
431-
event.accepted = false
449+
listviewPage.setCurrentIndex(listItem.viewIndex - 1)
432450
}
433451
}
434452
Keys.onRightPressed: function(event) {
435-
if (listItem.viewIndex === (itemPageModel.rowCount() - 1) && itemPageModel.rowCount() > 1) {
453+
event.accepted = true
454+
455+
let count = proxyModel.count
456+
if (count === 0) {
457+
return
458+
}
459+
460+
let current = gridViewContainer.currentIndex
461+
if (current < count - 1) {
462+
gridViewContainer.currentIndex = current + 1
463+
return
464+
}
465+
466+
let pageCount = itemPageModel.rowCount()
467+
if (pageCount <= 1) {
468+
gridViewContainer.currentIndex = 0
469+
return
470+
}
471+
472+
if (listItem.viewIndex === (pageCount - 1) && pageCount > 1) {
436473
// is the last page, go to first page
474+
// mark this as a "next page" switch so that checkPageSwitchState
475+
// will select the first item on the target page
476+
listviewPage.previousIndex = 0
437477
listviewPage.setCurrentIndex(0)
438478
} else {
439-
// not the last page, simply use SwipeView default behavior
440-
event.accepted = false
479+
// switch to the next page in order and also treat it as "next page"
480+
let nextPageIndex = listItem.viewIndex + 1
481+
listviewPage.previousIndex = nextPageIndex
482+
listviewPage.setCurrentIndex(nextPageIndex)
441483
}
442484
}
443485
opacity: folderGridViewPopup.visible ? 0.2 : 1

0 commit comments

Comments
 (0)