add history widget
[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                 loops:  (value>-1)?0:Animation.Infinite
52                 SmoothedAnimation { velocity:450 ; to: progressBar.width - 96}
53                 SmoothedAnimation { velocity: 450 ; to: 6 }
54             }
55         }
56
57         radius: 1
58         anchors.top: parent.top
59         anchors.left: parent.left
60
61         anchors.bottom: parent.bottom
62         anchors.margins: 3
63
64         gradient: Gradient {
65             GradientStop {color:"#0510a0"; position: 0.0 }
66             GradientStop {color:"#6b98f7"; position: 1.0 }
67         }
68     }
69
70     Text {
71         z: 1;
72         anchors.right: highlight.right
73         anchors.rightMargin: (value>-1) ? 6 : 35;
74         anchors.verticalCenter: parent.verticalCenter
75         color: "white"
76         font.bold: true
77         text: (value>-1) ? (Math.floor((value - minimum) / (maximum - minimum) * 100) + '%') : ("");
78     }
79 }