Skip to content

Commit

Permalink
fix: all apps and favorite apps highlight focus
Browse files Browse the repository at this point in the history
Always scroll to the highlight when focus in.

Log: fix all apps and favorite apps highlight focus
Issue: linuxdeepin/developer-center#6397
  • Loading branch information
asterwyx authored and BLumia committed Jan 5, 2024
1 parent ad5d023 commit 765ca90
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
14 changes: 5 additions & 9 deletions qml/AppListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ Item {
}
}

function scrollToHighlight() {
listView.highlightMoveDuration = 0
listView.highlightRangeMode = ListView.StrictlyEnforceRange
postScrollDeferTimer.restart()
}

Component {
id: sectionHeading
ToolButton {
Expand Down Expand Up @@ -92,10 +86,12 @@ Item {
// displayMarginBeginning: -45
clip: true
focus: true
onFocusChanged: {
if (focus) {
onActiveFocusChanged: {
if (activeFocus) {
// When focus in, we always scroll to the highlight
scrollToHighlight()
listView.highlightMoveDuration = 0
listView.highlightRangeMode = ListView.StrictlyEnforceRange
postScrollDeferTimer.restart()
}
}

Expand Down
19 changes: 17 additions & 2 deletions qml/GridViewContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,31 @@ FocusScope {
height: rows == 0 ? parent.height : (item.cellSize * root.rows)
color: "transparent"

Timer {
id: postScrollDeferTimer
interval: 150
onTriggered: {
gridView.highlightMoveDuration = 150
gridView.highlightRangeMode = GridView.NoHighlightRange
}
}

GridView {
id: gridView
anchors.fill: parent
clip: true
highlightFollowsCurrentItem: true
keyNavigationEnabled: true
highlightMoveDuration: 0
highlightMoveDuration: 150
activeFocusOnTab: focus ? root.activeGridViewFocusOnTab : false
focus: count > 0

onActiveFocusChanged: {
if (activeFocus) {
gridView.highlightMoveDuration = 0
gridView.highlightRangeMode = GridView.StrictlyEnforceRange
postScrollDeferTimer.restart()
}
}
cellHeight: item.cellSize
cellWidth: item.cellSize

Expand Down

0 comments on commit 765ca90

Please sign in to comment.