-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 234 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 10 |
2 files changed, 200 insertions, 44 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp index 06eec58..e066a83 100644 --- a/core/applets/volumeapplet/volume.cpp +++ b/core/applets/volumeapplet/volume.cpp @@ -37,2 +37,3 @@ #include <qpixmap.h> +#include <qvbox.h> #include <qlabel.h> @@ -49,3 +50,3 @@ using namespace Opie; -#define RATE_TIMER_INTERVAL 100 +#define RATE_TIMER_INTERVAL 100 // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time @@ -125,2 +126,59 @@ static const char * mic_xpm[] = { + +static const char * bass_xpm[] = { +"20 20 3 1", +" c None", +". c #000000", +"+ c #0000FF", +" ", +" ", +" ", +"..... +++ ......", +" +++++++ ", +" ++ ++ ", +"... ++ ... ++ ++ .", +" +++ ++ ++ ", +" ++++ ++ ", +"... ++++ .. ++ .....", +" ++ ++ ", +" ++ ++ ", +"..........++ ++ .", +" ++ ", +" ++ ", +"...... ++ .........", +" + ", +" ", +" ", +" "}; + + +static const char * treble_xpm[] = { +"20 20 3 1", +" c None", +". c #0000FF", +"+ c #000000", +" .. ", +" . .. ", +" . .. ", +"++++++++ . .. ++++++", +" . . ", +" ... ", +"++++++++ . +++++++", +" .. ", +" .. . ", +"+++ .. ... +++++++", +" .. .. .. ", +" .. . . .. ", +"+++ .. . . + . +++++", +" .. . .. ", +" .. . .. ", +"++++ ...... +++++++", +" . ", +" .. . ", +" .. . ", +" .. "}; + + + + /* XPM */ @@ -186,5 +244,7 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa m_icon = icon; - + bool has_wav_alarm = true; - + bool has_bass = true; + bool has_treble = true; + switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually @@ -196,3 +256,8 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa } - + + if ( !ODevice::series == Model_iPAQ ) { + has_bass = false; + has_treble = false; + } + @@ -203,6 +268,6 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa grid-> setMargin ( 6 ); - + QVBoxLayout *vbox; QLabel *l; - + vbox = new QVBoxLayout ( ); @@ -210,3 +275,3 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa grid-> addLayout ( vbox, 1, 0 ); - + upButton = new QPushButton ( this ); @@ -217,3 +282,3 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa vbox-> addWidget ( upButton ); - + downButton = new QPushButton ( this ); @@ -230,6 +295,6 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa volSlider-> setFocusPolicy ( QWidget::NoFocus ); - + l = new QLabel ( this ); l-> setPixmap ( QPixmap ( vol_xpm )); - + grid-> addWidget ( l, 0, 1, AlignCenter ); @@ -239,6 +304,42 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa volLed-> setFocusPolicy ( QWidget::NoFocus ); - volLed-> setFixedSize ( 16, 16 ); - + volLed-> setFixedSize ( 16, 16 ); + grid-> addWidget ( volLed, 2, 1, AlignCenter ); + QVBox *basstrebleBox = new QVBox( this ); + + trebleSlider = new QSlider ( basstrebleBox ); + trebleSlider-> setRange ( 0, 100 ); + trebleSlider-> setTickmarks ( QSlider::Both ); + trebleSlider-> setTickInterval ( 20 ); + trebleSlider->setMaximumHeight( 40 ); + trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); + + bassSlider = new QSlider ( basstrebleBox ); + bassSlider-> setRange ( 0, 100 ); + bassSlider-> setTickmarks ( QSlider::Both ); + bassSlider-> setTickInterval ( 20 ); + bassSlider->setMaximumHeight( 40 ); + bassSlider-> setFocusPolicy ( QWidget::NoFocus ); + + QLabel *bassLabel = new QLabel ( this ); + bassLabel-> setPixmap ( QPixmap ( bass_xpm )); + + QLabel *trebleLabel = new QLabel( this ); + trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); + + grid->addWidget( trebleLabel, 0, 4, AlignCenter ); + grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); + grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); + + if ( !has_bass ) { + bassSlider->hide(); + bassLabel->hide(); + } + + if ( !has_treble ) { + trebleSlider->hide(); + trebleLabel->hide(); + } + micSlider = new QSlider ( this ); @@ -248,6 +349,6 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa micSlider-> setFocusPolicy ( QWidget::NoFocus ); - + l = new QLabel ( this ); l-> setPixmap ( QPixmap ( mic_xpm )); - + grid-> addWidget ( l, 0, 2, AlignCenter ); @@ -258,3 +359,3 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa micLed-> setFixedSize ( 16, 16 ); - + grid-> addWidget ( micLed, 2, 2, AlignCenter ); @@ -269,3 +370,3 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); - + grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); @@ -276,3 +377,3 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa alarmLed-> setFixedSize ( 16, 16 ); - + grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); @@ -284,4 +385,4 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa } - - grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft ); + + grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); @@ -289,7 +390,7 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa vbox-> setSpacing ( 4 ); - grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); - + grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); + tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); tapBox-> setFocusPolicy ( QWidget::NoFocus ); - + vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); @@ -298,3 +399,3 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa keyBox-> setFocusPolicy ( QWidget::NoFocus ); - + vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); @@ -303,3 +404,3 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa alarmBox-> setFocusPolicy ( QWidget::NoFocus ); - + vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); @@ -317,3 +418,3 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); - + connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); @@ -326,3 +427,6 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); - + connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int ))); + connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int ))); + + connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); @@ -338,6 +442,8 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa readConfig ( true ); - + // initialize the config file, in case some entries are missing - + writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); + writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); + writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); @@ -347,3 +453,3 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); - + writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); @@ -405,9 +511,9 @@ void VolumeControl::show ( bool /*showMic*/ ) QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); - + int w = sizeHint ( ). width ( ); int x = curPos.x ( ) - ( w / 2 ); - + if (( x + w ) > QPEApplication::desktop ( )-> width ( )) x = QPEApplication::desktop ( )-> width ( ) - w; - + move ( x, curPos. y ( ) - sizeHint ( ). height ( )); @@ -424,2 +530,4 @@ void VolumeControl::readConfig ( bool force ) int old_mp = m_mic_percent; + int old_bass = m_bass_percent; + int old_treble = m_treble_percent; bool old_vm = m_vol_muted; @@ -433,2 +541,4 @@ void VolumeControl::readConfig ( bool force ) m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); + m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); + m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); @@ -440,3 +550,3 @@ void VolumeControl::readConfig ( bool force ) - if ( force || ( m_vol_percent != old_vp )) + if ( force || ( m_vol_percent != old_vp )) volSlider-> setValue ( 100 - m_vol_percent ); @@ -444,5 +554,10 @@ void VolumeControl::readConfig ( bool force ) micSlider-> setValue ( 100 - m_mic_percent ); - if ( force || ( m_alarm_percent != old_ap )) + if ( force || ( m_alarm_percent != old_ap )) alarmSlider-> setValue ( 100 - m_alarm_percent ); - + if ( force || ( m_bass_percent != old_bass )) + bassSlider-> setValue ( 100 - m_bass_percent ); + if ( force || ( m_treble_percent != old_treble )) + trebleSlider-> setValue ( 100 - m_treble_percent ); + + if ( force || ( m_vol_muted != old_vm )) @@ -453,3 +568,3 @@ void VolumeControl::readConfig ( bool force ) alarmLed-> setOn ( m_snd_alarm ); - + if ( force || ( m_snd_key != old_sk )) @@ -459,3 +574,3 @@ void VolumeControl::readConfig ( bool force ) if ( force || ( m_snd_alarm != old_sa )) - alarmBox-> setChecked ( m_snd_alarm ); + alarmBox-> setChecked ( m_snd_alarm ); } @@ -505,5 +620,5 @@ void VolumeControl::volMuteToggled ( bool b ) m_vol_muted = !b; - + m_icon-> redraw ( true ); - + writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); @@ -513,3 +628,3 @@ void VolumeControl::micMuteToggled ( bool b ) { - m_mic_muted = !b; + m_mic_muted = !b; writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); @@ -526,3 +641,3 @@ void VolumeControl::volMoved ( int percent ) m_icon-> redraw ( false ); - + writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); @@ -551,2 +666,26 @@ void VolumeControl::alarmMoved ( int percent ) +void VolumeControl::bassMoved ( int percent ) +{ + m_bass_percent = 100 - percent; + + // clamp bass percent to be between 0 and 100 + m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); + + writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); +} + + + +void VolumeControl::trebleMoved ( int percent ) +{ + m_treble_percent = 100 - percent; + + // clamp treble percent to be between 0 and 100 + m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); + + writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); +} + + + void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) @@ -557,3 +696,3 @@ void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) // cfg. write ( ); - + #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) @@ -568,3 +707,12 @@ void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) } - case UPD_None: + case UPD_Bass: { + QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; + break; + } + case UPD_Treble: { + QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; + break; + } + + case UPD_None: break; diff --git a/core/applets/volumeapplet/volume.h b/core/applets/volumeapplet/volume.h index 4d988ac..d2345b5 100644 --- a/core/applets/volumeapplet/volume.h +++ b/core/applets/volumeapplet/volume.h @@ -57,2 +57,4 @@ private slots: void alarmMoved ( int percent ); + void bassMoved( int percent ); + void trebleMoved( int percent ); @@ -73,3 +75,5 @@ private: UPD_Vol, - UPD_Mic + UPD_Mic, + UPD_Bass, + UPD_Treble }; @@ -80,2 +84,4 @@ private: QSlider *volSlider; + QSlider *bassSlider; + QSlider *trebleSlider; QSlider *micSlider; @@ -96,2 +102,4 @@ private: int m_alarm_percent; + int m_bass_percent; + int m_treble_percent; bool m_vol_muted; |