summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-03-29 11:58:21 (UTC)
committer mickeyl <mickeyl>2004-03-29 11:58:21 (UTC)
commit17e6e34865c25bd6bb89e0f2b9c1669db0ffc281 (patch) (unidiff)
tree2bc41d085c826e9a523d5390e27ef597b355a84c
parentf06be785e84ae52b665ca791925031da335f1f12 (diff)
downloadopie-17e6e34865c25bd6bb89e0f2b9c1669db0ffc281.zip
opie-17e6e34865c25bd6bb89e0f2b9c1669db0ffc281.tar.gz
opie-17e6e34865c25bd6bb89e0f2b9c1669db0ffc281.tar.bz2
eliminate bar graph display style
first shot at drawing the antenna symbol 'by hand' to support multiple display resolutions
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/wirelessapplet/connect0.xpm28
-rw-r--r--noncore/applets/wirelessapplet/connect1.xpm28
-rw-r--r--noncore/applets/wirelessapplet/connect2.xpm29
-rw-r--r--noncore/applets/wirelessapplet/connect3.xpm28
-rw-r--r--noncore/applets/wirelessapplet/connect4.xpm26
-rw-r--r--noncore/applets/wirelessapplet/connect5.xpm26
-rw-r--r--noncore/applets/wirelessapplet/nowireless.xpm22
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp137
-rw-r--r--noncore/applets/wirelessapplet/wireless.h5
9 files changed, 44 insertions, 285 deletions
diff --git a/noncore/applets/wirelessapplet/connect0.xpm b/noncore/applets/wirelessapplet/connect0.xpm
deleted file mode 100644
index f2c0bb7..0000000
--- a/noncore/applets/wirelessapplet/connect0.xpm
+++ b/dev/null
@@ -1,28 +0,0 @@
1/* XPM */
2static char * connect0_xpm[] = {
3"14 14 11 1",
4 " c None",
5 ".c #FFFFFF",
6 "+c #848284",
7 "@c #000000",
8 "#c #C6C3C6",
9 "$c #877F81",
10 "%c #191819",
11 "&c #897D7F",
12 "*c #0E0E0E",
13 "=c #575657",
14 "-c #131313",
15" ",
16" ",
17" ",
18" +@+ ",
19" #@@ ",
20" $%+ ",
21" + ",
22" @ ",
23" &*= ",
24" +-@ ",
25" +@@ ",
26" +#@@+ ",
27" +#@@@ ",
28" +#@@@ "};
diff --git a/noncore/applets/wirelessapplet/connect1.xpm b/noncore/applets/wirelessapplet/connect1.xpm
deleted file mode 100644
index d831437..0000000
--- a/noncore/applets/wirelessapplet/connect1.xpm
+++ b/dev/null
@@ -1,28 +0,0 @@
1/* XPM */
2static char * connect1_xpm[] = {
3"14 14 11 1",
4 " c None",
5 ".c #FFFFFF",
6 "+c #848284",
7 "@c #FF2609",
8 "#c #877F81",
9 "$c #000000",
10 "%c #897D7F",
11 "&c #0E0E0E",
12 "*c #575657",
13 "=c #131313",
14 "-c #C6C3C6",
15" ",
16" ",
17" ",
18" +@+ ",
19" @@@ ",
20" #@+ ",
21" + ",
22" $ ",
23" %&* ",
24" +=$ ",
25" +$$ ",
26" +-$$+ ",
27" +-$$$ ",
28" +-$$$ "};
diff --git a/noncore/applets/wirelessapplet/connect2.xpm b/noncore/applets/wirelessapplet/connect2.xpm
deleted file mode 100644
index 9e42f33..0000000
--- a/noncore/applets/wirelessapplet/connect2.xpm
+++ b/dev/null
@@ -1,29 +0,0 @@
1/* XPM */
2static char * connect2_xpm[] = {
3"14 14 12 1",
4 " c None",
5 ".c #FF2609",
6 "+c #FFFFFF",
7 "@c #848284",
8 "#c #000000",
9 "$c #C6C3C6",
10 "%c #877F81",
11 "&c #191819",
12 "*c #897D7F",
13 "=c #0E0E0E",
14 "-c #575657",
15 ";c #131313",
16" ",
17" ",
18" ... ",
19" .@#@. ",
20" .$##. ",
21" .%&@. ",
22" ... ",
23" # ",
24" *=- ",
25" @;# ",
26" @## ",
27" @$##@ ",
28" @$### ",
29" @$### "};
diff --git a/noncore/applets/wirelessapplet/connect3.xpm b/noncore/applets/wirelessapplet/connect3.xpm
deleted file mode 100644
index 263443d..0000000
--- a/noncore/applets/wirelessapplet/connect3.xpm
+++ b/dev/null
@@ -1,28 +0,0 @@
1/* XPM */
2static char * connect3_xpm[] = {
3"14 14 11 1",
4 " c None",
5 ".c #FF2609",
6 "+c #848284",
7 "@c #000000",
8 "#c #C6C3C6",
9 "$c #877F81",
10 "%c #191819",
11 "&c #897D7F",
12 "*c #0E0E0E",
13 "=c #575657",
14 "-c #131313",
15" ",
16" ... ",
17" . . ",
18" . +@+ . ",
19" . #@@ . ",
20" . $%+ . ",
21" . + . ",
22" ... ",
23" &*= ",
24" +-@ ",
25" +@@ ",
26" +#@@+ ",
27" +#@@@ ",
28" +#@@@ "};
diff --git a/noncore/applets/wirelessapplet/connect4.xpm b/noncore/applets/wirelessapplet/connect4.xpm
deleted file mode 100644
index 471ed64..0000000
--- a/noncore/applets/wirelessapplet/connect4.xpm
+++ b/dev/null
@@ -1,26 +0,0 @@
1/* XPM */
2static char * connect4_xpm[] = {
3"14 14 9 1",
4 " c None",
5 ".c #FF2609",
6 "+c #FFFFFF",
7 "@c #848284",
8 "#c #000000",
9 "$c #C6C3C6",
10 "%c #877F81",
11 "&c #191819",
12 "*c #131313",
13" ... ",
14" .. .. ",
15" . . ",
16" . @#@ . ",
17" . $## . ",
18" . %&@ . ",
19" . @ . ",
20" .. # .. ",
21" ... ",
22" @*# ",
23" @## ",
24" @$##@ ",
25" @$### ",
26" @$### "};
diff --git a/noncore/applets/wirelessapplet/connect5.xpm b/noncore/applets/wirelessapplet/connect5.xpm
deleted file mode 100644
index a67be9a..0000000
--- a/noncore/applets/wirelessapplet/connect5.xpm
+++ b/dev/null
@@ -1,26 +0,0 @@
1/* XPM */
2static char * connect5_xpm[] = {
3"14 14 9 1",
4 " c None",
5 ".c #FF2609",
6 "+c #FFFFFF",
7 "@c #848284",
8 "#c #000000",
9 "$c #C6C3C6",
10 "%c #877F81",
11 "&c #191819",
12 "*c #131313",
13" . ... . ",
14" . .. .. . ",
15" . . . .",
16" . . @#@ . .",
17" . . $## . .",
18" . . %&@ . .",
19" . . @ . .",
20" . .. # .. . ",
21" . ... . ",
22" @*# ",
23" @## ",
24" @$##@ ",
25" @$### ",
26" @$### "};
diff --git a/noncore/applets/wirelessapplet/nowireless.xpm b/noncore/applets/wirelessapplet/nowireless.xpm
deleted file mode 100644
index a76322d..0000000
--- a/noncore/applets/wirelessapplet/nowireless.xpm
+++ b/dev/null
@@ -1,22 +0,0 @@
1static char * nowireless_xpm[] = {
2"14 14 6 1",
3" c None",
4". c #FFFFFF",
5"+ c #848284",
6"@ c #000000",
7"# c #FF0000",
8"$ c #C6C3C6",
9" ",
10" ",
11" ",
12" +@+ ",
13" # $#@ ",
14" ####@+ ",
15" ## + ",
16" ####@ ",
17" # #@+ ",
18" # +#@ ",
19" +@@ ",
20" +$@@+ ",
21" +$@@@ ",
22" +$@@@ "};
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp
index f244426..711d0dd 100644
--- a/noncore/applets/wirelessapplet/wireless.cpp
+++ b/noncore/applets/wirelessapplet/wireless.cpp
@@ -14,13 +14,6 @@
14#include "wireless.h" 14#include "wireless.h"
15#include "mgraph.h" 15#include "mgraph.h"
16#include "advancedconfig.h" 16#include "advancedconfig.h"
17#include "connect0.xpm"
18#include "connect1.xpm"
19#include "connect2.xpm"
20#include "connect3.xpm"
21#include "connect4.xpm"
22#include "connect5.xpm"
23#include "nowireless.xpm"
24 17
25/* OPIE */ 18/* OPIE */
26#include <opie2/onetwork.h> 19#include <opie2/onetwork.h>
@@ -40,12 +33,10 @@
40#include <qtextstream.h> 33#include <qtextstream.h>
41 34
42/* STD */ 35/* STD */
36#include <math.h>
43#include <sys/types.h> 37#include <sys/types.h>
44#include <signal.h> 38#include <signal.h>
45 39
46#define STYLE_BARS 0
47#define STYLE_ANTENNA 1
48
49//#define MDEBUG 40//#define MDEBUG
50#undef MDEBUG 41#undef MDEBUG
51 42
@@ -57,7 +48,6 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const
57 48
58 readConfig(); 49 readConfig();
59 writeConfigEntry( "UpdateFrequency", updateFrequency ); 50 writeConfigEntry( "UpdateFrequency", updateFrequency );
60 writeConfigEntry( "DisplayStyle", displayStyle );
61 51
62 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 52 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
63 QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); 53 QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" );
@@ -71,7 +61,7 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const
71 "Or Sharp ROM ?<br>" 61 "Or Sharp ROM ?<br>"
72 "CELL: 00:00:00:00:00:00" ); 62 "CELL: 00:00:00:00:00:00" );
73 /* QString text( "Station: Unknown<br>" 63 /* QString text( "Station: Unknown<br>"
74 "ESSID: Unknown<br>" 64 "ESSID: Unknown<br>"
75 "MODE: Unknown<br>" 65 "MODE: Unknown<br>"
76 "FREQ: Unknown<br>" 66 "FREQ: Unknown<br>"
77 "CELL: AA:BB:CC:DD:EE:FF" ); */ 67 "CELL: AA:BB:CC:DD:EE:FF" ); */
@@ -81,15 +71,6 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const
81 71
82 /* visualization group box */ 72 /* visualization group box */
83 73
84 QButtonGroup* group = new QButtonGroup( 1, Qt::Horizontal, "Visualization", this );
85 QRadioButton* r1 = new QRadioButton( "Color Bars", group );
86 QRadioButton* r2 = new QRadioButton( "Antenna", group );
87 r1->setFocusPolicy( QWidget::NoFocus );
88 r2->setFocusPolicy( QWidget::NoFocus );
89 group->setFocusPolicy( QWidget::NoFocus );
90 group->setButton( displayStyle );
91 grid->addWidget( group, 0, 1 );
92
93 /* quality graph */ 74 /* quality graph */
94 75
95 mgraph = new MGraph( this ); 76 mgraph = new MGraph( this );
@@ -130,12 +111,8 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const
130 setFixedSize( sizeHint() ); 111 setFixedSize( sizeHint() );
131 setFocusPolicy( QWidget::NoFocus ); 112 setFocusPolicy( QWidget::NoFocus );
132 113
133 applet->displayStyleChange( displayStyle );
134 applet->updateDelayChange( updateFrequency ); 114 applet->updateDelayChange( updateFrequency );
135 115
136 connect( group, SIGNAL( clicked(int) ),
137 this, SLOT( displayStyleChange(int) ) );
138
139 applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); 116 applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE );
140} 117}
141 118
@@ -187,7 +164,6 @@ void WirelessControl::readConfig()
187 cfg.setGroup( "Wireless" ); 164 cfg.setGroup( "Wireless" );
188 165
189 updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); 166 updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 );
190 displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA );
191 rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); 167 rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false );
192 rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); 168 rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false );
193 rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); 169 rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false );
@@ -204,7 +180,7 @@ void WirelessControl::writeConfigEntry( const char *entry, int val )
204//=========================================================================== 180//===========================================================================
205 181
206WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) 182WirelessApplet::WirelessApplet( QWidget *parent, const char *name )
207 : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), 183 : QWidget( parent, name ),
208 timer( 0 ), interface( 0 ), oldiface( 0 ), 184 timer( 0 ), interface( 0 ), oldiface( 0 ),
209 rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) 185 rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false )
210{ 186{
@@ -391,11 +367,11 @@ bool WirelessApplet::mustRepaint()
391 } 367 }
392 } 368 }
393 369
394 const char** pixmap = getQualityPixmap(); 370 int rings = numberOfRings();
395 371
396 if ( pixmap && ( pixmap != oldpixmap ) ) 372 if ( rings != oldrings )
397 { 373 {
398 oldpixmap = pixmap; 374 oldrings = rings;
399 return true; 375 return true;
400 } 376 }
401 377
@@ -467,84 +443,55 @@ void WirelessApplet::updatePopupWindow()
467 cell + " " + interface->associatedAP().toString() ); 443 cell + " " + interface->associatedAP().toString() );
468} 444}
469 445
470const char** WirelessApplet::getQualityPixmap() 446int WirelessApplet::numberOfRings()
471{ 447{
472 if ( !interface ) return ( const char** ) nowireless_xpm; 448 if ( !interface ) return -1;
473 int qualityH = interface->signalStrength(); 449 int qualityH = interface->signalStrength();
474 if ( qualityH < 0 ) return ( const char** ) nowireless_xpm; 450 qDebug( "quality = %d", qualityH );
475 451 if ( qualityH < 1 ) return -1;
476 if ( visualStyle == STYLE_ANTENNA ) 452 if ( qualityH < 20 ) return 0;
477 { 453 if ( qualityH < 40 ) return 1;
478 if ( qualityH < 1 ) return ( const char** ) connect0_xpm; 454 if ( qualityH < 60 ) return 2;
479 if ( qualityH < 17 ) return ( const char** ) connect1_xpm; 455 if ( qualityH < 65 ) return 3;
480 if ( qualityH < 34 ) return ( const char** ) connect2_xpm; 456 return 4;
481 if ( qualityH < 50 ) return ( const char** ) connect3_xpm;
482 if ( qualityH < 65 ) return ( const char** ) connect4_xpm;
483 return ( const char** ) connect5_xpm;
484 }
485
486 return 0; // please draw your bars
487} 457}
488 458
489void WirelessApplet::paintEvent( QPaintEvent* ) 459void WirelessApplet::paintEvent( QPaintEvent* )
490{ 460{
491 QPainter p( this ); 461 QPainter p( this );
492 QColor color; 462 int h = height();
463 int w = width();
464 int m = 2;
493 465
494 const char** pixmap = getQualityPixmap(); 466 p.drawLine( m, h-m-1, round( w/2.0 ), round( 0+h/3.0 ) );
467 p.drawLine( round( w/2.0 ), round( 0+h/3.0 ), w-m, h-m-1 );
468 p.setPen( QColor( 150, 150, 150 ) );
469 p.drawLine( w-m, h-m-1, m, h-m-1 );
495 470
496 if ( pixmap ) 471 int rings = numberOfRings();
497 p.drawPixmap( 0, 1, pixmap ); 472
498 else 473 if ( rings == -1 )
474 {
475 p.setPen( QPen( QColor( 200, 20, 20 ), 2 ) );
476 p.drawLine( w/2-m-m, h/2-m-m, w/2+m+m, h/2+m+m );
477 p.drawLine( w/2+m+m, h/2-m-m, w/2-m-m, h/2+m+m );
478 return;
479 }
480
481 qDebug( "WirelessApplet: painting %d rings", rings );
482 int radius = 2;
483 int rstep = 4;
484 int maxrings = w/rstep;
485
486 p.setPen( QColor( 200, 20, 20 ) );
487 for ( int i = 0; i < rings; ++i )
499 { 488 {
489 p.drawEllipse( w/2 - radius/2, h/3 - radius/2, radius, radius );
490 radius += rstep;
491 };
500 492
501 int noiseH = 30; // iface->noisePercent() * ( height() - 3 ) / 100;
502 int signalH = 50; // iface->signalPercent() * ( height() - 3 ) / 100;
503 int qualityH = interface->signalStrength(); // iface->qualityPercent() * ( height() - 3 ) / 100;
504
505 double intensity;
506 int pixelHeight;
507 int pixelWidth = 2;
508 int Hue;
509 int barSpace = 3;
510 int leftoffset = 0;
511 int bottomoffset = 2;
512
513 // draw noise indicator
514 pixelHeight = noiseH;
515 Hue = 50;
516 for ( int i = 0; i < pixelHeight; ++i )
517 {
518 intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205;
519 color.setHsv( Hue, 255, intensity );
520 p.setPen ( color );
521 p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i );
522 }
523 493
524 // draw signal indicator
525 pixelHeight = signalH;
526 Hue = 100;
527 leftoffset += pixelWidth + barSpace;
528 for ( int i = 0; i < pixelHeight; ++i )
529 {
530 intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205;
531 color.setHsv( Hue, 255, intensity );
532 p.setPen ( color );
533 p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i );
534 }
535 494
536 // draw quality indicator
537 pixelHeight = qualityH;
538 Hue = 250;
539 leftoffset += pixelWidth + barSpace;
540 for ( int i = 0; i < pixelHeight; ++i )
541 {
542 intensity = 50 + ( ( double ) i / ( double ) pixelHeight ) * 205;
543 color.setHsv( Hue, 255, intensity );
544 p.setPen ( color );
545 p.drawLine( leftoffset, height() - bottomoffset - i, pixelWidth + leftoffset, height() - bottomoffset - i );
546 }
547 }
548} 495}
549 496
550 497
diff --git a/noncore/applets/wirelessapplet/wireless.h b/noncore/applets/wirelessapplet/wireless.h
index b475a46..9146c66 100644
--- a/noncore/applets/wirelessapplet/wireless.h
+++ b/noncore/applets/wirelessapplet/wireless.h
@@ -50,7 +50,6 @@ class WirelessControl : public QFrame
50 private: 50 private:
51 WirelessApplet* applet; 51 WirelessApplet* applet;
52 52
53 int displayStyle;
54 int updateFrequency; 53 int updateFrequency;
55 54
56 bool rocESSID; 55 bool rocESSID;
@@ -82,7 +81,7 @@ class WirelessApplet : public QWidget
82 81
83 bool mustRepaint(); 82 bool mustRepaint();
84 void updatePopupWindow(); 83 void updatePopupWindow();
85 const char** getQualityPixmap(); 84 int numberOfRings();
86 85
87 private: 86 private:
88 QPixmap snapshotPixmap; 87 QPixmap snapshotPixmap;
@@ -92,7 +91,7 @@ class WirelessApplet : public QWidget
92 Opie::Net::OWirelessNetworkInterface* interface; 91 Opie::Net::OWirelessNetworkInterface* interface;
93 92
94 private: 93 private:
95 const char** oldpixmap; 94 int oldrings;
96 Opie::Net::OWirelessNetworkInterface* oldiface; 95 Opie::Net::OWirelessNetworkInterface* oldiface;
97 int oldqualityH; 96 int oldqualityH;
98 int oldsignalH; 97 int oldsignalH;