author | sandman <sandman> | 2002-10-31 02:12:34 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-31 02:12:34 (UTC) |
commit | 035eaf63bb2156ea7facd6b50f8891503d1f7bed (patch) (unidiff) | |
tree | cbb390a9a67952ea501eaa376ae72b425ae16f6b | |
parent | ddd5f680b3dbd5e169d43f5216fbf24b04e4cb33 (diff) | |
download | opie-035eaf63bb2156ea7facd6b50f8891503d1f7bed.zip opie-035eaf63bb2156ea7facd6b50f8891503d1f7bed.tar.gz opie-035eaf63bb2156ea7facd6b50f8891503d1f7bed.tar.bz2 |
Applied the same fix as in volume applet (parent widget should not be 0 for
taskbar applets) even though wireless applet seems not to be causing any
troubles. But IMHO it's better to apply it now ...
-rw-r--r-- | noncore/applets/wirelessapplet/wireless.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp index fb9522a..763aab8 100644 --- a/noncore/applets/wirelessapplet/wireless.cpp +++ b/noncore/applets/wirelessapplet/wireless.cpp | |||
@@ -122,193 +122,193 @@ WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const | |||
122 | 122 | ||
123 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); | 123 | QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); |
124 | updateSlider->setRange( 0, 9 ); | 124 | updateSlider->setRange( 0, 9 ); |
125 | updateSlider->setValue( updateFrequency ); | 125 | updateSlider->setValue( updateFrequency ); |
126 | updateSlider->setTickmarks( QSlider::Both ); | 126 | updateSlider->setTickmarks( QSlider::Both ); |
127 | updateSlider->setTickInterval( 1 ); | 127 | updateSlider->setTickInterval( 1 ); |
128 | updateSlider->setSteps( 1, 1 ); | 128 | updateSlider->setSteps( 1, 1 ); |
129 | updateSlider->setFocusPolicy( QWidget::NoFocus ); | 129 | updateSlider->setFocusPolicy( QWidget::NoFocus ); |
130 | grid->addWidget( updateSlider, 1, 1 ); | 130 | grid->addWidget( updateSlider, 1, 1 ); |
131 | connect( updateSlider, SIGNAL( valueChanged( int ) ), | 131 | connect( updateSlider, SIGNAL( valueChanged( int ) ), |
132 | this, SLOT( updateDelayChange( int ) ) ); | 132 | this, SLOT( updateDelayChange( int ) ) ); |
133 | 133 | ||
134 | setFixedSize( sizeHint() ); | 134 | setFixedSize( sizeHint() ); |
135 | setFocusPolicy( QWidget::NoFocus ); | 135 | setFocusPolicy( QWidget::NoFocus ); |
136 | 136 | ||
137 | applet->displayStyleChange( displayStyle ); | 137 | applet->displayStyleChange( displayStyle ); |
138 | applet->updateDelayChange( updateFrequency ); | 138 | applet->updateDelayChange( updateFrequency ); |
139 | 139 | ||
140 | connect( group, SIGNAL( clicked( int ) ), | 140 | connect( group, SIGNAL( clicked( int ) ), |
141 | this, SLOT( displayStyleChange( int ) ) ); | 141 | this, SLOT( displayStyleChange( int ) ) ); |
142 | 142 | ||
143 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | 143 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); |
144 | } | 144 | } |
145 | 145 | ||
146 | void WirelessControl::advancedConfigClicked() | 146 | void WirelessControl::advancedConfigClicked() |
147 | { | 147 | { |
148 | AdvancedConfig* a = new AdvancedConfig( this, "dialog", TRUE ); | 148 | AdvancedConfig* a = new AdvancedConfig( this, "dialog", TRUE ); |
149 | int result = a->exec(); | 149 | int result = a->exec(); |
150 | a->hide(); | 150 | a->hide(); |
151 | delete a; | 151 | delete a; |
152 | if ( result == QDialog::Accepted ) | 152 | if ( result == QDialog::Accepted ) |
153 | { | 153 | { |
154 | readConfig(); | 154 | readConfig(); |
155 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); | 155 | applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | void WirelessControl::updateDelayChange( int delay ) | 159 | void WirelessControl::updateDelayChange( int delay ) |
160 | { | 160 | { |
161 | QString text; | 161 | QString text; |
162 | text.sprintf( "Update every %d s", delay ); | 162 | text.sprintf( "Update every %d s", delay ); |
163 | updateLabel->setText( text ); | 163 | updateLabel->setText( text ); |
164 | applet->updateDelayChange( delay ); | 164 | applet->updateDelayChange( delay ); |
165 | writeConfigEntry( "UpdateFrequency", delay ); | 165 | writeConfigEntry( "UpdateFrequency", delay ); |
166 | } | 166 | } |
167 | 167 | ||
168 | void WirelessControl::displayStyleChange( int style ) | 168 | void WirelessControl::displayStyleChange( int style ) |
169 | { | 169 | { |
170 | applet->displayStyleChange( style ); | 170 | applet->displayStyleChange( style ); |
171 | writeConfigEntry( "DisplayStyle", style ); | 171 | writeConfigEntry( "DisplayStyle", style ); |
172 | } | 172 | } |
173 | 173 | ||
174 | void WirelessControl::show ( bool ) | 174 | void WirelessControl::show ( bool ) |
175 | { | 175 | { |
176 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); | 176 | QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); |
177 | 177 | ||
178 | int w = sizeHint().width(); | 178 | int w = sizeHint().width(); |
179 | int x = curPos.x() - ( w / 2 ); | 179 | int x = curPos.x() - ( w / 2 ); |
180 | 180 | ||
181 | if ( ( x + w ) > QPEApplication::desktop()->width() ) | 181 | if ( ( x + w ) > QPEApplication::desktop()->width() ) |
182 | x = QPEApplication::desktop ( )-> width ( ) - w; | 182 | x = QPEApplication::desktop ( )-> width ( ) - w; |
183 | 183 | ||
184 | move( x, curPos.y () - sizeHint().height () ); | 184 | move( x, curPos.y () - sizeHint().height () ); |
185 | QFrame::show(); | 185 | QFrame::show(); |
186 | } | 186 | } |
187 | 187 | ||
188 | void WirelessControl::readConfig() | 188 | void WirelessControl::readConfig() |
189 | { | 189 | { |
190 | Config cfg( "qpe" ); | 190 | Config cfg( "qpe" ); |
191 | cfg.setGroup( "Wireless" ); | 191 | cfg.setGroup( "Wireless" ); |
192 | 192 | ||
193 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); | 193 | updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); |
194 | displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA ); | 194 | displayStyle = cfg.readNumEntry( "DisplayStyle", STYLE_ANTENNA ); |
195 | rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); | 195 | rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); |
196 | rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); | 196 | rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); |
197 | rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); | 197 | rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); |
198 | rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); | 198 | rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); |
199 | } | 199 | } |
200 | 200 | ||
201 | void WirelessControl::writeConfigEntry( const char *entry, int val ) | 201 | void WirelessControl::writeConfigEntry( const char *entry, int val ) |
202 | { | 202 | { |
203 | Config cfg( "qpe" ); | 203 | Config cfg( "qpe" ); |
204 | cfg.setGroup( "Wireless" ); | 204 | cfg.setGroup( "Wireless" ); |
205 | cfg.writeEntry( entry, val ); | 205 | cfg.writeEntry( entry, val ); |
206 | } | 206 | } |
207 | 207 | ||
208 | //=========================================================================== | 208 | //=========================================================================== |
209 | 209 | ||
210 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) | 210 | WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) |
211 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), | 211 | : QWidget( parent, name ), visualStyle( STYLE_ANTENNA ), |
212 | timer( 0 ), interface( 0 ), | 212 | timer( 0 ), interface( 0 ), |
213 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) | 213 | rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) |
214 | { | 214 | { |
215 | setFixedHeight( 18 ); | 215 | setFixedHeight( 18 ); |
216 | setFixedWidth( 14 ); | 216 | setFixedWidth( 14 ); |
217 | network = new MWirelessNetwork(); | 217 | network = new MWirelessNetwork(); |
218 | status = new WirelessControl( this, 0, "wireless status" ); | 218 | status = new WirelessControl( this, this, "wireless status" ); |
219 | } | 219 | } |
220 | 220 | ||
221 | void WirelessApplet::checkInterface() | 221 | void WirelessApplet::checkInterface() |
222 | { | 222 | { |
223 | interface = network->getFirstInterface(); | 223 | interface = network->getFirstInterface(); |
224 | if ( interface ) | 224 | if ( interface ) |
225 | { | 225 | { |
226 | #ifdef MDEBUG | 226 | #ifdef MDEBUG |
227 | qDebug( "WIFIAPPLET: using interface '%s'", (const char*) interface->getName() ); | 227 | qDebug( "WIFIAPPLET: using interface '%s'", (const char*) interface->getName() ); |
228 | #endif | 228 | #endif |
229 | } | 229 | } |
230 | else | 230 | else |
231 | { | 231 | { |
232 | #ifdef MDEBUG | 232 | #ifdef MDEBUG |
233 | qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); | 233 | qDebug( "WIFIAPPLET: D'oh! No Wireless interface present... :(" ); |
234 | #endif | 234 | #endif |
235 | hide(); | 235 | hide(); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | void WirelessApplet::renewDHCP() | 239 | void WirelessApplet::renewDHCP() |
240 | { | 240 | { |
241 | #ifdef MDEBUG | 241 | #ifdef MDEBUG |
242 | qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); | 242 | qDebug( "WIFIAPPLET: Going to request a DHCP configuration renew." ); |
243 | #endif | 243 | #endif |
244 | 244 | ||
245 | QString pidfile; | 245 | QString pidfile; |
246 | if ( !interface ) | 246 | if ( !interface ) |
247 | return; | 247 | return; |
248 | QString ifacename( interface->getName() ); | 248 | QString ifacename( interface->getName() ); |
249 | 249 | ||
250 | // At first we are trying dhcpcd | 250 | // At first we are trying dhcpcd |
251 | 251 | ||
252 | pidfile.sprintf( "/var/run/dhcpcd-%s.pid", (const char* ) ifacename ); | 252 | pidfile.sprintf( "/var/run/dhcpcd-%s.pid", (const char* ) ifacename ); |
253 | #ifdef MDEBUG | 253 | #ifdef MDEBUG |
254 | qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", (const char*) pidfile ); | 254 | qDebug( "WIFIAPPLET: dhcpcd pidfile is '%s'", (const char*) pidfile ); |
255 | #endif | 255 | #endif |
256 | int pid; | 256 | int pid; |
257 | QFile pfile( pidfile ); | 257 | QFile pfile( pidfile ); |
258 | bool hasFile = pfile.open( IO_ReadOnly ); | 258 | bool hasFile = pfile.open( IO_ReadOnly ); |
259 | QTextStream s( &pfile ); | 259 | QTextStream s( &pfile ); |
260 | if ( hasFile ) | 260 | if ( hasFile ) |
261 | { | 261 | { |
262 | s >> pid; | 262 | s >> pid; |
263 | #ifdef MDEBUG | 263 | #ifdef MDEBUG |
264 | qDebug( "WIFIAPPLET: sent SIGALARM to pid %d", pid ); | 264 | qDebug( "WIFIAPPLET: sent SIGALARM to pid %d", pid ); |
265 | #endif | 265 | #endif |
266 | kill( pid, SIGALRM ); | 266 | kill( pid, SIGALRM ); |
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | 269 | ||
270 | // No dhcpcd, so we are trying udhcpc | 270 | // No dhcpcd, so we are trying udhcpc |
271 | #ifdef MDEBUG | 271 | #ifdef MDEBUG |
272 | qDebug( "WIFIAPPLET: dhcpcd not available." ); | 272 | qDebug( "WIFIAPPLET: dhcpcd not available." ); |
273 | #endif | 273 | #endif |
274 | pidfile.sprintf( "/var/run/udhcpc.%s.pid", (const char*) ifacename ); | 274 | pidfile.sprintf( "/var/run/udhcpc.%s.pid", (const char*) ifacename ); |
275 | #ifdef MDEBUG | 275 | #ifdef MDEBUG |
276 | qDebug( "WIFIAPPLET: udhcpc pidfile is '%s'", (const char*) pidfile ); | 276 | qDebug( "WIFIAPPLET: udhcpc pidfile is '%s'", (const char*) pidfile ); |
277 | #endif | 277 | #endif |
278 | QFile pfile2( pidfile ); | 278 | QFile pfile2( pidfile ); |
279 | hasFile = pfile2.open( IO_ReadOnly ); | 279 | hasFile = pfile2.open( IO_ReadOnly ); |
280 | QTextStream s2( &pfile2 ); | 280 | QTextStream s2( &pfile2 ); |
281 | if ( hasFile ) | 281 | if ( hasFile ) |
282 | { | 282 | { |
283 | s2 >> pid; | 283 | s2 >> pid; |
284 | #ifdef MDEBUG | 284 | #ifdef MDEBUG |
285 | qDebug( "WIFIAPPLET: sent SIGUSR1 to pid %d", pid ); | 285 | qDebug( "WIFIAPPLET: sent SIGUSR1 to pid %d", pid ); |
286 | #endif | 286 | #endif |
287 | kill( pid, SIGUSR1 ); | 287 | kill( pid, SIGUSR1 ); |
288 | return; | 288 | return; |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) | 292 | void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) |
293 | { | 293 | { |
294 | rocESSID = ESSID; | 294 | rocESSID = ESSID; |
295 | rocFREQ = FREQ; | 295 | rocFREQ = FREQ; |
296 | rocAP = AP; | 296 | rocAP = AP; |
297 | rocMODE = MODE; | 297 | rocMODE = MODE; |
298 | } | 298 | } |
299 | 299 | ||
300 | void WirelessApplet::updateDelayChange( int delay ) | 300 | void WirelessApplet::updateDelayChange( int delay ) |
301 | { | 301 | { |
302 | if ( timer ) | 302 | if ( timer ) |
303 | killTimer( timer ); | 303 | killTimer( timer ); |
304 | delay *= 1000; | 304 | delay *= 1000; |
305 | if ( delay == 0 ) | 305 | if ( delay == 0 ) |
306 | delay = 50; | 306 | delay = 50; |
307 | timer = startTimer( delay ); | 307 | timer = startTimer( delay ); |
308 | } | 308 | } |
309 | 309 | ||
310 | void WirelessApplet::displayStyleChange( int style ) | 310 | void WirelessApplet::displayStyleChange( int style ) |
311 | { | 311 | { |
312 | visualStyle = style; | 312 | visualStyle = style; |
313 | repaint(); | 313 | repaint(); |
314 | } | 314 | } |