2e102c3257a8aa829cac6e23366dae95b6b539e8
[mdictionary] / src / mdictionary / qml / ProgressBar.qml
1 import Qt 4.7
2
3 Rectangle {
4     id: progressBar
5
6     property int minimum: 0
7     property int maximum: 100
8     property int value: -1
9     property int value2: 50
10
11     function setMax(intiger) { maximum=intiger }
12     function setMin(intiger) { minimum=intiger }
13     function setValue(intiger) { value= intiger }
14     function setValue2(intiger) { value2= intiger }
15
16     width: 250;
17     height: 23
18     clip: true
19
20     BorderImage {
21         source: "qrc:/progressBar/background.png"
22         width: parent.width; height: parent.height
23         border { left: 4; top: 4; right: 4; bottom: 4 }
24     }
25
26
27     Rectangle {
28         id: highlight
29         z: 1;
30
31         property int widthDest: (progressBar.width * (value - minimum)) / (maximum - minimum) - 6
32         property int position: (progressBar.width * (value2 - minimum)) / (maximum - minimum)
33
34         width: (value>-1) ? (highlight.widthDest) : (90)
35         anchors.leftMargin: (value>-1) ? (0) : (highlight.position)
36
37         Behavior on width {
38             SmoothedAnimation {
39                 velocity:  1200
40             }
41         }
42
43         Behavior on anchors.leftMargin {
44             SequentialAnimation{
45                 loops: Animation.Infinite
46                 SmoothedAnimation { velocity: 450; to: progressBar.width - 96}
47                 SmoothedAnimation { velocity: 450; to: 6 }
48             }
49         }
50
51         radius: 1
52         anchors.top: parent.top
53         anchors.left: parent.left
54
55         anchors.bottom: parent.bottom
56         anchors.margins: 3
57
58         gradient: Gradient {
59             GradientStop {color:"#0510a0"; position: 0.0 }
60             GradientStop {color:"#6b98f7"; position: 1.0 }
61         }
62     }
63
64     Text {
65         z: 1;
66         anchors.right: highlight.right
67         anchors.rightMargin: (value>-1) ? 6 : 35;
68         anchors.verticalCenter: parent.verticalCenter
69         color: "white"
70         font.bold: true
71         text: (value>-1) ? (Math.floor((value - minimum) / (maximum - minimum) * 100) + '%') : ("???");
72     }
73 }