Merge lp:~ted/ubuntu-system-settings/wifi-panel into lp:ubuntu-system-settings

Proposed by Ted Gould
Status: Rejected
Rejected by: Alberto Mardegan
Proposed branch: lp:~ted/ubuntu-system-settings/wifi-panel
Merge into: lp:ubuntu-system-settings
Diff against target: 1154 lines (+1008/-2)
21 files modified
debian/control (+2/-0)
plugins/time-date/plugin.cpp (+1/-1)
plugins/wifi/AccessPoint.qml (+71/-0)
plugins/wifi/BaseMenuItem.qml (+37/-0)
plugins/wifi/DivMenuItem.qml (+25/-0)
plugins/wifi/FramedMenuItem.qml (+37/-0)
plugins/wifi/HLine.qml (+29/-0)
plugins/wifi/IndicatorBase.qml (+45/-0)
plugins/wifi/MenuItemFactory.qml (+134/-0)
plugins/wifi/PageComponent.qml (+127/-0)
plugins/wifi/RemoveBackground.qml (+55/-0)
plugins/wifi/SectionMenuItem.qml (+54/-0)
plugins/wifi/StandardMenuItem.qml (+70/-0)
plugins/wifi/SwitchMenuItem.qml (+52/-0)
plugins/wifi/plugin.cpp (+32/-0)
plugins/wifi/plugin.h (+33/-0)
plugins/wifi/qmldir (+2/-0)
plugins/wifi/unitymenumodelstack.cpp (+69/-0)
plugins/wifi/unitymenumodelstack.h (+58/-0)
plugins/wifi/wifi.pro (+69/-0)
plugins/wifi/wifi.settings (+6/-1)
To merge this branch: bzr merge lp:~ted/ubuntu-system-settings/wifi-panel
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Alberto Mardegan Needs Fixing
Review via email: mp+185828@code.launchpad.net

Commit message

Add Wifi Panel

Description of the change

Adds the base of the Wifi panel. This works with the menu model exported by indicator-network, so you need a version of indicator network that includes this branch:

https://code.launchpad.net/~ted/indicator-network/phone-settings

For the most part this branch consists of code stolen from the Unity8 indicators and refactored so that it works in this context (and mostly removed stuff that we didn't need). Hopefully eventually most of it will find its way into System Components and then we can pull it from there.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
331. By Ted Gould

Build dep on qmenumodel

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
332. By Ted Gould

Making sure we have an indicator-network version with the wifi settings

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) wrote :

Wow, that's a lot of code! :-)

I didn't go through all of that, but here's just a few things I noticed:

- License: the other plugins are GPL3, not LGPL. Either is fine to me, but unless you have good reasons for having the code LGPL, it'd be easier if all the plugins use the same license.
- Do not submit code commented out (MenuItemFactory.qml)
- Coding style in C++ files: the "*" must have one space before it, and none after it; in classes declarations of the inheritance, put a space after the ":", but none before; last, the constructor should be indented like this:

UnityMenuModelStack::UnityMenuModelStack(QObject *parent):
    QObject(parent)
{
}

review: Needs Fixing
333. By Ted Gould

These should be GPL'd not LGPL'd, fix that

334. By Ted Gould

Put the strength in

Revision history for this message
Ted Gould (ted) wrote :

On Wed, 2013-09-18 at 07:39 +0000, Alberto Mardegan wrote:

> - License: the other plugins are GPL3, not LGPL. Either is fine to me, but unless you have good reasons for having the code LGPL, it'd be easier if all the plugins use the same license.

Fixed.

> - Do not submit code commented out (MenuItemFactory.qml)

Fixed.

> - Coding style in C++ files: the "*" must have one space before it, and none after it; in classes declarations of the inheritance, put a space after the ":", but none before; last, the constructor should be indented like this:
>
> UnityMenuModelStack::UnityMenuModelStack(QObject *parent):
> QObject(parent)
> {
> }

Frankly, I'd rather keep this the same as the code that I cut-and-pasted
so that we can easily grab revisions from that code and understand the
diffs. For minor things like that I don't think divergence is a good
idea. Personally, I don't care either way on the style itself, but I'd
like to be able to diff them.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) wrote :

Given the urgency, I created another branch, which supersedes this request:
https://code.launchpad.net/~mardy/ubuntu-system-settings/wifi-panel/+merge/186492

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2013-09-03 19:59:09 +0000
+++ debian/control 2013-09-18 20:04:27 +0000
@@ -10,6 +10,7 @@
10 libglib2.0-dev,10 libglib2.0-dev,
11 libnm-glib-dev,11 libnm-glib-dev,
12 libofono-qt-dev,12 libofono-qt-dev,
13 libqmenumodel-dev,
13 libtimezonemap1-dev (>= 0.4.0.1),14 libtimezonemap1-dev (>= 0.4.0.1),
14 libupower-glib-dev,15 libupower-glib-dev,
15 pkg-config,16 pkg-config,
@@ -31,6 +32,7 @@
31 accountsservice,32 accountsservice,
32 gsettings-desktop-schemas,33 gsettings-desktop-schemas,
33 gsettings-ubuntu-touch-schemas (>= 0.0.1+13.10.20130730),34 gsettings-ubuntu-touch-schemas (>= 0.0.1+13.10.20130730),
35 indicator-network (>> 0.5.0+13.10.20130913),
34 powerd | gnome-settings-daemon,36 powerd | gnome-settings-daemon,
35 qtdeclarative5-folderlistmodel-plugin,37 qtdeclarative5-folderlistmodel-plugin,
36 qtdeclarative5-qtmultimedia-plugin,38 qtdeclarative5-qtmultimedia-plugin,
3739
=== modified file 'plugins/time-date/plugin.cpp'
--- plugins/time-date/plugin.cpp 2013-07-24 13:43:20 +0000
+++ plugins/time-date/plugin.cpp 2013-09-18 20:04:27 +0000
@@ -27,7 +27,7 @@
27void BackendPlugin::registerTypes(const char *uri)27void BackendPlugin::registerTypes(const char *uri)
28{28{
29 Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.TimeDate"));29 Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.TimeDate"));
30 30
31 qmlRegisterType<TimeDate>(uri, 1, 0, "UbuntuTimeDatePanel");31 qmlRegisterType<TimeDate>(uri, 1, 0, "UbuntuTimeDatePanel");
32}32}
3333
3434
=== added file 'plugins/wifi/AccessPoint.qml'
--- plugins/wifi/AccessPoint.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/AccessPoint.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,71 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Ubuntu.Components.ListItems 0.1 as ListItem
23
24FramedMenuItem {
25 id: accessPoint
26
27 property bool checked: false
28 property bool secure: false
29 property bool adHoc: false
30 property int signalStrength: 0
31
32 signal activate()
33
34 onCheckedChanged: {
35 // Can't rely on binding. Checked is assigned on click.
36 checkBoxActive.checked = checked;
37 }
38
39 icon: {
40 var imageName = "nm-signal-100"
41
42 if (adHoc) {
43 imageName = "nm-adhoc";
44 } else if (signalStrength == 0) {
45 imageName = "nm-signal-00";
46 } else if (signalStrength <= 25) {
47 imageName = "nm-signal-25";
48 } else if (signalStrength <= 50) {
49 imageName = "nm-signal-50";
50 } else if (signalStrength <= 75) {
51 imageName = "nm-signal-75";
52 }
53
54 if (secure) {
55 imageName += "-secure";
56 }
57 return "image://gicon/" + imageName;
58 }
59
60 iconFrame: false
61 control: CheckBox {
62 id: checkBoxActive
63 height: units.gu(4)
64 width: units.gu(4)
65 anchors.centerIn: parent
66
67 onClicked: {
68 accessPoint.activate();
69 }
70 }
71}
072
=== added file 'plugins/wifi/BaseMenuItem.qml'
--- plugins/wifi/BaseMenuItem.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/BaseMenuItem.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Nick Dedekind <nick.dedekind@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components.ListItems 0.1 as ListItem
23
24ListItem.Standard {
25 id: baseMenu
26
27 property bool menuActivated: false
28
29 signal selectMenu()
30 signal deselectMenu()
31
32 showDivider: false
33
34 backgroundIndicator: RemoveBackground {
35 state: baseMenu.swipingState
36 }
37}
038
=== added file 'plugins/wifi/DivMenuItem.qml'
--- plugins/wifi/DivMenuItem.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/DivMenuItem.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,25 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Olivier Tilloy <olivier.tilloy@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22
23Rectangle {
24 implicitHeight: units.gu(1)
25}
026
=== added file 'plugins/wifi/FramedMenuItem.qml'
--- plugins/wifi/FramedMenuItem.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/FramedMenuItem.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Nick Dedekind <nick.dedekind@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Ubuntu.Components.ListItems 0.1 as ListItem
24
25BaseMenuItem {
26 implicitHeight: units.gu(7)
27
28 iconFrame: false
29
30 HLine {
31 anchors.top: parent.top
32 }
33
34 HLine {
35 anchors.bottom: parent.bottom
36 }
37}
038
=== added file 'plugins/wifi/HLine.qml'
--- plugins/wifi/HLine.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/HLine.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,29 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22
23Rectangle {
24 height: units.dp(1)
25 anchors {
26 left: parent.left
27 right: parent.right
28 }
29}
030
=== added file 'plugins/wifi/IndicatorBase.qml'
--- plugins/wifi/IndicatorBase.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/IndicatorBase.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21import QMenuModel 0.1 as QMenuModel
22import SystemSettings 1.0
23import Ubuntu.Components 0.1
24
25ItemPage {
26 id: indicatorItem
27
28 // FIXME : should be disabled until bus available when we have desktop indicators
29 // for now, disable when we dont habe the correct profile.
30 enabled: menuObjectPaths.hasOwnProperty(device)
31
32 //const
33 property string title
34 property string busName
35 property string actionsObjectPath
36 property var menuObjectPaths: undefined
37 readonly property string device: "phone_wifi_settings"
38 property string rootMenuType: "com.canonical.indicator.root"
39 property bool active: false
40
41 property string deviceMenuObjectPath: menuObjectPaths.hasOwnProperty(device) ? menuObjectPaths[device] : ""
42
43 signal actionGroupUpdated()
44 signal modelUpdated()
45}
046
=== added file 'plugins/wifi/MenuItemFactory.qml'
--- plugins/wifi/MenuItemFactory.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/MenuItemFactory.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,134 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21import QMenuModel 0.1 as QMenuModel
22
23Item {
24 id: menuFactory
25
26 property var model: null
27
28 property var _map: {
29 "unity.widgets.systemsettings.tablet.switch" : switchMenu,
30
31 "com.canonical.indicator.div" : divMenu,
32 "com.canonical.indicator.section" : sectionMenu,
33 "com.canonical.indicator.switch" : switchMenu,
34
35 "com.canonical.unity.switch" : switchMenu,
36
37 "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
38 "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
39 }
40
41 Component { id: divMenu; DivMenuItem {} }
42
43 Component {
44 id: sectionMenu;
45 SectionMenuItem {
46 property QtObject menu: null
47
48 text: menu && menu.label ? menu.label : ""
49 }
50 }
51
52 Component {
53 id: standardMenu;
54 StandardMenuItem {
55 property QtObject menu: null
56
57 text: menu && menu.label ? menu.label : ""
58 icon: menu ? menu.icon : ""
59 checkable: menu ? (menu.isCheck || menu.isRadio) : false
60 checked: checkable ? menu.isToggled : false
61 enabled: menu ? menu.sensitive : false
62
63 onActivate: model.activate(modelIndex);
64 }
65 }
66
67 Component {
68 id: switchMenu;
69 SwitchMenuItem {
70 property QtObject menu: null
71
72 text: menu && menu.label ? menu.label : ""
73 icon: menu ? menu.icon : ""
74 checked: menu ? menu.isToggled : false
75 enabled: menu ? menu.sensitive : false
76
77 onActivate: model.activate(modelIndex);
78 }
79 }
80
81 Component {
82 id: wifiSection;
83 SectionMenuItem {
84 property QtObject menu: null
85
86 text: menu && menu.label ? menu.label : ""
87 busy: menu ? menu.ext.xCanonicalBusyAction : false
88
89 Component.onCompleted: {
90 model.loadExtendedAttributes(modelIndex, {'x-canonical-busy-action': 'bool'});
91 }
92 }
93 }
94
95 Component {
96 id: accessPoint;
97 AccessPoint {
98 property QtObject menu: null
99 property var strenthAction: QMenuModel.UnityMenuAction {
100 model: menuFactory.model ? menuFactory.model : null
101 name: menu ? menu.ext.xCanonicalWifiApStrengthAction : ""
102 }
103
104 text: menu && menu.label ? menu.label : ""
105 icon: menu ? menu.icon : ""
106 secure: menu ? menu.ext.xCanonicalWifiApIsSecure : false
107 adHoc: menu ? menu.ext.xCanonicalWifiApIsAdhoc : false
108 checked: menu ? menu.isToggled : false
109 signalStrength: strenthAction.valid ? strenthAction.state : 0
110 enabled: menu ? menu.sensitive : false
111
112 Component.onCompleted: {
113 model.loadExtendedAttributes(modelIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
114 'x-canonical-wifi-ap-is-secure': 'bool',
115 'x-canonical-wifi-ap-strength-action': 'string'});
116 }
117 onActivate: model.activate(modelIndex);
118 }
119 }
120
121 function load(modelData) {
122 if (modelData.type !== undefined) {
123 var component = _map[modelData.type];
124 if (component !== undefined) {
125 return component;
126 }
127 } else {
128 if (modelData.isSeparator) {
129 return divMenu;
130 }
131 }
132 return standardMenu;
133 }
134}
0135
=== added file 'plugins/wifi/PageComponent.qml'
--- plugins/wifi/PageComponent.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/PageComponent.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,127 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import SystemSettings 1.0
19import Ubuntu.Components 0.1
20import Ubuntu.Components.ListItems 0.1 as ListItem
21import Ubuntu.SystemSettings.Wifi 1.0
22import QMenuModel 0.1
23
24
25IndicatorBase {
26 id: wifibase
27 title: i18n.tr("Wi-Fi")
28 busName: "com.canonical.indicator.network"
29 actionsObjectPath: "/com/canonical/indicator/network"
30 menuObjectPaths: {"phone_wifi_settings": "/com/canonical/indicator/network/phone_wifi_settings"}
31 active: true
32
33 UnityMenuModel {
34 id: menuModel
35 busName: "com.canonical.indicator.network"
36 actions: { "indicator": "/com/canonical/indicator/network" }
37 menuObjectPath: "/com/canonical/indicator/network/phone_wifi_settings"
38 Component.onCompleted: {
39 menuStack.head = menuModel;
40 }
41 }
42
43 MenuItemFactory {
44 id: menuFactory
45 model: mainMenu.model
46 }
47
48 UnityMenuModelStack {
49 id: menuStack
50 }
51
52 ListView {
53 id: mainMenu
54 model: menuStack.tail ? menuStack.tail : null
55
56 anchors {
57 fill: parent
58 bottomMargin: Qt.inputMethod.visible ? (Qt.inputMethod.keyboardRectangle.height - main.anchors.bottomMargin) : 0
59
60 Behavior on bottomMargin {
61 NumberAnimation {
62 duration: 175
63 easing.type: Easing.OutQuad
64 }
65 }
66 // TODO - does ever frame.
67 onBottomMarginChanged: {
68 mainMenu.positionViewAtIndex(mainMenu.currentIndex, ListView.End)
69 }
70 }
71
72 // Ensure all delegates are cached in order to improve smoothness of scrolling
73 cacheBuffer: 10000
74
75 // Only allow flicking if the content doesn't fit on the page
76 interactive: contentHeight > height
77
78 currentIndex: -1
79 delegate: Item {
80 id: menuDelegate
81
82 anchors {
83 left: parent.left
84 right: parent.right
85 }
86 height: loader.height
87 visible: height > 0
88
89 Loader {
90 id: loader
91 asynchronous: true
92
93 property int modelIndex: index
94
95 anchors {
96 left: parent.left
97 right: parent.right
98 }
99
100 sourceComponent: menuFactory.load(model)
101
102 onLoaded: {
103 if (model.type === rootMenuType) {
104 menuStack.push(mainMenu.model.submenu(index));
105 }
106
107 if (item.hasOwnProperty("menuActivated")) {
108 item.menuActivated = Qt.binding(function() { return ListView.isCurrentItem; });
109 item.selectMenu.connect(function() { ListView.view.currentIndex = index });
110 item.deselectMenu.connect(function() { ListView.view.currentIndex = -1 });
111 }
112 if (item.hasOwnProperty("menu")) {
113 item.menu = Qt.binding(function() { return model; });
114 }
115 }
116
117/*
118 Binding {
119 target: item ? item : null
120 property: "objectName"
121 value: model.action
122 }
123 */
124 }
125 }
126 }
127}
0128
=== added file 'plugins/wifi/RemoveBackground.qml'
--- plugins/wifi/RemoveBackground.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/RemoveBackground.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,55 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19
20Rectangle {
21 anchors.fill: parent
22 color: "#333130"
23 Label {
24 id: backgroundText
25
26 anchors.fill: parent
27 verticalAlignment: Text.AlignVCenter
28 text: "Clear"
29 fontSize: "medium"
30 color: "#e8e1d0"
31 font.bold: true
32 }
33
34 states: [
35 State {
36 name: "SwipingRight"
37 PropertyChanges {
38 target: backgroundText
39 anchors.rightMargin: units.gu(3)
40 anchors.leftMargin: 0
41 horizontalAlignment: Text.AlignRight
42
43 }
44 },
45 State {
46 name: "SwipingLeft"
47 PropertyChanges {
48 target: backgroundText
49 anchors.rightMargin: 0
50 anchors.leftMargin: units.gu(3)
51 horizontalAlignment: Text.AlignLeft
52 }
53 }
54 ]
55}
056
=== added file 'plugins/wifi/SectionMenuItem.qml'
--- plugins/wifi/SectionMenuItem.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/SectionMenuItem.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,54 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Ubuntu.Components.ListItems 0.1 as ListItem
23
24BaseMenuItem {
25 id: menuItem
26 property alias text: header.text
27 property bool busy: false
28
29 implicitHeight: text !== "" ? header.height : 0
30
31 ListItem.Header {
32 id: header
33
34 height: units.gu(4)
35 anchors {
36 left: parent.left
37 right: parent.right
38 top: parent.top
39 }
40 visible: text != ""
41
42 ActivityIndicator {
43 id: indicator
44 running: busy
45 anchors {
46 margins: units.gu(0.5)
47 right: parent.right
48 }
49 height: parent.height - (anchors.margins * 2)
50 width: height
51 anchors.verticalCenter: parent.verticalCenter
52 }
53 }
54}
055
=== added file 'plugins/wifi/StandardMenuItem.qml'
--- plugins/wifi/StandardMenuItem.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/StandardMenuItem.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,70 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21import Ubuntu.Components 0.1 as Components
22
23FramedMenuItem {
24 id: menuItem
25
26 property bool checkable: false
27 property bool checked: false
28
29 signal activate()
30
31 // FIXME : need a radio button from sdk
32 // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1211866
33 onCheckableChanged: {
34 if (checkable) {
35 icon = checkComponent.createObject(menuItem);
36 }
37 }
38
39 onCheckedChanged: {
40 // Can't rely on binding. Checked is assigned on click.
41 if (icon) {
42 icon.checked = checked;
43 }
44 }
45
46 onClicked: {
47 if (checkable && icon) {
48 icon.clicked();
49 } else {
50 menuItem.activate();
51 }
52 }
53
54 property var checkComponent: Component {
55 Components.CheckBox {
56 anchors.verticalCenter: parent.verticalCenter
57 anchors.left: parent.left
58
59 Component.onCompleted: {
60 checked = menuItem.checked;
61 }
62
63 // FIXME : should use Checkbox.toggled signal
64 // lp:~nick-dedekind/ubuntu-ui-toolkit/checkbox.toggled
65 onClicked: {
66 menuItem.activate();
67 }
68 }
69 }
70}
071
=== added file 'plugins/wifi/SwitchMenuItem.qml'
--- plugins/wifi/SwitchMenuItem.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/SwitchMenuItem.qml 2013-09-18 20:04:27 +0000
@@ -0,0 +1,52 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Nick Dedekind <nick.dedekind@canonical.com>
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23
24FramedMenuItem {
25 id: menuItem
26
27 property bool checked: false
28
29 signal activate()
30
31 onCheckedChanged: {
32 // Can't rely on binding. Checked is assigned on click.
33 switcher.checked = checked;
34 }
35
36 control: Switch {
37 id: switcher
38
39 Component.onCompleted: {
40 checked = menuItem.checked;
41 }
42
43 anchors.verticalCenter: parent.verticalCenter
44 anchors.right: parent.right
45
46 // FIXME : should use Checkbox.toggled signal
47 // lp:~nick-dedekind/ubuntu-ui-toolkit/checkbox.toggled
48 onClicked: {
49 menuItem.activate();
50 }
51 }
52}
053
=== added file 'plugins/wifi/plugin.cpp'
--- plugins/wifi/plugin.cpp 1970-01-01 00:00:00 +0000
+++ plugins/wifi/plugin.cpp 2013-09-18 20:04:27 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16*/
17
18#include <QtQml>
19#include <QtQml/QQmlContext>
20#include "plugin.h"
21#include "unitymenumodelstack.h"
22
23void BackendPlugin::registerTypes(const char *uri)
24{
25 Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.Wifi"));
26 qmlRegisterType<UnityMenuModelStack>(uri, 1, 0, "UnityMenuModelStack");
27}
28
29void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
30{
31 QQmlExtensionPlugin::initializeEngine(engine, uri);
32}
033
=== added file 'plugins/wifi/plugin.h'
--- plugins/wifi/plugin.h 1970-01-01 00:00:00 +0000
+++ plugins/wifi/plugin.h 2013-09-18 20:04:27 +0000
@@ -0,0 +1,33 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16*/
17
18#ifndef PLUGIN_H
19#define PLUGIN_H
20
21#include <QtQml/QQmlEngine>
22#include <QtQml/QQmlExtensionPlugin>
23
24class BackendPlugin : public QQmlExtensionPlugin
25{
26 Q_OBJECT
27 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
28
29public:
30 void registerTypes(const char *uri);
31 void initializeEngine(QQmlEngine *engine, const char *uri);
32};
33#endif // PLUGIN_H
034
=== added file 'plugins/wifi/qmldir'
--- plugins/wifi/qmldir 1970-01-01 00:00:00 +0000
+++ plugins/wifi/qmldir 2013-09-18 20:04:27 +0000
@@ -0,0 +1,2 @@
1module Ubuntu.SystemSettings.Wifi
2plugin UbuntuWifiPanel
03
=== added file 'plugins/wifi/unitymenumodelstack.cpp'
--- plugins/wifi/unitymenumodelstack.cpp 1970-01-01 00:00:00 +0000
+++ plugins/wifi/unitymenumodelstack.cpp 2013-09-18 20:04:27 +0000
@@ -0,0 +1,69 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20#include "unitymenumodelstack.h"
21
22UnityMenuModelStack::UnityMenuModelStack(QObject* parent)
23 : QObject(parent)
24{
25}
26
27UnityMenuModelStack::~UnityMenuModelStack()
28{
29}
30
31UnityMenuModel* UnityMenuModelStack::head() const
32{
33 return !m_menuModels.isEmpty() ? m_menuModels.first() : NULL;
34}
35
36void UnityMenuModelStack::setHead(UnityMenuModel* model)
37{
38 if (head() != model) {
39 m_menuModels.clear();
40 push(model);
41 Q_EMIT headChanged(model);
42 }
43}
44
45UnityMenuModel* UnityMenuModelStack::tail() const
46{
47 return !m_menuModels.isEmpty() ? m_menuModels.last() : NULL;
48}
49
50void UnityMenuModelStack::push(UnityMenuModel* model)
51{
52 m_menuModels << model;
53 Q_EMIT tailChanged(model);
54}
55
56UnityMenuModel* UnityMenuModelStack::pop()
57{
58 if (m_menuModels.isEmpty()) {
59 return NULL;
60 }
61 UnityMenuModel* model = m_menuModels.takeLast();
62
63 Q_EMIT tailChanged(tail());
64 if (m_menuModels.isEmpty()) {
65 Q_EMIT headChanged(NULL);
66 }
67
68 return model;
69}
070
=== added file 'plugins/wifi/unitymenumodelstack.h'
--- plugins/wifi/unitymenumodelstack.h 1970-01-01 00:00:00 +0000
+++ plugins/wifi/unitymenumodelstack.h 2013-09-18 20:04:27 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20#ifndef UNITYMENUMODELSTACK_H
21#define UNITYMENUMODELSTACK_H
22
23#include <QObject>
24#include <QList>
25
26class UnityMenuModel;
27
28// A LIFO queue for storing the current submenu of a UnityMenuModel.
29// The root menu model is set as the head, and each subsiquent submenu that is
30// opened can be pushed onto the queue.
31// The tail is set to the last item on the queue
32// Popping the queue will remove the last entry, and the tail be updated to the last item.
33class UnityMenuModelStack : public QObject
34{
35 Q_OBJECT
36 Q_PROPERTY(UnityMenuModel* head READ head WRITE setHead NOTIFY headChanged)
37 Q_PROPERTY(UnityMenuModel* tail READ tail NOTIFY tailChanged)
38public:
39 UnityMenuModelStack(QObject*parent=NULL);
40 ~UnityMenuModelStack();
41
42 UnityMenuModel* head() const;
43 void setHead(UnityMenuModel* model);
44
45 UnityMenuModel* tail() const;
46
47 Q_INVOKABLE void push(UnityMenuModel* model);
48 Q_INVOKABLE UnityMenuModel* pop();
49
50Q_SIGNALS:
51 void headChanged(UnityMenuModel* head);
52 void tailChanged(UnityMenuModel* tail);
53
54private:
55 QList<UnityMenuModel*> m_menuModels;
56};
57
58#endif // UNITYMENUMODELSTACK_H
059
=== modified file 'plugins/wifi/wifi.pro'
--- plugins/wifi/wifi.pro 2013-08-02 06:18:29 +0000
+++ plugins/wifi/wifi.pro 2013-09-18 20:04:27 +0000
@@ -4,6 +4,39 @@
4TEMPLATE = lib4TEMPLATE = lib
5TARGET = wifi5TARGET = wifi
66
7QML_SOURCES = \
8 AccessPoint.qml \
9 BaseMenuItem.qml \
10 DivMenuItem.qml \
11 FramedMenuItem.qml \
12 HLine.qml \
13 IndicatorBase.qml \
14 MenuItemFactory.qml \
15 PageComponent.qml \
16 RemoveBackground.qml \
17 SectionMenuItem.qml \
18 StandardMenuItem.qml \
19 SwitchMenuItem.qml
20
21OTHER_FILES += \
22 $${QML_SOURCES} \
23 AccessPoint.qml \
24 BaseMenuItem.qml \
25 DivMenuItem.qml \
26 FramedMenuItem.qml \
27 HLine.qml \
28 IndicatorBase.qml \
29 MenuItemFactory.qml \
30 PageComponent.qml \
31 RemoveBackground.qml \
32 SectionMenuItem.qml \
33 StandardMenuItem.qml \
34 SwitchMenuItem.qml
35
36qml.files = $${QML_SOURCES}
37qml.path = $${PLUGIN_QML_DIR}/$${TARGET}
38INSTALLS += qml
39
7settings.files = $${TARGET}.settings40settings.files = $${TARGET}.settings
8settings.path = $${PLUGIN_MANIFEST_DIR}41settings.path = $${PLUGIN_MANIFEST_DIR}
9INSTALLS += settings42INSTALLS += settings
@@ -11,3 +44,39 @@
11image.files = settings-wifi.svg44image.files = settings-wifi.svg
12image.path = $${PLUGIN_MANIFEST_DIR}/icons45image.path = $${PLUGIN_MANIFEST_DIR}/icons
13INSTALLS += image46INSTALLS += image
47
48# C++ bits
49TARGET = UbuntuWifiPanel
50QT += qml quick dbus
51CONFIG += qt plugin no_keywords
52
53TARGET = $$qtLibraryTarget($$TARGET)
54uri = Ubuntu.SystemSettings.Wifi
55
56SOURCES += \
57 plugin.cpp \
58 unitymenumodelstack.cpp
59
60HEADERS += \
61 plugin.h \
62 unitymenumodelstack.h
63
64unix: CONFIG += link_pkgconfig
65unix: PKGCONFIG += qmenumodel
66
67# Install path for the plugin
68installPath = $${PLUGIN_PRIVATE_MODULE_DIR}/$$replace(uri, \\., /)
69target.path = $$installPath
70INSTALLS += target
71
72# find files
73QMLDIR_FILE = qmldir
74
75# make visible to qt creator
76OTHER_FILES += $$QMLDIR_FILE
77
78# create install targets for files
79qmldir.path = $$installPath
80qmldir.files = $$QMLDIR_FILE
81
82INSTALLS += qmldir
1483
=== modified file 'plugins/wifi/wifi.settings'
--- plugins/wifi/wifi.settings 2013-08-02 11:01:13 +0000
+++ plugins/wifi/wifi.settings 2013-09-18 20:04:27 +0000
@@ -4,6 +4,9 @@
4 "translations": "ubuntu-system-settings",4 "translations": "ubuntu-system-settings",
5 "category": "network",5 "category": "network",
6 "priority": 0,6 "priority": 0,
7 "form-factors": [
8 "phone"
9 ],
7 "keywords": [10 "keywords": [
8 "network",11 "network",
9 "wireless",12 "wireless",
@@ -12,5 +15,7 @@
12 "settings"15 "settings"
13 ],16 ],
14 "has-dynamic-keywords": false,17 "has-dynamic-keywords": false,
15 "has-dynamic-visibility": false18 "has-dynamic-visibility": false,
19 "page-component": "PageComponent.qml",
20 "plugin": "UbuntuWifiPanel"
16}21}

Subscribers

People subscribed via source and target branches