Skip to content

Commit

Permalink
Implement scroll to top by using Flickable.flick() and a Timer.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Sep 12, 2023
1 parent 4616757 commit 0c9a348
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
22 changes: 19 additions & 3 deletions src/gui/tray/ActivityList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/gui/tray/Window.qml
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,7 @@ ApplicationWindow {

text: qsTr("New activities")
onClicked: {
//activityList.positionViewAtBeginning();
activityList.contentY = 0;
activityList.scrollToTop();
newActivitiesButtonLoader.active = false;
}

Expand Down Expand Up @@ -927,7 +926,7 @@ ApplicationWindow {
Connections {
target: activityModel
onInteractiveActivityReceived: {
if (activityList.contentY > 0) {
if (!activityList.atYBeginning) {
newActivitiesButtonLoader.active = true;
}
}
Expand Down

0 comments on commit 0c9a348

Please sign in to comment.