From 0c9a34847bc1d1e87dfdf0837a954e1f73e16fe4 Mon Sep 17 00:00:00 2001 From: alex-z Date: Tue, 12 Sep 2023 22:30:46 +0200 Subject: [PATCH] Implement scroll to top by using Flickable.flick() and a Timer. Signed-off-by: alex-z --- src/gui/tray/ActivityList.qml | 22 +++++++++++++++++++--- src/gui/tray/Window.qml | 5 ++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/gui/tray/ActivityList.qml b/src/gui/tray/ActivityList.qml index 9c51b4c58009b..a697e3a0cb8b3 100644 --- a/src/gui/tray/ActivityList.qml +++ b/src/gui/tray/ActivityList.qml @@ -8,13 +8,15 @@ ScrollView { id: controlRoot property alias model: sortedActivityList.sourceModel property alias count: activityList.count - property alias contentY : activityList.contentY + property alias atYBeginning : activityList.atYBeginning property bool isFileActivityList: false property int iconSize: Style.trayListItemIconSize property int delegateHorizontalPadding: 0 - function positionViewAtBeginning() { - activityList.positionViewAtIndex(0, ListView.Beginning) + property bool scrollingToTop: false + + function scrollToTop() { + scrollingToTop = true; } signal openFile(string filePath) @@ -42,6 +44,20 @@ ScrollView { currentIndex: -1 interactive: true + Timer { + id: disappearTimer + interval: 50; + running: controlRoot.scrollingToTop + repeat: true + onTriggered: { + if (!activityList.atYBeginning) { + activityList.flick(0, 10000) + } else { + controlRoot.scrollingToTop = false; + } + } + } + highlight: Rectangle { id: activityHover anchors.fill: activityList.currentItem diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index 016290b12ea66..8dbc6989af157 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -880,8 +880,7 @@ ApplicationWindow { text: qsTr("New activities") onClicked: { - //activityList.positionViewAtBeginning(); - activityList.contentY = 0; + activityList.scrollToTop(); newActivitiesButtonLoader.active = false; } @@ -927,7 +926,7 @@ ApplicationWindow { Connections { target: activityModel onInteractiveActivityReceived: { - if (activityList.contentY > 0) { + if (!activityList.atYBeginning) { newActivitiesButtonLoader.active = true; } }