1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the Qt Components project.
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
39 ****************************************************************************/
42 import Qt.labs.components 1.1
49 property alias minimumValue: model.minimumValue
50 property alias maximumValue: model.maximumValue
51 property alias value: model.value
52 property bool indeterminate: false
54 // Symbian specific API
55 property bool platformInverted: false
57 implicitWidth: Math.max(50, screen.width / 2) // TODO: use screen.displayWidth
58 implicitHeight: privateStyle.sliderThickness
63 source: privateStyle.imagePath("qtg_fr_progressbar_track", root.platformInverted)
64 border { left: platformStyle.borderSizeMedium; top: 0; right: platformStyle.borderSizeMedium; bottom: 0 }
69 id: progressBarContent
71 LayoutMirroring.enabled: false
72 LayoutMirroring.childrenInherit: true
77 when: root.indeterminate
78 PropertyChanges { target: progressBarContent; sourceComponent: indeterminateContent; anchors.fill: parent }
82 when: !root.indeterminate
83 PropertyChanges { target: progressBarContent; sourceComponent: determinateContent }
85 target: progressBarContent
86 anchors.top: parent.top
87 anchors.bottom: parent.bottom
88 anchors.left: parent.left
96 id: indeterminateContent
102 id: indeterminateImageMask
104 // Mask margins prevent indeterminateImage to appear outside the rounded
105 // frame corners, hardcoded 3 has been instructed by UX
106 anchors { fill: parent; leftMargin: 3; rightMargin: 3 }
110 id: indeterminateImage
113 height: parent.height
114 width: parent.width + height // height is the amount of horizontal movement
115 fillMode: Image.TileHorizontally
116 source: privateStyle.imagePath(root.platformInverted ? "qtg_graf_progressbar_wait_inverse"
117 : "qtg_graf_progressbar_wait")
119 NumberAnimation on x {
120 loops: Animation.Infinite
123 to: -indeterminateImage.height // see indeterminateImage.width
124 easing.type: Easing.Linear
125 duration: privateStyle.sliderThickness * 30
131 id: indeterminateOverlay
134 source: privateStyle.imagePath("qtg_fr_progressbar_overlay", root.platformInverted)
136 left: platformStyle.borderSizeMedium
137 right: platformStyle.borderSizeMedium
146 id: determinateContent
151 width: model.position
157 source: privateStyle.imagePath("qtg_fr_progressbar_fill", root.platformInverted)
159 left: platformStyle.borderSizeMedium
160 right: platformStyle.borderSizeMedium
164 height: parent.height
174 positionAtMinimum: 0.0
175 positionAtMaximum: background.width