@@ -20,7 +20,7 @@
20import QtQuick 2.0
20import QtQuick 2.0
23− \qmltype DBusActionState
23+ \qmltype MenuItemActionValue
24 \inqmlmodule Indicators 0.1
24 \inqmlmodule Indicators 0.1
25 \brief Helper class to connect dbus action state with qml components property
25 \brief Helper class to connect dbus action state with qml components property
@@ -29,7 +29,7 @@ import QtQuick 2.0
32− DBusActionState {
32+ MenuItemActionValue {
33 actionGroup: menuItem.actionGroup
33 actionGroup: menuItem.actionGroup
34 action: "/ubuntu/sound/volume"
34 action: "/ubuntu/sound/volume"
35 target: slider
35 target: slider
@@ -40,27 +40,9 @@ import QtQuick 2.0
40 \b{This component is under heavy development.}
40 \b{This component is under heavy development.}
43−Item {
43+MenuItemAction {
44 id: dbusActionState
44 id: dbusActionState
50− property string action : ""
54− The dbus action group object
56− property QtObject actionGroup : null
60− This is a read-only property with the action current value
62− property var value : undefined
65 \preliminary
47 \preliminary
66 The component which will have the property changed by action
48 The component which will have the property changed by action
@@ -85,23 +67,23 @@ Item {
88− property var actionObject: action != "" && dbusActionState.actionGroup ? dbusActionState.actionGroup.action(action) : null
70+ property alias actionObject : dbusActionState.__actionObject
89− property var actionState: actionObject ? actionObject.state : undefined
91 property var currentTarget: undefined
72 property var currentTarget: undefined
92 property string currentSignal
73 property string currentSignal
95 id: propertyBinding
77 id: propertyBinding
96− value: priv.actionState
78+ value: dbusActionState.state
97− when: (actionGroup && active && priv.actionObject)
79+ when: priv.actionObject && dbusActionState.active
98 property: dbusActionState.property
80 property: dbusActionState.property
102 function connectViewChanges() {
84 function connectViewChanges() {
103 if (priv.currentTarget != undefined && priv.currentSignal !== "") {
85 if (priv.currentTarget != undefined && priv.currentSignal !== "") {
104− if (priv.currentTarget[priv.currentSignal] != undefined) {
86+ if (priv.currentTarget[priv.currentSignal] !== undefined) {
105 priv.currentTarget[priv.currentSignal].disconnect(onViewValueChanged);
87 priv.currentTarget[priv.currentSignal].disconnect(onViewValueChanged);
@@ -110,7 +92,7 @@ Item {
110 priv.currentSignal = "";
92 priv.currentSignal = "";
111 if (target) {
93 if (target) {
112 var signal = "on%1Changed".arg(property.charAt(0).toUpperCase() + property.slice(1));
94 var signal = "on%1Changed".arg(property.charAt(0).toUpperCase() + property.slice(1));
113− if (target[signal] != undefined) {
95+ if (target[signal] !== undefined) {
114 target[signal].connect(onViewValueChanged);
96 target[signal].connect(onViewValueChanged);
115 priv.currentTarget = target;
97 priv.currentTarget = target;
116 priv.currentSignal = signal;
98 priv.currentSignal = signal;
@@ -119,7 +101,7 @@ Item {
121 function onViewValueChanged() {
103 function onViewValueChanged() {
122− if (priv.actionObject.valid) {
104+ if (valid) {
123 var propertyValue = target[property];
105 var propertyValue = target[property];
124 priv.actionObject.updateState(propertyValue);
106 priv.actionObject.updateState(propertyValue);