summaryrefslogtreecommitdiff
authorsandman <sandman>2002-06-30 00:24:42 (UTC)
committer sandman <sandman>2002-06-30 00:24:42 (UTC)
commit2e3c599f9b2498ecd9c2332d38a0ae293954b570 (patch) (unidiff)
tree1a5f95206bba7ca896b09558cf1b46ac6e03f205
parent0235faab30f436ae3fbfed21e9f07486181bb0dd (diff)
downloadopie-2e3c599f9b2498ecd9c2332d38a0ae293954b570.zip
opie-2e3c599f9b2498ecd9c2332d38a0ae293954b570.tar.gz
opie-2e3c599f9b2498ecd9c2332d38a0ae293954b570.tar.bz2
Some fixes (keeping vol/mute in sync with other apps)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp49
-rw-r--r--core/applets/volumeapplet/volume.h2
2 files changed, 22 insertions, 29 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index b047877..eedc749 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -182,22 +182,13 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa
182 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) 182 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup )
183{ 183{
184 m_icon = icon; 184 m_icon = icon;
185 185
186 bool has_wav_alarm = false; 186 bool has_wav_alarm = true;
187 187
188 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually 188 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually
189 case OMODEL_iPAQ_H31xx:
190 case OMODEL_iPAQ_H36xx:
191 case OMODEL_iPAQ_H37xx:
192 case OMODEL_iPAQ_H38xx:
193 has_wav_alarm = true;
194 break;
195 case OMODEL_Zaurus_SL5000: 189 case OMODEL_Zaurus_SL5000:
196 has_wav_alarm = false; //poor guys probably feeling left out... 190 has_wav_alarm = false; //poor guys probably feeling left out...
197 break;
198 default:
199 has_wav_alarm = true; //lets just presume
200 break; 191 break;
201 } 192 }
202 193
203 194
@@ -407,18 +398,15 @@ void VolumeControl::show ( bool /*showMic*/ )
407{ 398{
408 readConfig ( ); 399 readConfig ( );
409 400
410 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); 401 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
411 printf ( "SHOW AT : %d/%d\n", curPos.x(), curPos.y());
412 printf ( "SIZEHINT: %d/%d\n", sizeHint().width(),sizeHint().height());
413 402
414 int w = sizeHint ( ). width ( ); 403 int w = sizeHint ( ). width ( );
415 int x = curPos.x ( ) - ( w / 2 ); 404 int x = curPos.x ( ) - ( w / 2 );
416 405
417 if (( x + w ) > QPEApplication::desktop ( )-> width ( )) 406 if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
418 x = QPEApplication::desktop ( )-> width ( ) - w; 407 x = QPEApplication::desktop ( )-> width ( ) - w;
419 408
420
421 move ( x, curPos. y ( ) - sizeHint ( ). height ( )); 409 move ( x, curPos. y ( ) - sizeHint ( ). height ( ));
422 QFrame::show ( ); 410 QFrame::show ( );
423 411
424} 412}
@@ -470,23 +458,18 @@ void VolumeControl::readConfig ( bool force )
470 458
471 459
472void VolumeControl::volumeChanged ( bool nowMuted ) 460void VolumeControl::volumeChanged ( bool nowMuted )
473{ 461{
474 int previousVolume = m_vol_percent; 462 int prevVol = m_vol_percent;
463 bool prevMute = m_vol_muted;
475 464
476 if ( !nowMuted ) 465 readConfig ( );
477 readConfig ( );
478 466
479 // Handle case where muting it toggled 467 // Handle case where muting it toggled
480 if ( m_vol_muted != nowMuted ) { 468 if ( m_vol_muted != prevMute )
481 m_vol_muted = nowMuted; 469 m_icon-> redraw ( true );
482 m_icon-> repaint ( true ); 470 else if ( prevVol != m_vol_percent ) // Avoid over repainting
483 } 471 m_icon-> redraw ( false );
484 else if ( previousVolume != m_vol_percent ) {
485 // Avoid over repainting
486 m_icon-> repaint( 2, height ( ) - 3, width ( ) - 4, 2, false );
487 }
488
489} 472}
490 473
491void VolumeControl::micChanged ( bool nowMuted ) 474void VolumeControl::micChanged ( bool nowMuted )
492{ 475{
@@ -516,9 +499,9 @@ void VolumeControl::alarmSoundToggled ( bool b )
516void VolumeControl::volMuteToggled ( bool b ) 499void VolumeControl::volMuteToggled ( bool b )
517{ 500{
518 m_vol_muted = !b; 501 m_vol_muted = !b;
519 502
520 m_icon-> repaint ( !m_vol_muted ); // clear if removing mute 503 m_icon-> redraw ( true );
521 504
522 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); 505 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol );
523} 506}
524 507
@@ -535,10 +518,10 @@ void VolumeControl::volMoved ( int percent )
535 518
536 // clamp volume percent to be between 0 and 100 519 // clamp volume percent to be between 0 and 100
537 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); 520 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent );
538 // repaint just the little volume rectangle 521 // repaint just the little volume rectangle
539 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); 522 m_icon-> redraw ( false );
540 523
541 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); 524 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
542} 525}
543 526
544void VolumeControl::micMoved ( int percent ) 527void VolumeControl::micMoved ( int percent )
@@ -613,8 +596,16 @@ void VolumeApplet::mousePressEvent ( QMouseEvent * )
613 else 596 else
614 m_dialog-> show ( true ); 597 m_dialog-> show ( true );
615} 598}
616 599
600void VolumeApplet::redraw ( bool all )
601{
602 if ( all )
603 repaint ( true );
604 else
605 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
606}
607
617 608
618void VolumeApplet::paintEvent ( QPaintEvent * ) 609void VolumeApplet::paintEvent ( QPaintEvent * )
619{ 610{
620 QPainter p ( this ); 611 QPainter p ( this );
diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h
index ff5c64a..4d988ac 100644
--- a/core/applets/volumeapplet/volume.h
+++ b/core/applets/volumeapplet/volume.h
@@ -109,8 +109,10 @@ class VolumeApplet : public QWidget {
109public: 109public:
110 VolumeApplet ( QWidget *parent = 0, const char *name=0 ); 110 VolumeApplet ( QWidget *parent = 0, const char *name=0 );
111 ~VolumeApplet ( ); 111 ~VolumeApplet ( );
112 112
113 void redraw ( bool all = true );
114
113protected: 115protected:
114 virtual void mousePressEvent ( QMouseEvent * ); 116 virtual void mousePressEvent ( QMouseEvent * );
115 virtual void paintEvent ( QPaintEvent* ); 117 virtual void paintEvent ( QPaintEvent* );
116 118