From 19c2b40e8f153b8e6fda1e285f689f143871282a Mon Sep 17 00:00:00 2001 From: Wang Zichong Date: Tue, 9 Jan 2024 14:48:35 +0800 Subject: [PATCH] fix: reset scrollview/swipeview position when hide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 隐藏启动器时,重置可滚动/翻页区域的位置到最顶部/首页。 Issue: https://github.com/linuxdeepin/developer-center/issues/6402 Log: --- qml/AppListView.qml | 4 ++++ qml/FullscreenFrame.qml | 2 ++ qml/GridViewContainer.qml | 4 ++++ qml/WindowedFrame.qml | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/qml/AppListView.qml b/qml/AppListView.qml index 44d77d87..36cf8102 100644 --- a/qml/AppListView.qml +++ b/qml/AppListView.qml @@ -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 diff --git a/qml/FullscreenFrame.qml b/qml/FullscreenFrame.qml index 891e3e04..4350f34b 100644 --- a/qml/FullscreenFrame.qml +++ b/qml/FullscreenFrame.qml @@ -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) } } } diff --git a/qml/GridViewContainer.qml b/qml/GridViewContainer.qml index 55ddb6d4..7df89254 100644 --- a/qml/GridViewContainer.qml +++ b/qml/GridViewContainer.qml @@ -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) diff --git a/qml/WindowedFrame.qml b/qml/WindowedFrame.qml index c2cc7b8f..fbf34b91 100644 --- a/qml/WindowedFrame.qml +++ b/qml/WindowedFrame.qml @@ -336,6 +336,10 @@ StackView { searchEdit.text = "" // reset(remove) keyboard focus baseLayer.focus = true + // reset scroll area position + appListView.positionViewAtBeginning() + favoriteGridViewContainer.positionViewAtBeginning() + allAppsGridContainer.positionViewAtBeginning() } } }