summaryrefslogtreecommitdiff
authorsandman <sandman>2002-09-30 21:10:05 (UTC)
committer sandman <sandman>2002-09-30 21:10:05 (UTC)
commitf49ad5cf3bdc1d1c06be4615a649b6be6f179b83 (patch) (unidiff)
tree77ad6928937375e116529fab2e5a746fce5ba936
parent3ff016b281a3c059e6ecb728c60fd6847756f291 (diff)
downloadopie-f49ad5cf3bdc1d1c06be4615a649b6be6f179b83.zip
opie-f49ad5cf3bdc1d1c06be4615a649b6be6f179b83.tar.gz
opie-f49ad5cf3bdc1d1c06be4615a649b6be6f179b83.tar.bz2
- small cleanup
- changed to work with the new ODevice API
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index eedc749..aec346b 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -16,64 +16,66 @@
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <stdio.h> 21#include <stdio.h>
22 22
23#include "volume.h" 23#include "volume.h"
24 24
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 28#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
29#include <qpe/qcopenvelope_qws.h> 29#include <qpe/qcopenvelope_qws.h>
30#endif 30#endif
31 31
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 <qlabel.h> 38#include <qlabel.h>
39 39
40#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qtimer.h> 42#include <qtimer.h>
43 43
44#include <opie/odevice.h> 44#include <opie/odevice.h>
45 45
46#include "oledbox.h" 46#include "oledbox.h"
47 47
48using namespace Opie;
49
48#define RATE_TIMER_INTERVAL 100 50#define RATE_TIMER_INTERVAL 100
49// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time 51// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time
50// results in "hanging" buttons on the iPAQ due to quite high CPU consumption. 52// results in "hanging" buttons on the iPAQ due to quite high CPU consumption.
51 53
52 54
53/* XPM */ 55/* XPM */
54static const char * vol_xpm[] = { 56static const char * vol_xpm[] = {
55"20 20 3 1", 57"20 20 3 1",
56" c None", 58" c None",
57". c #0000FF", 59". c #0000FF",
58"+ c #000000", 60"+ c #000000",
59" ", 61" ",
60" . ", 62" . ",
61" . . . . ", 63" . . . . ",
62" . . . . . . ", 64" . . . . . . ",
63" . . . . . . . ", 65" . . . . . . . ",
64" . . ..... . . ", 66" . . ..... . . ",
65" . ... ..... ... ", 67" . ... ..... ... ",
66" ........... .... ", 68" ........... .... ",
67" ................. ", 69" ................. ",
68"++++++++++++++++++++", 70"++++++++++++++++++++",
69" .................. ", 71" .................. ",
70" . ............. . ", 72" . ............. . ",
71" . ..... ....... ", 73" . ..... ....... ",
72" . ... ..... . ", 74" . ... ..... . ",
73" . ... ..... . ", 75" . ... ..... . ",
74" . ... ..... ", 76" . ... ..... ",
75" . . . . . ", 77" . . . . . ",
76" . . . ", 78" . . . ",
77" . . . ", 79" . . . ",
78" "}; 80" "};
79/* XPM */ 81/* XPM */
@@ -157,67 +159,69 @@ static const char * alarm_xpm[] = {
157"2 c #B1AC6B", 159"2 c #B1AC6B",
158"3 c #F7F710", 160"3 c #F7F710",
159"4 c #838204", 161"4 c #838204",
160" ", 162" ",
161" ", 163" ",
162" 4'4/ ", 164" 4'4/ ",
163" /-^= ", 165" /-^= ",
164" 42{4>4 ", 166" 42{4>4 ",
165" '2|+*$44 ", 167" '2|+*$44 ",
166" +2&3+$1*44 ", 168" +2&3+$1*44 ",
167" (%_}_+/$:>/4 ", 169" (%_}_+/$:>/4 ",
168" 4%_}3+#;>:*4 ", 170" 4%_}3+#;>:*4 ",
169" 4%_}&+#[1$/4 ", 171" 4%_}&+#[1$/4 ",
170" 4%_,2')[~~>4 ", 172" 4%_,2')[~~>4 ",
171" 4%33'4#@~1>4 ", 173" 4%33'4#@~1>4 ",
172" 4%3344#[:>/4 ", 174" 4%3344#[:>/4 ",
173" 42&_3'4#@>:*44 ", 175" 42&_3'4#@>:*44 ",
174" 42|}}3'4#[;$)$44 ", 176" 42|}}3'4#[;$)$44 ",
175"444{]]2^~~:!!#.@##/ ", 177"444{]]2^~~:!!#.@##/ ",
176"4444-%*:==!!=...../ ", 178"4444-%*:==!!=...../ ",
177" /:[.. ", 179" /:[.. ",
178" /@. ", 180" /@. ",
179" "}; 181" "};
180 182
181VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name ) 183VolumeControl::VolumeControl ( VolumeApplet *icon, bool /*showMic*/, QWidget *parent, const char *name )
182 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup ) 184 : QFrame ( parent, name, WStyle_StaysOnTop | WType_Popup )
183{ 185{
184 m_icon = icon; 186 m_icon = icon;
185 187
186 bool has_wav_alarm = true; 188 bool has_wav_alarm = true;
187 189
188 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually 190 switch ( ODevice::inst ( )-> model ( )) { // we need to add other devices eventually
189 case OMODEL_Zaurus_SL5000: 191 case Model_Zaurus_SL5000:
190 has_wav_alarm = false; //poor guys probably feeling left out... 192 has_wav_alarm = false; //poor guys probably feeling left out...
191 break; 193 break;
194 default:
195 break;
192 } 196 }
193 197
194 198
195 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); 199 setFrameStyle ( QFrame::PopupPanel | QFrame::Raised );
196 200
197 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 ); 201 QGridLayout *grid = new QGridLayout ( this, 1, 1, 6, 4 );
198 grid-> setSpacing ( 4 ); 202 grid-> setSpacing ( 4 );
199 grid-> setMargin ( 6 ); 203 grid-> setMargin ( 6 );
200 204
201 QVBoxLayout *vbox; 205 QVBoxLayout *vbox;
202 QLabel *l; 206 QLabel *l;
203 207
204 vbox = new QVBoxLayout ( ); 208 vbox = new QVBoxLayout ( );
205 vbox-> setSpacing ( 4 ); 209 vbox-> setSpacing ( 4 );
206 grid-> addLayout ( vbox, 1, 0 ); 210 grid-> addLayout ( vbox, 1, 0 );
207 211
208 upButton = new QPushButton ( this ); 212 upButton = new QPushButton ( this );
209 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 213 upButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
210 upButton-> setPixmap ( Resource::loadPixmap ( "up" )); 214 upButton-> setPixmap ( Resource::loadPixmap ( "up" ));
211 upButton-> setFocusPolicy ( QWidget::NoFocus ); 215 upButton-> setFocusPolicy ( QWidget::NoFocus );
212 216
213 vbox-> addWidget ( upButton ); 217 vbox-> addWidget ( upButton );
214 218
215 downButton = new QPushButton ( this ); 219 downButton = new QPushButton ( this );
216 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding )); 220 downButton-> setSizePolicy ( QSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Expanding ));
217 downButton-> setPixmap ( Resource::loadPixmap ( "down" )); 221 downButton-> setPixmap ( Resource::loadPixmap ( "down" ));
218 downButton-> setFocusPolicy ( QWidget::NoFocus ); 222 downButton-> setFocusPolicy ( QWidget::NoFocus );
219 223
220 vbox-> addWidget ( downButton ); 224 vbox-> addWidget ( downButton );
221 225
222 volSlider = new QSlider ( this ); 226 volSlider = new QSlider ( this );
223 volSlider-> setRange ( 0, 100 ); 227 volSlider-> setRange ( 0, 100 );
@@ -428,65 +432,65 @@ void VolumeControl::readConfig ( bool force )
428 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 ); 432 m_vol_percent = cfg. readNumEntry ( "VolumePercent", 50 );
429 m_mic_percent = cfg. readNumEntry ( "Mic", 50 ); 433 m_mic_percent = cfg. readNumEntry ( "Mic", 50 );
430 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 ); 434 m_vol_muted = cfg. readBoolEntry ( "Mute", 0 );
431 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 ); 435 m_mic_muted = cfg. readBoolEntry ( "MicMute", 0 );
432 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 ); 436 m_snd_key = cfg. readBoolEntry ( "KeySound", 0 );
433 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 ); 437 m_snd_touch = cfg. readBoolEntry ( "TouchSound", 0 );
434 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 ); 438 m_snd_alarm = cfg. readBoolEntry ( "AlarmSound", 1 );
435 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 ); 439 m_alarm_percent = cfg. readNumEntry ( "AlarmPercent", 65 );
436 440
437 if ( force || ( m_vol_percent != old_vp )) 441 if ( force || ( m_vol_percent != old_vp ))
438 volSlider-> setValue ( 100 - m_vol_percent ); 442 volSlider-> setValue ( 100 - m_vol_percent );
439 if ( force || ( m_mic_percent != old_mp )) 443 if ( force || ( m_mic_percent != old_mp ))
440 micSlider-> setValue ( 100 - m_mic_percent ); 444 micSlider-> setValue ( 100 - m_mic_percent );
441 if ( force || ( m_alarm_percent != old_ap )) 445 if ( force || ( m_alarm_percent != old_ap ))
442 alarmSlider-> setValue ( 100 - m_alarm_percent ); 446 alarmSlider-> setValue ( 100 - m_alarm_percent );
443 447
444 if ( force || ( m_vol_muted != old_vm )) 448 if ( force || ( m_vol_muted != old_vm ))
445 volLed-> setOn ( !m_vol_muted ); 449 volLed-> setOn ( !m_vol_muted );
446 if ( force || ( m_mic_muted != old_mm )) 450 if ( force || ( m_mic_muted != old_mm ))
447 micLed-> setOn ( !m_mic_muted ); 451 micLed-> setOn ( !m_mic_muted );
448 if ( force || ( m_snd_alarm != old_sa )) 452 if ( force || ( m_snd_alarm != old_sa ))
449 alarmLed-> setOn ( m_snd_alarm ); 453 alarmLed-> setOn ( m_snd_alarm );
450 454
451 if ( force || ( m_snd_key != old_sk )) 455 if ( force || ( m_snd_key != old_sk ))
452 keyBox-> setChecked ( m_snd_key ); 456 keyBox-> setChecked ( m_snd_key );
453 if ( force || ( m_snd_touch != old_st )) 457 if ( force || ( m_snd_touch != old_st ))
454 tapBox-> setChecked ( m_snd_touch ); 458 tapBox-> setChecked ( m_snd_touch );
455 if ( force || ( m_snd_alarm != old_sa )) 459 if ( force || ( m_snd_alarm != old_sa ))
456 alarmBox-> setChecked ( m_snd_alarm ); 460 alarmBox-> setChecked ( m_snd_alarm );
457} 461}
458 462
459 463
460void VolumeControl::volumeChanged ( bool nowMuted ) 464void VolumeControl::volumeChanged ( bool /*nowMuted*/ )
461{ 465{
462 int prevVol = m_vol_percent; 466 int prevVol = m_vol_percent;
463 bool prevMute = m_vol_muted; 467 bool prevMute = m_vol_muted;
464 468
465 readConfig ( ); 469 readConfig ( );
466 470
467 // Handle case where muting it toggled 471 // Handle case where muting it toggled
468 if ( m_vol_muted != prevMute ) 472 if ( m_vol_muted != prevMute )
469 m_icon-> redraw ( true ); 473 m_icon-> redraw ( true );
470 else if ( prevVol != m_vol_percent ) // Avoid over repainting 474 else if ( prevVol != m_vol_percent ) // Avoid over repainting
471 m_icon-> redraw ( false ); 475 m_icon-> redraw ( false );
472} 476}
473 477
474void VolumeControl::micChanged ( bool nowMuted ) 478void VolumeControl::micChanged ( bool nowMuted )
475{ 479{
476 if ( !nowMuted ) 480 if ( !nowMuted )
477 readConfig ( ); 481 readConfig ( );
478 m_mic_muted = nowMuted; 482 m_mic_muted = nowMuted;
479} 483}
480 484
481void VolumeControl::screenTapToggled ( bool b ) 485void VolumeControl::screenTapToggled ( bool b )
482{ 486{
483 m_snd_touch = b; 487 m_snd_touch = b;
484 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol ); 488 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_Vol );
485} 489}
486 490
487void VolumeControl::keyClickToggled ( bool b ) 491void VolumeControl::keyClickToggled ( bool b )
488{ 492{
489 m_snd_key = b; 493 m_snd_key = b;
490 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol ); 494 writeConfigEntry ( "KeySound", m_snd_key, UPD_Vol );
491} 495}
492 496