summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp70
-rw-r--r--noncore/applets/wirelessapplet/wireless.h12
2 files changed, 60 insertions, 22 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp
index 15ccc58..183aab8 100644
--- a/noncore/applets/wirelessapplet/wireless.cpp
+++ b/noncore/applets/wirelessapplet/wireless.cpp
@@ -1,358 +1,390 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer 2** Copyright (C) 2002 Michael 'Mickey' Lauer
3** <mickey@tm.informatik.uni-frankfurt.de> 3** <mickey@tm.informatik.uni-frankfurt.de>
4** http://www.Vanille.de 4** http://www.Vanille.de
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "wireless.h" 16#include "wireless.h"
17 17
18#include <qapplication.h> 18#include <qapplication.h>
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qpe/config.h>
20 21
21#include <qpoint.h> 22#include <qpoint.h>
22#include <qradiobutton.h> 23#include <qradiobutton.h>
23#include <qcheckbox.h> 24#include <qcheckbox.h>
24#include <qpainter.h> 25#include <qpainter.h>
25#include <qlabel.h> 26#include <qlabel.h>
26#include <qslider.h> 27#include <qslider.h>
27#include <qbuttongroup.h> 28#include <qbuttongroup.h>
28#include <qlayout.h> 29#include <qlayout.h>
29#include <qframe.h> 30#include <qframe.h>
30#include <qpixmap.h> 31#include <qpixmap.h>
31#include <qstring.h> 32#include <qstring.h>
32#include <qfile.h> 33#include <qfile.h>
33 34
34#include "networkinfo.h" 35#include "networkinfo.h"
35#include "mgraph.h" 36#include "mgraph.h"
36 37
37#include "connect0.xpm" 38#include "connect0.xpm"
38#include "connect1.xpm" 39#include "connect1.xpm"
39#include "connect2.xpm" 40#include "connect2.xpm"
40#include "connect3.xpm" 41#include "connect3.xpm"
41#include "connect4.xpm" 42#include "connect4.xpm"
42#include "connect5.xpm" 43#include "connect5.xpm"
43#include "nowireless.xpm" 44#include "nowireless.xpm"
44 45
45#define STYLE_BARS 0 46#define STYLE_BARS 0
46#define STYLE_ANTENNA 1 47#define STYLE_ANTENNA 1
47 48
48WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) 49WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name )
49 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) 50 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet )
50{ 51{
51 52
53 readConfig();
54 writeConfigEntry( "UpdateFrequency", updateFrequency );
55 writeConfigEntry( "DisplayStyle", displayStyle );
56
52 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 57 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
53 QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); 58 QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" );
54 59
55 /* status label */ 60 /* status label */
56 61
57 statusLabel = new QLabel( this, "statuslabel" ); 62 statusLabel = new QLabel( this, "statuslabel" );
58 QString text( "Wireless Status:<br>" 63 QString text( "Wireless Status:<br>"
59 "*** Unknown ***<br>" 64 "*** Unknown ***<br>"
60 "Card not inserted ?<br>" 65 "Card not inserted ?<br>"
61 "Or Sharp ROM ?<br>" 66 "Or Sharp ROM ?<br>"
62 "CELL: 00:00:00:00:00:00" ); 67 "CELL: 00:00:00:00:00:00" );
63/* QString text( "Station: Unknown<br>" 68/* QString text( "Station: Unknown<br>"
64 "ESSID: Unknown<br>" 69 "ESSID: Unknown<br>"
65 "MODE: Unknown<br>" 70 "MODE: Unknown<br>"
66 "FREQ: Unknown<br>" 71 "FREQ: Unknown<br>"
67 "CELL: AA:BB:CC:DD:EE:FF" ); */ 72 "CELL: AA:BB:CC:DD:EE:FF" ); */
68 statusLabel->setText( text ); 73 statusLabel->setText( text );
69 statusLabel->setFixedSize( statusLabel->sizeHint() ); 74 statusLabel->setFixedSize( statusLabel->sizeHint() );
70 grid->addWidget( statusLabel, 0, 0 ); 75 grid->addWidget( statusLabel, 0, 0 );
71 76
72 /* visualization group box */ 77 /* visualization group box */
73 78
74 QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this ); 79 QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this );
75 QRadioButton* r1 = new QRadioButton( "Color Bars", group ); 80 QRadioButton* r1 = new QRadioButton( "Color Bars", group );
76 QRadioButton* r2 = new QRadioButton( "Antenna", group ); 81 QRadioButton* r2 = new QRadioButton( "Antenna", group );
77 r1->setFocusPolicy( QWidget::NoFocus ); 82 r1->setFocusPolicy( QWidget::NoFocus );
78 r2->setFocusPolicy( QWidget::NoFocus ); 83 r2->setFocusPolicy( QWidget::NoFocus );
79 group->setFocusPolicy( QWidget::NoFocus ); 84 group->setFocusPolicy( QWidget::NoFocus );
80 group->setButton( STYLE_ANTENNA ); 85 group->setButton( displayStyle );
81 grid->addWidget( group, 0, 1 ); 86 grid->addWidget( group, 0, 1 );
82 87
83 /* quality graph */ 88 /* quality graph */
84 89
85 mgraph = new MGraph( this ); 90 mgraph = new MGraph( this );
86 mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 91 mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
87 mgraph->setMin( 0 ); 92 mgraph->setMin( 0 );
88 mgraph->setMax( 92 ); 93 mgraph->setMax( 92 );
89 grid->addWidget( mgraph, 1, 0 ); 94 grid->addWidget( mgraph, 1, 0 );
90 mgraph->setFocusPolicy( QWidget::NoFocus ); 95 mgraph->setFocusPolicy( QWidget::NoFocus );
91 96
92 /* dhcp renew CheckBox */ 97 /* dhcp renew CheckBox */
93 98
94 //FIXME: under construction 99 //FIXME: under construction
95 //QCheckBox* dhcpCheckBox = new QCheckBox( "DHCP renew", this ); 100 //QCheckBox* dhcpCheckBox = new QCheckBox( "DHCP renew", this );
96 //dhcpCheckBox->setFocusPolicy( QWidget::NoFocus ); 101 //dhcpCheckBox->setFocusPolicy( QWidget::NoFocus );
97 //grid->addWidget( dhcpCheckBox, 2, 0, Qt::AlignCenter ); 102 //grid->addWidget( dhcpCheckBox, 2, 0, Qt::AlignCenter );
98 103
99 /* update Frequency Label */ 104 /* update Frequency Label */
100 105
101 updateLabel = new QLabel( this ); 106 updateLabel = new QLabel( this );
102 updateLabel->setText( "Update every 500 ms" ); 107 text.sprintf( "Update every %d s", updateFrequency );
108 updateLabel->setText( text );
103 grid->addWidget( updateLabel, 2, 1 ); 109 grid->addWidget( updateLabel, 2, 1 );
104 110
105 /* update Frequency Slider */ 111 /* update Frequency Slider */
106 112
107 QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); 113 QSlider* updateSlider = new QSlider( QSlider::Horizontal, this );
108 updateSlider->setRange( 50, 999 ); 114 updateSlider->setRange( 0, 9 );
109 updateSlider->setValue( 500 ); 115 updateSlider->setValue( updateFrequency );
110 updateSlider->setTickmarks( QSlider::Both ); 116 updateSlider->setTickmarks( QSlider::Both );
111 updateSlider->setTickInterval( 100 ); 117 updateSlider->setTickInterval( 1 );
112 updateSlider->setSteps( 50, 50 ); 118 updateSlider->setSteps( 1, 1 );
113 updateSlider->setFocusPolicy( QWidget::NoFocus ); 119 updateSlider->setFocusPolicy( QWidget::NoFocus );
114 grid->addWidget( updateSlider, 1, 1 ); 120 grid->addWidget( updateSlider, 1, 1 );
115 connect( updateSlider, SIGNAL( valueChanged( int ) ), 121 connect( updateSlider, SIGNAL( valueChanged( int ) ),
116 this, SLOT( updateDelayChange( int ) ) ); 122 this, SLOT( updateDelayChange( int ) ) );
117 123
118 setFixedSize( sizeHint() ); 124 setFixedSize( sizeHint() );
119 setFocusPolicy( QWidget::NoFocus ); 125 setFocusPolicy( QWidget::NoFocus );
120 126
127 applet->displayStyleChange( displayStyle );
128 applet->updateDelayChange( updateFrequency );
129
121 connect( group, SIGNAL( clicked( int ) ), 130 connect( group, SIGNAL( clicked( int ) ),
122 applet, SLOT( styleChange( int ) ) ); 131 this, SLOT( displayStyleChange( int ) ) );
123
124} 132}
125 133
126void WirelessControl::updateDelayChange( int delay ) 134void WirelessControl::updateDelayChange( int delay )
127{ 135{
128 QString text; 136 QString text;
129 text.sprintf( "Update every %3d ms", delay ); 137 text.sprintf( "Update every %d s", delay );
130 updateLabel->setText( text ); 138 updateLabel->setText( text );
131 applet->updateDelayChange( delay ); 139 applet->updateDelayChange( delay );
140 writeConfigEntry( "UpdateFrequency", delay );
141}
142
143void WirelessControl::displayStyleChange( int style )
144{
145 applet->displayStyleChange( style );
146 writeConfigEntry( "DisplayStyle", style );
132} 147}
133 148
134void WirelessControl::show ( bool ) 149void WirelessControl::show ( bool )
135{ 150{
136 QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); 151 QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) );
137 152
138 int w = sizeHint().width(); 153 int w = sizeHint().width();
139 int x = curPos.x() - ( w / 2 ); 154 int x = curPos.x() - ( w / 2 );
140 155
141 if ( ( x + w ) > QPEApplication::desktop()->width() ) 156 if ( ( x + w ) > QPEApplication::desktop()->width() )
142 x = QPEApplication::desktop ( )-> width ( ) - w; 157 x = QPEApplication::desktop ( )-> width ( ) - w;
143 158
144 move( x, curPos.y () - sizeHint().height () ); 159 move( x, curPos.y () - sizeHint().height () );
145 QFrame::show(); 160 QFrame::show();
146} 161}
147 162
163void WirelessControl::readConfig()
164{
165 Config cfg( "qpe" );
166 cfg.setGroup( "Wireless" );
167
168 updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 );
169 displayStyle = cfg. readNumEntry( "DisplayStyle", STYLE_ANTENNA );
170}
148 171
172void WirelessControl::writeConfigEntry( const char *entry, int val )
173{
174 Config cfg( "qpe" );
175 cfg.setGroup( "Wireless" );
176 cfg.writeEntry( entry, val );
177}
178
149//=========================================================================== 179//===========================================================================
150 180
151WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) 181WirelessApplet::WirelessApplet( QWidget *parent, const char *name )
152 : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), interface( 0 ) 182 : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ),
183 timer( 0 ), interface( 0 )
153{ 184{
154 setFixedHeight( 18 ); 185 setFixedHeight( 18 );
155 setFixedWidth( 14 ); 186 setFixedWidth( 14 );
156 status = new WirelessControl( this, 0, "wireless status" );
157
158 network = new MWirelessNetwork(); 187 network = new MWirelessNetwork();
159 188 status = new WirelessControl( this, 0, "wireless status" );
160 timer = startTimer( 500 );
161} 189}
162 190
163void WirelessApplet::checkInterface() 191void WirelessApplet::checkInterface()
164{ 192{
165 interface = network->getFirstInterface(); 193 interface = network->getFirstInterface();
166 if ( interface ) 194 if ( interface )
167 { 195 {
168 qDebug( "WIFIAPPLET: using interface '%s'", (const char*) 196 qDebug( "WIFIAPPLET: using interface '%s'", (const char*)
169 interface->getName() ); 197 interface->getName() );
170 } 198 }
171 else 199 else
172 { 200 {
173 qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); 201 qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" );
174 } 202 }
175} 203}
176 204
177void WirelessApplet::updateDelayChange( int delay ) 205void WirelessApplet::updateDelayChange( int delay )
178{ 206{
179 killTimer( timer ); 207 if ( timer )
208 killTimer( timer );
209 delay *= 1000;
210 if ( delay == 0 )
211 delay = 50;
180 timer = startTimer( delay ); 212 timer = startTimer( delay );
181} 213}
182 214
183WirelessApplet::~WirelessApplet() 215void WirelessApplet::displayStyleChange( int style )
184{ 216{
217 visualStyle = style;
218 repaint();
185} 219}
186 220
187void WirelessApplet::styleChange( int style ) 221WirelessApplet::~WirelessApplet()
188{ 222{
189 visualStyle = style;
190 repaint();
191} 223}
192 224
193void WirelessApplet::timerEvent( QTimerEvent* ) 225void WirelessApplet::timerEvent( QTimerEvent* )
194{ 226{
195 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; 227 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface;
196 228
197 if ( iface ) 229 if ( iface )
198 { 230 {
199 iface->updateStatistics(); 231 iface->updateStatistics();
200 if ( mustRepaint() ) 232 if ( mustRepaint() )
201 { 233 {
202 //qDebug( "WIFIAPPLET: A value has changed -> repainting." ); 234 //qDebug( "WIFIAPPLET: A value has changed -> repainting." );
203 repaint(); 235 repaint();
204 } 236 }
205 237
206 if ( status->isVisible() ) 238 if ( status->isVisible() )
207 updatePopupWindow(); 239 updatePopupWindow();
208 } else checkInterface(); 240 } else checkInterface();
209} 241}
210 242
211void WirelessApplet::mousePressEvent( QMouseEvent *) 243void WirelessApplet::mousePressEvent( QMouseEvent *)
212{ 244{
213 if ( status->isVisible() ) 245 if ( status->isVisible() )
214 status->hide(); 246 status->hide();
215 else 247 else
216 status->show( true ); 248 status->show( true );
217} 249}
218 250
219bool WirelessApplet::mustRepaint() 251bool WirelessApplet::mustRepaint()
220{ 252{
221 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; 253 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface;
222 254
223 // check if there are enough changes to justify a (flickering) repaint 255 // check if there are enough changes to justify a (flickering) repaint
224 256
225 // has the interface changed? 257 // has the interface changed?
226 258
227 if ( iface != oldiface ) 259 if ( iface != oldiface )
228 { 260 {
229 oldiface = iface; 261 oldiface = iface;
230 return true; 262 return true;
231 } 263 }
232 264
233 const char** pixmap = getQualityPixmap(); 265 const char** pixmap = getQualityPixmap();
234 266
235 if ( pixmap && ( pixmap != oldpixmap ) ) 267 if ( pixmap && ( pixmap != oldpixmap ) )
236 { 268 {
237 oldpixmap = pixmap; 269 oldpixmap = pixmap;
238 return true; 270 return true;
239 } 271 }
240 272
241 int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; 273 int noiseH = iface->noisePercent() * ( height() - 3 ) / 100;
242 int signalH = iface->signalPercent() * ( height() - 3 ) / 100; 274 int signalH = iface->signalPercent() * ( height() - 3 ) / 100;
243 int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; 275 int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100;
244 276
245 if ( ( noiseH != oldnoiseH ) 277 if ( ( noiseH != oldnoiseH )
246 || ( signalH != oldsignalH ) 278 || ( signalH != oldsignalH )
247 || ( qualityH != oldqualityH ) ) 279 || ( qualityH != oldqualityH ) )
248 { 280 {
249 oldnoiseH = noiseH; 281 oldnoiseH = noiseH;
250 oldsignalH = signalH; 282 oldsignalH = signalH;
251 oldqualityH = qualityH; 283 oldqualityH = qualityH;
252 return true; 284 return true;
253 } 285 }
254 286
255 return false; 287 return false;
256} 288}
257 289
258void WirelessApplet::updatePopupWindow() 290void WirelessApplet::updatePopupWindow()
259{ 291{
260 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; 292 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface;
261 int qualityH = iface->qualityPercent(); 293 int qualityH = iface->qualityPercent();
262 294
263 if ( status->mgraph ) 295 if ( status->mgraph )
264 status->mgraph->addValue( qualityH, false ); 296 status->mgraph->addValue( qualityH, false );
265 297
266 QString freqString; 298 QString freqString;
267 QString cell = ( iface->mode == "Managed" ) ? "AP: " : "Cell: "; 299 QString cell = ( iface->mode == "Managed" ) ? "AP: " : "Cell: ";
268 freqString.sprintf( "%.3f GHz", iface->freq ); 300 freqString.sprintf( "%.3f GHz", iface->freq );
269 status->statusLabel->setText( "Station: " + iface->nick + "<br>" + 301 status->statusLabel->setText( "Station: " + iface->nick + "<br>" +
270 "ESSID: " + iface->essid + "<br>" + 302 "ESSID: " + iface->essid + "<br>" +
271 "MODE: " + iface->mode + "<br>" + 303 "MODE: " + iface->mode + "<br>" +
272 "FREQ: " + freqString + "<br>" + 304 "FREQ: " + freqString + "<br>" +
273 cell + " " + iface->APAddr ); 305 cell + " " + iface->APAddr );
274} 306}
275 307
276const char** WirelessApplet::getQualityPixmap() 308const char** WirelessApplet::getQualityPixmap()
277{ 309{
278 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; 310 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface;
279 311
280 if ( !iface ) return ( const char** ) nowireless_xpm; 312 if ( !iface ) return ( const char** ) nowireless_xpm;
281 int qualityH = iface->qualityPercent(); 313 int qualityH = iface->qualityPercent();
282 if ( qualityH < 0 ) return ( const char** ) nowireless_xpm; 314 if ( qualityH < 0 ) return ( const char** ) nowireless_xpm;
283 315
284 if ( visualStyle == STYLE_ANTENNA ) 316 if ( visualStyle == STYLE_ANTENNA )
285 { 317 {
286 if ( qualityH < 1 ) return ( const char** ) connect0_xpm; 318 if ( qualityH < 1 ) return ( const char** ) connect0_xpm;
287 if ( qualityH < 17 ) return ( const char** ) connect1_xpm; 319 if ( qualityH < 17 ) return ( const char** ) connect1_xpm;
288 if ( qualityH < 34 ) return ( const char** ) connect2_xpm; 320 if ( qualityH < 34 ) return ( const char** ) connect2_xpm;
289 if ( qualityH < 50 ) return ( const char** ) connect3_xpm; 321 if ( qualityH < 50 ) return ( const char** ) connect3_xpm;
290 if ( qualityH < 65 ) return ( const char** ) connect4_xpm; 322 if ( qualityH < 65 ) return ( const char** ) connect4_xpm;
291 return ( const char** ) connect5_xpm; 323 return ( const char** ) connect5_xpm;
292 } 324 }
293 325
294 return 0; // please draw your bars 326 return 0; // please draw your bars
295} 327}
296 328
297void WirelessApplet::paintEvent( QPaintEvent* ) 329void WirelessApplet::paintEvent( QPaintEvent* )
298{ 330{
299 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface; 331 MWirelessNetworkInterface* iface = ( MWirelessNetworkInterface* ) interface;
300 332
301 QPainter p(this); 333 QPainter p(this);
302 QColor color; 334 QColor color;
303 335
304 const char** pixmap = getQualityPixmap(); 336 const char** pixmap = getQualityPixmap();
305 337
306 if ( pixmap ) 338 if ( pixmap )
307 p.drawPixmap( 0, 1, pixmap ); 339 p.drawPixmap( 0, 1, pixmap );
308 else 340 else
309 { 341 {
310 342
311 int noiseH = iface->noisePercent() * ( height() - 3 ) / 100; 343 int noiseH = iface->noisePercent() * ( height() - 3 ) / 100;
312 int signalH = iface->signalPercent() * ( height() - 3 ) / 100; 344 int signalH = iface->signalPercent() * ( height() - 3 ) / 100;
313 int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100; 345 int qualityH = iface->qualityPercent() * ( height() - 3 ) / 100;
314 346
315 double intensity; 347 double intensity;
316 int pixelHeight; 348 int pixelHeight;
317 int pixelWidth = 2; 349 int pixelWidth = 2;
318 int Hue; 350 int Hue;
319 int barSpace = 3; 351 int barSpace = 3;
320 int leftoffset = 0; 352 int leftoffset = 0;
321 int bottomoffset = 2; 353 int bottomoffset = 2;
322 354
323 // draw noise indicator 355 // draw noise indicator
324 pixelHeight = noiseH; 356 pixelHeight = noiseH;
325 Hue = 50; 357 Hue = 50;
326 for ( int i = 0; i < pixelHeight; ++i ) 358 for ( int i = 0; i < pixelHeight; ++i )
327 { 359 {
328 intensity = 50 + ( (double) i / (double) pixelHeight ) * 205; 360 intensity = 50 + ( (double) i / (double) pixelHeight ) * 205;
329 color.setHsv( Hue, 255, intensity ); 361 color.setHsv( Hue, 255, intensity );
330 p.setPen ( color ); 362 p.setPen ( color );
331 p.drawLine( leftoffset, height()-bottomoffset-i, pixelWidth+leftoffset, height()-bottomoffset-i ); 363 p.drawLine( leftoffset, height()-bottomoffset-i, pixelWidth+leftoffset, height()-bottomoffset-i );
332 } 364 }
333 365
334 // draw signal indicator 366 // draw signal indicator
335 pixelHeight = signalH; 367 pixelHeight = signalH;
336 Hue = 100; 368 Hue = 100;
337 leftoffset += pixelWidth + barSpace; 369 leftoffset += pixelWidth + barSpace;
338 for ( int i = 0; i < pixelHeight; ++i ) 370 for ( int i = 0; i < pixelHeight; ++i )
339 { 371 {
340 intensity = 50 + ( (double) i / (double) pixelHeight ) * 205; 372 intensity = 50 + ( (double) i / (double) pixelHeight ) * 205;
341 color.setHsv( Hue, 255, intensity ); 373 color.setHsv( Hue, 255, intensity );
342 p.setPen ( color ); 374 p.setPen ( color );
343 p.drawLine( leftoffset, height()-bottomoffset-i, pixelWidth+leftoffset, height()-bottomoffset-i ); 375 p.drawLine( leftoffset, height()-bottomoffset-i, pixelWidth+leftoffset, height()-bottomoffset-i );
344 } 376 }
345 377
346 // draw quality indicator 378 // draw quality indicator
347 pixelHeight = qualityH; 379 pixelHeight = qualityH;
348 Hue = 250; 380 Hue = 250;
349 leftoffset += pixelWidth + barSpace; 381 leftoffset += pixelWidth + barSpace;
350 for ( int i = 0; i < pixelHeight; ++i ) 382 for ( int i = 0; i < pixelHeight; ++i )
351 { 383 {
352 intensity = 50 + ( (double) i / (double) pixelHeight ) * 205; 384 intensity = 50 + ( (double) i / (double) pixelHeight ) * 205;
353 color.setHsv( Hue, 255, intensity ); 385 color.setHsv( Hue, 255, intensity );
354 p.setPen ( color ); 386 p.setPen ( color );
355 p.drawLine( leftoffset, height()-bottomoffset-i, pixelWidth+leftoffset, height()-bottomoffset-i ); 387 p.drawLine( leftoffset, height()-bottomoffset-i, pixelWidth+leftoffset, height()-bottomoffset-i );
356 } 388 }
357 } 389 }
358} 390}
diff --git a/noncore/applets/wirelessapplet/wireless.h b/noncore/applets/wirelessapplet/wireless.h
index d45ac68..45c519d 100644
--- a/noncore/applets/wirelessapplet/wireless.h
+++ b/noncore/applets/wirelessapplet/wireless.h
@@ -1,89 +1,95 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 2** Copyright (C) 2002 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
3** All rights reserved. 3** All rights reserved.
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13**********************************************************************/ 13**********************************************************************/
14 14
15#ifndef __WIRELESS_APPLET_H__ 15#ifndef __WIRELESS_APPLET_H__
16#define __WIRELESS_APPLET_H__ 16#define __WIRELESS_APPLET_H__
17 17
18#include <qwidget.h> 18#include <qwidget.h>
19#include <qframe.h> 19#include <qframe.h>
20#include <qpixmap.h> 20#include <qpixmap.h>
21 21
22class MNetwork; 22class MNetwork;
23class MWirelessNetwork; 23class MWirelessNetwork;
24class MNetworkInterface; 24class MNetworkInterface;
25class MWirelessNetworkInterface; 25class MWirelessNetworkInterface;
26class Y; 26class Y;
27class QLabel; 27class QLabel;
28class WirelessApplet; 28class WirelessApplet;
29class MGraph; 29class MGraph;
30 30
31class WirelessControl : public QFrame 31class WirelessControl : public QFrame
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34public: 34public:
35 WirelessControl( WirelessApplet* icon, QWidget *parent=0, const char *name=0 ); 35 WirelessControl( WirelessApplet* icon, QWidget *parent=0, const char *name=0 );
36 void show( bool ); 36 void show( bool );
37
38 void readConfig();
39 void writeConfigEntry( const char* entry, int val );
37 40
38 MGraph* mgraph; 41 MGraph* mgraph;
39 QLabel* statusLabel; 42 QLabel* statusLabel;
40 QLabel* updateLabel; 43 QLabel* updateLabel;
41 44
42public slots: 45public slots:
43 void updateDelayChange( int ); 46 void updateDelayChange( int );
47 void displayStyleChange( int );
44 48
45private: 49private:
46 WirelessApplet* applet; 50 WirelessApplet* applet;
51
52 int displayStyle;
53 int updateFrequency;
54
47}; 55};
48 56
49class WirelessApplet : public QWidget 57class WirelessApplet : public QWidget
50{ 58{
51 Q_OBJECT 59 Q_OBJECT
52public: 60public:
53 WirelessApplet( QWidget *parent = 0, const char *name=0 ); 61 WirelessApplet( QWidget *parent = 0, const char *name=0 );
54 ~WirelessApplet(); 62 ~WirelessApplet();
55 WirelessControl* status; 63 WirelessControl* status;
56 64
57 virtual void timerEvent( QTimerEvent* ); 65 virtual void timerEvent( QTimerEvent* );
58 void updateDelayChange( int delay ); 66 void updateDelayChange( int delay );
59 67 void displayStyleChange( int style );
60public slots:
61 void styleChange( int );
62 68
63private: 69private:
64 void mousePressEvent( QMouseEvent * ); 70 void mousePressEvent( QMouseEvent * );
65 void paintEvent( QPaintEvent* ); 71 void paintEvent( QPaintEvent* );
66 void checkInterface(); 72 void checkInterface();
67 73
68 bool mustRepaint(); 74 bool mustRepaint();
69 void updatePopupWindow(); 75 void updatePopupWindow();
70 const char** getQualityPixmap(); 76 const char** getQualityPixmap();
71 77
72private: 78private:
73 QPixmap snapshotPixmap; 79 QPixmap snapshotPixmap;
74 int visualStyle; 80 int visualStyle;
75 int timer; 81 int timer;
76 82
77 MWirelessNetwork* network; 83 MWirelessNetwork* network;
78 MNetworkInterface* interface; 84 MNetworkInterface* interface;
79 85
80private: 86private:
81 const char** oldpixmap; 87 const char** oldpixmap;
82 MWirelessNetworkInterface* oldiface; 88 MWirelessNetworkInterface* oldiface;
83 int oldqualityH; 89 int oldqualityH;
84 int oldsignalH; 90 int oldsignalH;
85 int oldnoiseH; 91 int oldnoiseH;
86}; 92};
87 93
88#endif // __WIRELESS_APPLET_H__ 94#endif // __WIRELESS_APPLET_H__
89 95