Diffstat (limited to 'noncore/applets/networkapplet/networkapplet.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/applets/networkapplet/networkapplet.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/noncore/applets/networkapplet/networkapplet.cpp b/noncore/applets/networkapplet/networkapplet.cpp index 5eb5ad2..534a8d0 100644 --- a/noncore/applets/networkapplet/networkapplet.cpp +++ b/noncore/applets/networkapplet/networkapplet.cpp | |||
@@ -27,35 +27,37 @@ | |||
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "networkapplet.h" | 31 | #include "networkapplet.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | #include <opie2/onetwork.h> | 35 | #include <opie2/onetwork.h> |
36 | #include <opie2/otaskbarapplet.h> | 36 | #include <opie2/otaskbarapplet.h> |
37 | #include <qpe/applnk.h> | 37 | #include <qpe/applnk.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | #include <qpainter.h> | 39 | using namespace Opie::Core; |
40 | using namespace Opie::Ui; | ||
41 | using namespace Opie::Net; | ||
40 | 42 | ||
41 | /* QT */ | 43 | /* QT */ |
44 | #include <qpainter.h> | ||
42 | #include <qlabel.h> | 45 | #include <qlabel.h> |
43 | #include <qlayout.h> | 46 | #include <qlayout.h> |
44 | #include <qobjectlist.h> | 47 | #include <qobjectlist.h> |
45 | 48 | ||
49 | /* STD */ | ||
46 | #include <assert.h> | 50 | #include <assert.h> |
47 | 51 | ||
48 | using namespace Opie::Ui; | ||
49 | using namespace Opie::Net; | ||
50 | IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) | 52 | IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) |
51 | :QToolButton( parent, name ) | 53 | :QToolButton( parent, name ) |
52 | { | 54 | { |
53 | _iface = ONetwork::instance()->interface( name ); | 55 | _iface = ONetwork::instance()->interface( name ); |
54 | assert( _iface ); | 56 | assert( _iface ); |
55 | setToggleButton( true ); | 57 | setToggleButton( true ); |
56 | //setAutoRaise( true ); | 58 | //setAutoRaise( true ); |
57 | setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) ); | 59 | setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) ); |
58 | setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) ); | 60 | setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) ); |
59 | setOn( _iface->isUp() ); | 61 | setOn( _iface->isUp() ); |
60 | //setFixedWidth( 16 ); | 62 | //setFixedWidth( 16 ); |
61 | connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); | 63 | connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); |
@@ -158,61 +160,61 @@ QString NetworkAppletControl::guessDevice( ONetworkInterface* iface ) | |||
158 | if ( QString( iface->name() ).contains( "ir" ) ) | 160 | if ( QString( iface->name() ).contains( "ir" ) ) |
159 | return "networksettings/irda"; | 161 | return "networksettings/irda"; |
160 | 162 | ||
161 | //TODO: Insert neat symbol and check for tunnel devices | 163 | //TODO: Insert neat symbol and check for tunnel devices |
162 | 164 | ||
163 | return "networksettings/lan"; | 165 | return "networksettings/lan"; |
164 | 166 | ||
165 | } | 167 | } |
166 | 168 | ||
167 | 169 | ||
168 | void NetworkAppletControl::showEvent( QShowEvent* e ) | 170 | void NetworkAppletControl::showEvent( QShowEvent* e ) |
169 | { | 171 | { |
170 | qDebug( "showEvent" ); | 172 | odebug << "showEvent" << oendl; |
171 | build(); | 173 | build(); |
172 | QWidget::showEvent( e ); | 174 | QWidget::showEvent( e ); |
173 | } | 175 | } |
174 | 176 | ||
175 | 177 | ||
176 | void NetworkAppletControl::hideEvent( QHideEvent* e ) | 178 | void NetworkAppletControl::hideEvent( QHideEvent* e ) |
177 | { | 179 | { |
178 | qDebug( "hideEvent" ); | 180 | odebug << "hideEvent" << oendl; |
179 | QWidget::hideEvent( e ); | 181 | QWidget::hideEvent( e ); |
180 | 182 | ||
181 | delete l; | 183 | delete l; |
182 | 184 | ||
183 | // delete all child widgets from this frame | 185 | // delete all child widgets from this frame |
184 | QObjectList* list = const_cast<QObjectList*>( children() ); | 186 | QObjectList* list = const_cast<QObjectList*>( children() ); |
185 | QObjectListIt it(*list); | 187 | QObjectListIt it(*list); |
186 | QObject* obj; | 188 | QObject* obj; |
187 | while ( (obj=it.current()) ) | 189 | while ( (obj=it.current()) ) |
188 | { | 190 | { |
189 | ++it; | 191 | ++it; |
190 | delete obj; | 192 | delete obj; |
191 | } | 193 | } |
192 | 194 | ||
193 | list = const_cast<QObjectList*>( children() ); | 195 | list = const_cast<QObjectList*>( children() ); |
194 | if ( list ) | 196 | if ( list ) |
195 | qWarning( "D'oh! We still have %d children...", list->count() ); | 197 | owarn << "D'oh! We still have " << list->count() << " children..." << oendl; |
196 | 198 | ||
197 | // renew layout | 199 | // renew layout |
198 | l = new QVBoxLayout( this, 4, 2 ); | 200 | l = new QVBoxLayout( this, 4, 2 ); |
199 | resize( 0, 0 ); | 201 | resize( 0, 0 ); |
200 | } | 202 | } |
201 | 203 | ||
202 | 204 | ||
203 | QSize NetworkAppletControl::sizeHint() const | 205 | QSize NetworkAppletControl::sizeHint() const |
204 | { | 206 | { |
205 | ONetwork::instance()->synchronize(); // rebuild interface database | 207 | ONetwork::instance()->synchronize(); // rebuild interface database |
206 | qDebug( "sizeHint (#ifaces=%d)", ONetwork::instance()->count() ); | 208 | odebug << "sizeHint (#ifaces=" << ONetwork::instance()->count() << ")" << oendl; |
207 | return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); | 209 | return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); |
208 | } | 210 | } |
209 | 211 | ||
210 | 212 | ||
211 | NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) | 213 | NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) |
212 | :OTaskbarApplet( parent, name ) | 214 | :OTaskbarApplet( parent, name ) |
213 | { | 215 | { |
214 | setFixedHeight( AppLnk::smallIconSize() ); | 216 | setFixedHeight( AppLnk::smallIconSize() ); |
215 | setFixedWidth( AppLnk::smallIconSize() ); | 217 | setFixedWidth( AppLnk::smallIconSize() ); |
216 | _pixmap.convertFromImage( Resource::loadImage( "networkapplet/network" ).smoothScale( height(), width() ) ); | 218 | _pixmap.convertFromImage( Resource::loadImage( "networkapplet/network" ).smoothScale( height(), width() ) ); |
217 | _control = new NetworkAppletControl( this, "control" ); | 219 | _control = new NetworkAppletControl( this, "control" ); |
218 | } | 220 | } |