Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import QtQuick 2.4
DapScrollViewForm
{
// All the logic (including state names and vars) was taken from master branch
// Var for current pos while scrolling (in function updateY())
property var contentPos: 0.0
// Connect to new ListView if changed
onViewDataChanged:
{
viewData.contentYChanged.connect(updateY)
}
// Changes position of arrows when scroll
function updateY()
{
if (viewData.atYBeginning)
{
scrollButton.state = "goUp"
}
else if (viewData.atYEnd)
{
scrollButton.state = "goDown"
}
else if (contentPos > viewData.contentItem.y)
{
scrollButton.state = "goUp"
}
else
{
scrollButton.state = "goDown"
}
contentPos = viewData.contentItem.y
}
onEntered:
{
scrollButton.visible = true;
}
onExited:
{
scrollButton.visible = false;
}
scrollButton.onEntered:
{
if (scrollButton.state === "goUp")
{
scrollButtonImage.source = scrollDownButtonHoveredImageSource
}
else if (scrollButton.state === "goDown")
{
scrollButtonImage.source = scrollUpButtonHoveredImageSource
}
}
scrollButton.onExited:
{
if (scrollButton.state === "goUp")
{
scrollButtonImage.source = scrollDownButtonImageSource
}
else if (scrollButton.state === "goDown")
{
scrollButtonImage.source = scrollUpButtonImageSource
}
}
scrollButton.onClicked:
{
if(scrollButton.state === "goUp")
{
viewData.positionViewAtEnd();
scrollButton.state = "goDown";
}
else if(scrollButton.state === "goDown")
{
viewData.positionViewAtBeginning();
scrollButton.state = "goUp";
}
}
scrollButton.states:
[
State
{
name: "goDown"
PropertyChanges
{
target: scrollButton
onStateChanged:
{
scrollButton.anchors.top = undefined
scrollButton.anchors.bottom = parent.bottom
scrollButton.exited()
}
}
},
State
{
name: "goUp"
PropertyChanges
{
target: scrollButton
onStateChanged:
{
scrollButton.anchors.bottom = undefined
scrollButton.anchors.top = parent.top
scrollButton.exited()
}
}
}
]
scrollButton.state: "goUp"
}