-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 | |||
@@ -32,25 +32,26 @@ | |||
32 | #include <qpainter.h> | 32 | #include <qpainter.h> |
33 | #include <qcheckbox.h> | 33 | #include <qcheckbox.h> |
34 | #include <qslider.h> | 34 | #include <qslider.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qframe.h> | 36 | #include <qframe.h> |
37 | #include <qpixmap.h> | 37 | #include <qpixmap.h> |
38 | #include <qvbox.h> | ||
38 | #include <qlabel.h> | 39 | #include <qlabel.h> |
39 | 40 | ||
40 | #include <qtoolbutton.h> | 41 | #include <qtoolbutton.h> |
41 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
42 | #include <qtimer.h> | 43 | #include <qtimer.h> |
43 | 44 | ||
44 | #include <opie/odevice.h> | 45 | #include <opie/odevice.h> |
45 | 46 | ||
46 | #include "oledbox.h" | 47 | #include "oledbox.h" |
47 | 48 | ||
48 | using namespace Opie; | 49 | using namespace Opie; |
49 | 50 | ||
50 | #define RATE_TIMER_INTERVAL 100 | 51 | #define RATE_TIMER_INTERVAL 100 |
51 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time | 52 | // Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time |
52 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. | 53 | // results in "hanging" buttons on the iPAQ due to quite high CPU consumption. |
53 | 54 | ||
54 | 55 | ||
55 | /* XPM */ | 56 | /* XPM */ |
56 | static const char * vol_xpm[] = { | 57 | static const char * vol_xpm[] = { |
@@ -120,12 +121,69 @@ static const char * mic_xpm[] = { | |||
120 | " .... ", | 121 | " .... ", |
121 | " .... ", | 122 | " .... ", |
122 | " .. ", | 123 | " .. ", |
123 | " . ", | 124 | " . ", |
124 | ". "}; | 125 | ". "}; |
125 | 126 | ||
127 | |||
128 | static const char * bass_xpm[] = { | ||
129 | "20 20 3 1", | ||
130 | " c None", | ||
131 | ". c #000000", | ||
132 | "+ c #0000FF", | ||
133 | " ", | ||
134 | " ", | ||
135 | " ", | ||
136 | "..... +++ ......", | ||
137 | " +++++++ ", | ||
138 | " ++ ++ ", | ||
139 | "... ++ ... ++ ++ .", | ||
140 | " +++ ++ ++ ", | ||
141 | " ++++ ++ ", | ||
142 | "... ++++ .. ++ .....", | ||
143 | " ++ ++ ", | ||
144 | " ++ ++ ", | ||
145 | "..........++ ++ .", | ||
146 | " ++ ", | ||
147 | " ++ ", | ||
148 | "...... ++ .........", | ||
149 | " + ", | ||
150 | " ", | ||
151 | " ", | ||
152 | " "}; | ||
153 | |||
154 | |||
155 | static const char * treble_xpm[] = { | ||
156 | "20 20 3 1", | ||
157 | " c None", | ||
158 | ". c #0000FF", | ||
159 | "+ c #000000", | ||
160 | " .. ", | ||
161 | " . .. ", | ||
162 | " . .. ", | ||
163 | "++++++++ . .. ++++++", | ||
164 | " . . ", | ||
165 | " ... ", | ||
166 | "++++++++ . +++++++", | ||
167 | " .. ", | ||
168 | " .. . ", | ||
169 | "+++ .. ... +++++++", | ||
170 | " .. .. .. ", | ||
171 | " .. . . .. ", | ||
172 | "+++ .. . . + . +++++", | ||
173 | " .. . .. ", | ||
174 | " .. . .. ", | ||
175 | "++++ ...... +++++++", | ||
176 | " . ", | ||
177 | " .. . ", | ||
178 | " .. . ", | ||
179 | " .. "}; | ||
180 | |||
181 | |||
182 | |||
183 | |||
126 | /* XPM */ | 184 | /* XPM */ |
127 | static const char * alarm_xpm[] = { | 185 | static const char * alarm_xpm[] = { |
128 | "20 20 33 1", | 186 | "20 20 33 1", |
129 | " c None", | 187 | " c None", |
130 | ". c #080602", | 188 | ". c #080602", |
131 | "+ c #AAA602", | 189 | "+ c #AAA602", |
@@ -181,130 +239,173 @@ static const char * alarm_xpm[] = { | |||
181 | " "}; | 239 | " "}; |
182 | 240 | ||
183 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) | 241 | VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) |
184 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) | 242 | : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) |
185 | { | 243 | { |
186 | m_icon = icon; | 244 | m_icon = icon; |
187 | 245 | ||
188 | bool has_wav_alarm = true; | 246 | bool has_wav_alarm = true; |
189 | 247 | bool has_bass = true; | |
248 | bool has_treble = true; | ||
249 | |||
190 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually | 250 | switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually |
191 | case Model_Zaurus_SL5000: | 251 | case Model_Zaurus_SL5000: |
192 | has_wav_alarm = false; //poor guys probably feeling left out... | 252 | has_wav_alarm = false; //poor guys probably feeling left out... |
193 | break; | 253 | break; |
194 | default: | 254 | default: |
195 | break; | 255 | break; |
196 | } | 256 | } |
197 | 257 | ||
258 | if ( !ODevice::series == Model_iPAQ ) { | ||
259 | has_bass = false; | ||
260 | has_treble = false; | ||
261 | } | ||
262 | |||
198 | 263 | ||
199 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 264 | setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
200 | 265 | ||
201 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); | 266 | QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); |
202 | grid-> setSpacing ( 4 ); | 267 | grid-> setSpacing ( 4 ); |
203 | grid-> setMargin ( 6 ); | 268 | grid-> setMargin ( 6 ); |
204 | 269 | ||
205 | QVBoxLayout *vbox; | 270 | QVBoxLayout *vbox; |
206 | QLabel *l; | 271 | QLabel *l; |
207 | 272 | ||
208 | vbox = new QVBoxLayout ( ); | 273 | vbox = new QVBoxLayout ( ); |
209 | vbox-> setSpacing ( 4 ); | 274 | vbox-> setSpacing ( 4 ); |
210 | grid-> addLayout ( vbox, 1, 0 ); | 275 | grid-> addLayout ( vbox, 1, 0 ); |
211 | 276 | ||
212 | upButton = new QPushButton ( this ); | 277 | upButton = new QPushButton ( this ); |
213 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 278 | upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
214 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); | 279 | upButton-> setPixmap ( Resource::loadPixmap ( "up" )); |
215 | upButton-> setFocusPolicy ( QWidget::NoFocus ); | 280 | upButton-> setFocusPolicy ( QWidget::NoFocus ); |
216 | 281 | ||
217 | vbox-> addWidget ( upButton ); | 282 | vbox-> addWidget ( upButton ); |
218 | 283 | ||
219 | downButton = new QPushButton ( this ); | 284 | downButton = new QPushButton ( this ); |
220 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); | 285 | downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); |
221 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); | 286 | downButton-> setPixmap ( Resource::loadPixmap ( "down" )); |
222 | downButton-> setFocusPolicy ( QWidget::NoFocus ); | 287 | downButton-> setFocusPolicy ( QWidget::NoFocus ); |
223 | 288 | ||
224 | vbox-> addWidget ( downButton ); | 289 | vbox-> addWidget ( downButton ); |
225 | 290 | ||
226 | volSlider = new QSlider ( this ); | 291 | volSlider = new QSlider ( this ); |
227 | volSlider-> setRange ( 0, 100 ); | 292 | volSlider-> setRange ( 0, 100 ); |
228 | volSlider-> setTickmarks ( QSlider::Both ); | 293 | volSlider-> setTickmarks ( QSlider::Both ); |
229 | volSlider-> setTickInterval ( 20 ); | 294 | volSlider-> setTickInterval ( 20 ); |
230 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); | 295 | volSlider-> setFocusPolicy ( QWidget::NoFocus ); |
231 | 296 | ||
232 | l = new QLabel ( this ); | 297 | l = new QLabel ( this ); |
233 | l-> setPixmap ( QPixmap ( vol_xpm )); | 298 | l-> setPixmap ( QPixmap ( vol_xpm )); |
234 | 299 | ||
235 | grid-> addWidget ( l, 0, 1, AlignCenter ); | 300 | grid-> addWidget ( l, 0, 1, AlignCenter ); |
236 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); | 301 | grid-> addWidget ( volSlider, 1, 1, AlignCenter ); |
237 | 302 | ||
238 | volLed = new OLedBox ( green, this ); | 303 | volLed = new OLedBox ( green, this ); |
239 | volLed-> setFocusPolicy ( QWidget::NoFocus ); | 304 | volLed-> setFocusPolicy ( QWidget::NoFocus ); |
240 | volLed-> setFixedSize ( 16, 16 ); | 305 | volLed-> setFixedSize ( 16, 16 ); |
241 | 306 | ||
242 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); | 307 | grid-> addWidget ( volLed, 2, 1, AlignCenter ); |
243 | 308 | ||
309 | QVBox *basstrebleBox = new QVBox( this ); | ||
310 | |||
311 | trebleSlider = new QSlider ( basstrebleBox ); | ||
312 | trebleSlider-> setRange ( 0, 100 ); | ||
313 | trebleSlider-> setTickmarks ( QSlider::Both ); | ||
314 | trebleSlider-> setTickInterval ( 20 ); | ||
315 | trebleSlider->setMaximumHeight( 40 ); | ||
316 | trebleSlider-> setFocusPolicy ( QWidget::NoFocus ); | ||
317 | |||
318 | bassSlider = new QSlider ( basstrebleBox ); | ||
319 | bassSlider-> setRange ( 0, 100 ); | ||
320 | bassSlider-> setTickmarks ( QSlider::Both ); | ||
321 | bassSlider-> setTickInterval ( 20 ); | ||
322 | bassSlider->setMaximumHeight( 40 ); | ||
323 | bassSlider-> setFocusPolicy ( QWidget::NoFocus ); | ||
324 | |||
325 | QLabel *bassLabel = new QLabel ( this ); | ||
326 | bassLabel-> setPixmap ( QPixmap ( bass_xpm )); | ||
327 | |||
328 | QLabel *trebleLabel = new QLabel( this ); | ||
329 | trebleLabel->setPixmap( QPixmap ( treble_xpm ) ); | ||
330 | |||
331 | grid->addWidget( trebleLabel, 0, 4, AlignCenter ); | ||
332 | grid->addWidget( basstrebleBox, 1, 4, AlignCenter ); | ||
333 | grid-> addWidget ( bassLabel, 2, 4, AlignCenter ); | ||
334 | |||
335 | if ( !has_bass ) { | ||
336 | bassSlider->hide(); | ||
337 | bassLabel->hide(); | ||
338 | } | ||
339 | |||
340 | if ( !has_treble ) { | ||
341 | trebleSlider->hide(); | ||
342 | trebleLabel->hide(); | ||
343 | } | ||
344 | |||
244 | micSlider = new QSlider ( this ); | 345 | micSlider = new QSlider ( this ); |
245 | micSlider-> setRange ( 0, 100 ); | 346 | micSlider-> setRange ( 0, 100 ); |
246 | micSlider-> setTickmarks ( QSlider::Both ); | 347 | micSlider-> setTickmarks ( QSlider::Both ); |
247 | micSlider-> setTickInterval ( 20 ); | 348 | micSlider-> setTickInterval ( 20 ); |
248 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); | 349 | micSlider-> setFocusPolicy ( QWidget::NoFocus ); |
249 | 350 | ||
250 | l = new QLabel ( this ); | 351 | l = new QLabel ( this ); |
251 | l-> setPixmap ( QPixmap ( mic_xpm )); | 352 | l-> setPixmap ( QPixmap ( mic_xpm )); |
252 | 353 | ||
253 | grid-> addWidget ( l, 0, 2, AlignCenter ); | 354 | grid-> addWidget ( l, 0, 2, AlignCenter ); |
254 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); | 355 | grid-> addWidget ( micSlider, 1, 2, AlignCenter ); |
255 | 356 | ||
256 | micLed = new OLedBox ( red, this ); | 357 | micLed = new OLedBox ( red, this ); |
257 | micLed-> setFocusPolicy ( QWidget::NoFocus ); | 358 | micLed-> setFocusPolicy ( QWidget::NoFocus ); |
258 | micLed-> setFixedSize ( 16, 16 ); | 359 | micLed-> setFixedSize ( 16, 16 ); |
259 | 360 | ||
260 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); | 361 | grid-> addWidget ( micLed, 2, 2, AlignCenter ); |
261 | 362 | ||
262 | alarmSlider = new QSlider ( this ); | 363 | alarmSlider = new QSlider ( this ); |
263 | alarmSlider-> setRange ( 0, 100 ); | 364 | alarmSlider-> setRange ( 0, 100 ); |
264 | alarmSlider-> setTickmarks ( QSlider::Both ); | 365 | alarmSlider-> setTickmarks ( QSlider::Both ); |
265 | alarmSlider-> setTickInterval ( 20 ); | 366 | alarmSlider-> setTickInterval ( 20 ); |
266 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); | 367 | alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); |
267 | 368 | ||
268 | QLabel *alarmLabel = new QLabel ( this ); | 369 | QLabel *alarmLabel = new QLabel ( this ); |
269 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); | 370 | alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); |
270 | 371 | ||
271 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); | 372 | grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); |
272 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); | 373 | grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); |
273 | 374 | ||
274 | alarmLed = new OLedBox ( yellow, this ); | 375 | alarmLed = new OLedBox ( yellow, this ); |
275 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); | 376 | alarmLed-> setFocusPolicy ( QWidget::NoFocus ); |
276 | alarmLed-> setFixedSize ( 16, 16 ); | 377 | alarmLed-> setFixedSize ( 16, 16 ); |
277 | 378 | ||
278 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); | 379 | grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); |
279 | 380 | ||
280 | if ( !has_wav_alarm ) { | 381 | if ( !has_wav_alarm ) { |
281 | alarmSlider-> hide ( ); | 382 | alarmSlider-> hide ( ); |
282 | alarmLabel-> hide ( ); | 383 | alarmLabel-> hide ( ); |
283 | alarmLed-> hide ( ); | 384 | alarmLed-> hide ( ); |
284 | } | 385 | } |
285 | 386 | ||
286 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft ); | 387 | grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 6, AlignVCenter | AlignLeft ); |
287 | 388 | ||
288 | vbox = new QVBoxLayout ( ); | 389 | vbox = new QVBoxLayout ( ); |
289 | vbox-> setSpacing ( 4 ); | 390 | vbox-> setSpacing ( 4 ); |
290 | grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); | 391 | grid-> addMultiCellLayout ( vbox, 1, 2, 6, 6 ); |
291 | 392 | ||
292 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); | 393 | tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); |
293 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); | 394 | tapBox-> setFocusPolicy ( QWidget::NoFocus ); |
294 | 395 | ||
295 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); | 396 | vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); |
296 | 397 | ||
297 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); | 398 | keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); |
298 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); | 399 | keyBox-> setFocusPolicy ( QWidget::NoFocus ); |
299 | 400 | ||
300 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); | 401 | vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); |
301 | 402 | ||
302 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); | 403 | alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); |
303 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); | 404 | alarmBox-> setFocusPolicy ( QWidget::NoFocus ); |
304 | 405 | ||
305 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); | 406 | vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); |
306 | 407 | ||
307 | if ( has_wav_alarm ) { | 408 | if ( has_wav_alarm ) { |
308 | alarmBox-> hide ( ); | 409 | alarmBox-> hide ( ); |
309 | } | 410 | } |
310 | 411 | ||
@@ -312,43 +413,48 @@ VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *pa | |||
312 | 413 | ||
313 | setFixedSize ( sizeHint ( )); | 414 | setFixedSize ( sizeHint ( )); |
314 | setFocusPolicy ( QWidget::NoFocus ); | 415 | setFocusPolicy ( QWidget::NoFocus ); |
315 | 416 | ||
316 | rateTimer = new QTimer( this ); | 417 | rateTimer = new QTimer( this ); |
317 | connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); | 418 | connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); |
318 | 419 | ||
319 | connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 420 | connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); |
320 | connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 421 | connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); |
321 | connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); | 422 | connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); |
322 | connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); | 423 | connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); |
323 | 424 | ||
324 | connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); | 425 | connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); |
325 | connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); | 426 | connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); |
326 | connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); | 427 | connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); |
327 | 428 | connect ( bassSlider, SIGNAL( valueChanged ( int )), this, SLOT( bassMoved( int ))); | |
429 | connect ( trebleSlider, SIGNAL( valueChanged ( int )), this, SLOT( trebleMoved( int ))); | ||
430 | |||
431 | |||
328 | connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); | 432 | connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); |
329 | connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); | 433 | connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); |
330 | connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 434 | connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); |
331 | 435 | ||
332 | connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); | 436 | connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); |
333 | connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); | 437 | connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); |
334 | connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); | 438 | connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); |
335 | 439 | ||
336 | // initialize variables | 440 | // initialize variables |
337 | 441 | ||
338 | readConfig ( true ); | 442 | readConfig ( true ); |
339 | 443 | ||
340 | // initialize the config file, in case some entries are missing | 444 | // initialize the config file, in case some entries are missing |
341 | 445 | ||
342 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); | 446 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); |
447 | writeConfigEntry ( "BassPercent", m_vol_percent, UPD_None ); | ||
448 | writeConfigEntry ( "TreblePercent", m_vol_percent, UPD_None ); | ||
343 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); | 449 | writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); |
344 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 450 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
345 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); | 451 | writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); |
346 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); | 452 | writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); |
347 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 453 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
348 | 454 | ||
349 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); | 455 | writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); |
350 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 456 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
351 | } | 457 | } |
352 | 458 | ||
353 | bool VolumeControl::volMuted ( ) const | 459 | bool VolumeControl::volMuted ( ) const |
354 | { | 460 | { |
@@ -400,67 +506,76 @@ void VolumeControl::rateTimerDone ( ) | |||
400 | 506 | ||
401 | void VolumeControl::show ( bool /*showMic*/ ) | 507 | void VolumeControl::show ( bool /*showMic*/ ) |
402 | { | 508 | { |
403 | readConfig ( ); | 509 | readConfig ( ); |
404 | 510 | ||
405 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); | 511 | QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); |
406 | 512 | ||
407 | int w = sizeHint ( ). width ( ); | 513 | int w = sizeHint ( ). width ( ); |
408 | int x = curPos.x ( ) - ( w / 2 ); | 514 | int x = curPos.x ( ) - ( w / 2 ); |
409 | 515 | ||
410 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) | 516 | if (( x + w ) > QPEApplication::desktop ( )-> width ( )) |
411 | x = QPEApplication::desktop ( )-> width ( ) - w; | 517 | x = QPEApplication::desktop ( )-> width ( ) - w; |
412 | 518 | ||
413 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); | 519 | move ( x, curPos. y ( ) - sizeHint ( ). height ( )); |
414 | QFrame::show ( ); | 520 | QFrame::show ( ); |
415 | 521 | ||
416 | } | 522 | } |
417 | 523 | ||
418 | void VolumeControl::readConfig ( bool force ) | 524 | void VolumeControl::readConfig ( bool force ) |
419 | { | 525 | { |
420 | Config cfg ( "qpe" ); | 526 | Config cfg ( "qpe" ); |
421 | cfg. setGroup ( "Volume" ); | 527 | cfg. setGroup ( "Volume" ); |
422 | 528 | ||
423 | int old_vp = m_vol_percent; | 529 | int old_vp = m_vol_percent; |
424 | int old_mp = m_mic_percent; | 530 | int old_mp = m_mic_percent; |
531 | int old_bass = m_bass_percent; | ||
532 | int old_treble = m_treble_percent; | ||
425 | bool old_vm = m_vol_muted; | 533 | bool old_vm = m_vol_muted; |
426 | bool old_mm = m_mic_muted; | 534 | bool old_mm = m_mic_muted; |
427 | bool old_sk = m_snd_key; | 535 | bool old_sk = m_snd_key; |
428 | bool old_st = m_snd_touch; | 536 | bool old_st = m_snd_touch; |
429 | bool old_sa = m_snd_alarm; | 537 | bool old_sa = m_snd_alarm; |
430 | int old_ap = m_alarm_percent; | 538 | int old_ap = m_alarm_percent; |
431 | 539 | ||
432 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); | 540 | m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); |
433 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); | 541 | m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); |
542 | m_bass_percent = cfg. readNumEntry ( "BassPercent", 50 ); | ||
543 | m_treble_percent = cfg. readNumEntry ( "TreblePercent", 50 ); | ||
434 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); | 544 | m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); |
435 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); | 545 | m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); |
436 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); | 546 | m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); |
437 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); | 547 | m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); |
438 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); | 548 | m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); |
439 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); | 549 | m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); |
440 | 550 | ||
441 | if ( force || ( m_vol_percent != old_vp )) | 551 | if ( force || ( m_vol_percent != old_vp )) |
442 | volSlider-> setValue ( 100 - m_vol_percent ); | 552 | volSlider-> setValue ( 100 - m_vol_percent ); |
443 | if ( force || ( m_mic_percent != old_mp )) | 553 | if ( force || ( m_mic_percent != old_mp )) |
444 | micSlider-> setValue ( 100 - m_mic_percent ); | 554 | micSlider-> setValue ( 100 - m_mic_percent ); |
445 | if ( force || ( m_alarm_percent != old_ap )) | 555 | if ( force || ( m_alarm_percent != old_ap )) |
446 | alarmSlider-> setValue ( 100 - m_alarm_percent ); | 556 | alarmSlider-> setValue ( 100 - m_alarm_percent ); |
447 | 557 | if ( force || ( m_bass_percent != old_bass )) | |
558 | bassSlider-> setValue ( 100 - m_bass_percent ); | ||
559 | if ( force || ( m_treble_percent != old_treble )) | ||
560 | trebleSlider-> setValue ( 100 - m_treble_percent ); | ||
561 | |||
562 | |||
448 | if ( force || ( m_vol_muted != old_vm )) | 563 | if ( force || ( m_vol_muted != old_vm )) |
449 | volLed-> setOn ( !m_vol_muted ); | 564 | volLed-> setOn ( !m_vol_muted ); |
450 | if ( force || ( m_mic_muted != old_mm )) | 565 | if ( force || ( m_mic_muted != old_mm )) |
451 | micLed-> setOn ( !m_mic_muted ); | 566 | micLed-> setOn ( !m_mic_muted ); |
452 | if ( force || ( m_snd_alarm != old_sa )) | 567 | if ( force || ( m_snd_alarm != old_sa )) |
453 | alarmLed-> setOn ( m_snd_alarm ); | 568 | alarmLed-> setOn ( m_snd_alarm ); |
454 | 569 | ||
455 | if ( force || ( m_snd_key != old_sk )) | 570 | if ( force || ( m_snd_key != old_sk )) |
456 | keyBox-> setChecked ( m_snd_key ); | 571 | keyBox-> setChecked ( m_snd_key ); |
457 | if ( force || ( m_snd_touch != old_st )) | 572 | if ( force || ( m_snd_touch != old_st )) |
458 | tapBox-> setChecked ( m_snd_touch ); | 573 | tapBox-> setChecked ( m_snd_touch ); |
459 | if ( force || ( m_snd_alarm != old_sa )) | 574 | if ( force || ( m_snd_alarm != old_sa )) |
460 | alarmBox-> setChecked ( m_snd_alarm ); | 575 | alarmBox-> setChecked ( m_snd_alarm ); |
461 | } | 576 | } |
462 | 577 | ||
463 | 578 | ||
464 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) | 579 | void VolumeControl::volumeChanged ( bool /*nowMuted*/ ) |
465 | { | 580 | { |
466 | int prevVol = m_vol_percent; | 581 | int prevVol = m_vol_percent; |
@@ -500,34 +615,34 @@ void VolumeControl::alarmSoundToggled ( bool b ) | |||
500 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); | 615 | writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); |
501 | } | 616 | } |
502 | 617 | ||
503 | void VolumeControl::volMuteToggled ( bool b ) | 618 | void VolumeControl::volMuteToggled ( bool b ) |
504 | { | 619 | { |
505 | m_vol_muted = !b; | 620 | m_vol_muted = !b; |
506 | 621 | ||
507 | m_icon-> redraw ( true ); | 622 | m_icon-> redraw ( true ); |
508 | 623 | ||
509 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); | 624 | writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); |
510 | } | 625 | } |
511 | 626 | ||
512 | void VolumeControl::micMuteToggled ( bool b ) | 627 | void VolumeControl::micMuteToggled ( bool b ) |
513 | { | 628 | { |
514 | m_mic_muted = !b; | 629 | m_mic_muted = !b; |
515 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); | 630 | writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); |
516 | } | 631 | } |
517 | 632 | ||
518 | 633 | ||
519 | void VolumeControl::volMoved ( int percent ) | 634 | void VolumeControl::volMoved ( int percent ) |
520 | { | 635 | { |
521 | m_vol_percent = 100 - percent; | 636 | m_vol_percent = 100 - percent; |
522 | 637 | ||
523 | // clamp volume percent to be between 0 and 100 | 638 | // clamp volume percent to be between 0 and 100 |
524 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); | 639 | m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); |
525 | // repaint just the little volume rectangle | 640 | // repaint just the little volume rectangle |
526 | m_icon-> redraw ( false ); | 641 | m_icon-> redraw ( false ); |
527 | 642 | ||
528 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); | 643 | writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); |
529 | } | 644 | } |
530 | 645 | ||
531 | void VolumeControl::micMoved ( int percent ) | 646 | void VolumeControl::micMoved ( int percent ) |
532 | { | 647 | { |
533 | m_mic_percent = 100 - percent; | 648 | m_mic_percent = 100 - percent; |
@@ -546,30 +661,63 @@ void VolumeControl::alarmMoved ( int percent ) | |||
546 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); | 661 | m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); |
547 | 662 | ||
548 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); | 663 | writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); |
549 | } | 664 | } |
550 | 665 | ||
551 | 666 | ||
667 | void VolumeControl::bassMoved ( int percent ) | ||
668 | { | ||
669 | m_bass_percent = 100 - percent; | ||
670 | |||
671 | // clamp bass percent to be between 0 and 100 | ||
672 | m_bass_percent = ( m_bass_percent < 0 ) ? 0 : (( m_bass_percent > 100 ) ? 100 : m_bass_percent ); | ||
673 | |||
674 | writeConfigEntry ( "BassPercent", m_bass_percent, UPD_Bass ); | ||
675 | } | ||
676 | |||
677 | |||
678 | |||
679 | void VolumeControl::trebleMoved ( int percent ) | ||
680 | { | ||
681 | m_treble_percent = 100 - percent; | ||
682 | |||
683 | // clamp treble percent to be between 0 and 100 | ||
684 | m_treble_percent = ( m_treble_percent < 0 ) ? 0 : (( m_treble_percent > 100 ) ? 100 : m_treble_percent ); | ||
685 | |||
686 | writeConfigEntry ( "TreblePercent", m_treble_percent, UPD_Treble ); | ||
687 | } | ||
688 | |||
689 | |||
690 | |||
552 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) | 691 | void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) |
553 | { | 692 | { |
554 | Config cfg ( "qpe" ); | 693 | Config cfg ( "qpe" ); |
555 | cfg. setGroup ( "Volume" ); | 694 | cfg. setGroup ( "Volume" ); |
556 | cfg. writeEntry ( entry, val ); | 695 | cfg. writeEntry ( entry, val ); |
557 | // cfg. write ( ); | 696 | // cfg. write ( ); |
558 | 697 | ||
559 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 698 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
560 | switch ( upd ) { | 699 | switch ( upd ) { |
561 | case UPD_Vol: { | 700 | case UPD_Vol: { |
562 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; | 701 | QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; |
563 | break; | 702 | break; |
564 | } | 703 | } |
565 | case UPD_Mic: { | 704 | case UPD_Mic: { |
566 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; | 705 | QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; |
567 | break; | 706 | break; |
568 | } | 707 | } |
569 | case UPD_None: | 708 | case UPD_Bass: { |
709 | QCopEnvelope ( "QPE/System", "bassChange(bool)" ) << true; | ||
710 | break; | ||
711 | } | ||
712 | case UPD_Treble: { | ||
713 | QCopEnvelope ( "QPE/System", "trebleChange(bool)" ) << true; | ||
714 | break; | ||
715 | } | ||
716 | |||
717 | case UPD_None: | ||
570 | break; | 718 | break; |
571 | } | 719 | } |
572 | #endif | 720 | #endif |
573 | } | 721 | } |
574 | 722 | ||
575 | //=========================================================================== | 723 | //=========================================================================== |
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 | |||
@@ -52,12 +52,14 @@ protected slots: | |||
52 | void micChanged ( bool muted ); | 52 | void micChanged ( bool muted ); |
53 | 53 | ||
54 | private slots: | 54 | private slots: |
55 | void volMoved ( int percent ); | 55 | void volMoved ( int percent ); |
56 | void micMoved ( int percent ); | 56 | void micMoved ( int percent ); |
57 | void alarmMoved ( int percent ); | 57 | void alarmMoved ( int percent ); |
58 | void bassMoved( int percent ); | ||
59 | void trebleMoved( int percent ); | ||
58 | 60 | ||
59 | void volMuteToggled ( bool ); | 61 | void volMuteToggled ( bool ); |
60 | void micMuteToggled ( bool ); | 62 | void micMuteToggled ( bool ); |
61 | void alarmSoundToggled ( bool ); | 63 | void alarmSoundToggled ( bool ); |
62 | void keyClickToggled ( bool ); | 64 | void keyClickToggled ( bool ); |
63 | void screenTapToggled ( bool ); | 65 | void screenTapToggled ( bool ); |
@@ -68,19 +70,23 @@ private slots: | |||
68 | private: | 70 | private: |
69 | void readConfig ( bool force = false ); | 71 | void readConfig ( bool force = false ); |
70 | 72 | ||
71 | enum eUpdate { | 73 | enum eUpdate { |
72 | UPD_None, | 74 | UPD_None, |
73 | UPD_Vol, | 75 | UPD_Vol, |
74 | UPD_Mic | 76 | UPD_Mic, |
77 | UPD_Bass, | ||
78 | UPD_Treble | ||
75 | }; | 79 | }; |
76 | void writeConfigEntry ( const char *entry, int val, eUpdate upd ); | 80 | void writeConfigEntry ( const char *entry, int val, eUpdate upd ); |
77 | 81 | ||
78 | 82 | ||
79 | private: | 83 | private: |
80 | QSlider *volSlider; | 84 | QSlider *volSlider; |
85 | QSlider *bassSlider; | ||
86 | QSlider *trebleSlider; | ||
81 | QSlider *micSlider; | 87 | QSlider *micSlider; |
82 | QSlider *alarmSlider; | 88 | QSlider *alarmSlider; |
83 | OLedBox *volLed; | 89 | OLedBox *volLed; |
84 | OLedBox *micLed; | 90 | OLedBox *micLed; |
85 | OLedBox *alarmLed; | 91 | OLedBox *alarmLed; |
86 | 92 | ||
@@ -91,12 +97,14 @@ private: | |||
91 | QPushButton *downButton; | 97 | QPushButton *downButton; |
92 | QTimer *rateTimer; | 98 | QTimer *rateTimer; |
93 | 99 | ||
94 | int m_vol_percent; | 100 | int m_vol_percent; |
95 | int m_mic_percent; | 101 | int m_mic_percent; |
96 | int m_alarm_percent; | 102 | int m_alarm_percent; |
103 | int m_bass_percent; | ||
104 | int m_treble_percent; | ||
97 | bool m_vol_muted; | 105 | bool m_vol_muted; |
98 | bool m_mic_muted; | 106 | bool m_mic_muted; |
99 | bool m_snd_alarm; | 107 | bool m_snd_alarm; |
100 | bool m_snd_touch; | 108 | bool m_snd_touch; |
101 | bool m_snd_key; | 109 | bool m_snd_key; |
102 | 110 | ||