on xenial help sign in
renamed a few things in menuAction
68669d9Nick Dedekind
modules/Unity/Indicators/qml/MenuAction.qml+12−17
@@ -38,8 +38,8 @@ import QtQuick 2.0
38 \endqml
38 \endqml
39*/
39*/
40
40
41−QtObject {
41+Item {
42− id: dbusAction
42+ id: menuAction
43
43
44 /*!
44 /*!
45 \preliminary
45 \preliminary
@@ -57,35 +57,30 @@ QtObject {
57 \preliminary
57 \preliminary
58 This is a read-only property with the current validity of the action
58 This is a read-only property with the current validity of the action
59 */
59 */
60− readonly property bool valid: __actionObject ? __actionObject.valid : false
60+ readonly property bool valid: actionObject ? actionObject.valid : false
61
61
62− readonly property var state: __actionObject ? __actionObject.state : undefined
62+ readonly property var state: actionObject ? actionObject.state : undefined
63
63
64 // internal
64 // internal
65− property QtObject __actionObject: null
65+ property QtObject actionObject: null
66
66
67 function activate(param) {
67 function activate(param) {
68 if (valid) {
68 if (valid) {
69− __actionObject.activate(param);
69+ actionObject.activate(param);
70 }
70 }
71 }
71 }
72
72
73 onActionGroupChanged: updateAction()
73 onActionGroupChanged: updateAction()
74 onActionChanged: updateAction()
74 onActionChanged: updateAction()
75
75
76− QtObject {
77− id: priv
78− property var actionObject: null
79−
80− Connections {
76+ Connections {
81− target: dbusAction.actionGroup != undefined ? dbusAction.actionGroup : null
77+ target: menuAction.actionGroup != undefined ? menuAction.actionGroup : null
82− onActionAppear: dbusAction.updateAction();
78+ onActionAppear: menuAction.updateAction();
83− onActionVanish: dbusAction.updateAction();
79+ onActionVanish: menuAction.updateAction();
84− onStatusChanged: dbusAction.updateAction();
80+ onStatusChanged: menuAction.updateAction();
85− }
86 }
81 }
87
82
88 function updateAction() {
83 function updateAction() {
89− __actionObject = action !== "" && actionGroup ? actionGroup.action(action) : null
84+ actionObject = action !== "" && actionGroup ? actionGroup.action(action) : null
90 }
85 }
91}
86}
modules/Unity/Indicators/qml/MenuActionBinding.qml+21−22
@@ -39,19 +39,19 @@ import QtQuick 2.0
39*/
39*/
40
40
41MenuAction {
41MenuAction {
42− id: dbusActionState
42+ id: menuAction
43
43
44 /*!
44 /*!
45 \preliminary
45 \preliminary
46 The component which will have the property changed by action
46 The component which will have the property changed by action
47 */
47 */
48− property alias target: propertyBinding.target
48+ property QtObject target: null
49
49
50 /*!
50 /*!
51 \preliminary
51 \preliminary
52 The property name of \l target component which will be linked with action state
52 The property name of \l target component which will be linked with action state
53 */
53 */
54− property string property: propertyBinding.property
54+ property string property
55
55
56 /*!
56 /*!
57 \preliminary
57 \preliminary
@@ -63,37 +63,36 @@ MenuAction {
63 onTargetChanged: connectViewChanges()
63 onTargetChanged: connectViewChanges()
64 onPropertyChanged: connectViewChanges()
64 onPropertyChanged: connectViewChanges()
65
65
66− QtObject {
66+ Item {
67− id: priv
67+ id: d
68− property alias actionObject : dbusActionState.__actionObject
69−
70 property var currentTarget: undefined
68 property var currentTarget: undefined
71 property string currentSignal
69 property string currentSignal
70+ }
72
71
73−
74− Binding {
72+ Binding {
75− id: propertyBinding
73+ id: propertyBinding
74+ target: menuAction.target
75+ property: menuAction.property
76− value: dbusActionState.state
76+ value: menuAction.state
77− when: priv.actionObject && dbusActionState.active
77+ when: menuAction.actionObject && menuAction.active
78− property: dbusActionState.property
79− }
80 }
78 }
81
79
80+ // TODO - re-evaluate in c++
82 function connectViewChanges() {
81 function connectViewChanges() {
83− if (priv.currentTarget != undefined && priv.currentSignal !== "") {
82+ if (d.currentTarget != undefined && d.currentSignal !== "") {
84− if (priv.currentTarget[priv.currentSignal] !== undefined) {
83+ if (d.currentTarget[d.currentSignal] !== undefined) {
85− priv.currentTarget[priv.currentSignal].disconnect(onViewValueChanged);
84+ d.currentTarget[d.currentSignal].disconnect(onViewValueChanged);
86 }
85 }
87 }
86 }
88
87
89− priv.currentTarget = null;
88+ d.currentTarget = null;
90− priv.currentSignal = "";
89+ d.currentSignal = "";
91 if (target) {
90 if (target) {
92 var signal = "on%1Changed".arg(property.charAt(0).toUpperCase() + property.slice(1));
91 var signal = "on%1Changed".arg(property.charAt(0).toUpperCase() + property.slice(1));
93 if (target[signal] !== undefined) {
92 if (target[signal] !== undefined) {
94 target[signal].connect(onViewValueChanged);
93 target[signal].connect(onViewValueChanged);
95− priv.currentTarget = target;
94+ d.currentTarget = target;
96− priv.currentSignal = signal;
95+ d.currentSignal = signal;
97 }
96 }
98 }
97 }
99 }
98 }
@@ -101,7 +100,7 @@ MenuAction {
101 function onViewValueChanged() {
100 function onViewValueChanged() {
102 if (valid) {
101 if (valid) {
103 var propertyValue = target[property];
102 var propertyValue = target[property];
104− priv.actionObject.updateState(propertyValue);
103+ actionObject.updateState(propertyValue);
105 }
104 }
106 }
105 }
107}
106}