Changeset View
Changeset View
Standalone View
Standalone View
libs/declarative/connectionicon.cpp
Show All 13 Lines | 1 | /* | |||
---|---|---|---|---|---|
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | Lesser General Public License for more details. | 15 | Lesser General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU Lesser General Public | 17 | You should have received a copy of the GNU Lesser General Public | ||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "connectionicon.h" | 21 | #include "connectionicon.h" | ||
22 | #include "configuration.h" | ||||
22 | #include "uiutils.h" | 23 | #include "uiutils.h" | ||
23 | 24 | | |||
24 | #include <NetworkManagerQt/BluetoothDevice> | 25 | #include <NetworkManagerQt/BluetoothDevice> | ||
25 | #include <NetworkManagerQt/Connection> | 26 | #include <NetworkManagerQt/Connection> | ||
26 | #include <NetworkManagerQt/ConnectionSettings> | 27 | #include <NetworkManagerQt/ConnectionSettings> | ||
27 | #include <NetworkManagerQt/Device> | 28 | #include <NetworkManagerQt/Device> | ||
28 | #include <NetworkManagerQt/Manager> | 29 | #include <NetworkManagerQt/Manager> | ||
29 | #include <NetworkManagerQt/ModemDevice> | 30 | #include <NetworkManagerQt/ModemDevice> | ||
30 | #include <NetworkManagerQt/WiredDevice> | 31 | #include <NetworkManagerQt/WiredDevice> | ||
31 | #include <NetworkManagerQt/WirelessDevice> | 32 | #include <NetworkManagerQt/WirelessDevice> | ||
32 | #include <NetworkManagerQt/WirelessSetting> | 33 | #include <NetworkManagerQt/WirelessSetting> | ||
33 | 34 | | |||
34 | #if WITH_MODEMMANAGER_SUPPORT | 35 | #if WITH_MODEMMANAGER_SUPPORT | ||
35 | #include <ModemManagerQt/manager.h> | 36 | #include <ModemManagerQt/manager.h> | ||
36 | #include <ModemManagerQt/modem.h> | 37 | #include <ModemManagerQt/modem.h> | ||
37 | #endif | 38 | #endif | ||
38 | 39 | | |||
39 | ConnectionIcon::ConnectionIcon(QObject* parent) | 40 | ConnectionIcon::ConnectionIcon(QObject* parent) | ||
40 | : QObject(parent) | 41 | : QObject(parent) | ||
41 | , m_signal(0) | 42 | , m_signal(0) | ||
42 | , m_wirelessNetwork(nullptr) | 43 | , m_wirelessNetwork(nullptr) | ||
43 | , m_connecting(false) | 44 | , m_connecting(false) | ||
44 | , m_limited(false) | 45 | , m_limited(false) | ||
45 | , m_vpn(false) | 46 | , m_vpn(false) | ||
46 | , m_airplaneMode(false) | | |||
47 | #if WITH_MODEMMANAGER_SUPPORT | 47 | #if WITH_MODEMMANAGER_SUPPORT | ||
48 | , m_modemNetwork(nullptr) | 48 | , m_modemNetwork(nullptr) | ||
49 | #endif | 49 | #endif | ||
50 | { | 50 | { | ||
51 | connect(NetworkManager::notifier(), &NetworkManager::Notifier::primaryConnectionChanged, this, &ConnectionIcon::primaryConnectionChanged); | 51 | connect(NetworkManager::notifier(), &NetworkManager::Notifier::primaryConnectionChanged, this, &ConnectionIcon::primaryConnectionChanged); | ||
52 | connect(NetworkManager::notifier(), &NetworkManager::Notifier::activatingConnectionChanged, this, &ConnectionIcon::activatingConnectionChanged); | 52 | connect(NetworkManager::notifier(), &NetworkManager::Notifier::activatingConnectionChanged, this, &ConnectionIcon::activatingConnectionChanged); | ||
53 | connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionAdded, this, &ConnectionIcon::activeConnectionAdded); | 53 | connect(NetworkManager::notifier(), &NetworkManager::Notifier::activeConnectionAdded, this, &ConnectionIcon::activeConnectionAdded); | ||
54 | connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityChanged, this, &ConnectionIcon::connectivityChanged); | 54 | connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityChanged, this, &ConnectionIcon::connectivityChanged); | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 98 | { | |||
107 | return m_connectionIcon; | 107 | return m_connectionIcon; | ||
108 | } | 108 | } | ||
109 | 109 | | |||
110 | QString ConnectionIcon::connectionTooltipIcon() const | 110 | QString ConnectionIcon::connectionTooltipIcon() const | ||
111 | { | 111 | { | ||
112 | return m_connectionTooltipIcon; | 112 | return m_connectionTooltipIcon; | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | bool ConnectionIcon::airplaneMode() const | | |||
116 | { | | |||
117 | return m_airplaneMode; | | |||
118 | } | | |||
119 | | ||||
120 | void ConnectionIcon::setAirplaneMode(bool airplaneMode) | | |||
121 | { | | |||
122 | if (m_airplaneMode != airplaneMode) { | | |||
123 | m_airplaneMode = airplaneMode; | | |||
124 | Q_EMIT airplaneModeChanged(airplaneMode); | | |||
125 | | ||||
126 | setIcons(); | | |||
127 | } | | |||
128 | } | | |||
129 | | ||||
130 | void ConnectionIcon::activatingConnectionChanged(const QString& connection) | 115 | void ConnectionIcon::activatingConnectionChanged(const QString& connection) | ||
131 | { | 116 | { | ||
132 | Q_UNUSED(connection); | 117 | Q_UNUSED(connection); | ||
133 | setIcons(); | 118 | setIcons(); | ||
134 | } | 119 | } | ||
135 | 120 | | |||
136 | void ConnectionIcon::addActiveConnection(const QString &activeConnection) | 121 | void ConnectionIcon::addActiveConnection(const QString &activeConnection) | ||
137 | { | 122 | { | ||
▲ Show 20 Lines • Show All 274 Lines • ▼ Show 20 Line(s) | 382 | #endif | |||
412 | } | 397 | } | ||
413 | } else { | 398 | } else { | ||
414 | setDisconnectedIcon(); | 399 | setDisconnectedIcon(); | ||
415 | } | 400 | } | ||
416 | } | 401 | } | ||
417 | 402 | | |||
418 | void ConnectionIcon::setDisconnectedIcon() | 403 | void ConnectionIcon::setDisconnectedIcon() | ||
419 | { | 404 | { | ||
420 | if (m_airplaneMode) { | 405 | if (Configuration::airplaneModeEnabled()) { | ||
421 | setConnectionIcon(QStringLiteral("network-flightmode-on")); | 406 | setConnectionIcon(QStringLiteral("network-flightmode-on")); | ||
422 | return; | 407 | return; | ||
423 | } | 408 | } | ||
424 | 409 | | |||
425 | if (NetworkManager::status() == NetworkManager::Unknown || | 410 | if (NetworkManager::status() == NetworkManager::Unknown || | ||
426 | NetworkManager::status() == NetworkManager::Asleep) { | 411 | NetworkManager::status() == NetworkManager::Asleep) { | ||
427 | setConnectionIcon("network-unavailable"); | 412 | setConnectionIcon("network-unavailable"); | ||
428 | return; | 413 | return; | ||
▲ Show 20 Lines • Show All 223 Lines • Show Last 20 Lines |