2
Copyright 2008, 2009 Will Stephenson <wstephenson@kde.org>
3
Copyright 2008, 2009 Sebastian Kügler <sebas@kde.org>
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License or (at your option) version 3 or any later version
9
accepted by the membership of KDE e.V. (or its successor approved
10
by the membership of KDE e.V.), which shall act as a proxy
11
defined in Section 14 of version 3 of the license.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
22
#include "networkmanager.h"
26
#include <QPaintEngine>
28
#include <QDesktopWidget>
29
#include <QGraphicsPixmapItem>
32
#include <QGraphicsBlurEffect>
34
#include <KCModuleProxy>
35
#include <KCModuleInfo>
37
#include <KIconLoader>
38
#include <KToolInvocation>
39
#include <KConfigDialog>
42
#include <KNotification>
43
#include <KPushButton>
44
#include <kdeversion.h>
46
#include <solid/device.h>
47
#include <solid/networking.h>
48
#include <solid/control/networking.h>
49
#include <solid/control/networkinterface.h>
50
#include <solid/control/wirednetworkinterface.h>
51
#include <solid/control/wirelessnetworkinterface.h>
52
#include <solid/control/networkmanager.h>
54
#include <Plasma/Animator>
55
#include <Plasma/CheckBox>
56
#include <Plasma/Theme>
58
#include "../libs/types.h"
59
#include "knmserviceprefs.h"
60
#include "remoteactivatablelist.h"
66
K_EXPORT_PLASMA_APPLET(networkmanagement, NetworkManagerApplet)
69
bool networkInterfaceLessThan(Solid::Control::NetworkInterfaceNm09 * if1, Solid::Control::NetworkInterfaceNm09 * if2);
70
bool networkInterfaceSameConnectionStateLessThan(Solid::Control::NetworkInterfaceNm09 * if1, Solid::Control::NetworkInterfaceNm09 * if2);
72
NetworkManagerApplet::NetworkManagerApplet(QObject * parent, const QVariantList & args)
73
: Plasma::PopupApplet(parent, args),
74
m_iconPerDevice(false),
78
KGlobal::locale()->insertCatalog("libknetworkmanager");
79
KGlobal::locale()->insertCatalog("solidcontrol");
81
setHasConfigurationInterface(true);
82
setPopupIcon(QIcon());
83
//setPassivePopup(true); // FIXME: disable, only true for testing ...
84
m_overlayTimeline.setEasingCurve(QEasingCurve::OutExpo);
85
m_currentState = Solid::Control::NetworkInterfaceNm09::UnknownState;
86
connect(&m_overlayTimeline, SIGNAL(valueChanged(qreal)), this, SLOT(repaint()));
88
Plasma::ToolTipManager::self()->registerWidget(this);
89
setAspectRatioMode(Plasma::ConstrainedSquare);
91
m_svg = new Plasma::Svg(this);
92
m_svg->setImagePath("icons/network");
93
m_svg->setContainsMultipleImages(true);
94
m_meterBgSvg = new Plasma::FrameSvg(this);
95
m_meterBgSvg->setImagePath("widgets/bar_meter_horizontal");
96
m_meterBgSvg->setElementPrefix("bar-inactive");
97
m_meterFgSvg = new Plasma::FrameSvg(this);
98
m_meterFgSvg->setImagePath("widgets/bar_meter_horizontal");
99
m_meterFgSvg->setElementPrefix("bar-active");
100
setStatus(Plasma::ActiveStatus);
101
m_interfaces = Solid::Control::NetworkManagerNm09::networkInterfaces();
102
if (activeInterface()) {
103
m_currentState = static_cast<Solid::Control::NetworkInterfaceNm09::ConnectionState>(activeInterface()->connectionState());
105
interfaceConnectionStateChanged();
106
m_activatables = new RemoteActivatableList(this);
107
setMinimumSize(16, 16);
109
//(void)graphicsWidget();
112
NetworkManagerApplet::~NetworkManagerApplet()
116
QString NetworkManagerApplet::svgElement(Solid::Control::NetworkInterfaceNm09 *iface)
118
if (iface->type() != Solid::Control::NetworkInterfaceNm09::Wifi
119
&& iface->type() != Solid::Control::NetworkInterfaceNm09::Ethernet) {
124
int _s = qMin(contentsRect().width(), contentsRect().height());
126
// Figure out the maximum size of the element
127
// those pixelsizes are taken from the svg
143
// For our fixed sizes, we want a fixed rect to render into
144
if (_s >= 19 && _s <= 76) {
145
m_contentSquare = QRect(contentsRect().x() + (contentsRect().width() - s) / 2,
146
contentsRect().y() + (contentsRect().height() - s) / 2,
148
} else { // .... otherwise, for free scaling, we just want a square that fits in
149
m_contentSquare = QRect(contentsRect().x() + (contentsRect().width() - _s) / 2,
150
contentsRect().y() + (contentsRect().height() - _s) / 2,
154
if (iface->type() == Solid::Control::NetworkInterfaceNm09::Ethernet) {
155
if (iface->connectionState() == Solid::Control::NetworkInterfaceNm09::Activated) {
156
icon = "network-wired-activated";
158
icon = "network-wired";
163
// Now figure out which exact element we'll use
164
QString strength = "00";
165
Solid::Control::WirelessNetworkInterfaceNm09 *wiface = qobject_cast<Solid::Control::WirelessNetworkInterfaceNm09*>(iface);
168
QString uni = wiface->activeAccessPoint();
169
Solid::Control::AccessPointNm09 *ap = wiface->findAccessPoint(uni);
171
int str = ap->signalStrength();
174
} else if (str < 30) {
176
} else if (str < 50) {
178
} else if (str < 70) {
180
} else if (str < 90) {
189
return QString("dialog-error");
191
QString w = QString::number(s);
193
// The format in the SVG looks like this: wireless-signal-<strenght>
194
icon = QString("network-wireless-%1").arg(strength);
195
//kDebug() << "Icon:" << icon;
199
void NetworkManagerApplet::setupInterfaceSignals()
201
foreach (Solid::Control::NetworkInterfaceNm09* interface, m_interfaces) {
202
// be aware of state changes
203
QObject::disconnect(interface, SIGNAL(connectionStateChanged(int, int, int)), this, SLOT(interfaceConnectionStateChanged()));
204
QObject::disconnect(interface, SIGNAL(connectionStateChanged(int)), this, SLOT(interfaceConnectionStateChanged()));
205
QObject::disconnect(interface, SIGNAL(linkUpChanged(bool)));
207
//connect(iface, SIGNAL(connectionStateChanged(int,int,int)), this, SLOT(handleConnectionStateChange(int,int,int)));
208
connect(interface, SIGNAL(connectionStateChanged(int,int,int)), this, SLOT(interfaceConnectionStateChanged()));
209
//connect(iface, SIGNAL(linkUpChanged(bool)), this, SLOT(switchToDefaultTab()));
211
QObject::connect(interface, SIGNAL(connectionStateChanged(int)), this, SLOT(interfaceConnectionStateChanged()));
212
QObject::connect(interface, SIGNAL(linkUpChanged(bool)), this, SLOT(interfaceConnectionStateChanged()));
214
// Interface type-specific connections
215
if (interface->type() == Solid::Control::NetworkInterfaceNm09::Ethernet) {
216
Solid::Control::WiredNetworkInterfaceNm09* wirediface =
217
static_cast<Solid::Control::WiredNetworkInterfaceNm09*>(interface);
218
connect(wirediface, SIGNAL(carrierChanged(bool)), this, SLOT(interfaceConnectionStateChanged()));
219
} else if (interface->type() == Solid::Control::NetworkInterfaceNm09::Wifi) {
220
Solid::Control::WirelessNetworkInterfaceNm09* wirelessiface =
221
static_cast<Solid::Control::WirelessNetworkInterfaceNm09*>(interface);
222
connect(wirelessiface, SIGNAL(activeAccessPointChanged(const QString&)), SLOT(interfaceConnectionStateChanged()));
223
QString uni = wirelessiface->activeAccessPoint();
224
Solid::Control::AccessPointNm09 *ap = wirelessiface->findAccessPoint(uni);
226
connect(ap, SIGNAL(signalStrengthChanged(int)), SLOT(interfaceConnectionStateChanged()));
227
connect(ap, SIGNAL(destroyed(QObject*)), SLOT(interfaceConnectionStateChanged()));
233
void NetworkManagerApplet::init()
235
// bogus, just to make sure we have some remotely sensible value
236
m_contentSquare = contentsRect().toRect();
239
QObject::connect(Solid::Control::NetworkManagerNm09::notifier(), SIGNAL(networkInterfaceAdded(const QString&)),
240
this, SLOT(networkInterfaceAdded(const QString&)));
241
QObject::connect(Solid::Control::NetworkManagerNm09::notifier(), SIGNAL(networkInterfaceRemoved(const QString&)),
242
this, SLOT(networkInterfaceRemoved(const QString&)));
244
QObject::connect(Solid::Control::NetworkManagerNm09::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)),
245
this, SLOT(managerStatusChanged(Solid::Networking::Status)));
247
m_activatables->init();
248
setupInterfaceSignals();
250
// Just to make sure the kded module is loaded.
251
QDBusInterface kded(QLatin1String("org.kde.kded"), QLatin1String("/kded"),
252
QLatin1String("org.kde.kded"), QDBusConnection::sessionBus());
254
kded.call(QLatin1String("loadModule"), QLatin1String("networkmanagement"));
256
// Import old connection files.
257
QDBusInterface networkmanagement(QLatin1String("org.kde.networkmanagement"), QLatin1String("/org/kde/networkmanagement"),
258
QLatin1String("org.kde.networkmanagement"), QDBusConnection::sessionBus());
260
networkmanagement.call(QLatin1String("ImportNm08Connections"));
263
void NetworkManagerApplet::configChanged()
265
KConfigGroup cg = config();
266
m_iconPerDevice = cg.readEntry("IconPerDevice", false);
271
QGraphicsWidget* NetworkManagerApplet::graphicsWidget()
274
m_popup = new NMPopup(m_activatables, this);
275
connect(m_popup, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));
281
void NetworkManagerApplet::createConfigurationInterface(KConfigDialog *parent)
283
// Add the networkmanager KCM pages to the applet's configdialog
284
m_kcmNM = new KCModuleProxy("kcm_networkmanagement");
285
m_kcmNMTray = new KCModuleProxy("kcm_networkmanagement_tray");
286
parent->addPage(m_kcmNM, m_kcmNM->moduleInfo().moduleName(),
287
m_kcmNM->moduleInfo().icon());
288
parent->addPage(m_kcmNMTray, m_kcmNMTray->moduleInfo().moduleName(),
289
m_kcmNMTray->moduleInfo().icon());
291
connect(parent, SIGNAL(applyClicked()), this, SLOT(saveConfiguration()));
292
connect(parent, SIGNAL(okClicked()), this, SLOT(saveConfiguration()));
295
void NetworkManagerApplet::saveConfiguration()
297
// kcm_networkmanagement implicitly saves connection definition after
298
// editing is finished, so no need to call its save() method
299
// FIXME This just writes out changed values to ini file. kded module
300
// still continues to use old value
304
void NetworkManagerApplet::constraintsEvent(Plasma::Constraints constraints)
306
// update the pixmap when a new size from kiconloader fits in, this makes sure the
307
// icon is only displayed in sizes provides by KIconLoader, so we don't get blurry
309
if (constraints & (Plasma::SizeConstraint | Plasma::FormFactorConstraint)) {
310
if (UiUtils::iconSize(contentsRect().size()) != UiUtils::iconSize(m_pixmap.size())) {
316
void NetworkManagerApplet::updatePixmap()
318
int s = UiUtils::iconSize(contentsRect().size());
319
m_pixmap = KIcon(UiUtils::iconName(activeInterface())).pixmap(s, s);
323
void NetworkManagerApplet::paintInterface(QPainter * p, const QStyleOptionGraphicsItem *option, const QRect &contentsRect)
327
Solid::Control::NetworkInterfaceNm09* interface = activeInterface();
330
useSvg = interface->type() == Solid::Control::NetworkInterfaceNm09::Wifi || interface->type() == Solid::Control::NetworkInterfaceNm09::Ethernet;
334
QString el = svgElement(interface);
335
m_svg->paint(p, m_contentSquare, el);
337
paintPixmap(p, m_pixmap, contentsRect);
339
paintStatusOverlay(p);
340
paintNeedAuthOverlay(p);
343
void NetworkManagerApplet::paintNeedAuthOverlay(QPainter *p)
345
// Needs authentication, show this in the panel
346
if (!activeInterface()) {
347
kDebug() << "No active interface";
351
kDebug() << "Painting overlay ...>" << activeInterface()->connectionState();
353
if (activeInterface() && activeInterface()->connectionState() == Solid::Control::NetworkInterfaceNm09::NeedAuth) {
354
//kDebug() << "Needing auth ...>";
355
int i_s = (int)contentsRect().width()/4;
356
int iconsize = qMax(UiUtils::iconSize(QSizeF(i_s, i_s)), 8);
358
//kDebug() << "Security:iconsize" << iconsize;
359
QPixmap icon = KIcon("dialog-password").pixmap(iconsize);
360
QPoint pos = QPoint(contentsRect().right() - iconsize,
361
contentsRect().bottom() - iconsize);
363
p->drawPixmap(pos, icon);
367
void NetworkManagerApplet::paintStatusOverlay(QPainter *p)
369
int oldOpacity = p->opacity();
370
qreal opacity = m_overlayTimeline.currentValue();
371
if (!qFuzzyCompare(opacity, 1) && !m_previousStatusOverlay.isNull()) {
372
p->setOpacity(1 - opacity);
373
p->drawPixmap(contentsRect().left(), contentsRect().bottom() - m_previousStatusOverlay.height(), m_previousStatusOverlay);
375
if (!m_statusOverlay.isNull()) {
376
p->setOpacity(opacity);
377
p->drawPixmap(contentsRect().left(), contentsRect().bottom() - m_statusOverlay.height(), m_statusOverlay);
379
p->setOpacity(oldOpacity);
382
void NetworkManagerApplet::paintPixmap(QPainter *painter, QPixmap pixmap, const QRectF &rect, qreal opacity)
384
int size = pixmap.size().width();
385
QPointF iconOrigin = QPointF(rect.left() + (rect.width() - size) / 2,
386
rect.top() + (rect.height() - size) / 2);
388
painter->setRenderHint(QPainter::SmoothPixmapTransform);
389
painter->setRenderHint(QPainter::Antialiasing);
391
if (painter->paintEngine()->hasFeature(QPaintEngine::ConstantOpacity)) {
392
// NOTE: Works, but makes hw acceleration impossible, use below code path
393
//kWarning() << "You don't really want to hit this path, it means slow painting. Your paintengine is not good enough.";
394
qreal old = painter->opacity();
395
painter->setOpacity(opacity);
396
painter->drawPixmap(iconOrigin, pixmap);
397
painter->setOpacity(old);
399
QPixmap temp(QSize(size, size));
400
temp.fill(Qt::transparent);
405
p.setCompositionMode(QPainter::CompositionMode_Source);
406
p.drawPixmap(QPoint(0,0), pixmap);
408
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
409
p.fillRect(pixmap.rect(), QColor(0, 0, 0, opacity * 254));
413
painter->drawPixmap(iconOrigin, temp);
417
void NetworkManagerApplet::repaint()
422
/* Slots to react to changes from the daemon */
423
void NetworkManagerApplet::networkInterfaceAdded(const QString & uni)
426
// update the tray icon
427
m_interfaces = Solid::Control::NetworkManagerNm09::networkInterfaces();
429
setupInterfaceSignals();
430
interfaceConnectionStateChanged();
434
void NetworkManagerApplet::networkInterfaceRemoved(const QString & uni)
437
// update the tray icon
438
m_interfaces = Solid::Control::NetworkManagerNm09::networkInterfaces();
439
KConfigGroup cg = config();
441
setupInterfaceSignals();
442
interfaceConnectionStateChanged();
444
// kill any animations involving this interface
447
Solid::Control::NetworkInterfaceNm09* NetworkManagerApplet::activeInterface()
449
if (!m_interfaces.isEmpty()) {
450
qSort(m_interfaces.begin(), m_interfaces.end(), networkInterfaceLessThan);
451
return m_interfaces.first();
458
void NetworkManagerApplet::interfaceConnectionStateChanged()
460
//kDebug() << " +++ +++ +++ Connection State Changed +++ +++ +++";
461
if (activeInterface()) {
462
//kDebug() << "busy ... ?";
463
Solid::Control::NetworkInterfaceNm09::ConnectionState state = static_cast<Solid::Control::NetworkInterfaceNm09::ConnectionState>(activeInterface()->connectionState());
465
case Solid::Control::NetworkInterfaceNm09::Preparing:
466
case Solid::Control::NetworkInterfaceNm09::Configuring:
467
case Solid::Control::NetworkInterfaceNm09::IPConfig:
468
case Solid::Control::NetworkInterfaceNm09::IPCheck:
469
case Solid::Control::NetworkInterfaceNm09::Secondaries:
470
if (m_currentState != state) {
471
setStatusOverlay(generateProgressStatusOverlay());
475
case Solid::Control::NetworkInterfaceNm09::NeedAuth:
478
case Solid::Control::NetworkInterfaceNm09::Activated:
480
if (m_currentState != state) {
481
// We want to show the full circle a bit
482
setStatusOverlay(generateProgressStatusOverlay());
483
setStatusOverlay("task-complete");
484
QTimer::singleShot(4000, this, SLOT(clearActivatedOverlay()));
487
case Solid::Control::NetworkInterfaceNm09::UnknownState:
488
kDebug() << "UnknownState! should this happen?";
489
case Solid::Control::NetworkInterfaceNm09::Unmanaged:
490
case Solid::Control::NetworkInterfaceNm09::Unavailable:
491
case Solid::Control::NetworkInterfaceNm09::Failed:
492
if (m_currentState != state) {
493
setStatusOverlay("dialog-error");
496
case Solid::Control::NetworkInterfaceNm09::Disconnected:
497
if (m_currentState != state) {
498
setStatusOverlay("dialog-cancel");
502
m_currentState = state;
507
void NetworkManagerApplet::toolTipAboutToShow()
509
Solid::Control::NetworkInterfaceNm09List interfaces
510
= Solid::Control::NetworkManagerNm09::networkInterfaces();
511
if (interfaces.isEmpty()) {
512
m_toolTip = Plasma::ToolTipContent(QString(),
513
i18nc("Tooltip sub text", "No network interfaces"),
514
KIcon("networkmanager").pixmap(IconSize(KIconLoader::Desktop))
517
qSort(interfaces.begin(), interfaces.end(), networkInterfaceLessThan);
518
bool hasActive = false;
519
bool iconChanged = false;
520
QString icon = "networkmanager";
522
foreach (Solid::Control::NetworkInterfaceNm09 *iface, interfaces) {
523
if (iface->connectionState() != Solid::Control::NetworkInterfaceNm09::Unavailable) {
524
if (!lines.isEmpty()) {
529
QString deviceText = UiUtils::interfaceNameLabel(iface->uni());
531
QString ifaceName = iface->interfaceName();
532
lines << QString::fromLatin1("<b>%1</b>").arg(deviceText);
533
QString connectionName;
534
RemoteInterfaceConnection *conn = m_activatables->connectionForInterface(iface);
536
connectionName = conn->connectionName();
539
lines << QString("%1").arg(UiUtils::connectionStateToString(static_cast<Solid::Control::NetworkInterfaceNm09::ConnectionState>(iface->connectionState()), connectionName));
541
Solid::Control::IPv4Config ip4Config = iface->ipV4Config();
542
QList<Solid::Control::IPv4Address> addresses = ip4Config.addresses();
543
if (!addresses.isEmpty()) {
544
QHostAddress addr(addresses.first().address());
545
QString currentIp = addr.toString();
546
lines << i18nc("Display of the IP (network) address in the tooltip", "<font size=\"-1\">Address: %1</font>", currentIp);
549
// Show the first active connection's icon, otherwise the networkmanager icon
550
if (!iconChanged && iface->connectionState() == Solid::Control::NetworkInterfaceNm09::Activated) {
551
icon = UiUtils::iconName(iface);
552
iconChanged = true; // we only want the first one
559
subText = lines.join(QLatin1String("<br>"));
561
text = i18nc("tooltip, all interfaces are down", "Disconnected");
563
if (m_popup->hasWireless() && !Solid::Control::NetworkManagerNm09::isWirelessEnabled()) {
564
subText = i18nc("tooltip, wireless is disabled in software", "Wireless disabled in software");
566
if (!Solid::Control::NetworkManagerNm09::isNetworkingEnabled()) {
567
subText = i18nc("tooltip, all interfaces are down", "Networking disabled");
569
if (m_popup->hasWireless() && !Solid::Control::NetworkManagerNm09::isWirelessHardwareEnabled()) {
570
subText = i18nc("tooltip, wireless is disabled by hardware", "Wireless disabled by hardware");
574
m_toolTip = Plasma::ToolTipContent(text,
576
KIcon(icon).pixmap(IconSize(KIconLoader::Desktop))
579
Plasma::ToolTipManager::self()->setContent(this, m_toolTip);
583
bool networkInterfaceLessThan(Solid::Control::NetworkInterfaceNm09 *if1, Solid::Control::NetworkInterfaceNm09 * if2)
586
* status merging algorithm
587
* In descending order of importance:
588
* - Connecting devices
589
* - Cellular devices (because of cost)
593
* - Connected devices
595
* - Disconnected devices
602
if2status = Unavailable,
603
if1status = Unavailable;
605
switch (if1->connectionState()) {
606
case Solid::Control::NetworkInterfaceNm09::Preparing:
607
case Solid::Control::NetworkInterfaceNm09::Configuring:
608
case Solid::Control::NetworkInterfaceNm09::NeedAuth:
609
case Solid::Control::NetworkInterfaceNm09::IPConfig:
610
case Solid::Control::NetworkInterfaceNm09::IPCheck:
611
case Solid::Control::NetworkInterfaceNm09::Secondaries:
612
if1status = Connecting;
614
case Solid::Control::NetworkInterfaceNm09::Activated:
615
if1status = Connected;
617
case Solid::Control::NetworkInterfaceNm09::Disconnected:
618
if1status = Disconnected;
620
default: // all kind of unavailable
623
switch (if2->connectionState()) {
624
case Solid::Control::NetworkInterfaceNm09::Preparing:
625
case Solid::Control::NetworkInterfaceNm09::Configuring:
626
case Solid::Control::NetworkInterfaceNm09::NeedAuth:
627
case Solid::Control::NetworkInterfaceNm09::IPConfig:
628
case Solid::Control::NetworkInterfaceNm09::IPCheck:
629
case Solid::Control::NetworkInterfaceNm09::Secondaries:
630
if2status = Connecting;
632
case Solid::Control::NetworkInterfaceNm09::Activated:
633
if2status = Connected;
635
case Solid::Control::NetworkInterfaceNm09::Disconnected:
636
if2status = Disconnected;
638
default: // all kind of disconnected
642
bool lessThan = false;
645
lessThan = (if2status != Connecting || networkInterfaceSameConnectionStateLessThan(if1, if2));
649
if ( if2status == Connecting) {
652
lessThan = ((if2status != Connected) || networkInterfaceSameConnectionStateLessThan(if1, if2));
656
if ( if2status == Disconnected) {
657
lessThan = networkInterfaceSameConnectionStateLessThan(if1, if2);
659
if (if2status == Unavailable) {
665
if ( if2status == Unavailable) {
666
lessThan = networkInterfaceSameConnectionStateLessThan(if1, if2);
674
bool networkInterfaceSameConnectionStateLessThan(Solid::Control::NetworkInterfaceNm09 * if1, Solid::Control::NetworkInterfaceNm09 * if2)
676
bool lessThan = false;
677
switch (if1->type() ) {
678
case Solid::Control::NetworkInterfaceNm09::Ethernet:
679
switch (if2->type()) {
680
case Solid::Control::NetworkInterfaceNm09::Ethernet:
681
lessThan = if1->uni() < if2->uni();
683
case Solid::Control::NetworkInterfaceNm09::Wifi:
686
case Solid::Control::NetworkInterfaceNm09::Modem:
692
case Solid::Control::NetworkInterfaceNm09::Wifi:
693
switch (if2->type()) {
694
case Solid::Control::NetworkInterfaceNm09::Ethernet:
697
case Solid::Control::NetworkInterfaceNm09::Wifi:
698
lessThan = if1->uni() < if2->uni();
700
case Solid::Control::NetworkInterfaceNm09::Modem:
708
case Solid::Control::NetworkInterfaceNm09::Modem:
709
switch (if2->type()) {
710
case Solid::Control::NetworkInterfaceNm09::Ethernet:
711
case Solid::Control::NetworkInterfaceNm09::Wifi:
714
case Solid::Control::NetworkInterfaceNm09::Modem:
715
lessThan = if1->uni() < if2->uni();
728
void NetworkManagerApplet::managerWirelessEnabledChanged(bool)
730
setupInterfaceSignals();
733
void NetworkManagerApplet::managerWirelessHardwareEnabledChanged(bool enabled)
736
setupInterfaceSignals();
740
void NetworkManagerApplet::userNetworkingEnabledChanged(bool enabled)
743
Solid::Control::NetworkManagerNm09::setNetworkingEnabled(enabled);
744
setupInterfaceSignals();
747
void NetworkManagerApplet::userWirelessEnabledChanged(bool enabled)
750
Solid::Control::NetworkManagerNm09::setWirelessEnabled(enabled);
751
setupInterfaceSignals();
754
void NetworkManagerApplet::managerStatusChanged(Solid::Networking::Status status)
756
//kDebug() << "managerstatuschanged";
757
if (Solid::Networking::Unknown == status ) {
758
// FIXME: Do something smart
762
setupInterfaceSignals();
766
bool NetworkManagerApplet::hasInterfaceOfType(Solid::Control::NetworkInterfaceNm09::Type type)
768
foreach (Solid::Control::NetworkInterfaceNm09 * interface, m_interfaces) {
769
if (interface->type() == type) {
776
void NetworkManagerApplet::setStatusOverlay(const QPixmap& pix)
778
m_previousStatusOverlay = m_statusOverlay;
779
m_statusOverlay = pix;
780
if (m_overlayTimeline.state() == QTimeLine::Running) {
781
m_overlayTimeline.stop();
783
m_overlayTimeline.start();
786
void NetworkManagerApplet::setStatusOverlay(const QString& name)
788
int i_s = (int)contentsRect().width()/4;
789
int size = qMax(UiUtils::iconSize(QSizeF(i_s, i_s)), 8);
790
QPixmap pix = KIcon(name).pixmap(size);
791
setStatusOverlay(pix);
794
QPixmap NetworkManagerApplet::generateProgressStatusOverlay()
796
int width = contentsRect().width();
797
int height = qMax(width / 4, 4);
799
QPixmap pix(width, height);
800
pix.fill(Qt::transparent);
801
qreal state = UiUtils::interfaceState(activeInterface());
804
p.setRenderHint(QPainter::Antialiasing);
805
m_meterBgSvg->resizeFrame(pix.size());
806
m_meterBgSvg->paintFrame(&p, pix.rect());
808
QRectF innerRect = pix.rect();
809
innerRect.setWidth(innerRect.width() * state);
810
m_meterFgSvg->resizeFrame(innerRect.size());
811
m_meterFgSvg->paintFrame(&p, innerRect);
816
void NetworkManagerApplet::clearActivatedOverlay()
818
if (activeInterface() && static_cast<Solid::Control::NetworkInterfaceNm09::ConnectionState>(activeInterface()->connectionState()) == Solid::Control::NetworkInterfaceNm09::Activated) {
819
// Clear the overlay, but only if we are still activated
820
setStatusOverlay(QPixmap());
824
#include "networkmanager.moc"