~mzanetti/unity8/quicklist-unset-model-before-closing

« back to all changes in this revision

Viewing changes to plugins/Unity/Indicators/qml/SliderMenuItem.qml

  • Committer: Michael Zanetti
  • Date: 2013-08-27 06:59:04 UTC
  • mfrom: (235.1.20 trunk)
  • Revision ID: michael.zanetti@canonical.com-20130827065904-tdybcnq9cek07slp
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
FramedMenuItem {
26
26
    id: menuItem
27
 
    objectName: menuAction.name
28
 
    enabled: menuAction.active
29
27
 
30
28
    property alias minimumValue: slider.minimumValue
31
29
    property alias maximumValue: slider.maximumValue
32
 
    readonly property double value: menu ? menuAction.state : 0.0
 
30
    property double value: 0.0
 
31
 
 
32
    property alias minIcon: leftImage.source
 
33
    property alias maxIcon: rightImage.source
33
34
 
34
35
    property QtObject d: QtObject {
35
36
        property bool enableValueConnection: true
36
37
    }
37
38
 
 
39
    signal changeState(real value)
 
40
 
38
41
    onValueChanged: {
39
42
        // TODO: look into adding a component to manage bi-directional bindings.
40
43
        var oldEnable = d.enableValueConnection
58
61
            anchors.verticalCenter: row.verticalCenter
59
62
            height: units.gu(4)
60
63
            width: height
61
 
            source: menu.ext.minIcon
62
64
        }
63
65
 
64
66
        Components.Slider {
75
77
                value = menuItem.value
76
78
            }
77
79
 
78
 
            // FIXME: The interval should be [0.0 - 1.0]. Unfortunately, when
79
 
            // reaching the boundaries (0.0 or 1.0), the value is converted
80
 
            // to an integer when automatically wrapped in a variant when
81
 
            // passed to QStateAction::updateState(…). The server chokes on
82
 
            // those values, complaining that they’re not of the right type…
83
 
            minimumValue: menu.ext.minValue ? menu.ext.minValue * 1.000001 : 0.0000001
84
 
            maximumValue: {
85
 
                var maximum = menu.ext.maxValue ? menu.ext.maxValue * 1.000001 : 0.9999999
86
 
                if (maximum <= minimumValue) {
87
 
                        return minimumValue + 1;
88
 
                }
89
 
                return maximum;
90
 
            }
 
80
            minimumValue: 0.0
 
81
            maximumValue: 0.1
91
82
 
92
83
            // FIXME - to be deprecated in Ubuntu.Components.
93
84
            // Use this to disable the label, since there is not way to do it on the component.
109
100
            anchors.verticalCenter: row.verticalCenter
110
101
            height: units.gu(4)
111
102
            width: height
112
 
            source: menu.ext.maxIcon
113
103
        }
114
104
    }
115
 
 
116
 
    Indicators.MenuAction {
117
 
        id: menuAction
118
 
        menu: menuItem.menu
119
 
    }
120
105
}