ea3ec8657b656e213cd264f819e77652dc074d05
[mdictionary] / src / mdictionary / qml / ProgressBar.qml
1 import Qt 4.7
2
3 Item {
4     id: progressBar
5
6     property int minimum: 0
7     property int maximum: 100
8     property int value: 0
9     property alias color: gradient1.color
10     property alias secondColor: gradient2.color
11
12     function setMax(intiger) { maximum=intiger }
13     function setMin(intiger) { minimum=intiger }
14     function setValue(intiger) { value= intiger }
15
16     width: 250;
17     height: 23
18     clip: true
19
20     BorderImage {
21         source: "background.png"
22         width: parent.width; height: parent.height
23         border { left: 4; top: 4; right: 4; bottom: 4 }
24     }
25
26     Rectangle {
27         id: highlight
28
29         property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6)
30
31         width: highlight.widthDest
32         Behavior on width { SmoothedAnimation { velocity: 1200 } }
33
34         anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 }
35         radius: 1
36         gradient: Gradient {
37             GradientStop { id: gradient1; position: 0.0 }
38             GradientStop { id: gradient2; position: 1.0 }
39         }
40     }
41
42     Text {
43         anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter }
44         color: "white"
45         font.bold: true
46         text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%'
47     }
48 }