Merge lp:~aacid/connectivity-api/networking_status_singleton into lp:connectivity-api/14.10

Proposed by Albert Astals Cid
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 21
Merged at revision: 20
Proposed branch: lp:~aacid/connectivity-api/networking_status_singleton
Merge into: lp:connectivity-api/14.10
Diff against target: 96 lines (+20/-11)
4 files modified
doc/qt/qml/examples/example_networking_status.qml (+4/-5)
doc/qt/qml/qml-api/NetworkingStatus.qml (+2/-0)
src/qt/qml/Ubuntu/Connectivity/plugin.cpp (+9/-1)
tests/integration/qt/qml/tst_api.qml (+5/-5)
To merge this branch: bzr merge lp:~aacid/connectivity-api/networking_status_singleton
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Antti Kaijanmäki (community) Approve
Review via email: mp+232248@code.launchpad.net

Commit message

Make NetworkingStatus a singleton

This way it can be used from various places of an app without having to worry creating lots of them or to pass the information down

To post a comment you must log in.
21. By Albert Astals Cid

Give it a parent

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

Thanks!
LGTM.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'doc/qt/qml/examples/example_networking_status.qml'
--- doc/qt/qml/examples/example_networking_status.qml 2014-08-19 19:31:12 +0000
+++ doc/qt/qml/examples/example_networking_status.qml 2014-08-26 16:11:23 +0000
@@ -30,9 +30,8 @@
30 property real margins: units.gu(2)30 property real margins: units.gu(2)
31 property real buttonWidth: units.gu(9)31 property real buttonWidth: units.gu(9)
3232
33 // create the NetworkingStatus object33 Connections {
34 NetworkingStatus {34 target: NetworkingStatus
35 id: networkingStatus
3635
37 // full status can be retrieved from the base C++ class36 // full status can be retrieved from the base C++ class
38 // status property37 // status property
@@ -53,12 +52,12 @@
53 anchors.centerIn: parent52 anchors.centerIn: parent
54 Label {53 Label {
55 // use the online property54 // use the online property
56 text: networkingStatus.online ? "Online" : "Not online"55 text: NetworkingStatus.online ? "Online" : "Not online"
57 fontSize: "large"56 fontSize: "large"
58 }57 }
59 Label {58 Label {
60 // use the limitedBandwith property59 // use the limitedBandwith property
61 text: networkingStatus.limitedBandwith ? "Bandwith limited" : "Bandwith not limited"60 text: NetworkingStatus.limitedBandwith ? "Bandwith limited" : "Bandwith not limited"
62 fontSize: "large"61 fontSize: "large"
63 }62 }
64 }63 }
6564
=== modified file 'doc/qt/qml/qml-api/NetworkingStatus.qml'
--- doc/qt/qml/qml-api/NetworkingStatus.qml 2014-08-19 19:31:12 +0000
+++ doc/qt/qml/qml-api/NetworkingStatus.qml 2014-08-26 16:11:23 +0000
@@ -30,6 +30,8 @@
30 and provides two utility properties online and limitedBandwith for easier30 and provides two utility properties online and limitedBandwith for easier
31 QML usage.31 QML usage.
3232
33 This object is exposed as a singleton.
34
33 \b{note:}35 \b{note:}
34 Using this component in confined application requires \e{connectivity} policy group.36 Using this component in confined application requires \e{connectivity} policy group.
3537
3638
=== modified file 'src/qt/qml/Ubuntu/Connectivity/plugin.cpp'
--- src/qt/qml/Ubuntu/Connectivity/plugin.cpp 2014-08-19 19:31:12 +0000
+++ src/qt/qml/Ubuntu/Connectivity/plugin.cpp 2014-08-26 16:11:23 +0000
@@ -23,11 +23,19 @@
2323
24#include "networking-status.h"24#include "networking-status.h"
2525
26static QObject *
27networkingStatusSingletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
28{
29 Q_UNUSED(scriptEngine)
30
31 return new NetworkingStatus(engine);
32}
33
26void34void
27QmlConnectivityNetworkingPlugin::registerTypes(const char *uri)35QmlConnectivityNetworkingPlugin::registerTypes(const char *uri)
28{36{
29 // @uri Ubuntu.Connectivity37 // @uri Ubuntu.Connectivity
30 qmlRegisterType<NetworkingStatus> (uri, 1, 0, "NetworkingStatus");38 qmlRegisterSingletonType<NetworkingStatus>(uri, 1, 0, "NetworkingStatus", networkingStatusSingletonProvider);
31}39}
3240
33void41void
3442
=== modified file 'tests/integration/qt/qml/tst_api.qml'
--- tests/integration/qt/qml/tst_api.qml 2014-08-19 19:31:12 +0000
+++ tests/integration/qt/qml/tst_api.qml 2014-08-26 16:11:23 +0000
@@ -29,8 +29,8 @@
29 */29 */
30Item {30Item {
3131
32 NetworkingStatus {32 Connections {
33 id: networkingStatus33 target: NetworkingStatus
34 onStatusChanged: {}34 onStatusChanged: {}
35 onLimitationsChanged: {}35 onLimitationsChanged: {}
36 onOnlineChanged: {}36 onOnlineChanged: {}
@@ -41,9 +41,9 @@
41 name: "API Test"41 name: "API Test"
42 id: test_api42 id: test_api
4343
44 property int status : networkingStatus.status44 property int status : NetworkingStatus.status
45 property int online : networkingStatus.online45 property int online : NetworkingStatus.online
46 property int limitedBandwith : networkingStatus.limitedBandwith46 property int limitedBandwith : NetworkingStatus.limitedBandwith
4747
48 function test_api() {48 function test_api() {
49 // just make sure this file can be loaded properly by the QmlEngine.49 // just make sure this file can be loaded properly by the QmlEngine.

Subscribers

People subscribed via source and target branches