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
@@ -1,239 +1,215 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer <mickey@vanille.de> 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer <mickey@vanille.de>
3** 3**
4** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
5** GNU General Public License version 2 as published by the Free Software 5** GNU General Public License version 2 as published by the Free Software
6** Foundation and appearing in the file LICENSE.GPL included in the 6** Foundation and appearing in the file LICENSE.GPL included in the
7** packaging of this file. 7** packaging of this file.
8** 8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11** 11**
12**********************************************************************/ 12**********************************************************************/
13 13
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>
27#include <opie2/otaskbarapplet.h> 20#include <opie2/otaskbarapplet.h>
28#include <qpe/config.h> 21#include <qpe/config.h>
29#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
30 23
31/* QT */ 24/* QT */
32#include <qradiobutton.h> 25#include <qradiobutton.h>
33#include <qpushbutton.h> 26#include <qpushbutton.h>
34#include <qpainter.h> 27#include <qpainter.h>
35#include <qlabel.h> 28#include <qlabel.h>
36#include <qslider.h> 29#include <qslider.h>
37#include <qbuttongroup.h> 30#include <qbuttongroup.h>
38#include <qlayout.h> 31#include <qlayout.h>
39#include <qfile.h> 32#include <qfile.h>
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
52using namespace Opie::Ui; 43using namespace Opie::Ui;
53using namespace Opie::Net; 44using namespace Opie::Net;
54WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) 45WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name )
55 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) 46 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet )
56{ 47{
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" );
64 54
65 /* status label */ 55 /* status label */
66 56
67 statusLabel = new QLabel( this, "statuslabel" ); 57 statusLabel = new QLabel( this, "statuslabel" );
68 QString text( "Wireless Status:<br>" 58 QString text( "Wireless Status:<br>"
69 "*** Unknown ***<br>" 59 "*** Unknown ***<br>"
70 "Card not inserted ?<br>" 60 "Card not inserted ?<br>"
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" ); */
78 statusLabel->setText( text ); 68 statusLabel->setText( text );
79 statusLabel->setFixedSize( statusLabel->sizeHint() ); 69 statusLabel->setFixedSize( statusLabel->sizeHint() );
80 grid->addWidget( statusLabel, 0, 0 ); 70 grid->addWidget( statusLabel, 0, 0 );
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 );
96 mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 77 mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
97 mgraph->setMin( 0 ); 78 mgraph->setMin( 0 );
98 mgraph->setMax( 92 ); 79 mgraph->setMax( 92 );
99 grid->addWidget( mgraph, 1, 0 ); 80 grid->addWidget( mgraph, 1, 0 );
100 mgraph->setFocusPolicy( QWidget::NoFocus ); 81 mgraph->setFocusPolicy( QWidget::NoFocus );
101 82
102 /* advanced configuration Button */ 83 /* advanced configuration Button */
103 84
104 QPushButton* advanced = new QPushButton( "Advanced...", this ); 85 QPushButton* advanced = new QPushButton( "Advanced...", this );
105 advanced->setFocusPolicy( QWidget::NoFocus ); 86 advanced->setFocusPolicy( QWidget::NoFocus );
106 grid->addWidget( advanced, 2, 0, Qt::AlignCenter ); 87 grid->addWidget( advanced, 2, 0, Qt::AlignCenter );
107 connect( advanced, SIGNAL( clicked() ), 88 connect( advanced, SIGNAL( clicked() ),
108 this, SLOT( advancedConfigClicked() ) ); 89 this, SLOT( advancedConfigClicked() ) );
109 90
110 /* update Frequency Label */ 91 /* update Frequency Label */
111 92
112 updateLabel = new QLabel( this ); 93 updateLabel = new QLabel( this );
113 text.sprintf( "Update every %d s", updateFrequency ); 94 text.sprintf( "Update every %d s", updateFrequency );
114 updateLabel->setText( text ); 95 updateLabel->setText( text );
115 grid->addWidget( updateLabel, 2, 1 ); 96 grid->addWidget( updateLabel, 2, 1 );
116 97
117 /* update Frequency Slider */ 98 /* update Frequency Slider */
118 99
119 QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); 100 QSlider* updateSlider = new QSlider( QSlider::Horizontal, this );
120 updateSlider->setRange( 0, 9 ); 101 updateSlider->setRange( 0, 9 );
121 updateSlider->setValue( updateFrequency ); 102 updateSlider->setValue( updateFrequency );
122 updateSlider->setTickmarks( QSlider::Both ); 103 updateSlider->setTickmarks( QSlider::Both );
123 updateSlider->setTickInterval( 1 ); 104 updateSlider->setTickInterval( 1 );
124 updateSlider->setSteps( 1, 1 ); 105 updateSlider->setSteps( 1, 1 );
125 updateSlider->setFocusPolicy( QWidget::NoFocus ); 106 updateSlider->setFocusPolicy( QWidget::NoFocus );
126 grid->addWidget( updateSlider, 1, 1 ); 107 grid->addWidget( updateSlider, 1, 1 );
127 connect( updateSlider, SIGNAL( valueChanged(int) ), 108 connect( updateSlider, SIGNAL( valueChanged(int) ),
128 this, SLOT( updateDelayChange(int) ) ); 109 this, SLOT( updateDelayChange(int) ) );
129 110
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
142void WirelessControl::advancedConfigClicked() 119void WirelessControl::advancedConfigClicked()
143{ 120{
144 AdvancedConfig * a = new AdvancedConfig( this, "dialog", TRUE ); 121 AdvancedConfig * a = new AdvancedConfig( this, "dialog", TRUE );
145 int result = a->exec(); 122 int result = a->exec();
146 a->hide(); 123 a->hide();
147 delete a; 124 delete a;
148 if ( result == QDialog::Accepted ) 125 if ( result == QDialog::Accepted )
149 { 126 {
150 readConfig(); 127 readConfig();
151 applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); 128 applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE );
152 } 129 }
153} 130}
154 131
155void WirelessControl::updateDelayChange( int delay ) 132void WirelessControl::updateDelayChange( int delay )
156{ 133{
157 QString text; 134 QString text;
158 text.sprintf( "Update every %d s", delay ); 135 text.sprintf( "Update every %d s", delay );
159 updateLabel->setText( text ); 136 updateLabel->setText( text );
160 applet->updateDelayChange( delay ); 137 applet->updateDelayChange( delay );
161 writeConfigEntry( "UpdateFrequency", delay ); 138 writeConfigEntry( "UpdateFrequency", delay );
162} 139}
163 140
164void WirelessControl::displayStyleChange( int style ) 141void WirelessControl::displayStyleChange( int style )
165{ 142{
166 applet->displayStyleChange( style ); 143 applet->displayStyleChange( style );
167 writeConfigEntry( "DisplayStyle", style ); 144 writeConfigEntry( "DisplayStyle", style );
168} 145}
169 146
170void WirelessControl::show ( bool ) 147void WirelessControl::show ( bool )
171{ 148{
172 QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); 149 QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) );
173 150
174 int w = sizeHint().width(); 151 int w = sizeHint().width();
175 int x = curPos.x() - ( w / 2 ); 152 int x = curPos.x() - ( w / 2 );
176 153
177 if ( ( x + w ) > QPEApplication::desktop() ->width() ) 154 if ( ( x + w ) > QPEApplication::desktop() ->width() )
178 x = QPEApplication::desktop ( ) -> width ( ) - w; 155 x = QPEApplication::desktop ( ) -> width ( ) - w;
179 156
180 move( x, curPos.y () - sizeHint().height () ); 157 move( x, curPos.y () - sizeHint().height () );
181 QFrame::show(); 158 QFrame::show();
182} 159}
183 160
184void WirelessControl::readConfig() 161void WirelessControl::readConfig()
185{ 162{
186 Config cfg( "qpe" ); 163 Config cfg( "qpe" );
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 );
194 rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); 170 rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false );
195} 171}
196 172
197void WirelessControl::writeConfigEntry( const char *entry, int val ) 173void WirelessControl::writeConfigEntry( const char *entry, int val )
198{ 174{
199 Config cfg( "qpe" ); 175 Config cfg( "qpe" );
200 cfg.setGroup( "Wireless" ); 176 cfg.setGroup( "Wireless" );
201 cfg.writeEntry( entry, val ); 177 cfg.writeEntry( entry, val );
202} 178}
203 179
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{
211 setFixedHeight( 18 ); 187 setFixedHeight( 18 );
212 setFixedWidth( 14 ); 188 setFixedWidth( 14 );
213 status = new WirelessControl( this, this, "wireless status" ); 189 status = new WirelessControl( this, this, "wireless status" );
214} 190}
215 191
216void WirelessApplet::checkInterface() 192void WirelessApplet::checkInterface()
217{ 193{
218 interface = 0L; 194 interface = 0L;
219 ONetwork* net = ONetwork::instance(); 195 ONetwork* net = ONetwork::instance();
220 net->synchronize(); 196 net->synchronize();
221 ONetwork::InterfaceIterator it = net->iterator(); 197 ONetwork::InterfaceIterator it = net->iterator();
222 198
223 while ( it.current() && !it.current()->isWireless() ) ++it; 199 while ( it.current() && !it.current()->isWireless() ) ++it;
224 200
225 if ( it.current() && it.current()->isWireless() ) 201 if ( it.current() && it.current()->isWireless() )
226 interface = static_cast<OWirelessNetworkInterface*>( it.current() ); 202 interface = static_cast<OWirelessNetworkInterface*>( it.current() );
227 203
228 if ( interface ) 204 if ( interface )
229 { 205 {
230#ifdef MDEBUG 206#ifdef MDEBUG
231 qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() ); 207 qDebug( "WIFIAPPLET: using interface '%s'", ( const char* ) interface->name() );
232#endif 208#endif
233 209
234 } 210 }
235 else 211 else
236 { 212 {
237#ifdef MDEBUG 213#ifdef MDEBUG
238 qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); 214 qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" );
239#endif 215#endif
@@ -362,69 +338,69 @@ void WirelessApplet::mousePressEvent( QMouseEvent * )
362 if ( status->isVisible() ) 338 if ( status->isVisible() )
363 status->hide(); 339 status->hide();
364 else 340 else
365 status->show( true ); 341 status->show( true );
366} 342}
367 343
368bool WirelessApplet::mustRepaint() 344bool WirelessApplet::mustRepaint()
369{ 345{
370 // check if there are enough changes to justify a (flickering) repaint 346 // check if there are enough changes to justify a (flickering) repaint
371 347
372 // has the interface changed? 348 // has the interface changed?
373 349
374 if ( interface != oldiface ) 350 if ( interface != oldiface )
375 { 351 {
376 oldiface = interface; 352 oldiface = interface;
377 if ( interface ) 353 if ( interface )
378 { 354 {
379#ifdef MDEBUG 355#ifdef MDEBUG
380 qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" ); 356 qDebug( "WIFIAPPLET: We had no interface but now we have one! :-)" );
381#endif 357#endif
382 show(); 358 show();
383 } 359 }
384 else 360 else
385 { 361 {
386#ifdef MDEBUG 362#ifdef MDEBUG
387 qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" ); 363 qDebug( "WIFIAPPLET: We had a interface but now we don't have one! ;-(" );
388#endif 364#endif
389 hide(); 365 hide();
390 return true; 366 return true;
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
402 int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100; 378 int noiseH = 50; // iface->noisePercent() * ( height() - 3 ) / 100;
403 int signalH = interface->signalStrength() * ( height() - 3 ) / 100; 379 int signalH = interface->signalStrength() * ( height() - 3 ) / 100;
404 int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100; 380 int qualityH = 50; // iface->qualityPercent() * ( height() - 3 ) / 100;
405 381
406 if ( ( noiseH != oldnoiseH ) 382 if ( ( noiseH != oldnoiseH )
407 || ( signalH != oldsignalH ) 383 || ( signalH != oldsignalH )
408 || ( qualityH != oldqualityH ) ) 384 || ( qualityH != oldqualityH ) )
409 { 385 {
410 oldnoiseH = noiseH; 386 oldnoiseH = noiseH;
411 oldsignalH = signalH; 387 oldsignalH = signalH;
412 oldqualityH = qualityH; 388 oldqualityH = qualityH;
413 return true; 389 return true;
414 } 390 }
415 391
416 if ( rocESSID && ( oldESSID != interface->SSID() ) ) 392 if ( rocESSID && ( oldESSID != interface->SSID() ) )
417 { 393 {
418#ifdef MDEBUG 394#ifdef MDEBUG
419 qDebug( "WIFIAPPLET: ESSID has changed." ); 395 qDebug( "WIFIAPPLET: ESSID has changed." );
420#endif 396#endif
421 renewDHCP(); 397 renewDHCP();
422 } 398 }
423 else if ( rocFREQ && ( oldFREQ != interface->frequency() ) ) 399 else if ( rocFREQ && ( oldFREQ != interface->frequency() ) )
424 { 400 {
425#ifdef MDEBUG 401#ifdef MDEBUG
426 qDebug( "WIFIAPPLET: FREQ has changed." ); 402 qDebug( "WIFIAPPLET: FREQ has changed." );
427#endif 403#endif
428 renewDHCP(); 404 renewDHCP();
429 } 405 }
430 else if ( rocAP && ( oldAP != interface->associatedAP().toString() ) ) 406 else if ( rocAP && ( oldAP != interface->associatedAP().toString() ) )
@@ -438,120 +414,91 @@ bool WirelessApplet::mustRepaint()
438 { 414 {
439#ifdef MDEBUG 415#ifdef MDEBUG
440 qDebug( "WIFIAPPLET: MODE has changed." ); 416 qDebug( "WIFIAPPLET: MODE has changed." );
441#endif 417#endif
442 renewDHCP(); 418 renewDHCP();
443 } 419 }
444 420
445 oldESSID = interface->SSID(); 421 oldESSID = interface->SSID();
446 oldMODE = interface->mode(); 422 oldMODE = interface->mode();
447 oldFREQ = interface->frequency(); 423 oldFREQ = interface->frequency();
448 oldAP = interface->associatedAP().toString(); 424 oldAP = interface->associatedAP().toString();
449 425
450 return false; 426 return false;
451} 427}
452 428
453void WirelessApplet::updatePopupWindow() 429void WirelessApplet::updatePopupWindow()
454{ 430{
455 int qualityH = interface->signalStrength(); 431 int qualityH = interface->signalStrength();
456 432
457 if ( status->mgraph ) 433 if ( status->mgraph )
458 status->mgraph->addValue( qualityH, false ); 434 status->mgraph->addValue( qualityH, false );
459 435
460 QString freqString; 436 QString freqString;
461 QString cell = ( interface->mode() == "Managed" ) ? "AP: " : "Cell: "; 437 QString cell = ( interface->mode() == "Managed" ) ? "AP: " : "Cell: ";
462 freqString.sprintf( "%.3f GHz", interface->frequency() ); 438 freqString.sprintf( "%.3f GHz", interface->frequency() );
463 status->statusLabel->setText( "Station: " + interface->nickName() + "<br>" + 439 status->statusLabel->setText( "Station: " + interface->nickName() + "<br>" +
464 "ESSID: " + interface->SSID() + "<br>" + 440 "ESSID: " + interface->SSID() + "<br>" +
465 "MODE: " + interface->mode() + "<br>" + 441 "MODE: " + interface->mode() + "<br>" +
466 "FREQ: " + freqString + "<br>" + 442 "FREQ: " + freqString + "<br>" +
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
551int WirelessApplet::position() 498int WirelessApplet::position()
552{ 499{
553 return 6; 500 return 6;
554} 501}
555 502
556EXPORT_OPIE_APPLET_v1( WirelessApplet ) 503EXPORT_OPIE_APPLET_v1( WirelessApplet )
557 504
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
@@ -21,93 +21,92 @@
21 21
22namespace Opie {namespace Net { 22namespace Opie {namespace Net {
23 class OWirelessNetworkInterface; 23 class OWirelessNetworkInterface;
24} 24}
25} 25}
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
34 public: 34 public:
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 37
38 void readConfig(); 38 void readConfig();
39 void writeConfigEntry( const char* entry, int val ); 39 void writeConfigEntry( const char* entry, int val );
40 40
41 MGraph* mgraph; 41 MGraph* mgraph;
42 QLabel* statusLabel; 42 QLabel* statusLabel;
43 QLabel* updateLabel; 43 QLabel* updateLabel;
44 44
45 public slots: 45 public slots:
46 void updateDelayChange( int ); 46 void updateDelayChange( int );
47 void displayStyleChange( int ); 47 void displayStyleChange( int );
48 void advancedConfigClicked(); 48 void advancedConfigClicked();
49 49
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;
57 bool rocFREQ; 56 bool rocFREQ;
58 bool rocAP; 57 bool rocAP;
59 bool rocMODE; 58 bool rocMODE;
60}; 59};
61 60
62class WirelessApplet : public QWidget 61class WirelessApplet : public QWidget
63{ 62{
64 Q_OBJECT 63 Q_OBJECT
65 public: 64 public:
66 WirelessApplet( QWidget *parent = 0, const char *name=0 ); 65 WirelessApplet( QWidget *parent = 0, const char *name=0 );
67 ~WirelessApplet(); 66 ~WirelessApplet();
68 static int position(); 67 static int position();
69 WirelessControl* status; 68 WirelessControl* status;
70 69
71 virtual void timerEvent( QTimerEvent* ); 70 virtual void timerEvent( QTimerEvent* );
72 void updateDelayChange( int delay ); 71 void updateDelayChange( int delay );
73 void displayStyleChange( int style ); 72 void displayStyleChange( int style );
74 73
75 void updateDHCPConfig( bool, bool, bool, bool ); 74 void updateDHCPConfig( bool, bool, bool, bool );
76 75
77 private: 76 private:
78 void mousePressEvent( QMouseEvent * ); 77 void mousePressEvent( QMouseEvent * );
79 void paintEvent( QPaintEvent* ); 78 void paintEvent( QPaintEvent* );
80 void checkInterface(); 79 void checkInterface();
81 void renewDHCP(); 80 void renewDHCP();
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;
89 int visualStyle; 88 int visualStyle;
90 int timer; 89 int timer;
91 90
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;
99 int oldnoiseH; 98 int oldnoiseH;
100 99
101 QString oldESSID; 100 QString oldESSID;
102 QString oldAP; 101 QString oldAP;
103 QString oldMODE; 102 QString oldMODE;
104 double oldFREQ; 103 double oldFREQ;
105 104
106 bool rocESSID; 105 bool rocESSID;
107 bool rocFREQ; 106 bool rocFREQ;
108 bool rocAP; 107 bool rocAP;
109 bool rocMODE; 108 bool rocMODE;
110}; 109};
111 110
112#endif // __WIRELESS_APPLET_H__ 111#endif // __WIRELESS_APPLET_H__
113 112