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