~ci-train-bot/indicator-network/indicator-network-ubuntu-yakkety-landing-016

« back to all changes in this revision

Viewing changes to src/indicator/menu-builder.cpp

  • Committer: Bileto Bot
  • Author(s): Antti Kaijanmäki
  • Date: 2016-07-05 10:50:35 UTC
  • mfrom: (580.4.44 trunk)
  • Revision ID: ci-train-bot@canonical.com-20160705105035-sd9licwjiasi8u9m
Mobile Data Switch should also track the presence of the SimForMobileData. (LP: #1597615)

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        m_flightModeSwitch->setEnabled(!happening);
78
78
        m_wifiSwitch->setEnabled(!happening);
79
79
        updateHotspotSwitch();
 
80
        updateMobileDataSwitch();
80
81
 
81
82
        if (happening)
82
83
        {
91
92
            !m_manager->unstoppableOperationHappening()
92
93
            && !m_manager->flightMode());
93
94
    }
 
95
 
 
96
    void updateMobileDataSwitch()
 
97
    {
 
98
        m_mobileDataSwitch->setEnabled(!m_manager->flightMode() &&
 
99
                                        m_manager->simForMobileData() &&
 
100
                                        m_manager->simForMobileData()->present() &&
 
101
                                       !m_manager->unstoppableOperationHappening());
 
102
    }
 
103
 
 
104
    void updateSimForMobileData()
 
105
    {
 
106
        auto sim = m_manager->simForMobileData();
 
107
        if (sim)
 
108
        {
 
109
            QObject::connect(sim.get(), &nmofono::wwan::Sim::presentChanged,
 
110
                             this, &Priv::updateMobileDataSwitch);
 
111
        }
 
112
        updateMobileDataSwitch();
 
113
    }
94
114
};
95
115
 
96
116
MenuBuilder::MenuBuilder(nmofono::Manager::Ptr manager, Factory& factory) :
126
146
    connect(d->m_manager.get(), &nmofono::Manager::wifiEnabledUpdated,
127
147
            d.get(), &Priv::updateHotspotSwitch);
128
148
 
 
149
    // mobile data enabled depend on these properties
 
150
    connect(d->m_manager.get(), &nmofono::Manager::flightModeUpdated,
 
151
            d.get(), &Priv::updateMobileDataSwitch);
 
152
    connect(d->m_manager.get(), &nmofono::Manager::simForMobileDataChanged,
 
153
            d.get(), &Priv::updateSimForMobileData);
 
154
    // call updateSimForMobileData to also connect to the Sim::presentChanged()
 
155
    d->updateSimForMobileData();
 
156
 
129
157
    d->m_quickAccessSection = factory.newQuickAccessSection(d->m_flightModeSwitch);
130
158
    d->m_wwanSection = factory.newWwanSection(d->m_mobileDataSwitch, d->m_hotspotSwitch);
131
159
    d->m_wifiSection = factory.newWiFiSection(d->m_wifiSwitch);