on 331bab5 help sign in
66 lines 2.3 kB history raw
1/*
2 * Copyright 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 Lesser 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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
20import QtQuick 2.0
21import Ubuntu.Components 0.1
23Menu {
24 id: _sliderMenu
26 property alias minimumValue: slider.minimumValue
27 property alias maximumValue: slider.maximumValue
28 property alias value: slider.value
30 control: Slider {
31 id: slider
32 width: _sliderMenu.text ? units.gu(20) : _sliderMenu.width - units.gu(4)
33 anchors.verticalCenter: parent.verticalCenter
34 live: false
35 // FIXME: The interval should be [0.0 - 1.0]. Unfortunately, when
36 // reaching the boundaries (0.0 or 1.0), the value is converted
37 // to an integer when automatically wrapped in a variant when
38 // passed to QStateAction::updateState(…). The server chokes on
39 // those values, complaining that they’re not of the right type…
40 minimumValue: menu.extra.canonical_min ? menu.extra.canonical_min * 1.000001 : 0.0000001
41 maximumValue: menu.extra.canonical_max ? menu.extra.canonical_max * 1.000001 : 0.9999999
43 Binding {
44 target: slider.ItemStyle.style
45 property: "backgroundColor"
46 value: Qt.rgba(0.5, 0.5, 0.5, 0.1)
47 }
49 Binding {
50 target: slider.ItemStyle.style
51 property: "backgroundOpacity"
52 value: 1.0
53 }
55 // Use this to disable the label, since there is not way to do it on the component.
56 function formatValue(v) {
57 return ""
58 }
59 }
61 DBusActionState {
62 action: menu ? menu.action : undefined
63 target: slider
64 property: "value"
65 }