blob: 98dd246937e8ca702aa7f9be2968f40231de076d (
plain)
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
|
import Qt 4.6
Item {
id: root
property alias background: background.source
default property alias content: visualModel.children
property int currentIndex: 0
Image {
id: background
fillMode: Image.TileHorizontally
x: -list.viewportX / 2
width: Math.max(list.viewportWidth, parent.width)
}
ListView {
id: list
currentIndex: root.currentIndex
onCurrentIndexChanged: root.currentIndex = currentIndex
orientation: "Horizontal"
overShoot: false
anchors.fill: parent
model: VisualItemModel { id: visualModel }
highlight: Rectangle { height: 1; width: 1 }
highlightMoveSpeed: 2000
preferredHighlightBegin: 0
preferredHighlightEnd: 0
highlightRangeMode: "StrictlyEnforceRange"
flickDeceleration: 1000
}
ListView {
id: selector
Rectangle {
color: "#60FFFFFF"
x: -10; y: -10; radius: 10; z: -1
width: parent.width + 20; height: parent.height + 20
}
currentIndex: root.currentIndex
onCurrentIndexChanged: root.currentIndex = currentIndex
height: 50
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(count * 50, parent.width - 20)
interactive: width == parent.width - 20
orientation: "Horizontal"
delegate: Item {
width: 50; height: 50
id: delegateRoot
Image {
id: image
source: modelData.icon
smooth: true
scale: 0.8
transformOrigin: "Center"
}
MouseRegion {
anchors.fill: parent
onClicked: { root.currentIndex = index }
}
states: State {
name: "Selected"
when: delegateRoot.ListView.isCurrentItem == true
PropertyChanges {
target: image
scale: 1
y: -5
}
}
transitions: Transition {
NumberAnimation {
matchProperties: "scale,y"
}
}
}
model: visualModel.children
}
}
|