-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 152 | ||||
-rw-r--r-- | core/applets/volumeapplet/volume.h | 10 |
2 files changed, 159 insertions, 3 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 @@ -36,4 +36,5 @@ #include <qframe.h> #include <qpixmap.h> +#include <qvbox.h> #include <qlabel.h> @@ -124,4 +125,61 @@ 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 */ static const char * alarm_xpm[] = { @@ -187,4 +245,6 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa 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,4 +256,9 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa } + if ( !ODevice::series == Model_iPAQ ) { + has_bass = false; + has_treble = false; + } + setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); @@ -242,4 +307,40 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa 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 ); micSlider-> setRange ( 0, 100 ); @@ -284,9 +385,9 @@ 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 ); vbox = new QVBoxLayout ( ); vbox-> setSpacing ( 4 ); - grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); + grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); @@ -325,4 +426,7 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); 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 ))); @@ -341,4 +445,6 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa 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 ); writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); @@ -423,4 +529,6 @@ void VolumeControl::readConfig ( bool force ) int old_vp = m_vol_percent; int old_mp = m_mic_percent; + int old_bass = m_bass_percent; + int old_treble = m_treble_percent; bool old_vm = m_vol_muted; bool old_mm = m_mic_muted; @@ -432,4 +540,6 @@ void VolumeControl::readConfig ( bool force ) m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); 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 ); m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); @@ -445,4 +555,9 @@ void VolumeControl::readConfig ( bool force ) 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 )) @@ -550,4 +665,28 @@ 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 ) { @@ -567,4 +706,13 @@ void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) break; } + 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 @@ -56,4 +56,6 @@ private slots: void micMoved ( int percent ); void alarmMoved ( int percent ); + void bassMoved( int percent ); + void trebleMoved( int percent ); void volMuteToggled ( bool ); @@ -72,5 +74,7 @@ private: UPD_None, UPD_Vol, - UPD_Mic + UPD_Mic, + UPD_Bass, + UPD_Treble }; void writeConfigEntry ( const char *entry, int val, eUpdate upd ); @@ -79,4 +83,6 @@ private: private: QSlider *volSlider; + QSlider *bassSlider; + QSlider *trebleSlider; QSlider *micSlider; QSlider *alarmSlider; @@ -95,4 +101,6 @@ private: int m_mic_percent; int m_alarm_percent; + int m_bass_percent; + int m_treble_percent; bool m_vol_muted; bool m_mic_muted; |