@@ -30,6 +30,7 @@ import QtQuick 2.0
3030 id: slide
3131 }
3232 DBusActionState {
33+ actionGroup: menuItem.actionGroup
3334 action: "/ubuntu/sound/volume"
3435 target: slider
3536 property: "value"
@@ -48,11 +49,17 @@ Item {
4849 */
4950 property string action : ""
5051
52+ /*!
53+ \preliminary
54+ The dbus action group object
55+ */
56+ property QtObject actionGroup : null
57+
5158 /*!
5259 \preliminary
5360 This is a read-only property with the action current value
5461 */
55− property variant value : undefined
62+ property var value : undefined
5663
5764 /*!
5865 \preliminary
@@ -64,7 +71,7 @@ Item {
6471 \preliminary
6572 The property name of \l target component which will be linked with action state
6673 */
67− property alias property: propertyBinding.property
74+ property string property: propertyBinding.property
6875
6976 /*!
7077 \preliminary
@@ -72,26 +79,42 @@ Item {
7279 */
7380 property bool active: true
7481
75− Component.onCompleted: connectViewChanges ()
82+ Component.onCompleted: connectViewChanges()
7683 onTargetChanged: connectViewChanges()
7784 onPropertyChanged: connectViewChanges()
7885
7986 Item {
8087 id: priv
81− property variant actionObject : action!="" && actionGroup ? actionGroup.action(action) : null
82− property variant actionState: actionObject ? actionObject.state : undefined
88+ property var actionObject: action != "" && dbusActionState.actionGroup ? dbusActionState.actionGroup.action(action) : null
89+ property var actionState: actionObject ? actionObject.state : undefined
90+
91+ property var currentTarget: undefined
92+ property string currentSignal
8393
8494 Binding {
8595 id: propertyBinding
8696 value: priv.actionState
8797 when: (actionGroup && active && priv.actionObject)
98+ property: dbusActionState.property
8899 }
89100 }
90101
91102 function connectViewChanges() {
92− if (target && property) {
93− var signalName = "on%1Changed".arg(property.charAt(0).toUpperCase() + property.slice(1));
94− target[signalName].connect(onViewValueChanged);
103+ if (priv.currentTarget != undefined && priv.currentSignal !== "") {
104+ if (priv.currentTarget[priv.currentSignal] != undefined) {
105+ priv.currentTarget[priv.currentSignal].disconnect(onViewValueChanged);
106+ }
107+ }
108+
109+ priv.currentTarget = null;
110+ priv.currentSignal = "";
111+ if (target) {
112+ var signal = "on%1Changed".arg(property.charAt(0).toUpperCase() + property.slice(1));
113+ if (target[signal] != undefined) {
114+ target[signal].connect(onViewValueChanged);
115+ priv.currentTarget = target;
116+ priv.currentSignal = signal;
117+ }
95118 }
96119 }
97120