on xenial help sign in
added DBusActionState action group property. variant -> var. removed spaces before properties.
commit3623cdc9d26f2debe630061154b043ea2fbe0e0a authorNick Dedekind <nicholas.dedekind@gmail.com> dateFri 28 Jun 2013, 11:45 (13 years ago) parentbe81ccf
11 files changed+51−23
modules/Unity/Indicators/qml/BasicMenuItem.qml+1−1 modules/Unity/Indicators/qml/DBusActionState.qml+31−8 modules/Unity/Indicators/qml/IndicatorBase.qml+5−5 modules/Unity/Indicators/qml/IndicatorPage.qml+4−4 modules/Unity/Indicators/qml/ProgressMenuItem.qml+2−1 modules/Unity/Indicators/qml/SliderMenuItem.qml+1 modules/Unity/Indicators/qml/SwitchMenuItem.qml+1 modules/Unity/Indicators/qml/TextMenuItem.qml+1 modules/Unity/Indicators/qml/messaging/GroupedMessage.qml+1−1 modules/Unity/Indicators/qml/messaging/HeroMessage.qml+1−1 modules/Unity/Indicators/qml/network/AccessPoint.qml+3−2
modules/Unity/Indicators/qml/BasicMenuItem.qml+1−1
@@ -23,7 +23,7 @@ import Ubuntu.Components.ListItems 0.1 as ListItem
2323ListItem.Standard {
2424 id: _priv
2525
26− property bool menuActivated : false
26+ property bool menuActivated: false
2727 property QtObject menu
2828 property QtObject actionGroup
2929 property alias color: __bg.color
modules/Unity/Indicators/qml/DBusActionState.qml+31−8
@@ -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
modules/Unity/Indicators/qml/IndicatorBase.qml+5−5
@@ -29,18 +29,18 @@ Item {
2929
3030 //const
3131 property string title
32− property string device: "phone"
3332 property int busType
3433 property string busName
3534 property string actionsObjectPath
36− property var menuObjectPaths : undefined
35+ property var menuObjectPaths: undefined
36+ readonly property string device: "phone"
3737
38− property string deviceMenuObjectPath : menuObjectPaths.hasOwnProperty(device) ? menuObjectPaths[device] : ""
38+ property string deviceMenuObjectPath: menuObjectPaths.hasOwnProperty(device) ? menuObjectPaths[device] : ""
3939
4040 signal actionGroupUpdated()
4141 signal modelUpdated()
4242
43− property var actionGroup : QDBusActionGroup {
43+ property var actionGroup: QDBusActionGroup {
4444 busType: indicatorItem.busType
4545 busName: indicatorItem.busName
4646 objectPath: indicatorItem.actionsObjectPath
@@ -48,7 +48,7 @@ Item {
4848 onActionAppear: indicatorItem.actionGroupUpdated();
4949 }
5050
51− property var proxyModel : Indicators.FlatMenuProxyModel {
51+ property var proxyModel: Indicators.FlatMenuProxyModel {
5252 busType: indicatorItem.busType
5353 busName: indicatorItem.busName
5454 objectPath: indicatorItem.deviceMenuObjectPath
modules/Unity/Indicators/qml/IndicatorPage.qml+4−4
@@ -30,11 +30,8 @@ IndicatorBase {
3030 //const
3131 property alias emptyText: emptyLabel.text
3232 property alias highlightFollowsCurrentItem : mainMenu.highlightFollowsCurrentItem
33− readonly property real overshootHeight: (mainMenu.contentY < 0) ? -mainMenu.contentY : 0
3433 property bool __active: false
3534
36− anchors.fill: parent
37−
3835 ListView {
3936 id: mainMenu
4037
@@ -51,7 +48,10 @@ IndicatorBase {
5148 easing.type: Easing.OutQuad
5249 }
5350 }
54− onBottomMarginChanged: mainMenu.positionViewAtIndex(mainMenu.currentIndex, ListView.End)
51+ // TODO - does ever frame.
52+ onBottomMarginChanged: {
53+ mainMenu.positionViewAtIndex(mainMenu.currentIndex, ListView.End)
54+ }
5555 }
5656
5757 // Ensure all delegates are cached in order to improve smoothness of scrolling
modules/Unity/Indicators/qml/ProgressMenuItem.qml+2−1
@@ -21,7 +21,7 @@ import QtQuick 2.0
2121import Ubuntu.Components 0.1
2222
2323MenuItem {
24−
24+ id: _progressMenu
2525 property alias value : progressBar.value
2626
2727 // TODO: Replace this with the official ProgressBar component as soon as
@@ -55,6 +55,7 @@ MenuItem {
5555 }
5656
5757 DBusActionState {
58+ actionGroup: _progressMenu.actionGroup
5859 action: menu ? menu.action : ""
5960 target: progressBar
6061 property: "value"
modules/Unity/Indicators/qml/SliderMenuItem.qml+1
@@ -59,6 +59,7 @@ MenuItem {
5959 }
6060
6161 DBusActionState {
62+ actionGroup: _sliderMenu.actionGroup
6263 action: menu ? menu.action : ""
6364 target: slider
6465 property: "value"
modules/Unity/Indicators/qml/SwitchMenuItem.qml+1
@@ -33,6 +33,7 @@ MenuItem {
3333 }
3434
3535 DBusActionState {
36+ actionGroup: _switchMenu.actionGroup
3637 action: menu ? menu.action : ""
3738 target: switcher
3839 property: "checked"
modules/Unity/Indicators/qml/TextMenuItem.qml+1
@@ -74,6 +74,7 @@ MenuItem {
7474 }
7575
7676 DBusActionState {
77+ actionGroup: _textMenu.actionGroup
7778 action: menu ? menu.action : ""
7879 target: _textField
7980 property: "text"
modules/Unity/Indicators/qml/messaging/GroupedMessage.qml+1−1
@@ -23,7 +23,7 @@ import Ubuntu.Components 0.1
2323import Unity.Indicators 0.1 as Indicators
2424
2525Indicators.BasicMenuItem {
26− property variant action: menu && menu.action!="" && actionGroup ? actionGroup.action(menu.action) : null
26+ property var action: menu && menu.action != "" && actionGroup ? actionGroup.action(menu.action) : null
2727 property alias count: label.text
2828
2929 color: "#221e1b"
modules/Unity/Indicators/qml/messaging/HeroMessage.qml+1−1
@@ -26,7 +26,7 @@ Indicators.BasicMenuItem {
2626 id: __heroMessage
2727
2828 property variant actionsDescription: null
29− property variant action: menu && menu.action!="" && actionGroup ? actionGroup.action(menu.action) : null
29+ property var action: menu && menu.action != "" && actionGroup ? actionGroup.action(menu.action) : null
3030 property alias heroMessageHeader: __heroMessageHeader
3131 property real collapsedHeight: heroMessageHeader.y + heroMessageHeader.bodyBottom + units.gu(2)
3232 property real expandedHeight: collapsedHeight
modules/Unity/Indicators/qml/network/AccessPoint.qml+3−2
@@ -23,6 +23,7 @@ import Ubuntu.Components.ListItems 0.1 as ListItem
2323import Unity.Indicators 0.1 as Indicators
2424
2525Indicators.MenuItem {
26+ id: _accessPoint
2627 property variant actionWifiApStrength : menu && actionGroup ? actionGroup.action(menu.extra.canonical_wifi_ap_strength_action) : null
2728 property variant wifiApStrength : actionWifiApStrength && actionWifiApStrength.valid ? actionWifiApStrength.state : "0"
2829
@@ -57,11 +58,11 @@ Indicators.MenuItem {
5758 id: checkBoxActive
5859 height: units.gu(4)
5960 width: units.gu(4)
60− anchors.horizontalCenter: parent.horizontalCenter
61− anchors.verticalCenter: parent.verticalCenter
61+ anchors.centerIn: parent
6262 }
6363
6464 Indicators.DBusActionState {
65+ actionGroup: _accessPoint.actionGroup
6566 action: menu ? menu.action : ""
6667 target: checkBoxActive
6768 property: "checked"