2 * Copyright (C) 2012, 2013 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import Ubuntu.Components 0.1
21 height: childrenRect.height
22 width: childrenRect.width
23 property variant tooltip
25 property variant sliderData
26 property string action
27 property alias value: slider.value
29 // TODO We should not need this but without it
30 // slider.onValueChanged.connect(valueChanged) in
31 // HudParametrizedActionsPage.qml doesn't work
32 // Michael thinks it's related to https://bugreports.qt-project.org/browse/QTBUG-29141
35 onSliderDataChanged: {
36 label.text = sliderData["label"]
37 slider.minimumValue = sliderData["min"]
38 slider.maximumValue = sliderData["max"]
39 if("live" in sliderData)
40 slider.live = sliderData["live"]
41 // SDK Slider does not support step yet
42 // slider.step = sliderData["step"]
43 if("value" in sliderData)
44 slider.value = sliderData["value"]
45 action = sliderData["action"]
50 anchors.top: parent.top
51 anchors.left: parent.left
52 anchors.right: parent.right
53 anchors.margins: units.gu(1)
54 anchors.leftMargin: units.gu(2)
59 anchors.top: label.bottom
60 anchors.left: parent.left
61 anchors.right: parent.right
62 anchors.margins: units.gu(1)
65 function realFormatValue(v) { return Math.round(v) + " %" }
66 function formatValue(v) { return tooltip.target == slider ? "" : realFormatValue(v) }
67 onPressedChanged: tooltip.target = pressed ? slider : undefined
70 source: "graphics/divider.sci"
71 anchors.top: slider.bottom
72 anchors.left: parent.left
73 anchors.right: parent.right
74 anchors.topMargin: units.gu(2)