on xenial help sign in
indicators: Add ModemInfoItem
commitac047898886cc85929f5adc7fffef1cc3fcf7595 authorAntti Kaijanmäki <antti.kaijanmaki@canonical.com> dateTue 1 Jul 2014, 16:03 (12 years ago) parente82a901
4 files changed+258
plugins/Unity/Indicators/qml/MenuItemFactory.qml+75 plugins/Unity/Indicators/qml/ModemInfoItem.qml+126 plugins/Unity/Indicators/qml/RoamingIndication.qml+55 plugins/Unity/Indicators/qml/qmldir+2
plugins/Unity/Indicators/qml/MenuItemFactory.qml+75
@@ -53,6 +53,7 @@ Item {
5353
5454 "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
5555 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
56+ "com.canonical.indicator.network.modeminfoitem" : modeminfoitem,
5657 }
5758
5859 function getExtendedProperty(object, propertyName, defaultValue) {
@@ -363,6 +364,80 @@ Item {
363364 }
364365 }
365366
367+ Component {
368+ id: modeminfoitem;
369+ ModemInfoItem {
370+ objectName: "modemInfoItem"
371+ property QtObject menuData: null
372+ property var menuModel: menuFactory.menuModel
373+ property int menuIndex: -1
374+ property var extendedData: menuData && menuData.ext || undefined
375+
376+ property var statusLabelAction: QMenuModel.UnityMenuAction {
377+ model: menuModel
378+ index: menuIndex
379+ name: getExtendedProperty(extendedData, "xCanonicalModemStatusLabelAction", "")
380+ }
381+ statusText: statusLabelAction.valid ? statusLabelAction.state : ""
382+
383+ property var statusIconAction: QMenuModel.UnityMenuAction {
384+ model: menuModel
385+ index: menuIndex
386+ name: getExtendedProperty(extendedData, "xCanonicalModemStatusIconAction", "")
387+ }
388+ statusIcon: statusIconAction.valid ? statusIconAction.state : ""
389+
390+ property var connectivityIconAction: QMenuModel.UnityMenuAction {
391+ model: menuModel
392+ index: menuIndex
393+ name: getExtendedProperty(extendedData, "xCanonicalModemConnectivityIconAction", "")
394+ }
395+ connectivityIcon: connectivityIconAction.valid ? connectivityIconAction.state : ""
396+
397+ property var simIdentifierLabelAction: QMenuModel.UnityMenuAction {
398+ model: menuModel
399+ index: menuIndex
400+ name: getExtendedProperty(extendedData, "xCanonicalModemSimIdentifierLabelAction", "")
401+ }
402+ simIdentifierText: simIdentifierLabelAction.valid ? simIdentifierLabelAction.state : ""
403+
404+ property var roamingAction: QMenuModel.UnityMenuAction {
405+ model: menuModel
406+ index: menuIndex
407+ name: getExtendedProperty(extendedData, "xCanonicalModemRoamingAction", "")
408+ }
409+ roaming: roamingAction.valid ? roamingAction.state : false
410+
411+ property var unlockAction: QMenuModel.UnityMenuAction {
412+ model: menuModel
413+ index: menuIndex
414+ name: getExtendedProperty(extendedData, "xCanonicalModemLockedAction", "")
415+ }
416+ onUnlock: {
417+ unlockAction.activate();
418+ shell.hideIndicatorMenu(UbuntuAnimation.BriskDuration);
419+ }
420+ locked: unlockAction.valid ? unlockAction.state : false
421+
422+ onMenuModelChanged: {
423+ loadAttributes();
424+ }
425+ onMenuIndexChanged: {
426+ loadAttributes();
427+ }
428+
429+ function loadAttributes() {
430+ if (!menuModel || menuIndex == -1) return;
431+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-modem-status-label-action': 'string',
432+ 'x-canonical-modem-status-icon-action': 'string',
433+ 'x-canonical-modem-connectivity-icon-action': 'string',
434+ 'x-canonical-modem-sim-identifier-label': 'string',
435+ 'x-canonical-modem-roaming-action': 'string',
436+ 'x-canonical-modem-locked-action': 'string'});
437+ }
438+ }
439+ }
440+
366441 Component {
367442 id: messageItem
368443 MessageMenuItemFactory {
plugins/Unity/Indicators/qml/ModemInfoItem.qmlnew file+126
@@ -0,0 +1,126 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18+ */
19+
20+import QtQuick 2.0
21+import Ubuntu.Components 0.1
22+import Ubuntu.Components.ListItems 0.1 as ListItem
23+
24+ListItem.Empty {
25+ id: menu
26+ implicitHeight: units.gu(5.5)
27+
28+ property alias statusIcon: statusIcon.name
29+ property alias statusText: labelStatus.text
30+ property alias connectivityIcon: iconConnectivity.name
31+ property alias simIdentifierText: labelSimIdentifier.text
32+ property bool locked : false
33+ property bool roaming: false
34+ signal unlock
35+
36+ Row {
37+ id: iconRow
38+ height: parent.height
39+
40+ anchors {
41+ left: parent.left
42+ top: parent.top
43+ leftMargin: menu.__contentsMargins
44+ verticalCenter: parent.verticalCenter
45+ }
46+
47+ Icon {
48+ id: statusIcon
49+ color: Theme.palette.selected.backgroundText
50+ keyColor: "#cccccc"
51+
52+ width: height
53+ height: Math.min(units.gu(5), parent.height - units.gu(1))
54+ }
55+
56+ Icon {
57+ id: iconConnectivity
58+ color: Theme.palette.selected.backgroundText
59+ keyColor: "#cccccc"
60+
61+ width: height
62+ height: Math.min(units.gu(5), parent.height - units.gu(1))
63+ }
64+ }
65+
66+ Column {
67+ id: columnStatus
68+ anchors {
69+ left: iconRow.right
70+ leftMargin: units.gu(1)
71+ verticalCenter: parent.verticalCenter
72+ rightMargin: menu.__contentsMargins
73+ }
74+
75+ Label {
76+ id: labelStatus
77+
78+ elide: Text.ElideRight
79+ }
80+
81+ Label {
82+ id: labelSimIdentifier
83+
84+ elide: Text.ElideRight
85+ visible: text !== ""
86+
87+ fontSize: "x-small"
88+ font.bold: true
89+ }
90+ }
91+
92+ Item {
93+ height: parent.height
94+
95+ anchors {
96+ right: parent.right
97+ rightMargin: menu.__contentsMargins
98+ verticalCenter: parent.verticalCenter
99+ }
100+
101+ RoamingIndication {
102+ id: roamingIndication
103+ anchors {
104+ right: parent.right
105+ verticalCenter: parent.verticalCenter
106+ }
107+ visible: menu.roaming
108+ height: Math.min(units.gu(5), parent.height - units.gu(1))
109+ }
110+
111+ Button {
112+ anchors {
113+ right: parent.right
114+ verticalCenter: parent.verticalCenter
115+ }
116+ id: buttonUnlock
117+ objectName: "buttonUnlockSim"
118+ visible: menu.locked
119+
120+ text: i18n.tr("Unlock")
121+
122+ height: Math.min(units.gu(4), parent.height - units.gu(1))
123+ onTriggered: menu.unlock()
124+ }
125+ }
126+}
plugins/Unity/Indicators/qml/RoamingIndication.qmlnew file+55
@@ -0,0 +1,55 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18+ */
19+
20+import QtQuick 2.0
21+import Ubuntu.Components 0.1
22+
23+Item {
24+ width: (labelRoaming.width > iconRoaming.width) ? labelRoaming.width : iconRoaming.width
25+
26+ Icon {
27+ id: iconRoaming
28+ anchors {
29+ top: parent.top
30+ horizontalCenter: parent.horizontalCenter
31+ }
32+
33+ color: Theme.palette.selected.backgroundText
34+ keyColor: "#cccccc"
35+
36+ width: height
37+ height: units.gu(4)
38+
39+ name: "network-cellular-roaming"
40+ }
41+
42+ Label {
43+ id: labelRoaming
44+ anchors {
45+ bottom: parent.bottom
46+ horizontalCenter: parent.horizontalCenter
47+ }
48+ elide: Text.ElideRight
49+
50+ fontSize: "x-small"
51+ font.bold: true
52+
53+ text: i18n.tr("roaming")
54+ }
55+}
plugins/Unity/Indicators/qml/qmldir+2
@@ -8,3 +8,5 @@ MenuItemFactory 0.1 MenuItemFactory.qml
88MessageMenuItemFactory 0.1 MessageMenuItemFactory.qml
99
1010internal RemoveBackground RemoveBackground.qml
11+
12+ModemInfoItem 0.1 ModemInfoItem.qml