import Qt 4.7
-Item {
+Rectangle {
id: progressBar
property int minimum: 0
property int maximum: 100
- property int value: 0
- property alias color: gradient1.color
- property alias secondColor: gradient2.color
+ property int value: -1
+ property int value2: 50
function setMax(intiger) { maximum=intiger }
function setMin(intiger) { minimum=intiger }
function setValue(intiger) { value= intiger }
+ function setValue2(intiger) { value2= intiger }
width: 250;
height: 23
clip: true
BorderImage {
- source: "background.png"
+ source: "qrc:/progressBar/background.png"
width: parent.width; height: parent.height
border { left: 4; top: 4; right: 4; bottom: 4 }
}
+
Rectangle {
id: highlight
+ z: 1;
+
+ property int widthDest: (progressBar.width * (value - minimum)) / (maximum - minimum) - 6
+ property int position: (progressBar.width * (value2 - minimum)) / (maximum - minimum)
- property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6)
+ width: (value>-1) ? (highlight.widthDest) : (90)
+ anchors.leftMargin: (value>-1) ? (0) : (highlight.position)
- width: highlight.widthDest
- Behavior on width { SmoothedAnimation { velocity: 1200 } }
+ Behavior on width {
+ SmoothedAnimation {
+ velocity: 1200
+ }
+ }
+
+ Behavior on anchors.leftMargin {
+ SequentialAnimation{
+ loops: Animation.Infinite
+ SmoothedAnimation { velocity: 450; to: progressBar.width - 96}
+ SmoothedAnimation { velocity: 450; to: 0 }
+ }
+ }
- anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 }
radius: 1
+ anchors.top: parent.top
+ anchors.left: parent.left
+
+ anchors.bottom: parent.bottom
+ anchors.margins: 3
+
gradient: Gradient {
- GradientStop { id: gradient1; position: 0.0 }
- GradientStop { id: gradient2; position: 1.0 }
+ GradientStop {color:"#0510a0"; position: 0.0 }
+ GradientStop {color:"#6b98f7"; position: 1.0 }
}
}
Text {
- anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter }
+ z: 1;
+ anchors.right: highlight.right
+ anchors.rightMargin: (value>-1) ? 6 : 35;
+ anchors.verticalCenter: parent.verticalCenter
color: "white"
font.bold: true
- text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%'
+ text: (value>-1) ? (Math.floor((value - minimum) / (maximum - minimum) * 100) + '%') : ("???");
}
}