summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-21 18:13:28 (UTC)
committer mickeyl <mickeyl>2003-04-21 18:13:28 (UTC)
commite951446d52d2a89dd919b1665b034516567384ee (patch) (unidiff)
treefba427301e9872ed1b77dea8ddbef8b0eb634d3d
parente3d9c4f3e6a45128128cc22218c4fc30bbb41f3d (diff)
downloadopie-e951446d52d2a89dd919b1665b034516567384ee.zip
opie-e951446d52d2a89dd919b1665b034516567384ee.tar.gz
opie-e951446d52d2a89dd919b1665b034516567384ee.tar.bz2
fix irda image name
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/networkapplet/networkapplet.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/applets/networkapplet/networkapplet.cpp b/noncore/applets/networkapplet/networkapplet.cpp
index 3019456..4e658da 100644
--- a/noncore/applets/networkapplet/networkapplet.cpp
+++ b/noncore/applets/networkapplet/networkapplet.cpp
@@ -30,223 +30,223 @@
30 30
31#include "networkapplet.h" 31#include "networkapplet.h"
32#include <opie2/otaskbarapplet.h> 32#include <opie2/otaskbarapplet.h>
33#include <qpe/qlibrary.h> 33#include <qpe/qlibrary.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37#include <opie2/onetwork.h> 37#include <opie2/onetwork.h>
38 38
39#include <qpushbutton.h> 39#include <qpushbutton.h>
40#include <qlabel.h> 40#include <qlabel.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qlineedit.h> 42#include <qlineedit.h>
43#include <qtoolbutton.h> 43#include <qtoolbutton.h>
44#include <qhostaddress.h> 44#include <qhostaddress.h>
45#include <qobjectlist.h> 45#include <qobjectlist.h>
46 46
47#include <assert.h> 47#include <assert.h>
48 48
49IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name ) 49IfaceUpDownButton::IfaceUpDownButton( QWidget* parent, const char* name )
50 :QToolButton( parent, name ) 50 :QToolButton( parent, name )
51{ 51{
52 _iface = ONetwork::instance()->interface( name ); 52 _iface = ONetwork::instance()->interface( name );
53 assert( _iface ); 53 assert( _iface );
54 setToggleButton( true ); 54 setToggleButton( true );
55 //setAutoRaise( true ); 55 //setAutoRaise( true );
56 setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) ); 56 setOnIconSet( QIconSet( Resource::loadPixmap( "up" ) ) );
57 setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) ); 57 setOffIconSet( QIconSet( Resource::loadPixmap( "down" ) ) );
58 setOn( _iface->isUp() ); 58 setOn( _iface->isUp() );
59 //setFixedWidth( 16 ); 59 //setFixedWidth( 16 );
60 connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT( clicked() ) );
61} 61}
62 62
63 63
64IfaceUpDownButton::~IfaceUpDownButton() 64IfaceUpDownButton::~IfaceUpDownButton()
65{ 65{
66} 66}
67 67
68 68
69void IfaceUpDownButton::clicked() 69void IfaceUpDownButton::clicked()
70{ 70{
71 _iface->setUp( isOn() ); 71 _iface->setUp( isOn() );
72 setOn( _iface->isUp() ); // it might not have worked... 72 setOn( _iface->isUp() ); // it might not have worked...
73 repaint(); 73 repaint();
74} 74}
75 75
76 76
77IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name ) 77IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name )
78 :QLineEdit( parent, name ) 78 :QLineEdit( parent, name )
79{ 79{
80 setFont( QFont( "fixed" ) ); 80 setFont( QFont( "fixed" ) );
81 _iface = ONetwork::instance()->interface( name ); 81 _iface = ONetwork::instance()->interface( name );
82 setFixedWidth( 105 ); 82 setFixedWidth( 105 );
83 setText( _iface->ipV4Address() ); 83 setText( _iface->ipV4Address() );
84 connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) ); 84 connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) );
85} 85}
86 86
87 87
88IfaceIPAddress::~IfaceIPAddress() 88IfaceIPAddress::~IfaceIPAddress()
89{ 89{
90} 90}
91 91
92 92
93void IfaceIPAddress::returnPressed() 93void IfaceIPAddress::returnPressed()
94{ 94{
95 QHostAddress a; 95 QHostAddress a;
96 a.setAddress( text() ); 96 a.setAddress( text() );
97 QHostAddress mask; 97 QHostAddress mask;
98 mask.setAddress( _iface->ipV4Netmask() ); // setIPV4Address destroys the netmask... 98 mask.setAddress( _iface->ipV4Netmask() ); // setIPV4Address destroys the netmask...
99 _iface->setIPV4Address( a ); 99 _iface->setIPV4Address( a );
100 _iface->setIPV4Netmask( mask ); // recover the old netmask 100 _iface->setIPV4Netmask( mask ); // recover the old netmask
101 setText( _iface->ipV4Address() ); 101 setText( _iface->ipV4Address() );
102 repaint(); 102 repaint();
103} 103}
104 104
105 105
106NetworkAppletControl::NetworkAppletControl( OTaskbarApplet* parent, const char* name ) 106NetworkAppletControl::NetworkAppletControl( OTaskbarApplet* parent, const char* name )
107 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0) 107 :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0)
108{ 108{
109 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 109 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
110 l = new QVBoxLayout( this, 4, 2 ); 110 l = new QVBoxLayout( this, 4, 2 );
111} 111}
112 112
113 113
114void NetworkAppletControl::build() 114void NetworkAppletControl::build()
115{ 115{
116 ONetwork::InterfaceIterator it = ONetwork::instance()->iterator(); 116 ONetwork::InterfaceIterator it = ONetwork::instance()->iterator();
117 while ( it.current() ) 117 while ( it.current() )
118 { 118 {
119 QHBoxLayout* h = new QHBoxLayout( l ); 119 QHBoxLayout* h = new QHBoxLayout( l );
120 QLabel* symbol = new QLabel( this ); 120 QLabel* symbol = new QLabel( this );
121 symbol->setPixmap( Resource::loadPixmap( guessDevice( it.current() ) ) ); 121 symbol->setPixmap( Resource::loadPixmap( guessDevice( it.current() ) ) );
122 h->addWidget( symbol ); 122 h->addWidget( symbol );
123 symbol->show(); 123 symbol->show();
124 124
125 QLabel* name = new QLabel( it.current()->name(), this ); 125 QLabel* name = new QLabel( it.current()->name(), this );
126 name->setFixedWidth( 35 ); 126 name->setFixedWidth( 35 );
127 h->addWidget( name ); 127 h->addWidget( name );
128 name->show(); 128 name->show();
129 129
130 IfaceIPAddress* ip = new IfaceIPAddress( this, it.current()->name() ); 130 IfaceIPAddress* ip = new IfaceIPAddress( this, it.current()->name() );
131 h->addWidget( ip ); 131 h->addWidget( ip );
132 ip->show(); 132 ip->show();
133 133
134 IfaceUpDownButton* tb = new IfaceUpDownButton( this, it.current()->name() ); 134 IfaceUpDownButton* tb = new IfaceUpDownButton( this, it.current()->name() );
135 tb->show(); 135 tb->show();
136 136
137 h->addWidget( tb ); 137 h->addWidget( tb );
138 138
139 ++it; 139 ++it;
140 } 140 }
141} 141}
142 142
143 143
144NetworkAppletControl::~NetworkAppletControl() 144NetworkAppletControl::~NetworkAppletControl()
145{ 145{
146} 146}
147 147
148 148
149QString NetworkAppletControl::guessDevice( ONetworkInterface* iface ) 149QString NetworkAppletControl::guessDevice( ONetworkInterface* iface )
150{ 150{
151 if ( iface->isWireless() ) 151 if ( iface->isWireless() )
152 return "networksettings/wlan"; 152 return "networksettings/wlan";
153 if ( iface->isLoopback() ) 153 if ( iface->isLoopback() )
154 return "networksettings/lo"; 154 return "networksettings/lo";
155 if ( QString( iface->name() ).contains( "usb" ) ) 155 if ( QString( iface->name() ).contains( "usb" ) )
156 return "networksettings/usb"; 156 return "networksettings/usb";
157 if ( QString( iface->name() ).contains( "ir" ) ) 157 if ( QString( iface->name() ).contains( "ir" ) )
158 return "networksettings/ir"; 158 return "networksettings/irda";
159 159
160 //TODO: Insert neat symbol and check for tunnel devices 160 //TODO: Insert neat symbol and check for tunnel devices
161 161
162 return "networksettings/lan"; 162 return "networksettings/lan";
163 163
164} 164}
165 165
166 166
167void NetworkAppletControl::showEvent( QShowEvent* e ) 167void NetworkAppletControl::showEvent( QShowEvent* e )
168{ 168{
169 qDebug( "showEvent" ); 169 qDebug( "showEvent" );
170 build(); 170 build();
171 QWidget::showEvent( e ); 171 QWidget::showEvent( e );
172} 172}
173 173
174 174
175void NetworkAppletControl::hideEvent( QHideEvent* e ) 175void NetworkAppletControl::hideEvent( QHideEvent* e )
176{ 176{
177 qDebug( "hideEvent" ); 177 qDebug( "hideEvent" );
178 QWidget::hideEvent( e ); 178 QWidget::hideEvent( e );
179 179
180 delete l; 180 delete l;
181 181
182 // delete all child widgets from this frame 182 // delete all child widgets from this frame
183 QObjectList* list = const_cast<QObjectList*>( children() ); 183 QObjectList* list = const_cast<QObjectList*>( children() );
184 QObjectListIt it(*list); 184 QObjectListIt it(*list);
185 QObject* obj; 185 QObject* obj;
186 while ( (obj=it.current()) ) 186 while ( (obj=it.current()) )
187 { 187 {
188 ++it; 188 ++it;
189 delete obj; 189 delete obj;
190 } 190 }
191 191
192 list = const_cast<QObjectList*>( children() ); 192 list = const_cast<QObjectList*>( children() );
193 if ( list ) 193 if ( list )
194 qWarning( "D'oh! We still have %d children...", list->count() ); 194 qWarning( "D'oh! We still have %d children...", list->count() );
195 195
196 // renew layout 196 // renew layout
197 l = new QVBoxLayout( this, 4, 2 ); 197 l = new QVBoxLayout( this, 4, 2 );
198 resize( 0, 0 ); 198 resize( 0, 0 );
199} 199}
200 200
201 201
202QSize NetworkAppletControl::sizeHint() const 202QSize NetworkAppletControl::sizeHint() const
203{ 203{
204 ONetwork::instance()->synchronize(); // rebuild interface database 204 ONetwork::instance()->synchronize(); // rebuild interface database
205 qDebug( "sizeHint (#ifaces=%d)", ONetwork::instance()->count() ); 205 qDebug( "sizeHint (#ifaces=%d)", ONetwork::instance()->count() );
206 return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 ); 206 return QSize( 14+35+105+14 + 8, ONetwork::instance()->count() * 26 );
207} 207}
208 208
209 209
210NetworkApplet::NetworkApplet( QWidget *parent, const char *name ) 210NetworkApplet::NetworkApplet( QWidget *parent, const char *name )
211 :OTaskbarApplet( parent, name ) 211 :OTaskbarApplet( parent, name )
212{ 212{
213 _control = new NetworkAppletControl( this, "control" ); 213 _control = new NetworkAppletControl( this, "control" );
214} 214}
215 215
216 216
217NetworkApplet::~NetworkApplet() 217NetworkApplet::~NetworkApplet()
218{ 218{
219} 219}
220 220
221 221
222int NetworkApplet::position() 222int NetworkApplet::position()
223{ 223{
224 return 4; 224 return 4;
225} 225}
226 226
227 227
228void NetworkApplet::paintEvent( QPaintEvent* ) 228void NetworkApplet::paintEvent( QPaintEvent* )
229{ 229{
230 QPainter p(this); 230 QPainter p(this);
231 p.drawPixmap(0, 2, Resource::loadPixmap( "networkapplet/network" ) ); 231 p.drawPixmap(0, 2, Resource::loadPixmap( "networkapplet/network" ) );
232} 232}
233 233
234 234
235void NetworkApplet::mousePressEvent( QMouseEvent* ) 235void NetworkApplet::mousePressEvent( QMouseEvent* )
236{ 236{
237 if ( !_control->isVisible() ) 237 if ( !_control->isVisible() )
238 { 238 {
239 popup( _control ); 239 popup( _control );
240 } 240 }
241 else 241 else
242 { 242 {
243 _control->hide(); 243 _control->hide();
244 } 244 }
245} 245}
246 246
247 247
248Q_EXPORT_INTERFACE() 248Q_EXPORT_INTERFACE()
249{ 249{
250 Q_CREATE_INSTANCE( OTaskbarAppletWrapper<NetworkApplet> ); 250 Q_CREATE_INSTANCE( OTaskbarAppletWrapper<NetworkApplet> );
251} 251}
252 252