on 084ae64 help sign in
unity8/Hud/SliderLabel.qml
74 lines 2.5 kB history raw
1/*
2 * Copyright (C) 2012, 2013 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
20Item {
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
28 onValueChanged: {
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
33 }
35 onSliderDataChanged: {
36 label.text = sliderData["label"]
37 slider.minimumValue = sliderData["min"]
38 slider.maximumValue = sliderData["max"]
39 slider.live = sliderData["live"]
40 // SDK Slider does not support step yet
41// slider.step = sliderData["step"]
42 slider.value = sliderData["value"]
43 action = sliderData["action"]
44 }
46 Label {
47 id: label
48 anchors.top: parent.top
49 anchors.left: parent.left
50 anchors.right: parent.right
51 anchors.margins: units.gu(1)
52 anchors.leftMargin: units.gu(2)
53 color: "white"
54 }
55 Slider {
56 id: slider
57 anchors.top: label.bottom
58 anchors.left: parent.left
59 anchors.right: parent.right
60 anchors.margins: units.gu(1)
61 height: units.gu(6)
62 live: true
63 function realFormatValue(v) { return Math.round(v) + " %" }
64 function formatValue(v) { return tooltip.target == slider ? "" : realFormatValue(v) }
65 onPressedChanged: tooltip.target = pressed ? slider : undefined
66 }
67 BorderImage {
68 source: "graphics/divider.sci"
69 anchors.top: slider.bottom
70 anchors.left: parent.left
71 anchors.right: parent.right
72 anchors.topMargin: units.gu(2)
73 }