summaryrefslogtreecommitdiff
path: root/noncore/applets/networkapplet/networkapplet.cpp
Unidiff
Diffstat (limited to 'noncore/applets/networkapplet/networkapplet.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/networkapplet/networkapplet.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/noncore/applets/networkapplet/networkapplet.cpp b/noncore/applets/networkapplet/networkapplet.cpp
index bd6ca66..10c2b34 100644
--- a/noncore/applets/networkapplet/networkapplet.cpp
+++ b/noncore/applets/networkapplet/networkapplet.cpp
@@ -1,86 +1,86 @@
1/* 1/*
2                 This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4 =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 .=l. 5 .=l.
6           .>+-= 6 .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13    .%`+i>       _;_. 13 .%`+i> _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++=   -.     .`     .: details. 20++= -. .` .: details.
21 :     =  ...= . :.=- 21: = ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
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/oresource.h>
36#include <opie2/otaskbarapplet.h> 37#include <opie2/otaskbarapplet.h>
37#include <qpe/applnk.h> 38#include <qpe/applnk.h>
38#include <qpe/resource.h> 39#include <qpe/qpeapplication.h>
39using namespace Opie::Core; 40using namespace Opie::Core;
40using namespace Opie::Ui; 41using namespace Opie::Ui;
41using namespace Opie::Net; 42using namespace Opie::Net;
42 43
43/* QT */ 44/* QT */
44#include <qpainter.h> 45#include <qpainter.h>
45#include <qlabel.h> 46#include <qlabel.h>
46#include <qlayout.h> 47#include <qlayout.h>
47#include <qobjectlist.h> 48#include <qobjectlist.h>
48 49
49/* STD */ 50/* STD */
50#include <assert.h> 51#include <assert.h>
51 52
52IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) 53IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name )
53 :QToolButton( parent, name ) 54 :QToolButton( parent, name )
54{ 55{
55 _iface = ONetwork::instance()->interface( name ); 56 _iface = ONetwork::instance()->interface( name );
56 assert( _iface ); 57 assert( _iface );
57 setToggleButton( true ); 58 setToggleButton( true );
58 //setAutoRaise( true ); 59 setUsesBigPixmap( qApp->desktop()->size().width() > 330 );
59 setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) ); 60 setOnIconSet( QIconSet( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ) );
60 setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) ); 61 setOffIconSet( QIconSet( Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ) ) );
61 setOn( _iface->isUp() ); 62 setOn( _iface->isUp() );
62 //setFixedWidth( 16 );
63 connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); 63 connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) );
64} 64}
65 65
66 66
67IfaceUpDownButton::~IfaceUpDownButton() 67IfaceUpDownButton::~IfaceUpDownButton()
68{ 68{
69} 69}
70 70
71 71
72void IfaceUpDownButton::clicked() 72void IfaceUpDownButton::clicked()
73{ 73{
74 _iface->setUp( isOn() ); 74 _iface->setUp( isOn() );
75 setOn( _iface->isUp() ); // it might not have worked... 75 setOn( _iface->isUp() ); // it might not have worked...
76 repaint(); 76 repaint();
77} 77}
78 78
79 79
80IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name ) 80IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name )
81 :QLineEdit( parent, name ) 81 :QLineEdit( parent, name )
82{ 82{
83 setFont( QFont( "fixed" ) ); 83 setFont( QFont( "fixed" ) );
84 _iface = ONetwork::instance()->interface( name ); 84 _iface = ONetwork::instance()->interface( name );
85 setFixedWidth( 105 ); 85 setFixedWidth( 105 );
86 setText( _iface->ipV4Address().toString() ); 86 setText( _iface->ipV4Address().toString() );
@@ -100,49 +100,49 @@ void IfaceIPAddress::returnPressed()
100 QHostAddress mask; 100 QHostAddress mask;
101 mask.setAddress( _iface->ipV4Netmask().toString() ); // setIPV4Address destroys the netmask... 101 mask.setAddress( _iface->ipV4Netmask().toString() ); // setIPV4Address destroys the netmask...
102 _iface->setIPV4Address( a ); 102 _iface->setIPV4Address( a );
103 _iface->setIPV4Netmask( mask ); // recover the old netmask 103 _iface->setIPV4Netmask( mask ); // recover the old netmask
104 setText( _iface->ipV4Address().toString() ); 104 setText( _iface->ipV4Address().toString() );
105 repaint(); 105 repaint();
106} 106}
107 107
108 108
109NetworkAppletControl::NetworkAppletControl( OTaskbarApplet* parent, const char* name ) 109NetworkAppletControl::NetworkAppletControl( OTaskbarApplet* parent, const char* name )
110 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0) 110 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0)
111{ 111{
112 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 112 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
113 l = new QVBoxLayout( this, 4, 2 ); 113 l = new QVBoxLayout( this, 4, 2 );
114} 114}
115 115
116 116
117void NetworkAppletControl::build() 117void NetworkAppletControl::build()
118{ 118{
119 ONetwork::InterfaceIterator it = ONetwork::instance()->iterator(); 119 ONetwork::InterfaceIterator it = ONetwork::instance()->iterator();
120 while ( it.current() ) 120 while ( it.current() )
121 { 121 {
122 QHBoxLayout* h = new QHBoxLayout( l ); 122 QHBoxLayout* h = new QHBoxLayout( l );
123 QLabel* symbol = new QLabel( this ); 123 QLabel* symbol = new QLabel( this );
124 symbol->setPixmap( Resource::loadPixmap( guessDevice( it.current() ) ) ); 124 symbol->setPixmap( Opie::Core::OResource::loadPixmap( guessDevice( it.current() ), Opie::Core::OResource::SmallIcon ) );
125 h->addWidget( symbol ); 125 h->addWidget( symbol );
126 symbol->show(); 126 symbol->show();
127 127
128 QLabel* name = new QLabel( it.current()->name(), this ); 128 QLabel* name = new QLabel( it.current()->name(), this );
129 name->setFixedWidth( 35 ); 129 name->setFixedWidth( 35 );
130 h->addWidget( name ); 130 h->addWidget( name );
131 name->show(); 131 name->show();
132 132
133 IfaceIPAddress* ip = new IfaceIPAddress( this, it.current()->name() ); 133 IfaceIPAddress* ip = new IfaceIPAddress( this, it.current()->name() );
134 h->addWidget( ip ); 134 h->addWidget( ip );
135 ip->show(); 135 ip->show();
136 136
137 IfaceUpDownButton* tb = new IfaceUpDownButton( this, it.current()->name() ); 137 IfaceUpDownButton* tb = new IfaceUpDownButton( this, it.current()->name() );
138 tb->show(); 138 tb->show();
139 139
140 h->addWidget( tb ); 140 h->addWidget( tb );
141 141
142 ++it; 142 ++it;
143 } 143 }
144} 144}
145 145
146 146
147NetworkAppletControl::~NetworkAppletControl() 147NetworkAppletControl::~NetworkAppletControl()
148{ 148{
@@ -194,49 +194,49 @@ void NetworkAppletControl::hideEvent( QHideEvent* e )
194 194
195 list = const_cast<QObjectList*>( children() ); 195 list = const_cast<QObjectList*>( children() );
196 if ( list ) 196 if ( list )
197 owarn << "D'oh! We still have " << list->count() << " children..." << oendl; 197 owarn << "D'oh! We still have " << list->count() << " children..." << oendl;
198 198
199 // renew layout 199 // renew layout
200 l = new QVBoxLayout( this, 4, 2 ); 200 l = new QVBoxLayout( this, 4, 2 );
201 resize( 0, 0 ); 201 resize( 0, 0 );
202} 202}
203 203
204 204
205QSize NetworkAppletControl::sizeHint() const 205QSize NetworkAppletControl::sizeHint() const
206{ 206{
207 ONetwork::instance()->synchronize(); // rebuild interface database 207 ONetwork::instance()->synchronize(); // rebuild interface database
208 odebug << "sizeHint (#ifaces=" << ONetwork::instance()->count() << ")" << oendl; 208 odebug << "sizeHint (#ifaces=" << ONetwork::instance()->count() << ")" << oendl;
209 return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); 209 return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 );
210} 210}
211 211
212 212
213NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) 213NetworkApplet::NetworkApplet( QWidget *parent, const char *name )
214 :OTaskbarApplet( parent, name ) 214 :OTaskbarApplet( parent, name )
215{ 215{
216 setFixedHeight( AppLnk::smallIconSize() ); 216 setFixedHeight( AppLnk::smallIconSize() );
217 setFixedWidth( AppLnk::smallIconSize() ); 217 setFixedWidth( AppLnk::smallIconSize() );
218 _pixmap.convertFromImage( Resource::loadImage( "networkapplet/network" ).smoothScale( height(), width() ) ); 218 _pixmap = Opie::Core::OResource::loadPixmap( "networkapplet/network", Opie::Core::OResource::SmallIcon );
219 _control = new NetworkAppletControl( this, "control" ); 219 _control = new NetworkAppletControl( this, "control" );
220} 220}
221 221
222 222
223NetworkApplet::~NetworkApplet() 223NetworkApplet::~NetworkApplet()
224{ 224{
225} 225}
226 226
227 227
228int NetworkApplet::position() 228int NetworkApplet::position()
229{ 229{
230 return 4; 230 return 4;
231} 231}
232 232
233 233
234void NetworkApplet::paintEvent( QPaintEvent* ) 234void NetworkApplet::paintEvent( QPaintEvent* )
235{ 235{
236 QPainter p(this); 236 QPainter p(this);
237 p.drawPixmap(0, 2, _pixmap ); 237 p.drawPixmap(0, 2, _pixmap );
238} 238}
239 239
240 240
241void NetworkApplet::mousePressEvent( QMouseEvent* ) 241void NetworkApplet::mousePressEvent( QMouseEvent* )
242{ 242{