KIO
kstatusbarofflineindicator.cpp
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 2007 Will Stephenson <wstephenson@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library. If not, write to the Free Software 00015 Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 00018 As a special exception, permission is given to link this library 00019 with any edition of Qt, and distribute the resulting executable, 00020 without including the source code for Qt in the source distribution. 00021 */ 00022 00023 #include "kstatusbarofflineindicator.h" 00024 00025 #include <QLabel> 00026 #include <QVBoxLayout> 00027 #include <kiconloader.h> 00028 #include <klocale.h> 00029 00030 class KStatusBarOfflineIndicatorPrivate 00031 { 00032 public: 00033 KStatusBarOfflineIndicatorPrivate( KStatusBarOfflineIndicator *parent ) 00034 : q(parent) 00035 { 00036 } 00037 00038 void initialize(); 00039 void _k_networkStatusChanged( Solid::Networking::Status status ); 00040 00041 KStatusBarOfflineIndicator *q; 00042 }; 00043 00044 KStatusBarOfflineIndicator::KStatusBarOfflineIndicator( QWidget * parent) 00045 : QWidget( parent), 00046 d( new KStatusBarOfflineIndicatorPrivate( this ) ) 00047 { 00048 QVBoxLayout * layout = new QVBoxLayout( this ); 00049 layout->setMargin( 2 ); 00050 QLabel * label = new QLabel( this ); 00051 label->setPixmap( SmallIcon("network-disconnect") ); 00052 label->setToolTip( i18n( "The desktop is offline" ) ); 00053 layout->addWidget( label ); 00054 d->initialize(); 00055 connect( Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)), 00056 SLOT(_k_networkStatusChanged(Solid::Networking::Status)) ); 00057 } 00058 00059 KStatusBarOfflineIndicator::~KStatusBarOfflineIndicator() 00060 { 00061 delete d; 00062 } 00063 00064 void KStatusBarOfflineIndicatorPrivate::initialize() 00065 { 00066 _k_networkStatusChanged( Solid::Networking::status()); 00067 } 00068 00069 void KStatusBarOfflineIndicatorPrivate::_k_networkStatusChanged( Solid::Networking::Status status ) 00070 { 00071 if ( status == Solid::Networking::Connected || status == Solid::Networking::Unknown ) { 00072 q->hide(); 00073 } else { 00074 q->show(); 00075 } 00076 } 00077 00078 #include "kstatusbarofflineindicator.moc"
KDE 4.6 API Reference