Adding wip version for meego harmattan
[feedingit] / psa_harmattan / feedingit / deb_dist / feedingit-0.1.0 / qml / common / Slider.qml
1 import Qt 4.7
2
3 Item {
4     id: slider; width: 340; height: 48
5
6     // value is read/write.
7     property real value
8     onValueChanged: { handle.x = 2 + (value - minimum) * slider.xMax / (maximum - minimum); }
9     property real maximum: 1
10     property real minimum: 1
11     property int xMax: slider.width - handle.width - 4
12
13     Rectangle {
14         anchors.fill: parent
15         border.color: "white"; border.width: 0; radius: 8
16         gradient: Gradient {
17             GradientStop { position: 0.0; color: "#66343434" }
18             GradientStop { position: 1.0; color: "#66000000" }
19         }
20     }
21
22     Rectangle {
23         id: handle; smooth: true
24         x: slider.width / 2 - handle.width / 2; y: 2; width: 30; height: slider.height-4; radius: 6
25         gradient: Gradient {
26             GradientStop { position: 0.0; color: "lightgray" }
27             GradientStop { position: 1.0; color: "gray" }
28         }
29
30         MouseArea {
31             anchors.fill: parent; drag.target: parent
32             drag.axis: "XAxis"; drag.minimumX: 2; drag.maximumX: slider.xMax+2
33             onPositionChanged: { value = (maximum - minimum) * (handle.x-2) / slider.xMax + minimum; }
34         }
35     }
36 }