2 * Copyright 2013 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
20#include "indicatorclient_network.h"
21#include "networkagent.h"
27#include <qdbusmenumodel.h>
28#include <qdbusactiongroup.h>
29#include <qstateaction.h>
31IndicatorClientNetwork::IndicatorClientNetwork(QObject *parent)
32 : IndicatorClientCommon(parent),
36 setPriority(IndicatorPriority::NETWORK);
38 m_timedAnimation.setInterval(500);
39 connect(&m_timedAnimation, SIGNAL(timeout()), SLOT(animationNextFrame()));
42IndicatorClientNetwork::~IndicatorClientNetwork()
46void IndicatorClientNetwork::init(const QSettings& settings)
48 IndicatorClientCommon::init(settings);
49 Q_INIT_RESOURCE(indicatorclient_network);
51 qmlRegisterType<NetworkAgent>("NetworkSettings", 0, 1, "NetworkAgent");
52 setIcon(QUrl("image://gicon/wifi-none"));
55QQmlComponent *IndicatorClientNetwork::createComponent(QQmlEngine *engine, QObject *parent) const
57 return new QQmlComponent(engine, QUrl("qrc:/indicatorclient/network/qml/NetworkPage.qml"), parent);
60IndicatorClientInterface::WidgetsMap IndicatorClientNetwork::widgets()
64 w.insert("unity.widget.systemsettings.tablet.sectiontitle", QUrl("qrc:/indicatorclient/network/qml/WifiSection.qml"));
65 w.insert("unity.widgets.systemsettings.tablet.wifisection", QUrl("qrc:/indicatorclient/network/qml/WifiSection.qml"));
66 w.insert("unity.widgets.systemsettings.tablet.accesspoint", QUrl("qrc:/indicatorclient/network/qml/Accesspoint.qml"));
71bool IndicatorClientNetwork::parseRootElement(const QString &type, QMap<int, QVariant> data)
73 if (type == "com.canonical.indicator.root.network") {
78 QVariant action = data[QDBusMenuModel::Action];
79 m_action = actionGroup()->action(action.toString());
80 if (m_action->isValid()) {
81 updateNetworkStatus(m_action->state());
83 connect(m_action, SIGNAL(stateChanged(QVariant)), SLOT(updateNetworkStatus(QVariant)));
90QString IndicatorClientNetwork::getIconBasedOnSingal(uint signal) const
93 return "nm-signal-00";
94 } else if (signal <= 25) {
95 return "nm-signal-25";
96 } else if (signal <= 50) {
97 return "nm-signal-50";
98 } else if (signal <= 75) {
99 return "nm-signal-75";
101 return "nm-signal-100";
105void IndicatorClientNetwork::animationNextFrame()
107 static int frame = 0;
111 iconName = "nm-signal-00";
114 iconName = "nm-signal-25";
117 iconName = "nm-signal-50";
120 iconName = "nm-signal-75";
123 iconName = "nm-signal-100";
132 setIcon(QUrl("image://gicon/" + iconName));
135void IndicatorClientNetwork::updateNetworkStatus(const QVariant &state)
137 if (state.isValid()) {
140 // - Connection state
142 QVariantList states = state.toList();
143 if (states.size() == 3) {
145 uint connectionState = states[1].toUInt();
146 switch (connectionState)
148 case 3: // NM_ACTIVE_CONNECTION_STATE_DEACTIVATING
149 case 1: // NM_ACTIVE_CONNECTION_STATE_ACTIVATING
150 m_timedAnimation.start();
151 iconName = "nm-signal-100";
153 case 2: // NM_ACTIVE_CONNECTION_STATE_ACTIVATED
154 m_timedAnimation.stop();
155 iconName = getIconBasedOnSingal(states[2].toUInt());
157 case 0: // NM_ACTIVE_CONNECTION_STATE_UNKNOWN
159 m_timedAnimation.stop();
160 iconName = "wifi-none";
164 setIcon(QUrl("image://gicon/" + iconName));
167 qWarning() << "Invalid network root state value";
168 m_timedAnimation.stop();
172 qWarning() << "Invalid network root state";
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list