Merge lp:~unity-api-team/indicator-network/mobile-switch into lp:indicator-network

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 602
Merged at revision: 601
Proposed branch: lp:~unity-api-team/indicator-network/mobile-switch
Merge into: lp:indicator-network
Prerequisite: lp:~pete-woods/indicator-network/improve-logging
Diff against target: 145 lines (+32/-10)
5 files modified
src/indicator/factory.cpp (+18/-2)
src/indicator/factory.h (+1/-1)
src/indicator/menu-builder.cpp (+3/-1)
src/indicator/sections/wwan-section.cpp (+9/-5)
src/indicator/sections/wwan-section.h (+1/-1)
To merge this branch: bzr merge lp:~unity-api-team/indicator-network/mobile-switch
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Pending
Indicator Applet Developers Pending
Review via email: mp+295940@code.launchpad.net

This proposal supersedes a proposal from 2016-05-05.

Commit message

add mobile data switch

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/indicator/factory.cpp'
--- src/indicator/factory.cpp 2016-04-29 14:20:09 +0000
+++ src/indicator/factory.cpp 2016-05-27 11:26:43 +0000
@@ -155,9 +155,9 @@
155 return make_unique<QuickAccessSection>(d->singletonNmofono(), flightModeSwitch);155 return make_unique<QuickAccessSection>(d->singletonNmofono(), flightModeSwitch);
156}156}
157157
158unique_ptr<WwanSection> Factory::newWwanSection(SwitchItem::Ptr hotspotSwitch)158unique_ptr<WwanSection> Factory::newWwanSection(SwitchItem::Ptr mobileDataSwitch, SwitchItem::Ptr hotspotSwitch)
159{159{
160 return make_unique<WwanSection>(d->singletonNmofono(), hotspotSwitch);160 return make_unique<WwanSection>(d->singletonNmofono(), mobileDataSwitch, hotspotSwitch);
161}161}
162162
163unique_ptr<VpnSection> Factory::newVpnSection()163unique_ptr<VpnSection> Factory::newVpnSection()
@@ -206,6 +206,22 @@
206SwitchItem::UPtr Factory::newMobileDataSwitch()206SwitchItem::UPtr Factory::newMobileDataSwitch()
207{207{
208 auto s = make_unique<SwitchItem>(_("Cellular data"), "mobiledata", "enabled");208 auto s = make_unique<SwitchItem>(_("Cellular data"), "mobiledata", "enabled");
209 auto manager = d->singletonNmofono();
210
211 s->setState(manager->mobileDataEnabled());
212 QObject::connect(manager.get(), &nmofono::Manager::mobileDataEnabledChanged, s.get(), &SwitchItem::setState);
213 QObject::connect(s.get(), &SwitchItem::stateUpdated, manager.get(), &nmofono::Manager::setMobileDataEnabled);
214
215 s->setEnabled(!manager->flightMode() && manager->simForMobileData());
216 auto switch_r = s.get();
217 auto manager_r = manager.get();
218 QObject::connect(manager_r, &nmofono::Manager::flightModeUpdated, switch_r, [manager_r, switch_r](bool value) {
219 switch_r->setEnabled(!value && manager_r->simForMobileData());
220 });
221 QObject::connect(manager_r, &nmofono::Manager::simForMobileDataChanged, switch_r, [manager_r, switch_r]() {
222 switch_r->setEnabled(!manager_r->flightMode() && manager_r->simForMobileData());
223 });
224
209 return s;225 return s;
210}226}
211227
212228
=== modified file 'src/indicator/factory.h'
--- src/indicator/factory.h 2016-04-29 09:36:10 +0000
+++ src/indicator/factory.h 2016-05-27 11:26:43 +0000
@@ -56,7 +56,7 @@
5656
57 virtual std::unique_ptr<QuickAccessSection> newQuickAccessSection(SwitchItem::Ptr flightModeSwitch);57 virtual std::unique_ptr<QuickAccessSection> newQuickAccessSection(SwitchItem::Ptr flightModeSwitch);
5858
59 virtual std::unique_ptr<WwanSection> newWwanSection(SwitchItem::Ptr hotspotSwitch);59 virtual std::unique_ptr<WwanSection> newWwanSection(SwitchItem::Ptr mobileDataSwitch, SwitchItem::Ptr hotspotSwitch);
6060
61 virtual std::unique_ptr<WifiSection> newWiFiSection(SwitchItem::Ptr wifiSwitch);61 virtual std::unique_ptr<WifiSection> newWiFiSection(SwitchItem::Ptr wifiSwitch);
6262
6363
=== modified file 'src/indicator/menu-builder.cpp'
--- src/indicator/menu-builder.cpp 2015-10-06 10:14:57 +0000
+++ src/indicator/menu-builder.cpp 2016-05-27 11:26:43 +0000
@@ -43,6 +43,7 @@
43 RootState::Ptr m_rootState;43 RootState::Ptr m_rootState;
4444
45 SwitchItem::Ptr m_flightModeSwitch;45 SwitchItem::Ptr m_flightModeSwitch;
46 SwitchItem::Ptr m_mobileDataSwitch;
46 SwitchItem::Ptr m_hotspotSwitch;47 SwitchItem::Ptr m_hotspotSwitch;
47 SwitchItem::Ptr m_wifiSwitch;48 SwitchItem::Ptr m_wifiSwitch;
4849
@@ -111,6 +112,7 @@
111 d->m_ubiquityMenu = factory.newIndicatorMenu(d->m_rootState, "ubiquity");112 d->m_ubiquityMenu = factory.newIndicatorMenu(d->m_rootState, "ubiquity");
112113
113 d->m_flightModeSwitch = factory.newFlightModeSwitch();114 d->m_flightModeSwitch = factory.newFlightModeSwitch();
115 d->m_mobileDataSwitch = factory.newMobileDataSwitch();
114 d->m_hotspotSwitch = factory.newHotspotSwitch();116 d->m_hotspotSwitch = factory.newHotspotSwitch();
115 d->m_wifiSwitch = factory.newWifiSwitch();117 d->m_wifiSwitch = factory.newWifiSwitch();
116118
@@ -125,7 +127,7 @@
125 d.get(), &Priv::updateHotspotSwitch);127 d.get(), &Priv::updateHotspotSwitch);
126128
127 d->m_quickAccessSection = factory.newQuickAccessSection(d->m_flightModeSwitch);129 d->m_quickAccessSection = factory.newQuickAccessSection(d->m_flightModeSwitch);
128 d->m_wwanSection = factory.newWwanSection(d->m_hotspotSwitch);130 d->m_wwanSection = factory.newWwanSection(d->m_mobileDataSwitch, d->m_hotspotSwitch);
129 d->m_wifiSection = factory.newWiFiSection(d->m_wifiSwitch);131 d->m_wifiSection = factory.newWiFiSection(d->m_wifiSwitch);
130 d->m_vpnSection = factory.newVpnSection();132 d->m_vpnSection = factory.newVpnSection();
131133
132134
=== modified file 'src/indicator/sections/wwan-section.cpp'
--- src/indicator/sections/wwan-section.cpp 2016-02-12 14:25:16 +0000
+++ src/indicator/sections/wwan-section.cpp 2016-05-27 11:26:43 +0000
@@ -54,13 +54,14 @@
5454
55 Manager::Ptr m_manager;55 Manager::Ptr m_manager;
5656
57 SwitchItem::Ptr m_mobileDataSwitch;
57 SwitchItem::Ptr m_hotspotSwitch;58 SwitchItem::Ptr m_hotspotSwitch;
58 TextItem::Ptr m_openCellularSettings;59 TextItem::Ptr m_openCellularSettings;
5960
60 QMap<wwan::Modem::Ptr, WwanLinkItem::Ptr> m_items;61 QMap<wwan::Modem::Ptr, WwanLinkItem::Ptr> m_items;
6162
62 Private() = delete;63 Private() = delete;
63 Private(Manager::Ptr modemManager, SwitchItem::Ptr hotspotSwitch);64 Private(Manager::Ptr modemManager, SwitchItem::Ptr mobileDataSwitch ,SwitchItem::Ptr hotspotSwitch);
6465
65public Q_SLOTS:66public Q_SLOTS:
66 void modemsChanged();67 void modemsChanged();
@@ -77,8 +78,8 @@
77 }78 }
78};79};
7980
80WwanSection::Private::Private(Manager::Ptr modemManager, SwitchItem::Ptr hotspotSwitch)81WwanSection::Private::Private(Manager::Ptr modemManager, SwitchItem::Ptr mobileDataSwitch,SwitchItem::Ptr hotspotSwitch)
81 : QObject(nullptr), m_manager{modemManager}, m_hotspotSwitch{hotspotSwitch}82 : QObject(nullptr), m_manager{modemManager}, m_mobileDataSwitch{mobileDataSwitch}, m_hotspotSwitch{hotspotSwitch}
82{83{
83 m_actionGroupMerger = make_shared<ActionGroupMerger>();84 m_actionGroupMerger = make_shared<ActionGroupMerger>();
84 m_menuMerger = make_shared<MenuMerger>();85 m_menuMerger = make_shared<MenuMerger>();
@@ -91,6 +92,9 @@
91 m_menuMerger->append(m_linkMenuMerger);92 m_menuMerger->append(m_linkMenuMerger);
92 m_menuMerger->append(m_bottomMenu);93 m_menuMerger->append(m_bottomMenu);
9394
95 m_upperMenu->append(m_mobileDataSwitch->menuItem());
96 m_actionGroupMerger->add(m_mobileDataSwitch->actionGroup());
97
94 // have the modem list in their own section.98 // have the modem list in their own section.
95 m_topItem = MenuItem::newSection(m_menuMerger);99 m_topItem = MenuItem::newSection(m_menuMerger);
96 m_topMenu = make_shared<Menu>();100 m_topMenu = make_shared<Menu>();
@@ -186,8 +190,8 @@
186 }190 }
187}191}
188192
189WwanSection::WwanSection(nmofono::Manager::Ptr manager, SwitchItem::Ptr hotspotSwitch)193WwanSection::WwanSection(nmofono::Manager::Ptr manager, SwitchItem::Ptr mobileDataSwitch, SwitchItem::Ptr hotspotSwitch)
190 : d{new Private(manager, hotspotSwitch)}194 : d{new Private(manager, mobileDataSwitch, hotspotSwitch)}
191{195{
192}196}
193197
194198
=== modified file 'src/indicator/sections/wwan-section.h'
--- src/indicator/sections/wwan-section.h 2015-08-14 15:52:39 +0000
+++ src/indicator/sections/wwan-section.h 2016-05-27 11:26:43 +0000
@@ -30,7 +30,7 @@
3030
31public:31public:
32 typedef std::shared_ptr<WwanSection> Ptr;32 typedef std::shared_ptr<WwanSection> Ptr;
33 explicit WwanSection(nmofono::Manager::Ptr modemManager, SwitchItem::Ptr hotspotSwitch);33 explicit WwanSection(nmofono::Manager::Ptr modemManager, SwitchItem::Ptr mobileDataSwitch, SwitchItem::Ptr hotspotSwitch);
34 virtual ~WwanSection();34 virtual ~WwanSection();
3535
36 virtual ActionGroup::Ptr actionGroup();36 virtual ActionGroup::Ptr actionGroup();

Subscribers

People subscribed via source and target branches