Skip to content

Commit

Permalink
fix: reset scrollview/swipeview position when hide
Browse files Browse the repository at this point in the history
隐藏启动器时,重置可滚动/翻页区域的位置到最顶部/首页。

Issue: linuxdeepin/developer-center#6402
Log:
  • Loading branch information
BLumia committed Jan 9, 2024
1 parent 7589e73 commit 19c2b40
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qml/AppListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Item {
}
}

function positionViewAtBeginning() {
listView.positionViewAtBeginning()
}

function scrollToAlphabetCategory(character) {
for (let i = 0; i < model.count; i++) {
let transliterated1st = model.model.data(model.modelIndex(i), 4096)[0].toUpperCase() // 4096 is AppsModel::TransliteratedRole
Expand Down
2 changes: 2 additions & 0 deletions qml/FullscreenFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,8 @@ Control {
if (folderGridViewPopup.visible) folderGridViewPopup.close()
// reset(remove) keyboard focus
baseLayer.focus = true
// reset page to the first page
pages.setCurrentIndex(0)
}
}
}
4 changes: 4 additions & 0 deletions qml/GridViewContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ FocusScope {

readonly property alias gridViewWidth: gridView.width

function positionViewAtBeginning() {
gridView.positionViewAtBeginning()
}

function itemAt(x, y) {
let point = mapToItem(gridView, x, y)
return gridView.itemAt(point.x, point.y)
Expand Down
4 changes: 4 additions & 0 deletions qml/WindowedFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ StackView {
searchEdit.text = ""
// reset(remove) keyboard focus
baseLayer.focus = true
// reset scroll area position
appListView.positionViewAtBeginning()
favoriteGridViewContainer.positionViewAtBeginning()
allAppsGridContainer.positionViewAtBeginning()
}
}
}

0 comments on commit 19c2b40

Please sign in to comment.