summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp2
-rw-r--r--noncore/applets/wirelessapplet/wireless.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 11ba2f6..7f0aca5 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -326,385 +326,385 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa
326 326
327 QLabel *trebleLabel = new QLabel( this ); 327 QLabel *trebleLabel = new QLabel( this );
328 trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); 328 trebleLabel->setPixmap( QPixmap ( treble_xpm ) );
329 329
330 grid->addWidget( trebleLabel, 0, 4, AlignCenter ); 330 grid->addWidget( trebleLabel, 0, 4, AlignCenter );
331 grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); 331 grid->addWidget( basstrebleBox, 1, 4, AlignCenter );
332 grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); 332 grid-> addWidget ( bassLabel, 2, 4, AlignCenter );
333 333
334 if ( !has_bass ) { 334 if ( !has_bass ) {
335 bassSlider->hide(); 335 bassSlider->hide();
336 bassLabel->hide(); 336 bassLabel->hide();
337 } 337 }
338 338
339 if ( !has_treble ) { 339 if ( !has_treble ) {
340 trebleSlider->hide(); 340 trebleSlider->hide();
341 trebleLabel->hide(); 341 trebleLabel->hide();
342 } 342 }
343 343
344 micSlider = new QSlider ( this ); 344 micSlider = new QSlider ( this );
345 micSlider-> setRange ( 0, 100 ); 345 micSlider-> setRange ( 0, 100 );
346 micSlider-> setTickmarks ( QSlider::Both ); 346 micSlider-> setTickmarks ( QSlider::Both );
347 micSlider-> setTickInterval ( 20 ); 347 micSlider-> setTickInterval ( 20 );
348 micSlider-> setFocusPolicy ( QWidget::NoFocus ); 348 micSlider-> setFocusPolicy ( QWidget::NoFocus );
349 349
350 l = new QLabel ( this ); 350 l = new QLabel ( this );
351 l-> setPixmap ( QPixmap ( mic_xpm )); 351 l-> setPixmap ( QPixmap ( mic_xpm ));
352 352
353 grid-> addWidget ( l, 0, 2, AlignCenter ); 353 grid-> addWidget ( l, 0, 2, AlignCenter );
354 grid-> addWidget ( micSlider, 1, 2, AlignCenter ); 354 grid-> addWidget ( micSlider, 1, 2, AlignCenter );
355 355
356 micLed = new OLedBox ( red, this ); 356 micLed = new OLedBox ( red, this );
357 micLed-> setFocusPolicy ( QWidget::NoFocus ); 357 micLed-> setFocusPolicy ( QWidget::NoFocus );
358 micLed-> setFixedSize ( 16, 16 ); 358 micLed-> setFixedSize ( 16, 16 );
359 359
360 grid-> addWidget ( micLed, 2, 2, AlignCenter ); 360 grid-> addWidget ( micLed, 2, 2, AlignCenter );
361 361
362 alarmSlider = new QSlider ( this ); 362 alarmSlider = new QSlider ( this );
363 alarmSlider-> setRange ( 0, 100 ); 363 alarmSlider-> setRange ( 0, 100 );
364 alarmSlider-> setTickmarks ( QSlider::Both ); 364 alarmSlider-> setTickmarks ( QSlider::Both );
365 alarmSlider-> setTickInterval ( 20 ); 365 alarmSlider-> setTickInterval ( 20 );
366 alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); 366 alarmSlider-> setFocusPolicy ( QWidget::NoFocus );
367 367
368 QLabel *alarmLabel = new QLabel ( this ); 368 QLabel *alarmLabel = new QLabel ( this );
369 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); 369 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
370 370
371 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); 371 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
372 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); 372 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
373 373
374 alarmLed = new OLedBox ( yellow, this ); 374 alarmLed = new OLedBox ( yellow, this );
375 alarmLed-> setFocusPolicy ( QWidget::NoFocus ); 375 alarmLed-> setFocusPolicy ( QWidget::NoFocus );
376 alarmLed-> setFixedSize ( 16, 16 ); 376 alarmLed-> setFixedSize ( 16, 16 );
377 377
378 grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); 378 grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
379 379
380 if ( !has_wav_alarm ) { 380 if ( !has_wav_alarm ) {
381 alarmSlider-> hide ( ); 381 alarmSlider-> hide ( );
382 alarmLabel-> hide ( ); 382 alarmLabel-> hide ( );
383 alarmLed-> hide ( ); 383 alarmLed-> hide ( );
384 } 384 }
385 385
386 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); 386 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft );
387 387
388 vbox = new QVBoxLayout ( ); 388 vbox = new QVBoxLayout ( );
389 vbox-> setSpacing ( 4 ); 389 vbox-> setSpacing ( 4 );
390 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); 390 grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 );
391 391
392 tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); 392 tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
393 tapBox-> setFocusPolicy ( QWidget::NoFocus ); 393 tapBox-> setFocusPolicy ( QWidget::NoFocus );
394 394
395 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); 395 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
396 396
397 keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); 397 keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
398 keyBox-> setFocusPolicy ( QWidget::NoFocus ); 398 keyBox-> setFocusPolicy ( QWidget::NoFocus );
399 399
400 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); 400 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
401 401
402 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); 402 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
403 alarmBox-> setFocusPolicy ( QWidget::NoFocus ); 403 alarmBox-> setFocusPolicy ( QWidget::NoFocus );
404 404
405 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); 405 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
406 406
407 if ( has_wav_alarm ) { 407 if ( has_wav_alarm ) {
408 alarmBox-> hide ( ); 408 alarmBox-> hide ( );
409 } 409 }
410 410
411 vbox-> addStretch ( 100 ); 411 vbox-> addStretch ( 100 );
412 412
413 setFixedSize ( sizeHint ( )); 413 setFixedSize ( sizeHint ( ));
414 setFocusPolicy ( QWidget::NoFocus ); 414 setFocusPolicy ( QWidget::NoFocus );
415 415
416 rateTimer = new QTimer( this ); 416 rateTimer = new QTimer( this );
417 connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone())); 417 connect ( rateTimer, SIGNAL( timeout()), this, SLOT( rateTimerDone()));
418 418
419 connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); 419 connect ( upButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
420 connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged())); 420 connect ( upButton, SIGNAL( released()), this, SLOT( buttonChanged()));
421 connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged())); 421 connect ( downButton, SIGNAL( pressed()), this, SLOT( buttonChanged()));
422 connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged())); 422 connect ( downButton, SIGNAL( released()), this, SLOT( buttonChanged()));
423 423
424 connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int))); 424 connect ( micSlider, SIGNAL( valueChanged(int)), this, SLOT( micMoved(int)));
425 connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int))); 425 connect ( volSlider, SIGNAL( valueChanged(int)), this, SLOT( volMoved(int)));
426 connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int))); 426 connect ( alarmSlider, SIGNAL( valueChanged(int)), this, SLOT( alarmMoved(int)));
427 connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int))); 427 connect ( bassSlider, SIGNAL( valueChanged(int)), this, SLOT( bassMoved(int)));
428 connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int))); 428 connect ( trebleSlider, SIGNAL( valueChanged(int)), this, SLOT( trebleMoved(int)));
429 429
430 430
431 connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool))); 431 connect ( volLed, SIGNAL( toggled(bool)), this, SLOT( volMuteToggled(bool)));
432 connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool))); 432 connect ( micLed, SIGNAL( toggled(bool)), this, SLOT( micMuteToggled(bool)));
433 connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); 433 connect ( alarmLed, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
434 434
435 connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool))); 435 connect ( alarmBox, SIGNAL( toggled(bool)), this, SLOT( alarmSoundToggled(bool)));
436 connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool))); 436 connect ( keyBox, SIGNAL( toggled(bool)), this, SLOT( keyClickToggled(bool)));
437 connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool))); 437 connect ( tapBox, SIGNAL( toggled(bool)), this, SLOT( screenTapToggled(bool)));
438 438
439 // initialize variables 439 // initialize variables
440 440
441 readConfig ( true ); 441 readConfig ( true );
442 442
443 // initialize the config file, in case some entries are missing 443 // initialize the config file, in case some entries are missing
444 444
445 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); 445 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
446 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); 446 writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None );
447 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); 447 writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None );
448 writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); 448 writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
449 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 449 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
450 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); 450 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
451 writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); 451 writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
452 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 452 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
453 453
454 writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); 454 writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
455 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 455 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
456} 456}
457 457
458bool VolumeControl::volMuted ( ) const 458bool VolumeControl::volMuted ( ) const
459{ 459{
460 return m_vol_muted; 460 return m_vol_muted;
461} 461}
462 462
463int VolumeControl::volPercent ( ) const 463int VolumeControl::volPercent ( ) const
464{ 464{
465 return m_vol_percent; 465 return m_vol_percent;
466} 466}
467 467
468void VolumeControl::keyPressEvent ( QKeyEvent *e ) 468void VolumeControl::keyPressEvent ( QKeyEvent *e )
469{ 469{
470 switch ( e-> key ( )) { 470 switch ( e-> key ( )) {
471 case Key_Up: 471 case Key_Up:
472 volSlider-> subtractStep ( ); 472 volSlider-> subtractStep ( );
473 break; 473 break;
474 case Key_Down: 474 case Key_Down:
475 volSlider-> addStep ( ); 475 volSlider-> addStep ( );
476 break; 476 break;
477 case Key_Space: 477 case Key_Space:
478 volLed-> toggle ( ); 478 volLed-> toggle ( );
479 break; 479 break;
480 case Key_Escape: 480 case Key_Escape:
481 hide ( ); 481 hide ( );
482 break; 482 break;
483 } 483 }
484} 484}
485 485
486void VolumeControl::buttonChanged ( ) 486void VolumeControl::buttonChanged ( )
487{ 487{
488 if ( upButton-> isDown ( ) || downButton->isDown ( )) { 488 if ( upButton-> isDown ( ) || downButton->isDown ( )) {
489 rateTimerDone ( ); // Call it one time manually, otherwise it wont get 489 rateTimerDone ( ); // Call it one time manually, otherwise it wont get
490 // called at all when a button is pressed for a time 490 // called at all when a button is pressed for a time
491 // shorter than RATE_TIMER_INTERVAL. 491 // shorter than RATE_TIMER_INTERVAL.
492 rateTimer-> start ( RATE_TIMER_INTERVAL, false ); 492 rateTimer-> start ( RATE_TIMER_INTERVAL, false );
493 } 493 }
494 else 494 else
495 rateTimer-> stop ( ); 495 rateTimer-> stop ( );
496} 496}
497 497
498void VolumeControl::rateTimerDone ( ) 498void VolumeControl::rateTimerDone ( )
499{ 499{
500 if ( upButton-> isDown ( )) 500 if ( upButton-> isDown ( ))
501 volSlider-> setValue ( volSlider-> value ( ) - 2 ); 501 volSlider-> setValue ( volSlider-> value ( ) - 2 );
502 else // if ( downButton-> isDown ( )) 502 else // if ( downButton-> isDown ( ))
503 volSlider-> setValue ( volSlider-> value ( ) + 2 ); 503 volSlider-> setValue ( volSlider-> value ( ) + 2 );
504} 504}
505 505
506void VolumeControl::show ( bool /*showMic*/ ) 506void VolumeControl::show ( bool /*showMic*/ )
507{ 507{
508 readConfig ( ); 508 readConfig ( );
509 509
510 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); 510 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
511 511
512 int w = sizeHint ( ). width ( ); 512 int w = sizeHint ( ). width ( );
513 int x = curPos.x ( ) - ( w / 2 ); 513 int x = curPos.x ( ) - ( w / 2 );
514 514
515 if (( x + w ) > QPEApplication::desktop ( )-> width ( )) 515 if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
516 x = QPEApplication::desktop ( )-> width ( ) - w; 516 x = QPEApplication::desktop ( )-> width ( ) - w;
517 517
518 move ( x, curPos. y ( ) - sizeHint ( ). height ( )); 518 move ( QMAX(x,0), curPos. y ( ) - sizeHint ( ). height ( ));
519 QFrame::show ( ); 519 QFrame::show ( );
520 520
521} 521}
522 522
523void VolumeControl::readConfig ( bool force ) 523void VolumeControl::readConfig ( bool force )
524{ 524{
525 Config cfg ( "qpe" ); 525 Config cfg ( "qpe" );
526 cfg. setGroup ( "Volume" ); 526 cfg. setGroup ( "Volume" );
527 527
528 int old_vp = m_vol_percent; 528 int old_vp = m_vol_percent;
529 int old_mp = m_mic_percent; 529 int old_mp = m_mic_percent;
530 int old_bass = m_bass_percent; 530 int old_bass = m_bass_percent;
531 int old_treble = m_treble_percent; 531 int old_treble = m_treble_percent;
532 bool old_vm = m_vol_muted; 532 bool old_vm = m_vol_muted;
533 bool old_mm = m_mic_muted; 533 bool old_mm = m_mic_muted;
534 bool old_sk = m_snd_key; 534 bool old_sk = m_snd_key;
535 bool old_st = m_snd_touch; 535 bool old_st = m_snd_touch;
536 bool old_sa = m_snd_alarm; 536 bool old_sa = m_snd_alarm;
537 int old_ap = m_alarm_percent; 537 int old_ap = m_alarm_percent;
538 538
539 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); 539 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
540 m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); 540 m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
541 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); 541 m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 );
542 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); 542 m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 );
543 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); 543 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
544 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); 544 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
545 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); 545 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
546 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); 546 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
547 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); 547 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
548 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); 548 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
549 549
550 if ( force || ( m_vol_percent != old_vp )) 550 if ( force || ( m_vol_percent != old_vp ))
551 volSlider-> setValue ( 100 - m_vol_percent ); 551 volSlider-> setValue ( 100 - m_vol_percent );
552 if ( force || ( m_mic_percent != old_mp )) 552 if ( force || ( m_mic_percent != old_mp ))
553 micSlider-> setValue ( 100 - m_mic_percent ); 553 micSlider-> setValue ( 100 - m_mic_percent );
554 if ( force || ( m_alarm_percent != old_ap )) 554 if ( force || ( m_alarm_percent != old_ap ))
555 alarmSlider-> setValue ( 100 - m_alarm_percent ); 555 alarmSlider-> setValue ( 100 - m_alarm_percent );
556 if ( force || ( m_bass_percent != old_bass )) 556 if ( force || ( m_bass_percent != old_bass ))
557 bassSlider-> setValue ( 100 - m_bass_percent ); 557 bassSlider-> setValue ( 100 - m_bass_percent );
558 if ( force || ( m_treble_percent != old_treble )) 558 if ( force || ( m_treble_percent != old_treble ))
559 trebleSlider-> setValue ( 100 - m_treble_percent ); 559 trebleSlider-> setValue ( 100 - m_treble_percent );
560 560
561 561
562 if ( force || ( m_vol_muted != old_vm )) 562 if ( force || ( m_vol_muted != old_vm ))
563 volLed-> setOn ( !m_vol_muted ); 563 volLed-> setOn ( !m_vol_muted );
564 if ( force || ( m_mic_muted != old_mm )) 564 if ( force || ( m_mic_muted != old_mm ))
565 micLed-> setOn ( !m_mic_muted ); 565 micLed-> setOn ( !m_mic_muted );
566 if ( force || ( m_snd_alarm != old_sa )) 566 if ( force || ( m_snd_alarm != old_sa ))
567 alarmLed-> setOn ( m_snd_alarm ); 567 alarmLed-> setOn ( m_snd_alarm );
568 568
569 if ( force || ( m_snd_key != old_sk )) 569 if ( force || ( m_snd_key != old_sk ))
570 keyBox-> setChecked ( m_snd_key ); 570 keyBox-> setChecked ( m_snd_key );
571 if ( force || ( m_snd_touch != old_st )) 571 if ( force || ( m_snd_touch != old_st ))
572 tapBox-> setChecked ( m_snd_touch ); 572 tapBox-> setChecked ( m_snd_touch );
573 if ( force || ( m_snd_alarm != old_sa )) 573 if ( force || ( m_snd_alarm != old_sa ))
574 alarmBox-> setChecked ( m_snd_alarm ); 574 alarmBox-> setChecked ( m_snd_alarm );
575} 575}
576 576
577 577
578void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) 578void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
579{ 579{
580 int prevVol = m_vol_percent; 580 int prevVol = m_vol_percent;
581 bool prevMute = m_vol_muted; 581 bool prevMute = m_vol_muted;
582 582
583 readConfig ( ); 583 readConfig ( );
584 584
585 // Handle case where muting it toggled 585 // Handle case where muting it toggled
586 if ( m_vol_muted != prevMute ) 586 if ( m_vol_muted != prevMute )
587 m_icon-> redraw ( true ); 587 m_icon-> redraw ( true );
588 else if ( prevVol != m_vol_percent ) // Avoid over repainting 588 else if ( prevVol != m_vol_percent ) // Avoid over repainting
589 m_icon-> redraw ( false ); 589 m_icon-> redraw ( false );
590} 590}
591 591
592void VolumeControl::micChanged ( bool nowMuted ) 592void VolumeControl::micChanged ( bool nowMuted )
593{ 593{
594 if ( !nowMuted ) 594 if ( !nowMuted )
595 readConfig ( ); 595 readConfig ( );
596 m_mic_muted = nowMuted; 596 m_mic_muted = nowMuted;
597} 597}
598 598
599void VolumeControl::screenTapToggled ( bool b ) 599void VolumeControl::screenTapToggled ( bool b )
600{ 600{
601 m_snd_touch = b; 601 m_snd_touch = b;
602 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); 602 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol );
603} 603}
604 604
605void VolumeControl::keyClickToggled ( bool b ) 605void VolumeControl::keyClickToggled ( bool b )
606{ 606{
607 m_snd_key = b; 607 m_snd_key = b;
608 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); 608 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol );
609} 609}
610 610
611void VolumeControl::alarmSoundToggled ( bool b ) 611void VolumeControl::alarmSoundToggled ( bool b )
612{ 612{
613 m_snd_alarm = b; 613 m_snd_alarm = b;
614 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 614 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
615} 615}
616 616
617void VolumeControl::volMuteToggled ( bool b ) 617void VolumeControl::volMuteToggled ( bool b )
618{ 618{
619 m_vol_muted = !b; 619 m_vol_muted = !b;
620 620
621 m_icon-> redraw ( true ); 621 m_icon-> redraw ( true );
622 622
623 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); 623 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol );
624} 624}
625 625
626void VolumeControl::micMuteToggled ( bool b ) 626void VolumeControl::micMuteToggled ( bool b )
627{ 627{
628 m_mic_muted = !b; 628 m_mic_muted = !b;
629 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 629 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
630} 630}
631 631
632 632
633void VolumeControl::volMoved ( int percent ) 633void VolumeControl::volMoved ( int percent )
634{ 634{
635 m_vol_percent = 100 - percent; 635 m_vol_percent = 100 - percent;
636 636
637 // clamp volume percent to be between 0 and 100 637 // clamp volume percent to be between 0 and 100
638 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); 638 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent );
639 // repaint just the little volume rectangle 639 // repaint just the little volume rectangle
640 m_icon-> redraw ( false ); 640 m_icon-> redraw ( false );
641 641
642 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); 642 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
643} 643}
644 644
645void VolumeControl::micMoved ( int percent ) 645void VolumeControl::micMoved ( int percent )
646{ 646{
647 m_mic_percent = 100 - percent; 647 m_mic_percent = 100 - percent;
648 648
649 // clamp volume percent to be between 0 and 100 649 // clamp volume percent to be between 0 and 100
650 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); 650 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent );
651 651
652 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); 652 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
653} 653}
654 654
655void VolumeControl::alarmMoved ( int percent ) 655void VolumeControl::alarmMoved ( int percent )
656{ 656{
657 m_alarm_percent = 100 - percent; 657 m_alarm_percent = 100 - percent;
658 658
659 // clamp volume percent to be between 0 and 100 659 // clamp volume percent to be between 0 and 100
660 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); 660 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent );
661 661
662 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 662 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
663} 663}
664 664
665 665
666void VolumeControl::bassMoved ( int percent ) 666void VolumeControl::bassMoved ( int percent )
667{ 667{
668 m_bass_percent = 100 - percent; 668 m_bass_percent = 100 - percent;
669 669
670 // clamp bass percent to be between 0 and 100 670 // clamp bass percent to be between 0 and 100
671 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); 671 m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent );
672 672
673 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); 673 writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass );
674} 674}
675 675
676 676
677 677
678void VolumeControl::trebleMoved ( int percent ) 678void VolumeControl::trebleMoved ( int percent )
679{ 679{
680 m_treble_percent = 100 - percent; 680 m_treble_percent = 100 - percent;
681 681
682 // clamp treble percent to be between 0 and 100 682 // clamp treble percent to be between 0 and 100
683 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); 683 m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent );
684 684
685 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); 685 writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble );
686} 686}
687 687
688 688
689 689
690void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) 690void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
691{ 691{
692 Config cfg ( "qpe" ); 692 Config cfg ( "qpe" );
693 cfg. setGroup ( "Volume" ); 693 cfg. setGroup ( "Volume" );
694 cfg. writeEntry ( entry, val ); 694 cfg. writeEntry ( entry, val );
695// cfg. write ( ); 695// cfg. write ( );
696 696
697#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 697#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
698 switch ( upd ) { 698 switch ( upd ) {
699 case UPD_Vol: { 699 case UPD_Vol: {
700 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; 700 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
701 break; 701 break;
702 } 702 }
703 case UPD_Mic: { 703 case UPD_Mic: {
704 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; 704 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
705 break; 705 break;
706 } 706 }
707 case UPD_Bass: { 707 case UPD_Bass: {
708 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; 708 QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true;
709 break; 709 break;
710 } 710 }
diff --git a/noncore/applets/wirelessapplet/wireless.cpp b/noncore/applets/wirelessapplet/wireless.cpp
index 364f3ad..88ab032 100644
--- a/noncore/applets/wirelessapplet/wireless.cpp
+++ b/noncore/applets/wirelessapplet/wireless.cpp
@@ -1,354 +1,354 @@
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 17
18/* OPIE */ 18/* OPIE */
19#include <opie2/odebug.h> 19#include <opie2/odebug.h>
20#include <opie2/onetwork.h> 20#include <opie2/onetwork.h>
21#include <opie2/otaskbarapplet.h> 21#include <opie2/otaskbarapplet.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24using namespace Opie::Core; 24using namespace Opie::Core;
25using namespace Opie::Ui; 25using namespace Opie::Ui;
26using namespace Opie::Net; 26using namespace Opie::Net;
27 27
28/* QT */ 28/* QT */
29#include <qradiobutton.h> 29#include <qradiobutton.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qpainter.h> 31#include <qpainter.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qslider.h> 33#include <qslider.h>
34#include <qbuttongroup.h> 34#include <qbuttongroup.h>
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qfile.h> 36#include <qfile.h>
37#include <qtextstream.h> 37#include <qtextstream.h>
38 38
39/* STD */ 39/* STD */
40#include <math.h> 40#include <math.h>
41#include <sys/types.h> 41#include <sys/types.h>
42#include <signal.h> 42#include <signal.h>
43#if defined (__GNUC__) && (__GNUC__ < 3) 43#if defined (__GNUC__) && (__GNUC__ < 3)
44#define round qRound 44#define round qRound
45#endif 45#endif
46 46
47//#define MDEBUG 47//#define MDEBUG
48#undef MDEBUG 48#undef MDEBUG
49 49
50WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name ) 50WirelessControl::WirelessControl( WirelessApplet *applet, QWidget *parent, const char *name )
51 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet ) 51 : QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), applet( applet )
52{ 52{
53 53
54 readConfig(); 54 readConfig();
55 writeConfigEntry( "UpdateFrequency", updateFrequency ); 55 writeConfigEntry( "UpdateFrequency", updateFrequency );
56 56
57 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 57 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
58 QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" ); 58 QGridLayout *grid = new QGridLayout( this, 3, 2, 6, 2, "top layout" );
59 59
60 /* status label */ 60 /* status label */
61 61
62 statusLabel = new QLabel( this, "statuslabel" ); 62 statusLabel = new QLabel( this, "statuslabel" );
63 QString text( "Wireless Status:<br>" 63 QString text( "Wireless Status:<br>"
64 "*** Unknown ***<br>" 64 "*** Unknown ***<br>"
65 "Card not inserted ?<br>" 65 "Card not inserted ?<br>"
66 "Or Sharp ROM ?<br>" 66 "Or Sharp ROM ?<br>"
67 "CELL: 00:00:00:00:00:00" ); 67 "CELL: 00:00:00:00:00:00" );
68 /* QString text( "Station: Unknown<br>" 68 /* QString text( "Station: Unknown<br>"
69 "ESSID: Unknown<br>" 69 "ESSID: Unknown<br>"
70 "MODE: Unknown<br>" 70 "MODE: Unknown<br>"
71 "FREQ: Unknown<br>" 71 "FREQ: Unknown<br>"
72 "CELL: AA:BB:CC:DD:EE:FF" ); */ 72 "CELL: AA:BB:CC:DD:EE:FF" ); */
73 statusLabel->setText( text ); 73 statusLabel->setText( text );
74 statusLabel->setFixedSize( statusLabel->sizeHint() ); 74 statusLabel->setFixedSize( statusLabel->sizeHint() );
75 grid->addWidget( statusLabel, 0, 0 ); 75 grid->addWidget( statusLabel, 0, 0 );
76 76
77 /* visualization group box */ 77 /* visualization group box */
78 78
79 /* quality graph */ 79 /* quality graph */
80 80
81 mgraph = new MGraph( this ); 81 mgraph = new MGraph( this );
82 mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 82 mgraph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
83 mgraph->setMin( 0 ); 83 mgraph->setMin( 0 );
84 mgraph->setMax( 92 ); 84 mgraph->setMax( 92 );
85 grid->addWidget( mgraph, 1, 0 ); 85 grid->addWidget( mgraph, 1, 0 );
86 mgraph->setFocusPolicy( QWidget::NoFocus ); 86 mgraph->setFocusPolicy( QWidget::NoFocus );
87 87
88 /* advanced configuration Button */ 88 /* advanced configuration Button */
89 89
90 QPushButton* advanced = new QPushButton( "Advanced...", this ); 90 QPushButton* advanced = new QPushButton( "Advanced...", this );
91 advanced->setFocusPolicy( QWidget::NoFocus ); 91 advanced->setFocusPolicy( QWidget::NoFocus );
92 grid->addWidget( advanced, 2, 0, Qt::AlignCenter ); 92 grid->addWidget( advanced, 2, 0, Qt::AlignCenter );
93 connect( advanced, SIGNAL( clicked() ), 93 connect( advanced, SIGNAL( clicked() ),
94 this, SLOT( advancedConfigClicked() ) ); 94 this, SLOT( advancedConfigClicked() ) );
95 95
96 /* update Frequency Label */ 96 /* update Frequency Label */
97 97
98 updateLabel = new QLabel( this ); 98 updateLabel = new QLabel( this );
99 text.sprintf( "Update every %d s", updateFrequency ); 99 text.sprintf( "Update every %d s", updateFrequency );
100 updateLabel->setText( text ); 100 updateLabel->setText( text );
101 grid->addWidget( updateLabel, 2, 1 ); 101 grid->addWidget( updateLabel, 2, 1 );
102 102
103 /* update Frequency Slider */ 103 /* update Frequency Slider */
104 104
105 QSlider* updateSlider = new QSlider( QSlider::Horizontal, this ); 105 QSlider* updateSlider = new QSlider( QSlider::Horizontal, this );
106 updateSlider->setRange( 0, 9 ); 106 updateSlider->setRange( 0, 9 );
107 updateSlider->setValue( updateFrequency ); 107 updateSlider->setValue( updateFrequency );
108 updateSlider->setTickmarks( QSlider::Both ); 108 updateSlider->setTickmarks( QSlider::Both );
109 updateSlider->setTickInterval( 1 ); 109 updateSlider->setTickInterval( 1 );
110 updateSlider->setSteps( 1, 1 ); 110 updateSlider->setSteps( 1, 1 );
111 updateSlider->setFocusPolicy( QWidget::NoFocus ); 111 updateSlider->setFocusPolicy( QWidget::NoFocus );
112 grid->addWidget( updateSlider, 1, 1 ); 112 grid->addWidget( updateSlider, 1, 1 );
113 connect( updateSlider, SIGNAL( valueChanged(int) ), 113 connect( updateSlider, SIGNAL( valueChanged(int) ),
114 this, SLOT( updateDelayChange(int) ) ); 114 this, SLOT( updateDelayChange(int) ) );
115 115
116 setFixedSize( sizeHint() ); 116 setFixedSize( sizeHint() );
117 setFocusPolicy( QWidget::NoFocus ); 117 setFocusPolicy( QWidget::NoFocus );
118 118
119 applet->updateDelayChange( updateFrequency ); 119 applet->updateDelayChange( updateFrequency );
120 120
121 applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); 121 applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE );
122} 122}
123 123
124void WirelessControl::advancedConfigClicked() 124void WirelessControl::advancedConfigClicked()
125{ 125{
126 AdvancedConfig * a = new AdvancedConfig( this, "dialog", TRUE ); 126 AdvancedConfig * a = new AdvancedConfig( this, "dialog", TRUE );
127 int result = a->exec(); 127 int result = a->exec();
128 a->hide(); 128 a->hide();
129 delete a; 129 delete a;
130 if ( result == QDialog::Accepted ) 130 if ( result == QDialog::Accepted )
131 { 131 {
132 readConfig(); 132 readConfig();
133 applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE ); 133 applet->updateDHCPConfig( rocESSID, rocFREQ, rocAP, rocMODE );
134 } 134 }
135} 135}
136 136
137void WirelessControl::updateDelayChange( int delay ) 137void WirelessControl::updateDelayChange( int delay )
138{ 138{
139 QString text; 139 QString text;
140 text.sprintf( "Update every %d s", delay ); 140 text.sprintf( "Update every %d s", delay );
141 updateLabel->setText( text ); 141 updateLabel->setText( text );
142 applet->updateDelayChange( delay ); 142 applet->updateDelayChange( delay );
143 writeConfigEntry( "UpdateFrequency", delay ); 143 writeConfigEntry( "UpdateFrequency", delay );
144} 144}
145 145
146void WirelessControl::displayStyleChange( int style ) 146void WirelessControl::displayStyleChange( int style )
147{ 147{
148 applet->displayStyleChange( style ); 148 applet->displayStyleChange( style );
149 writeConfigEntry( "DisplayStyle", style ); 149 writeConfigEntry( "DisplayStyle", style );
150} 150}
151 151
152void WirelessControl::show ( bool ) 152void WirelessControl::show ( bool )
153{ 153{
154 QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) ); 154 QPoint curPos = applet->mapToGlobal( QPoint ( 0, 0 ) );
155 155
156 int w = sizeHint().width(); 156 int w = sizeHint().width();
157 int x = curPos.x() - ( w / 2 ); 157 int x = curPos.x() - ( w / 2 );
158 158
159 if ( ( x + w ) > QPEApplication::desktop() ->width() ) 159 if ( ( x + w ) > QPEApplication::desktop() ->width() )
160 x = QPEApplication::desktop ( ) -> width ( ) - w; 160 x = QPEApplication::desktop ( ) -> width ( ) - w;
161 161
162 move( x, curPos.y () - sizeHint().height () ); 162 move( QMAX(x,0), curPos.y () - sizeHint().height () );
163 QFrame::show(); 163 QFrame::show();
164} 164}
165 165
166void WirelessControl::readConfig() 166void WirelessControl::readConfig()
167{ 167{
168 Config cfg( "qpe" ); 168 Config cfg( "qpe" );
169 cfg.setGroup( "Wireless" ); 169 cfg.setGroup( "Wireless" );
170 170
171 updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 ); 171 updateFrequency = cfg.readNumEntry( "UpdateFrequency", 2 );
172 rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false ); 172 rocESSID = cfg.readBoolEntry( "renew_dhcp_on_essid_change", false );
173 rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false ); 173 rocFREQ = cfg.readBoolEntry( "renew_dhcp_on_freq_change", false );
174 rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false ); 174 rocAP = cfg.readBoolEntry( "renew_dhcp_on_ap_change", false );
175 rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false ); 175 rocMODE = cfg.readBoolEntry( "renew_dhcp_on_mode_change", false );
176} 176}
177 177
178void WirelessControl::writeConfigEntry( const char *entry, int val ) 178void WirelessControl::writeConfigEntry( const char *entry, int val )
179{ 179{
180 Config cfg( "qpe" ); 180 Config cfg( "qpe" );
181 cfg.setGroup( "Wireless" ); 181 cfg.setGroup( "Wireless" );
182 cfg.writeEntry( entry, val ); 182 cfg.writeEntry( entry, val );
183} 183}
184 184
185//=========================================================================== 185//===========================================================================
186 186
187WirelessApplet::WirelessApplet( QWidget *parent, const char *name ) 187WirelessApplet::WirelessApplet( QWidget *parent, const char *name )
188 : QWidget( parent, name ), 188 : QWidget( parent, name ),
189 timer( 0 ), interface( 0 ), oldiface( 0 ), 189 timer( 0 ), interface( 0 ), oldiface( 0 ),
190 rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false ) 190 rocESSID( false ), rocFREQ( false ), rocAP( false ), rocMODE( false )
191{ 191{
192 setFixedHeight( 18 ); 192 setFixedHeight( 18 );
193 setFixedWidth( 14 ); 193 setFixedWidth( 14 );
194 status = new WirelessControl( this, this, "wireless status" ); 194 status = new WirelessControl( this, this, "wireless status" );
195} 195}
196 196
197void WirelessApplet::checkInterface() 197void WirelessApplet::checkInterface()
198{ 198{
199 interface = 0L; 199 interface = 0L;
200 ONetwork* net = ONetwork::instance(); 200 ONetwork* net = ONetwork::instance();
201 net->synchronize(); 201 net->synchronize();
202 ONetwork::InterfaceIterator it = net->iterator(); 202 ONetwork::InterfaceIterator it = net->iterator();
203 203
204 while ( it.current() && !it.current()->isWireless() ) ++it; 204 while ( it.current() && !it.current()->isWireless() ) ++it;
205 205
206 if ( it.current() && it.current()->isWireless() ) 206 if ( it.current() && it.current()->isWireless() )
207 interface = static_cast<OWirelessNetworkInterface*>( it.current() ); 207 interface = static_cast<OWirelessNetworkInterface*>( it.current() );
208 208
209 if ( interface ) 209 if ( interface )
210 { 210 {
211#ifdef MDEBUG 211#ifdef MDEBUG
212 odebug << "WIFIAPPLET: using interface '" << ( const char* ) interface->name() << "'" << oendl; 212 odebug << "WIFIAPPLET: using interface '" << ( const char* ) interface->name() << "'" << oendl;
213#endif 213#endif
214 214
215 } 215 }
216 else 216 else
217 { 217 {
218#ifdef MDEBUG 218#ifdef MDEBUG
219 odebug << "WIFIAPPLET: D'oh! No Wireless interface present... :(" << oendl; 219 odebug << "WIFIAPPLET: D'oh! No Wireless interface present... :(" << oendl;
220#endif 220#endif
221 hide(); 221 hide();
222 } 222 }
223} 223}
224 224
225void WirelessApplet::renewDHCP() 225void WirelessApplet::renewDHCP()
226{ 226{
227#ifdef MDEBUG 227#ifdef MDEBUG
228 odebug << "WIFIAPPLET: Going to request a DHCP configuration renew." << oendl; 228 odebug << "WIFIAPPLET: Going to request a DHCP configuration renew." << oendl;
229#endif 229#endif
230 230
231 QString pidfile; 231 QString pidfile;
232 if ( !interface ) 232 if ( !interface )
233 return ; 233 return ;
234 QString ifacename( interface->name() ); 234 QString ifacename( interface->name() );
235 235
236 // At first we are trying dhcpcd 236 // At first we are trying dhcpcd
237 237
238 pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename ); 238 pidfile.sprintf( "/var/run/dhcpcd-%s.pid", ( const char* ) ifacename );
239#ifdef MDEBUG 239#ifdef MDEBUG
240 odebug << "WIFIAPPLET: dhcpcd pidfile is '" << ( const char* ) pidfile << "'" << oendl; 240 odebug << "WIFIAPPLET: dhcpcd pidfile is '" << ( const char* ) pidfile << "'" << oendl;
241#endif 241#endif
242 int pid; 242 int pid;
243 QFile pfile( pidfile ); 243 QFile pfile( pidfile );
244 bool hasFile = pfile.open( IO_ReadOnly ); 244 bool hasFile = pfile.open( IO_ReadOnly );
245 QTextStream s( &pfile ); 245 QTextStream s( &pfile );
246 if ( hasFile ) 246 if ( hasFile )
247 { 247 {
248 s >> pid; 248 s >> pid;
249#ifdef MDEBUG 249#ifdef MDEBUG
250 odebug << "WIFIAPPLET: sent SIGALARM to pid " << pid << "" << oendl; 250 odebug << "WIFIAPPLET: sent SIGALARM to pid " << pid << "" << oendl;
251#endif 251#endif
252 kill( pid, SIGALRM ); 252 kill( pid, SIGALRM );
253 return ; 253 return ;
254 } 254 }
255 255
256 // No dhcpcd, so we are trying udhcpc 256 // No dhcpcd, so we are trying udhcpc
257#ifdef MDEBUG 257#ifdef MDEBUG
258 odebug << "WIFIAPPLET: dhcpcd not available." << oendl; 258 odebug << "WIFIAPPLET: dhcpcd not available." << oendl;
259#endif 259#endif
260 pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename ); 260 pidfile.sprintf( "/var/run/udhcpc.%s.pid", ( const char* ) ifacename );
261#ifdef MDEBUG 261#ifdef MDEBUG
262 odebug << "WIFIAPPLET: udhcpc pidfile is '" << ( const char* ) pidfile << "'" << oendl; 262 odebug << "WIFIAPPLET: udhcpc pidfile is '" << ( const char* ) pidfile << "'" << oendl;
263#endif 263#endif
264 QFile pfile2( pidfile ); 264 QFile pfile2( pidfile );
265 hasFile = pfile2.open( IO_ReadOnly ); 265 hasFile = pfile2.open( IO_ReadOnly );
266 QTextStream s2( &pfile2 ); 266 QTextStream s2( &pfile2 );
267 if ( hasFile ) 267 if ( hasFile )
268 { 268 {
269 s2 >> pid; 269 s2 >> pid;
270#ifdef MDEBUG 270#ifdef MDEBUG
271 odebug << "WIFIAPPLET: sent SIGUSR1 to pid " << pid << "" << oendl; 271 odebug << "WIFIAPPLET: sent SIGUSR1 to pid " << pid << "" << oendl;
272#endif 272#endif
273 kill( pid, SIGUSR1 ); 273 kill( pid, SIGUSR1 );
274 return ; 274 return ;
275 } 275 }
276} 276}
277 277
278void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE ) 278void WirelessApplet::updateDHCPConfig( bool ESSID, bool FREQ, bool AP, bool MODE )
279{ 279{
280 rocESSID = ESSID; 280 rocESSID = ESSID;
281 rocFREQ = FREQ; 281 rocFREQ = FREQ;
282 rocAP = AP; 282 rocAP = AP;
283 rocMODE = MODE; 283 rocMODE = MODE;
284} 284}
285 285
286void WirelessApplet::updateDelayChange( int delay ) 286void WirelessApplet::updateDelayChange( int delay )
287{ 287{
288 if ( timer ) 288 if ( timer )
289 killTimer( timer ); 289 killTimer( timer );
290 delay *= 1000; 290 delay *= 1000;
291 if ( delay == 0 ) 291 if ( delay == 0 )
292 delay = 50; 292 delay = 50;
293 timer = startTimer( delay ); 293 timer = startTimer( delay );
294} 294}
295 295
296void WirelessApplet::displayStyleChange( int style ) 296void WirelessApplet::displayStyleChange( int style )
297{ 297{
298 visualStyle = style; 298 visualStyle = style;
299 repaint(); 299 repaint();
300} 300}
301 301
302WirelessApplet::~WirelessApplet() 302WirelessApplet::~WirelessApplet()
303{} 303{}
304 304
305void WirelessApplet::timerEvent( QTimerEvent* ) 305void WirelessApplet::timerEvent( QTimerEvent* )
306{ 306{
307#ifdef MDEBUG 307#ifdef MDEBUG
308 odebug << "WirelessApplet::timerEvent" << oendl; 308 odebug << "WirelessApplet::timerEvent" << oendl;
309#endif 309#endif
310 if ( interface ) 310 if ( interface )
311 { 311 {
312 if ( !ONetwork::instance()->isPresent( (const char*) interface->name() ) ) 312 if ( !ONetwork::instance()->isPresent( (const char*) interface->name() ) )
313 { 313 {
314#ifdef MDEBUG 314#ifdef MDEBUG
315 odebug << "WIFIAPPLET: Interface no longer present." << oendl; 315 odebug << "WIFIAPPLET: Interface no longer present." << oendl;
316#endif 316#endif
317 interface = 0L; 317 interface = 0L;
318 mustRepaint(); 318 mustRepaint();
319 return; 319 return;
320 } 320 }
321 321
322 if ( mustRepaint() ) 322 if ( mustRepaint() )
323 { 323 {
324#ifdef MDEBUG 324#ifdef MDEBUG
325 odebug << "WIFIAPPLET: A value has changed -> repainting." << oendl; 325 odebug << "WIFIAPPLET: A value has changed -> repainting." << oendl;
326#endif 326#endif
327 repaint(); 327 repaint();
328 } 328 }
329 329
330 if ( status->isVisible() ) 330 if ( status->isVisible() )
331 { 331 {
332 updatePopupWindow(); 332 updatePopupWindow();
333 } 333 }
334 } 334 }
335 else 335 else
336 { 336 {
337 checkInterface(); 337 checkInterface();
338 } 338 }
339} 339}
340 340
341void WirelessApplet::mousePressEvent( QMouseEvent * ) 341void WirelessApplet::mousePressEvent( QMouseEvent * )
342{ 342{
343 if ( status->isVisible() ) 343 if ( status->isVisible() )
344 status->hide(); 344 status->hide();
345 else 345 else
346 status->show( true ); 346 status->show( true );
347} 347}
348 348
349bool WirelessApplet::mustRepaint() 349bool WirelessApplet::mustRepaint()
350{ 350{
351 // check if there are enough changes to justify a (flickering) repaint 351 // check if there are enough changes to justify a (flickering) repaint
352 352
353 // has the interface changed? 353 // has the interface changed?
354 354