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
1=== modified file 'debian/control'
2--- debian/control 2013-09-03 19:59:09 +0000
3+++ debian/control 2013-09-18 20:04:27 +0000
4@@ -10,6 +10,7 @@
5 libglib2.0-dev,
6 libnm-glib-dev,
7 libofono-qt-dev,
8+ libqmenumodel-dev,
9 libtimezonemap1-dev (>= 0.4.0.1),
10 libupower-glib-dev,
11 pkg-config,
12@@ -31,6 +32,7 @@
13 accountsservice,
14 gsettings-desktop-schemas,
15 gsettings-ubuntu-touch-schemas (>= 0.0.1+13.10.20130730),
16+ indicator-network (>> 0.5.0+13.10.20130913),
17 powerd | gnome-settings-daemon,
18 qtdeclarative5-folderlistmodel-plugin,
19 qtdeclarative5-qtmultimedia-plugin,
20
21=== modified file 'plugins/time-date/plugin.cpp'
22--- plugins/time-date/plugin.cpp 2013-07-24 13:43:20 +0000
23+++ plugins/time-date/plugin.cpp 2013-09-18 20:04:27 +0000
24@@ -27,7 +27,7 @@
25 void BackendPlugin::registerTypes(const char *uri)
26 {
27 Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.TimeDate"));
28-
29+
30 qmlRegisterType<TimeDate>(uri, 1, 0, "UbuntuTimeDatePanel");
31 }
32
33
34=== added file 'plugins/wifi/AccessPoint.qml'
35--- plugins/wifi/AccessPoint.qml 1970-01-01 00:00:00 +0000
36+++ plugins/wifi/AccessPoint.qml 2013-09-18 20:04:27 +0000
37@@ -0,0 +1,71 @@
38+/*
39+ * Copyright 2013 Canonical Ltd.
40+ *
41+ * This program is free software; you can redistribute it and/or modify
42+ * it under the terms of the GNU General Public License as published by
43+ * the Free Software Foundation; version 3.
44+ *
45+ * This program is distributed in the hope that it will be useful,
46+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
47+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48+ * GNU General Public License for more details.
49+ *
50+ * You should have received a copy of the GNU General Public License
51+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
52+ *
53+ * Authors:
54+ * Renato Araujo Oliveira Filho <renato@canonical.com>
55+ */
56+
57+import QtQuick 2.0
58+import Ubuntu.Components 0.1
59+import Ubuntu.Components.ListItems 0.1 as ListItem
60+
61+FramedMenuItem {
62+ id: accessPoint
63+
64+ property bool checked: false
65+ property bool secure: false
66+ property bool adHoc: false
67+ property int signalStrength: 0
68+
69+ signal activate()
70+
71+ onCheckedChanged: {
72+ // Can't rely on binding. Checked is assigned on click.
73+ checkBoxActive.checked = checked;
74+ }
75+
76+ icon: {
77+ var imageName = "nm-signal-100"
78+
79+ if (adHoc) {
80+ imageName = "nm-adhoc";
81+ } else if (signalStrength == 0) {
82+ imageName = "nm-signal-00";
83+ } else if (signalStrength <= 25) {
84+ imageName = "nm-signal-25";
85+ } else if (signalStrength <= 50) {
86+ imageName = "nm-signal-50";
87+ } else if (signalStrength <= 75) {
88+ imageName = "nm-signal-75";
89+ }
90+
91+ if (secure) {
92+ imageName += "-secure";
93+ }
94+ return "image://gicon/" + imageName;
95+ }
96+
97+ iconFrame: false
98+ control: CheckBox {
99+ id: checkBoxActive
100+ height: units.gu(4)
101+ width: units.gu(4)
102+ anchors.centerIn: parent
103+
104+ onClicked: {
105+ accessPoint.activate();
106+ }
107+ }
108+}
109
110=== added file 'plugins/wifi/BaseMenuItem.qml'
111--- plugins/wifi/BaseMenuItem.qml 1970-01-01 00:00:00 +0000
112+++ plugins/wifi/BaseMenuItem.qml 2013-09-18 20:04:27 +0000
113@@ -0,0 +1,37 @@
114+/*
115+ * Copyright 2013 Canonical Ltd.
116+ *
117+ * This program is free software; you can redistribute it and/or modify
118+ * it under the terms of the GNU General Public License as published by
119+ * the Free Software Foundation; version 3.
120+ *
121+ * This program is distributed in the hope that it will be useful,
122+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
123+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
124+ * GNU General Public License for more details.
125+ *
126+ * You should have received a copy of the GNU General Public License
127+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
128+ *
129+ * Authors:
130+ * Renato Araujo Oliveira Filho <renato@canonical.com>
131+ * Nick Dedekind <nick.dedekind@canonical.com>
132+ */
133+
134+import QtQuick 2.0
135+import Ubuntu.Components.ListItems 0.1 as ListItem
136+
137+ListItem.Standard {
138+ id: baseMenu
139+
140+ property bool menuActivated: false
141+
142+ signal selectMenu()
143+ signal deselectMenu()
144+
145+ showDivider: false
146+
147+ backgroundIndicator: RemoveBackground {
148+ state: baseMenu.swipingState
149+ }
150+}
151
152=== added file 'plugins/wifi/DivMenuItem.qml'
153--- plugins/wifi/DivMenuItem.qml 1970-01-01 00:00:00 +0000
154+++ plugins/wifi/DivMenuItem.qml 2013-09-18 20:04:27 +0000
155@@ -0,0 +1,25 @@
156+/*
157+ * Copyright 2013 Canonical Ltd.
158+ *
159+ * This program is free software; you can redistribute it and/or modify
160+ * it under the terms of the GNU General Public License as published by
161+ * the Free Software Foundation; version 3.
162+ *
163+ * This program is distributed in the hope that it will be useful,
164+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
165+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
166+ * GNU General Public License for more details.
167+ *
168+ * You should have received a copy of the GNU General Public License
169+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
170+ *
171+ * Authors:
172+ * Olivier Tilloy <olivier.tilloy@canonical.com>
173+ */
174+
175+import QtQuick 2.0
176+import Ubuntu.Components 0.1
177+
178+Rectangle {
179+ implicitHeight: units.gu(1)
180+}
181
182=== added file 'plugins/wifi/FramedMenuItem.qml'
183--- plugins/wifi/FramedMenuItem.qml 1970-01-01 00:00:00 +0000
184+++ plugins/wifi/FramedMenuItem.qml 2013-09-18 20:04:27 +0000
185@@ -0,0 +1,37 @@
186+/*
187+ * Copyright 2013 Canonical Ltd.
188+ *
189+ * This program is free software; you can redistribute it and/or modify
190+ * it under the terms of the GNU General Public License as published by
191+ * the Free Software Foundation; version 3.
192+ *
193+ * This program is distributed in the hope that it will be useful,
194+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
195+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
196+ * GNU General Public License for more details.
197+ *
198+ * You should have received a copy of the GNU General Public License
199+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
200+ *
201+ * Authors:
202+ * Renato Araujo Oliveira Filho <renato@canonical.com>
203+ * Nick Dedekind <nick.dedekind@canonical.com>
204+ */
205+
206+import QtQuick 2.0
207+import Ubuntu.Components 0.1
208+import Ubuntu.Components.ListItems 0.1 as ListItem
209+
210+BaseMenuItem {
211+ implicitHeight: units.gu(7)
212+
213+ iconFrame: false
214+
215+ HLine {
216+ anchors.top: parent.top
217+ }
218+
219+ HLine {
220+ anchors.bottom: parent.bottom
221+ }
222+}
223
224=== added file 'plugins/wifi/HLine.qml'
225--- plugins/wifi/HLine.qml 1970-01-01 00:00:00 +0000
226+++ plugins/wifi/HLine.qml 2013-09-18 20:04:27 +0000
227@@ -0,0 +1,29 @@
228+/*
229+ * Copyright 2013 Canonical Ltd.
230+ *
231+ * This program is free software; you can redistribute it and/or modify
232+ * it under the terms of the GNU General Public License as published by
233+ * the Free Software Foundation; version 3.
234+ *
235+ * This program is distributed in the hope that it will be useful,
236+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
237+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
238+ * GNU General Public License for more details.
239+ *
240+ * You should have received a copy of the GNU General Public License
241+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
242+ *
243+ * Authors:
244+ * Renato Araujo Oliveira Filho <renato@canonical.com>
245+ */
246+
247+import QtQuick 2.0
248+import Ubuntu.Components 0.1
249+
250+Rectangle {
251+ height: units.dp(1)
252+ anchors {
253+ left: parent.left
254+ right: parent.right
255+ }
256+}
257
258=== added file 'plugins/wifi/IndicatorBase.qml'
259--- plugins/wifi/IndicatorBase.qml 1970-01-01 00:00:00 +0000
260+++ plugins/wifi/IndicatorBase.qml 2013-09-18 20:04:27 +0000
261@@ -0,0 +1,45 @@
262+/*
263+ * Copyright 2013 Canonical Ltd.
264+ *
265+ * This program is free software; you can redistribute it and/or modify
266+ * it under the terms of the GNU General Public License as published by
267+ * the Free Software Foundation; version 3.
268+ *
269+ * This program is distributed in the hope that it will be useful,
270+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
271+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
272+ * GNU General Public License for more details.
273+ *
274+ * You should have received a copy of the GNU General Public License
275+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
276+ *
277+ * Authors:
278+ * Nick Dedekind <nick.dedekind@canonical.com>
279+ */
280+
281+import QtQuick 2.0
282+import QMenuModel 0.1 as QMenuModel
283+import SystemSettings 1.0
284+import Ubuntu.Components 0.1
285+
286+ItemPage {
287+ id: indicatorItem
288+
289+ // FIXME : should be disabled until bus available when we have desktop indicators
290+ // for now, disable when we dont habe the correct profile.
291+ enabled: menuObjectPaths.hasOwnProperty(device)
292+
293+ //const
294+ property string title
295+ property string busName
296+ property string actionsObjectPath
297+ property var menuObjectPaths: undefined
298+ readonly property string device: "phone_wifi_settings"
299+ property string rootMenuType: "com.canonical.indicator.root"
300+ property bool active: false
301+
302+ property string deviceMenuObjectPath: menuObjectPaths.hasOwnProperty(device) ? menuObjectPaths[device] : ""
303+
304+ signal actionGroupUpdated()
305+ signal modelUpdated()
306+}
307
308=== added file 'plugins/wifi/MenuItemFactory.qml'
309--- plugins/wifi/MenuItemFactory.qml 1970-01-01 00:00:00 +0000
310+++ plugins/wifi/MenuItemFactory.qml 2013-09-18 20:04:27 +0000
311@@ -0,0 +1,134 @@
312+/*
313+ * Copyright 2013 Canonical Ltd.
314+ *
315+ * This program is free software; you can redistribute it and/or modify
316+ * it under the terms of the GNU General Public License as published by
317+ * the Free Software Foundation; version 3.
318+ *
319+ * This program is distributed in the hope that it will be useful,
320+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
321+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
322+ * GNU General Public License for more details.
323+ *
324+ * You should have received a copy of the GNU General Public License
325+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
326+ *
327+ * Authors:
328+ * Nick Dedekind <nick.dedekind@canonical.com>
329+ */
330+
331+import QtQuick 2.0
332+import QMenuModel 0.1 as QMenuModel
333+
334+Item {
335+ id: menuFactory
336+
337+ property var model: null
338+
339+ property var _map: {
340+ "unity.widgets.systemsettings.tablet.switch" : switchMenu,
341+
342+ "com.canonical.indicator.div" : divMenu,
343+ "com.canonical.indicator.section" : sectionMenu,
344+ "com.canonical.indicator.switch" : switchMenu,
345+
346+ "com.canonical.unity.switch" : switchMenu,
347+
348+ "unity.widgets.systemsettings.tablet.wifisection" : wifiSection,
349+ "unity.widgets.systemsettings.tablet.accesspoint" : accessPoint,
350+ }
351+
352+ Component { id: divMenu; DivMenuItem {} }
353+
354+ Component {
355+ id: sectionMenu;
356+ SectionMenuItem {
357+ property QtObject menu: null
358+
359+ text: menu && menu.label ? menu.label : ""
360+ }
361+ }
362+
363+ Component {
364+ id: standardMenu;
365+ StandardMenuItem {
366+ property QtObject menu: null
367+
368+ text: menu && menu.label ? menu.label : ""
369+ icon: menu ? menu.icon : ""
370+ checkable: menu ? (menu.isCheck || menu.isRadio) : false
371+ checked: checkable ? menu.isToggled : false
372+ enabled: menu ? menu.sensitive : false
373+
374+ onActivate: model.activate(modelIndex);
375+ }
376+ }
377+
378+ Component {
379+ id: switchMenu;
380+ SwitchMenuItem {
381+ property QtObject menu: null
382+
383+ text: menu && menu.label ? menu.label : ""
384+ icon: menu ? menu.icon : ""
385+ checked: menu ? menu.isToggled : false
386+ enabled: menu ? menu.sensitive : false
387+
388+ onActivate: model.activate(modelIndex);
389+ }
390+ }
391+
392+ Component {
393+ id: wifiSection;
394+ SectionMenuItem {
395+ property QtObject menu: null
396+
397+ text: menu && menu.label ? menu.label : ""
398+ busy: menu ? menu.ext.xCanonicalBusyAction : false
399+
400+ Component.onCompleted: {
401+ model.loadExtendedAttributes(modelIndex, {'x-canonical-busy-action': 'bool'});
402+ }
403+ }
404+ }
405+
406+ Component {
407+ id: accessPoint;
408+ AccessPoint {
409+ property QtObject menu: null
410+ property var strenthAction: QMenuModel.UnityMenuAction {
411+ model: menuFactory.model ? menuFactory.model : null
412+ name: menu ? menu.ext.xCanonicalWifiApStrengthAction : ""
413+ }
414+
415+ text: menu && menu.label ? menu.label : ""
416+ icon: menu ? menu.icon : ""
417+ secure: menu ? menu.ext.xCanonicalWifiApIsSecure : false
418+ adHoc: menu ? menu.ext.xCanonicalWifiApIsAdhoc : false
419+ checked: menu ? menu.isToggled : false
420+ signalStrength: strenthAction.valid ? strenthAction.state : 0
421+ enabled: menu ? menu.sensitive : false
422+
423+ Component.onCompleted: {
424+ model.loadExtendedAttributes(modelIndex, {'x-canonical-wifi-ap-is-adhoc': 'bool',
425+ 'x-canonical-wifi-ap-is-secure': 'bool',
426+ 'x-canonical-wifi-ap-strength-action': 'string'});
427+ }
428+ onActivate: model.activate(modelIndex);
429+ }
430+ }
431+
432+ function load(modelData) {
433+ if (modelData.type !== undefined) {
434+ var component = _map[modelData.type];
435+ if (component !== undefined) {
436+ return component;
437+ }
438+ } else {
439+ if (modelData.isSeparator) {
440+ return divMenu;
441+ }
442+ }
443+ return standardMenu;
444+ }
445+}
446
447=== added file 'plugins/wifi/PageComponent.qml'
448--- plugins/wifi/PageComponent.qml 1970-01-01 00:00:00 +0000
449+++ plugins/wifi/PageComponent.qml 2013-09-18 20:04:27 +0000
450@@ -0,0 +1,127 @@
451+/*
452+ * Copyright 2013 Canonical Ltd.
453+ *
454+ * This program is free software; you can redistribute it and/or modify
455+ * it under the terms of the GNU General Public License as published by
456+ * the Free Software Foundation; version 3.
457+ *
458+ * This program is distributed in the hope that it will be useful,
459+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
460+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
461+ * GNU General Public License for more details.
462+ *
463+ * You should have received a copy of the GNU General Public License
464+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
465+ */
466+
467+import QtQuick 2.0
468+import SystemSettings 1.0
469+import Ubuntu.Components 0.1
470+import Ubuntu.Components.ListItems 0.1 as ListItem
471+import Ubuntu.SystemSettings.Wifi 1.0
472+import QMenuModel 0.1
473+
474+
475+IndicatorBase {
476+ id: wifibase
477+ title: i18n.tr("Wi-Fi")
478+ busName: "com.canonical.indicator.network"
479+ actionsObjectPath: "/com/canonical/indicator/network"
480+ menuObjectPaths: {"phone_wifi_settings": "/com/canonical/indicator/network/phone_wifi_settings"}
481+ active: true
482+
483+ UnityMenuModel {
484+ id: menuModel
485+ busName: "com.canonical.indicator.network"
486+ actions: { "indicator": "/com/canonical/indicator/network" }
487+ menuObjectPath: "/com/canonical/indicator/network/phone_wifi_settings"
488+ Component.onCompleted: {
489+ menuStack.head = menuModel;
490+ }
491+ }
492+
493+ MenuItemFactory {
494+ id: menuFactory
495+ model: mainMenu.model
496+ }
497+
498+ UnityMenuModelStack {
499+ id: menuStack
500+ }
501+
502+ ListView {
503+ id: mainMenu
504+ model: menuStack.tail ? menuStack.tail : null
505+
506+ anchors {
507+ fill: parent
508+ bottomMargin: Qt.inputMethod.visible ? (Qt.inputMethod.keyboardRectangle.height - main.anchors.bottomMargin) : 0
509+
510+ Behavior on bottomMargin {
511+ NumberAnimation {
512+ duration: 175
513+ easing.type: Easing.OutQuad
514+ }
515+ }
516+ // TODO - does ever frame.
517+ onBottomMarginChanged: {
518+ mainMenu.positionViewAtIndex(mainMenu.currentIndex, ListView.End)
519+ }
520+ }
521+
522+ // Ensure all delegates are cached in order to improve smoothness of scrolling
523+ cacheBuffer: 10000
524+
525+ // Only allow flicking if the content doesn't fit on the page
526+ interactive: contentHeight > height
527+
528+ currentIndex: -1
529+ delegate: Item {
530+ id: menuDelegate
531+
532+ anchors {
533+ left: parent.left
534+ right: parent.right
535+ }
536+ height: loader.height
537+ visible: height > 0
538+
539+ Loader {
540+ id: loader
541+ asynchronous: true
542+
543+ property int modelIndex: index
544+
545+ anchors {
546+ left: parent.left
547+ right: parent.right
548+ }
549+
550+ sourceComponent: menuFactory.load(model)
551+
552+ onLoaded: {
553+ if (model.type === rootMenuType) {
554+ menuStack.push(mainMenu.model.submenu(index));
555+ }
556+
557+ if (item.hasOwnProperty("menuActivated")) {
558+ item.menuActivated = Qt.binding(function() { return ListView.isCurrentItem; });
559+ item.selectMenu.connect(function() { ListView.view.currentIndex = index });
560+ item.deselectMenu.connect(function() { ListView.view.currentIndex = -1 });
561+ }
562+ if (item.hasOwnProperty("menu")) {
563+ item.menu = Qt.binding(function() { return model; });
564+ }
565+ }
566+
567+/*
568+ Binding {
569+ target: item ? item : null
570+ property: "objectName"
571+ value: model.action
572+ }
573+ */
574+ }
575+ }
576+ }
577+}
578
579=== added file 'plugins/wifi/RemoveBackground.qml'
580--- plugins/wifi/RemoveBackground.qml 1970-01-01 00:00:00 +0000
581+++ plugins/wifi/RemoveBackground.qml 2013-09-18 20:04:27 +0000
582@@ -0,0 +1,55 @@
583+/*
584+ * Copyright 2013 Canonical Ltd.
585+ *
586+ * This program is free software; you can redistribute it and/or modify
587+ * it under the terms of the GNU General Public License as published by
588+ * the Free Software Foundation; version 3.
589+ *
590+ * This program is distributed in the hope that it will be useful,
591+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
592+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
593+ * GNU General Public License for more details.
594+ *
595+ * You should have received a copy of the GNU General Public License
596+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
597+ */
598+
599+import QtQuick 2.0
600+import Ubuntu.Components 0.1
601+
602+Rectangle {
603+ anchors.fill: parent
604+ color: "#333130"
605+ Label {
606+ id: backgroundText
607+
608+ anchors.fill: parent
609+ verticalAlignment: Text.AlignVCenter
610+ text: "Clear"
611+ fontSize: "medium"
612+ color: "#e8e1d0"
613+ font.bold: true
614+ }
615+
616+ states: [
617+ State {
618+ name: "SwipingRight"
619+ PropertyChanges {
620+ target: backgroundText
621+ anchors.rightMargin: units.gu(3)
622+ anchors.leftMargin: 0
623+ horizontalAlignment: Text.AlignRight
624+
625+ }
626+ },
627+ State {
628+ name: "SwipingLeft"
629+ PropertyChanges {
630+ target: backgroundText
631+ anchors.rightMargin: 0
632+ anchors.leftMargin: units.gu(3)
633+ horizontalAlignment: Text.AlignLeft
634+ }
635+ }
636+ ]
637+}
638
639=== added file 'plugins/wifi/SectionMenuItem.qml'
640--- plugins/wifi/SectionMenuItem.qml 1970-01-01 00:00:00 +0000
641+++ plugins/wifi/SectionMenuItem.qml 2013-09-18 20:04:27 +0000
642@@ -0,0 +1,54 @@
643+/*
644+ * Copyright 2013 Canonical Ltd.
645+ *
646+ * This program is free software; you can redistribute it and/or modify
647+ * it under the terms of the GNU General Public License as published by
648+ * the Free Software Foundation; version 3.
649+ *
650+ * This program is distributed in the hope that it will be useful,
651+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
652+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
653+ * GNU General Public License for more details.
654+ *
655+ * You should have received a copy of the GNU General Public License
656+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
657+ *
658+ * Authors:
659+ * Renato Araujo Oliveira Filho <renato@canonical.com>
660+ */
661+
662+import QtQuick 2.0
663+import Ubuntu.Components 0.1
664+import Ubuntu.Components.ListItems 0.1 as ListItem
665+
666+BaseMenuItem {
667+ id: menuItem
668+ property alias text: header.text
669+ property bool busy: false
670+
671+ implicitHeight: text !== "" ? header.height : 0
672+
673+ ListItem.Header {
674+ id: header
675+
676+ height: units.gu(4)
677+ anchors {
678+ left: parent.left
679+ right: parent.right
680+ top: parent.top
681+ }
682+ visible: text != ""
683+
684+ ActivityIndicator {
685+ id: indicator
686+ running: busy
687+ anchors {
688+ margins: units.gu(0.5)
689+ right: parent.right
690+ }
691+ height: parent.height - (anchors.margins * 2)
692+ width: height
693+ anchors.verticalCenter: parent.verticalCenter
694+ }
695+ }
696+}
697
698=== added file 'plugins/wifi/StandardMenuItem.qml'
699--- plugins/wifi/StandardMenuItem.qml 1970-01-01 00:00:00 +0000
700+++ plugins/wifi/StandardMenuItem.qml 2013-09-18 20:04:27 +0000
701@@ -0,0 +1,70 @@
702+/*
703+ * Copyright 2013 Canonical Ltd.
704+ *
705+ * This program is free software; you can redistribute it and/or modify
706+ * it under the terms of the GNU General Public License as published by
707+ * the Free Software Foundation; version 3.
708+ *
709+ * This program is distributed in the hope that it will be useful,
710+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
711+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
712+ * GNU General Public License for more details.
713+ *
714+ * You should have received a copy of the GNU General Public License
715+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
716+ *
717+ * Authors:
718+ * Nick Dedekind <nick.dedekind@canonical.com>
719+ */
720+
721+import QtQuick 2.0
722+import Ubuntu.Components 0.1 as Components
723+
724+FramedMenuItem {
725+ id: menuItem
726+
727+ property bool checkable: false
728+ property bool checked: false
729+
730+ signal activate()
731+
732+ // FIXME : need a radio button from sdk
733+ // https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1211866
734+ onCheckableChanged: {
735+ if (checkable) {
736+ icon = checkComponent.createObject(menuItem);
737+ }
738+ }
739+
740+ onCheckedChanged: {
741+ // Can't rely on binding. Checked is assigned on click.
742+ if (icon) {
743+ icon.checked = checked;
744+ }
745+ }
746+
747+ onClicked: {
748+ if (checkable && icon) {
749+ icon.clicked();
750+ } else {
751+ menuItem.activate();
752+ }
753+ }
754+
755+ property var checkComponent: Component {
756+ Components.CheckBox {
757+ anchors.verticalCenter: parent.verticalCenter
758+ anchors.left: parent.left
759+
760+ Component.onCompleted: {
761+ checked = menuItem.checked;
762+ }
763+
764+ // FIXME : should use Checkbox.toggled signal
765+ // lp:~nick-dedekind/ubuntu-ui-toolkit/checkbox.toggled
766+ onClicked: {
767+ menuItem.activate();
768+ }
769+ }
770+ }
771+}
772
773=== added file 'plugins/wifi/SwitchMenuItem.qml'
774--- plugins/wifi/SwitchMenuItem.qml 1970-01-01 00:00:00 +0000
775+++ plugins/wifi/SwitchMenuItem.qml 2013-09-18 20:04:27 +0000
776@@ -0,0 +1,52 @@
777+/*
778+ * Copyright 2013 Canonical Ltd.
779+ *
780+ * This program is free software; you can redistribute it and/or modify
781+ * it under the terms of the GNU General Public License as published by
782+ * the Free Software Foundation; version 3.
783+ *
784+ * This program is distributed in the hope that it will be useful,
785+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
786+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
787+ * GNU General Public License for more details.
788+ *
789+ * You should have received a copy of the GNU General Public License
790+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
791+ *
792+ * Authors:
793+ * Renato Araujo Oliveira Filho <renato@canonical.com>
794+ * Nick Dedekind <nick.dedekind@canonical.com>
795+ */
796+
797+import QtQuick 2.0
798+import Ubuntu.Components 0.1
799+
800+FramedMenuItem {
801+ id: menuItem
802+
803+ property bool checked: false
804+
805+ signal activate()
806+
807+ onCheckedChanged: {
808+ // Can't rely on binding. Checked is assigned on click.
809+ switcher.checked = checked;
810+ }
811+
812+ control: Switch {
813+ id: switcher
814+
815+ Component.onCompleted: {
816+ checked = menuItem.checked;
817+ }
818+
819+ anchors.verticalCenter: parent.verticalCenter
820+ anchors.right: parent.right
821+
822+ // FIXME : should use Checkbox.toggled signal
823+ // lp:~nick-dedekind/ubuntu-ui-toolkit/checkbox.toggled
824+ onClicked: {
825+ menuItem.activate();
826+ }
827+ }
828+}
829
830=== added file 'plugins/wifi/plugin.cpp'
831--- plugins/wifi/plugin.cpp 1970-01-01 00:00:00 +0000
832+++ plugins/wifi/plugin.cpp 2013-09-18 20:04:27 +0000
833@@ -0,0 +1,32 @@
834+/*
835+ * Copyright (C) 2013 Canonical Ltd
836+ *
837+ * This program is free software: you can redistribute it and/or modify
838+ * it under the terms of the GNU General Public License version 3 as
839+ * published by the Free Software Foundation.
840+ *
841+ * This program is distributed in the hope that it will be useful,
842+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
843+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
844+ * GNU General Public License for more details.
845+ *
846+ * You should have received a copy of the GNU General Public License
847+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
848+ *
849+*/
850+
851+#include <QtQml>
852+#include <QtQml/QQmlContext>
853+#include "plugin.h"
854+#include "unitymenumodelstack.h"
855+
856+void BackendPlugin::registerTypes(const char *uri)
857+{
858+ Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.Wifi"));
859+ qmlRegisterType<UnityMenuModelStack>(uri, 1, 0, "UnityMenuModelStack");
860+}
861+
862+void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
863+{
864+ QQmlExtensionPlugin::initializeEngine(engine, uri);
865+}
866
867=== added file 'plugins/wifi/plugin.h'
868--- plugins/wifi/plugin.h 1970-01-01 00:00:00 +0000
869+++ plugins/wifi/plugin.h 2013-09-18 20:04:27 +0000
870@@ -0,0 +1,33 @@
871+/*
872+ * Copyright (C) 2013 Canonical Ltd
873+ *
874+ * This program is free software: you can redistribute it and/or modify
875+ * it under the terms of the GNU General Public License version 3 as
876+ * published by the Free Software Foundation.
877+ *
878+ * This program is distributed in the hope that it will be useful,
879+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
880+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
881+ * GNU General Public License for more details.
882+ *
883+ * You should have received a copy of the GNU General Public License
884+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
885+ *
886+*/
887+
888+#ifndef PLUGIN_H
889+#define PLUGIN_H
890+
891+#include <QtQml/QQmlEngine>
892+#include <QtQml/QQmlExtensionPlugin>
893+
894+class BackendPlugin : public QQmlExtensionPlugin
895+{
896+ Q_OBJECT
897+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
898+
899+public:
900+ void registerTypes(const char *uri);
901+ void initializeEngine(QQmlEngine *engine, const char *uri);
902+};
903+#endif // PLUGIN_H
904
905=== added file 'plugins/wifi/qmldir'
906--- plugins/wifi/qmldir 1970-01-01 00:00:00 +0000
907+++ plugins/wifi/qmldir 2013-09-18 20:04:27 +0000
908@@ -0,0 +1,2 @@
909+module Ubuntu.SystemSettings.Wifi
910+plugin UbuntuWifiPanel
911
912=== added file 'plugins/wifi/unitymenumodelstack.cpp'
913--- plugins/wifi/unitymenumodelstack.cpp 1970-01-01 00:00:00 +0000
914+++ plugins/wifi/unitymenumodelstack.cpp 2013-09-18 20:04:27 +0000
915@@ -0,0 +1,69 @@
916+/*
917+ * Copyright 2013 Canonical Ltd.
918+ *
919+ * This program is free software; you can redistribute it and/or modify
920+ * it under the terms of the GNU General Public License as published by
921+ * the Free Software Foundation; version 3.
922+ *
923+ * This program is distributed in the hope that it will be useful,
924+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
925+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
926+ * GNU General Public License for more details.
927+ *
928+ * You should have received a copy of the GNU General Public License
929+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
930+ *
931+ * Authors:
932+ * Nick Dedekind <nick.dedekind@canonical.com>
933+ */
934+
935+#include "unitymenumodelstack.h"
936+
937+UnityMenuModelStack::UnityMenuModelStack(QObject* parent)
938+ : QObject(parent)
939+{
940+}
941+
942+UnityMenuModelStack::~UnityMenuModelStack()
943+{
944+}
945+
946+UnityMenuModel* UnityMenuModelStack::head() const
947+{
948+ return !m_menuModels.isEmpty() ? m_menuModels.first() : NULL;
949+}
950+
951+void UnityMenuModelStack::setHead(UnityMenuModel* model)
952+{
953+ if (head() != model) {
954+ m_menuModels.clear();
955+ push(model);
956+ Q_EMIT headChanged(model);
957+ }
958+}
959+
960+UnityMenuModel* UnityMenuModelStack::tail() const
961+{
962+ return !m_menuModels.isEmpty() ? m_menuModels.last() : NULL;
963+}
964+
965+void UnityMenuModelStack::push(UnityMenuModel* model)
966+{
967+ m_menuModels << model;
968+ Q_EMIT tailChanged(model);
969+}
970+
971+UnityMenuModel* UnityMenuModelStack::pop()
972+{
973+ if (m_menuModels.isEmpty()) {
974+ return NULL;
975+ }
976+ UnityMenuModel* model = m_menuModels.takeLast();
977+
978+ Q_EMIT tailChanged(tail());
979+ if (m_menuModels.isEmpty()) {
980+ Q_EMIT headChanged(NULL);
981+ }
982+
983+ return model;
984+}
985
986=== added file 'plugins/wifi/unitymenumodelstack.h'
987--- plugins/wifi/unitymenumodelstack.h 1970-01-01 00:00:00 +0000
988+++ plugins/wifi/unitymenumodelstack.h 2013-09-18 20:04:27 +0000
989@@ -0,0 +1,58 @@
990+/*
991+ * Copyright 2013 Canonical Ltd.
992+ *
993+ * This program is free software; you can redistribute it and/or modify
994+ * it under the terms of the GNU General Public License as published by
995+ * the Free Software Foundation; version 3.
996+ *
997+ * This program is distributed in the hope that it will be useful,
998+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
999+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1000+ * GNU General Public License for more details.
1001+ *
1002+ * You should have received a copy of the GNU General Public License
1003+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1004+ *
1005+ * Authors:
1006+ * Nick Dedekind <nick.dedekind@canonical.com>
1007+ */
1008+
1009+#ifndef UNITYMENUMODELSTACK_H
1010+#define UNITYMENUMODELSTACK_H
1011+
1012+#include <QObject>
1013+#include <QList>
1014+
1015+class UnityMenuModel;
1016+
1017+// A LIFO queue for storing the current submenu of a UnityMenuModel.
1018+// The root menu model is set as the head, and each subsiquent submenu that is
1019+// opened can be pushed onto the queue.
1020+// The tail is set to the last item on the queue
1021+// Popping the queue will remove the last entry, and the tail be updated to the last item.
1022+class UnityMenuModelStack : public QObject
1023+{
1024+ Q_OBJECT
1025+ Q_PROPERTY(UnityMenuModel* head READ head WRITE setHead NOTIFY headChanged)
1026+ Q_PROPERTY(UnityMenuModel* tail READ tail NOTIFY tailChanged)
1027+public:
1028+ UnityMenuModelStack(QObject*parent=NULL);
1029+ ~UnityMenuModelStack();
1030+
1031+ UnityMenuModel* head() const;
1032+ void setHead(UnityMenuModel* model);
1033+
1034+ UnityMenuModel* tail() const;
1035+
1036+ Q_INVOKABLE void push(UnityMenuModel* model);
1037+ Q_INVOKABLE UnityMenuModel* pop();
1038+
1039+Q_SIGNALS:
1040+ void headChanged(UnityMenuModel* head);
1041+ void tailChanged(UnityMenuModel* tail);
1042+
1043+private:
1044+ QList<UnityMenuModel*> m_menuModels;
1045+};
1046+
1047+#endif // UNITYMENUMODELSTACK_H
1048
1049=== modified file 'plugins/wifi/wifi.pro'
1050--- plugins/wifi/wifi.pro 2013-08-02 06:18:29 +0000
1051+++ plugins/wifi/wifi.pro 2013-09-18 20:04:27 +0000
1052@@ -4,6 +4,39 @@
1053 TEMPLATE = lib
1054 TARGET = wifi
1055
1056+QML_SOURCES = \
1057+ AccessPoint.qml \
1058+ BaseMenuItem.qml \
1059+ DivMenuItem.qml \
1060+ FramedMenuItem.qml \
1061+ HLine.qml \
1062+ IndicatorBase.qml \
1063+ MenuItemFactory.qml \
1064+ PageComponent.qml \
1065+ RemoveBackground.qml \
1066+ SectionMenuItem.qml \
1067+ StandardMenuItem.qml \
1068+ SwitchMenuItem.qml
1069+
1070+OTHER_FILES += \
1071+ $${QML_SOURCES} \
1072+ AccessPoint.qml \
1073+ BaseMenuItem.qml \
1074+ DivMenuItem.qml \
1075+ FramedMenuItem.qml \
1076+ HLine.qml \
1077+ IndicatorBase.qml \
1078+ MenuItemFactory.qml \
1079+ PageComponent.qml \
1080+ RemoveBackground.qml \
1081+ SectionMenuItem.qml \
1082+ StandardMenuItem.qml \
1083+ SwitchMenuItem.qml
1084+
1085+qml.files = $${QML_SOURCES}
1086+qml.path = $${PLUGIN_QML_DIR}/$${TARGET}
1087+INSTALLS += qml
1088+
1089 settings.files = $${TARGET}.settings
1090 settings.path = $${PLUGIN_MANIFEST_DIR}
1091 INSTALLS += settings
1092@@ -11,3 +44,39 @@
1093 image.files = settings-wifi.svg
1094 image.path = $${PLUGIN_MANIFEST_DIR}/icons
1095 INSTALLS += image
1096+
1097+# C++ bits
1098+TARGET = UbuntuWifiPanel
1099+QT += qml quick dbus
1100+CONFIG += qt plugin no_keywords
1101+
1102+TARGET = $$qtLibraryTarget($$TARGET)
1103+uri = Ubuntu.SystemSettings.Wifi
1104+
1105+SOURCES += \
1106+ plugin.cpp \
1107+ unitymenumodelstack.cpp
1108+
1109+HEADERS += \
1110+ plugin.h \
1111+ unitymenumodelstack.h
1112+
1113+unix: CONFIG += link_pkgconfig
1114+unix: PKGCONFIG += qmenumodel
1115+
1116+# Install path for the plugin
1117+installPath = $${PLUGIN_PRIVATE_MODULE_DIR}/$$replace(uri, \\., /)
1118+target.path = $$installPath
1119+INSTALLS += target
1120+
1121+# find files
1122+QMLDIR_FILE = qmldir
1123+
1124+# make visible to qt creator
1125+OTHER_FILES += $$QMLDIR_FILE
1126+
1127+# create install targets for files
1128+qmldir.path = $$installPath
1129+qmldir.files = $$QMLDIR_FILE
1130+
1131+INSTALLS += qmldir
1132
1133=== modified file 'plugins/wifi/wifi.settings'
1134--- plugins/wifi/wifi.settings 2013-08-02 11:01:13 +0000
1135+++ plugins/wifi/wifi.settings 2013-09-18 20:04:27 +0000
1136@@ -4,6 +4,9 @@
1137 "translations": "ubuntu-system-settings",
1138 "category": "network",
1139 "priority": 0,
1140+ "form-factors": [
1141+ "phone"
1142+ ],
1143 "keywords": [
1144 "network",
1145 "wireless",
1146@@ -12,5 +15,7 @@
1147 "settings"
1148 ],
1149 "has-dynamic-keywords": false,
1150- "has-dynamic-visibility": false
1151+ "has-dynamic-visibility": false,
1152+ "page-component": "PageComponent.qml",
1153+ "plugin": "UbuntuWifiPanel"
1154 }

Subscribers

People subscribed via source and target branches