summaryrefslogtreecommitdiff
Unidiff
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
@@ -1,630 +1,634 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
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 */
80static const char * mic_xpm[] = { 82static const char * mic_xpm[] = {
81"20 20 21 1", 83"20 20 21 1",
82" c None", 84" c None",
83". c #000000", 85". c #000000",
84"+ c #EEEEEE", 86"+ c #EEEEEE",
85"@ c #B4B6B4", 87"@ c #B4B6B4",
86"# c #8B8D8B", 88"# c #8B8D8B",
87"$ c #D5D6D5", 89"$ c #D5D6D5",
88"% c #E6E6E6", 90"% c #E6E6E6",
89"& c #9C9D9C", 91"& c #9C9D9C",
90"* c #6A696A", 92"* c #6A696A",
91"= c #E6E2E6", 93"= c #E6E2E6",
92"- c #F6F2F6", 94"- c #F6F2F6",
93"; c #CDC6CD", 95"; c #CDC6CD",
94"> c #737573", 96"> c #737573",
95", c #4A484A", 97", c #4A484A",
96"' c #DEDEDE", 98"' c #DEDEDE",
97") c #F6EEF6", 99") c #F6EEF6",
98"! c #414041", 100"! c #414041",
99"~ c #202020", 101"~ c #202020",
100"{ c #ACAEAC", 102"{ c #ACAEAC",
101"] c #838583", 103"] c #838583",
102"^ c #6A656A", 104"^ c #6A656A",
103" ", 105" ",
104" .... ", 106" .... ",
105" .+@+#. ", 107" .+@+#. ",
106" ..$%&%*. ", 108" ..$%&%*. ",
107" .=-.;=>=,. ", 109" .=-.;=>=,. ",
108" .'+).&+!+. ", 110" .'+).&+!+. ",
109" .+;+;.~+~. ", 111" .+;+;.~+~. ",
110" ..%{%,.... ", 112" ..%{%,.... ",
111" ..&=>=~.. ", 113" ..&=>=~.. ",
112" .+..]^,.. ", 114" .+..]^,.. ",
113" .+....... ", 115" .+....... ",
114" .%... ", 116" .%... ",
115" .=... ", 117" .=... ",
116" .+... ", 118" .+... ",
117" .+... ", 119" .+... ",
118" .... ", 120" .... ",
119" .... ", 121" .... ",
120" .. ", 122" .. ",
121" . ", 123" . ",
122". "}; 124". "};
123 125
124/* XPM */ 126/* XPM */
125static const char * alarm_xpm[] = { 127static const char * alarm_xpm[] = {
126"20 20 33 1", 128"20 20 33 1",
127" c None", 129" c None",
128". c #080602", 130". c #080602",
129"+ c #AAA602", 131"+ c #AAA602",
130"@ c #252002", 132"@ c #252002",
131"# c #434202", 133"# c #434202",
132"$ c #795602", 134"$ c #795602",
133"% c #C3C20D", 135"% c #C3C20D",
134"& c #DADAC2", 136"& c #DADAC2",
135"* c #826002", 137"* c #826002",
136"= c #740502", 138"= c #740502",
137"- c #D6D602", 139"- c #D6D602",
138"; c #322E02", 140"; c #322E02",
139"> c #826A02", 141"> c #826A02",
140", c #F1F195", 142", c #F1F195",
141"' c #959215", 143"' c #959215",
142") c #423602", 144") c #423602",
143"! c #4B0302", 145"! c #4B0302",
144"~ c #844315", 146"~ c #844315",
145"{ c #AAAA2A", 147"{ c #AAAA2A",
146"] c #E2DE42", 148"] c #E2DE42",
147"^ c #BA7E04", 149"^ c #BA7E04",
148"/ c #7F7502", 150"/ c #7F7502",
149"( c #828276", 151"( c #828276",
150"_ c #FEFE4E", 152"_ c #FEFE4E",
151": c #7D1902", 153": c #7D1902",
152"< c #989656", 154"< c #989656",
153"[ c #260B02", 155"[ c #260B02",
154"} c #F7F7D8", 156"} c #F7F7D8",
155"| c #DCDA5A", 157"| c #DCDA5A",
156"1 c #823102", 158"1 c #823102",
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 );
224 volSlider-> setTickmarks ( QSlider::Both ); 228 volSlider-> setTickmarks ( QSlider::Both );
225 volSlider-> setTickInterval ( 20 ); 229 volSlider-> setTickInterval ( 20 );
226 volSlider-> setFocusPolicy ( QWidget::NoFocus ); 230 volSlider-> setFocusPolicy ( QWidget::NoFocus );
227 231
228 l = new QLabel ( this ); 232 l = new QLabel ( this );
229 l-> setPixmap ( QPixmap ( vol_xpm )); 233 l-> setPixmap ( QPixmap ( vol_xpm ));
230 234
231 grid-> addWidget ( l, 0, 1, AlignCenter ); 235 grid-> addWidget ( l, 0, 1, AlignCenter );
232 grid-> addWidget ( volSlider, 1, 1, AlignCenter ); 236 grid-> addWidget ( volSlider, 1, 1, AlignCenter );
233 237
234 volLed = new OLedBox ( green, this ); 238 volLed = new OLedBox ( green, this );
235 volLed-> setFocusPolicy ( QWidget::NoFocus ); 239 volLed-> setFocusPolicy ( QWidget::NoFocus );
236 volLed-> setFixedSize ( 16, 16 ); 240 volLed-> setFixedSize ( 16, 16 );
237 241
238 grid-> addWidget ( volLed, 2, 1, AlignCenter ); 242 grid-> addWidget ( volLed, 2, 1, AlignCenter );
239 243
240 micSlider = new QSlider ( this ); 244 micSlider = new QSlider ( this );
241 micSlider-> setRange ( 0, 100 ); 245 micSlider-> setRange ( 0, 100 );
242 micSlider-> setTickmarks ( QSlider::Both ); 246 micSlider-> setTickmarks ( QSlider::Both );
243 micSlider-> setTickInterval ( 20 ); 247 micSlider-> setTickInterval ( 20 );
244 micSlider-> setFocusPolicy ( QWidget::NoFocus ); 248 micSlider-> setFocusPolicy ( QWidget::NoFocus );
245 249
246 l = new QLabel ( this ); 250 l = new QLabel ( this );
247 l-> setPixmap ( QPixmap ( mic_xpm )); 251 l-> setPixmap ( QPixmap ( mic_xpm ));
248 252
249 grid-> addWidget ( l, 0, 2, AlignCenter ); 253 grid-> addWidget ( l, 0, 2, AlignCenter );
250 grid-> addWidget ( micSlider, 1, 2, AlignCenter ); 254 grid-> addWidget ( micSlider, 1, 2, AlignCenter );
251 255
252 micLed = new OLedBox ( red, this ); 256 micLed = new OLedBox ( red, this );
253 micLed-> setFocusPolicy ( QWidget::NoFocus ); 257 micLed-> setFocusPolicy ( QWidget::NoFocus );
254 micLed-> setFixedSize ( 16, 16 ); 258 micLed-> setFixedSize ( 16, 16 );
255 259
256 grid-> addWidget ( micLed, 2, 2, AlignCenter ); 260 grid-> addWidget ( micLed, 2, 2, AlignCenter );
257 261
258 alarmSlider = new QSlider ( this ); 262 alarmSlider = new QSlider ( this );
259 alarmSlider-> setRange ( 0, 100 ); 263 alarmSlider-> setRange ( 0, 100 );
260 alarmSlider-> setTickmarks ( QSlider::Both ); 264 alarmSlider-> setTickmarks ( QSlider::Both );
261 alarmSlider-> setTickInterval ( 20 ); 265 alarmSlider-> setTickInterval ( 20 );
262 alarmSlider-> setFocusPolicy ( QWidget::NoFocus ); 266 alarmSlider-> setFocusPolicy ( QWidget::NoFocus );
263 267
264 QLabel *alarmLabel = new QLabel ( this ); 268 QLabel *alarmLabel = new QLabel ( this );
265 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm )); 269 alarmLabel-> setPixmap ( QPixmap ( alarm_xpm ));
266 270
267 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter ); 271 grid-> addWidget ( alarmLabel, 0, 3, AlignCenter );
268 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter ); 272 grid-> addWidget ( alarmSlider, 1, 3, AlignCenter );
269 273
270 alarmLed = new OLedBox ( yellow, this ); 274 alarmLed = new OLedBox ( yellow, this );
271 alarmLed-> setFocusPolicy ( QWidget::NoFocus ); 275 alarmLed-> setFocusPolicy ( QWidget::NoFocus );
272 alarmLed-> setFixedSize ( 16, 16 ); 276 alarmLed-> setFixedSize ( 16, 16 );
273 277
274 grid-> addWidget ( alarmLed, 2, 3, AlignCenter ); 278 grid-> addWidget ( alarmLed, 2, 3, AlignCenter );
275 279
276 if ( !has_wav_alarm ) { 280 if ( !has_wav_alarm ) {
277 alarmSlider-> hide ( ); 281 alarmSlider-> hide ( );
278 alarmLabel-> hide ( ); 282 alarmLabel-> hide ( );
279 alarmLed-> hide ( ); 283 alarmLed-> hide ( );
280 } 284 }
281 285
282 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft ); 286 grid-> addWidget ( new QLabel ( tr( "Enable Sounds for:" ), this ), 0, 4, AlignVCenter | AlignLeft );
283 287
284 vbox = new QVBoxLayout ( ); 288 vbox = new QVBoxLayout ( );
285 vbox-> setSpacing ( 4 ); 289 vbox-> setSpacing ( 4 );
286 grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 ); 290 grid-> addMultiCellLayout ( vbox, 1, 2, 4, 4 );
287 291
288 tapBox = new QCheckBox ( tr( "Screen Taps" ), this ); 292 tapBox = new QCheckBox ( tr( "Screen Taps" ), this );
289 tapBox-> setFocusPolicy ( QWidget::NoFocus ); 293 tapBox-> setFocusPolicy ( QWidget::NoFocus );
290 294
291 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft ); 295 vbox-> addWidget ( tapBox, AlignVCenter | AlignLeft );
292 296
293 keyBox = new QCheckBox ( tr( "Key Clicks" ), this ); 297 keyBox = new QCheckBox ( tr( "Key Clicks" ), this );
294 keyBox-> setFocusPolicy ( QWidget::NoFocus ); 298 keyBox-> setFocusPolicy ( QWidget::NoFocus );
295 299
296 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft ); 300 vbox-> addWidget ( keyBox, AlignVCenter | AlignLeft );
297 301
298 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this ); 302 alarmBox = new QCheckBox ( tr( "Alarm Sound" ), this );
299 alarmBox-> setFocusPolicy ( QWidget::NoFocus ); 303 alarmBox-> setFocusPolicy ( QWidget::NoFocus );
300 304
301 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft ); 305 vbox-> addWidget ( alarmBox, AlignVCenter | AlignLeft );
302 306
303 if ( has_wav_alarm ) { 307 if ( has_wav_alarm ) {
304 alarmBox-> hide ( ); 308 alarmBox-> hide ( );
305 } 309 }
306 310
307 vbox-> addStretch ( 100 ); 311 vbox-> addStretch ( 100 );
308 312
309 setFixedSize ( sizeHint ( )); 313 setFixedSize ( sizeHint ( ));
310 setFocusPolicy ( QWidget::NoFocus ); 314 setFocusPolicy ( QWidget::NoFocus );
311 315
312 rateTimer = new QTimer( this ); 316 rateTimer = new QTimer( this );
313 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( ))); 317 connect ( rateTimer, SIGNAL( timeout ( )), this, SLOT( rateTimerDone ( )));
314 318
315 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 319 connect ( upButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
316 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 320 connect ( upButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
317 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( ))); 321 connect ( downButton, SIGNAL( pressed ( )), this, SLOT( buttonChanged ( )));
318 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( ))); 322 connect ( downButton, SIGNAL( released ( )), this, SLOT( buttonChanged ( )));
319 323
320 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int ))); 324 connect ( micSlider, SIGNAL( valueChanged ( int )), this, SLOT( micMoved( int )));
321 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int ))); 325 connect ( volSlider, SIGNAL( valueChanged ( int )), this, SLOT( volMoved( int )));
322 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int ))); 326 connect ( alarmSlider, SIGNAL( valueChanged ( int )), this, SLOT( alarmMoved( int )));
323 327
324 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool ))); 328 connect ( volLed, SIGNAL( toggled ( bool )), this, SLOT( volMuteToggled ( bool )));
325 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool ))); 329 connect ( micLed, SIGNAL( toggled ( bool )), this, SLOT( micMuteToggled ( bool )));
326 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 330 connect ( alarmLed, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
327 331
328 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool ))); 332 connect ( alarmBox, SIGNAL( toggled ( bool )), this, SLOT( alarmSoundToggled ( bool )));
329 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool ))); 333 connect ( keyBox, SIGNAL( toggled ( bool )), this, SLOT( keyClickToggled ( bool )));
330 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool ))); 334 connect ( tapBox, SIGNAL( toggled ( bool )), this, SLOT( screenTapToggled ( bool )));
331 335
332 // initialize variables 336 // initialize variables
333 337
334 readConfig ( true ); 338 readConfig ( true );
335 339
336 // initialize the config file, in case some entries are missing 340 // initialize the config file, in case some entries are missing
337 341
338 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None ); 342 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_None );
339 writeConfigEntry ( "Mute", m_vol_muted, UPD_None ); 343 writeConfigEntry ( "Mute", m_vol_muted, UPD_None );
340 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 344 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
341 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None ); 345 writeConfigEntry ( "TouchSound", m_snd_touch, UPD_None );
342 writeConfigEntry ( "KeySound", m_snd_key, UPD_None ); 346 writeConfigEntry ( "KeySound", m_snd_key, UPD_None );
343 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 347 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
344 348
345 writeConfigEntry ( "Mic", m_mic_percent, UPD_None ); 349 writeConfigEntry ( "Mic", m_mic_percent, UPD_None );
346 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 350 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
347} 351}
348 352
349bool VolumeControl::volMuted ( ) const 353bool VolumeControl::volMuted ( ) const
350{ 354{
351 return m_vol_muted; 355 return m_vol_muted;
352} 356}
353 357
354int VolumeControl::volPercent ( ) const 358int VolumeControl::volPercent ( ) const
355{ 359{
356 return m_vol_percent; 360 return m_vol_percent;
357} 361}
358 362
359void VolumeControl::keyPressEvent ( QKeyEvent *e ) 363void VolumeControl::keyPressEvent ( QKeyEvent *e )
360{ 364{
361 switch ( e-> key ( )) { 365 switch ( e-> key ( )) {
362 case Key_Up: 366 case Key_Up:
363 volSlider-> subtractStep ( ); 367 volSlider-> subtractStep ( );
364 break; 368 break;
365 case Key_Down: 369 case Key_Down:
366 volSlider-> addStep ( ); 370 volSlider-> addStep ( );
367 break; 371 break;
368 case Key_Space: 372 case Key_Space:
369 volLed-> toggle ( ); 373 volLed-> toggle ( );
370 break; 374 break;
371 case Key_Escape: 375 case Key_Escape:
372 hide ( ); 376 hide ( );
373 break; 377 break;
374 } 378 }
375} 379}
376 380
377void VolumeControl::buttonChanged ( ) 381void VolumeControl::buttonChanged ( )
378{ 382{
379 if ( upButton-> isDown ( ) || downButton->isDown ( )) { 383 if ( upButton-> isDown ( ) || downButton->isDown ( )) {
380 rateTimerDone ( ); // Call it one time manually, otherwise it wont get 384 rateTimerDone ( ); // Call it one time manually, otherwise it wont get
381 // called at all when a button is pressed for a time 385 // called at all when a button is pressed for a time
382 // shorter than RATE_TIMER_INTERVAL. 386 // shorter than RATE_TIMER_INTERVAL.
383 rateTimer-> start ( RATE_TIMER_INTERVAL, false ); 387 rateTimer-> start ( RATE_TIMER_INTERVAL, false );
384 } 388 }
385 else 389 else
386 rateTimer-> stop ( ); 390 rateTimer-> stop ( );
387} 391}
388 392
389void VolumeControl::rateTimerDone ( ) 393void VolumeControl::rateTimerDone ( )
390{ 394{
391 if ( upButton-> isDown ( )) 395 if ( upButton-> isDown ( ))
392 volSlider-> setValue ( volSlider-> value ( ) - 2 ); 396 volSlider-> setValue ( volSlider-> value ( ) - 2 );
393 else // if ( downButton-> isDown ( )) 397 else // if ( downButton-> isDown ( ))
394 volSlider-> setValue ( volSlider-> value ( ) + 2 ); 398 volSlider-> setValue ( volSlider-> value ( ) + 2 );
395} 399}
396 400
397void VolumeControl::show ( bool /*showMic*/ ) 401void VolumeControl::show ( bool /*showMic*/ )
398{ 402{
399 readConfig ( ); 403 readConfig ( );
400 404
401 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 )); 405 QPoint curPos = m_icon-> mapToGlobal ( QPoint ( 0, 0 ));
402 406
403 int w = sizeHint ( ). width ( ); 407 int w = sizeHint ( ). width ( );
404 int x = curPos.x ( ) - ( w / 2 ); 408 int x = curPos.x ( ) - ( w / 2 );
405 409
406 if (( x + w ) > QPEApplication::desktop ( )-> width ( )) 410 if (( x + w ) > QPEApplication::desktop ( )-> width ( ))
407 x = QPEApplication::desktop ( )-> width ( ) - w; 411 x = QPEApplication::desktop ( )-> width ( ) - w;
408 412
409 move ( x, curPos. y ( ) - sizeHint ( ). height ( )); 413 move ( x, curPos. y ( ) - sizeHint ( ). height ( ));
410 QFrame::show ( ); 414 QFrame::show ( );
411 415
412} 416}
413 417
414void VolumeControl::readConfig ( bool force ) 418void VolumeControl::readConfig ( bool force )
415{ 419{
416 Config cfg ( "qpe" ); 420 Config cfg ( "qpe" );
417 cfg. setGroup ( "Volume" ); 421 cfg. setGroup ( "Volume" );
418 422
419 int old_vp = m_vol_percent; 423 int old_vp = m_vol_percent;
420 int old_mp = m_mic_percent; 424 int old_mp = m_mic_percent;
421 bool old_vm = m_vol_muted; 425 bool old_vm = m_vol_muted;
422 bool old_mm = m_mic_muted; 426 bool old_mm = m_mic_muted;
423 bool old_sk = m_snd_key; 427 bool old_sk = m_snd_key;
424 bool old_st = m_snd_touch; 428 bool old_st = m_snd_touch;
425 bool old_sa = m_snd_alarm; 429 bool old_sa = m_snd_alarm;
426 int old_ap = m_alarm_percent; 430 int old_ap = m_alarm_percent;
427 431
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
493void VolumeControl::alarmSoundToggled ( bool b ) 497void VolumeControl::alarmSoundToggled ( bool b )
494{ 498{
495 m_snd_alarm = b; 499 m_snd_alarm = b;
496 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol ); 500 writeConfigEntry ( "AlarmSound", m_snd_alarm, UPD_Vol );
497} 501}
498 502
499void VolumeControl::volMuteToggled ( bool b ) 503void VolumeControl::volMuteToggled ( bool b )
500{ 504{
501 m_vol_muted = !b; 505 m_vol_muted = !b;
502 506
503 m_icon-> redraw ( true ); 507 m_icon-> redraw ( true );
504 508
505 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol ); 509 writeConfigEntry ( "Mute", m_vol_muted, UPD_Vol );
506} 510}
507 511
508void VolumeControl::micMuteToggled ( bool b ) 512void VolumeControl::micMuteToggled ( bool b )
509{ 513{
510 m_mic_muted = !b; 514 m_mic_muted = !b;
511 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic ); 515 writeConfigEntry ( "MicMute", m_mic_muted, UPD_Mic );
512} 516}
513 517
514 518
515void VolumeControl::volMoved ( int percent ) 519void VolumeControl::volMoved ( int percent )
516{ 520{
517 m_vol_percent = 100 - percent; 521 m_vol_percent = 100 - percent;
518 522
519 // clamp volume percent to be between 0 and 100 523 // clamp volume percent to be between 0 and 100
520 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent ); 524 m_vol_percent = ( m_vol_percent < 0 ) ? 0 : (( m_vol_percent > 100 ) ? 100 : m_vol_percent );
521 // repaint just the little volume rectangle 525 // repaint just the little volume rectangle
522 m_icon-> redraw ( false ); 526 m_icon-> redraw ( false );
523 527
524 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol ); 528 writeConfigEntry ( "VolumePercent", m_vol_percent, UPD_Vol );
525} 529}
526 530
527void VolumeControl::micMoved ( int percent ) 531void VolumeControl::micMoved ( int percent )
528{ 532{
529 m_mic_percent = 100 - percent; 533 m_mic_percent = 100 - percent;
530 534
531 // clamp volume percent to be between 0 and 100 535 // clamp volume percent to be between 0 and 100
532 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent ); 536 m_mic_percent = ( m_mic_percent < 0 ) ? 0 : (( m_mic_percent > 100 ) ? 100 : m_mic_percent );
533 537
534 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic ); 538 writeConfigEntry ( "Mic", m_mic_percent, UPD_Mic );
535} 539}
536 540
537void VolumeControl::alarmMoved ( int percent ) 541void VolumeControl::alarmMoved ( int percent )
538{ 542{
539 m_alarm_percent = 100 - percent; 543 m_alarm_percent = 100 - percent;
540 544
541 // clamp volume percent to be between 0 and 100 545 // clamp volume percent to be between 0 and 100
542 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent ); 546 m_alarm_percent = ( m_alarm_percent < 0 ) ? 0 : (( m_alarm_percent > 100 ) ? 100 : m_alarm_percent );
543 547
544 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None ); 548 writeConfigEntry ( "AlarmPercent", m_alarm_percent, UPD_None );
545} 549}
546 550
547 551
548void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd ) 552void VolumeControl::writeConfigEntry ( const char *entry, int val, eUpdate upd )
549{ 553{
550 Config cfg ( "qpe" ); 554 Config cfg ( "qpe" );
551 cfg. setGroup ( "Volume" ); 555 cfg. setGroup ( "Volume" );
552 cfg. writeEntry ( entry, val ); 556 cfg. writeEntry ( entry, val );
553// cfg. write ( ); 557// cfg. write ( );
554 558
555#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 559#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
556 switch ( upd ) { 560 switch ( upd ) {
557 case UPD_Vol: { 561 case UPD_Vol: {
558 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted; 562 QCopEnvelope ( "QPE/System", "volumeChange(bool)" ) << m_vol_muted;
559 break; 563 break;
560 } 564 }
561 case UPD_Mic: { 565 case UPD_Mic: {
562 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted; 566 QCopEnvelope ( "QPE/System", "micChange(bool)" ) << m_mic_muted;
563 break; 567 break;
564 } 568 }
565 case UPD_None: 569 case UPD_None:
566 break; 570 break;
567 } 571 }
568#endif 572#endif
569} 573}
570 574
571//=========================================================================== 575//===========================================================================
572 576
573VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 577VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
574 : QWidget( parent, name ) 578 : QWidget( parent, name )
575{ 579{
576 setFixedHeight ( 18 ); 580 setFixedHeight ( 18 );
577 setFixedWidth ( 14 ); 581 setFixedWidth ( 14 );
578 582
579 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" )); 583 m_pixmap = new QPixmap ( Resource::loadPixmap ( "volume" ));
580 m_dialog = new VolumeControl ( this ); 584 m_dialog = new VolumeControl ( this );
581 585
582 connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool ))); 586 connect ( qApp, SIGNAL( volumeChanged ( bool )), m_dialog, SLOT( volumeChanged( bool )));
583 connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool ))); 587 connect ( qApp, SIGNAL( micChanged ( bool )), m_dialog, SLOT ( micChanged( bool )));
584} 588}
585 589
586VolumeApplet::~VolumeApplet() 590VolumeApplet::~VolumeApplet()
587{ 591{
588 delete m_pixmap; 592 delete m_pixmap;
589} 593}
590 594
591 595
592void VolumeApplet::mousePressEvent ( QMouseEvent * ) 596void VolumeApplet::mousePressEvent ( QMouseEvent * )
593{ 597{
594 if ( m_dialog-> isVisible ( )) 598 if ( m_dialog-> isVisible ( ))
595 m_dialog-> hide ( ); 599 m_dialog-> hide ( );
596 else 600 else
597 m_dialog-> show ( true ); 601 m_dialog-> show ( true );
598} 602}
599 603
600void VolumeApplet::redraw ( bool all ) 604void VolumeApplet::redraw ( bool all )
601{ 605{
602 if ( all ) 606 if ( all )
603 repaint ( true ); 607 repaint ( true );
604 else 608 else
605 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false ); 609 repaint ( 2, height ( ) - 3, width ( ) - 4, 2, false );
606} 610}
607 611
608 612
609void VolumeApplet::paintEvent ( QPaintEvent * ) 613void VolumeApplet::paintEvent ( QPaintEvent * )
610{ 614{
611 QPainter p ( this ); 615 QPainter p ( this );
612 616
613 p. drawPixmap ( 0, 1, *m_pixmap ); 617 p. drawPixmap ( 0, 1, *m_pixmap );
614 p. setPen ( darkGray ); 618 p. setPen ( darkGray );
615 p. drawRect ( 1, height() - 4, width() - 2, 4 ); 619 p. drawRect ( 1, height() - 4, width() - 2, 4 );
616 620
617 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100; 621 int pixelsWide = m_dialog-> volPercent ( ) * ( width() - 4 ) / 100;
618 p. fillRect ( 2, height() - 3, pixelsWide, 2, red ); 622 p. fillRect ( 2, height() - 3, pixelsWide, 2, red );
619 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); 623 p. fillRect ( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
620 624
621 if ( m_dialog-> volMuted ( )) { 625 if ( m_dialog-> volMuted ( )) {
622 p. setPen ( red ); 626 p. setPen ( red );
623 p. drawLine ( 1, 2, width() - 2, height() - 5 ); 627 p. drawLine ( 1, 2, width() - 2, height() - 5 );
624 p. drawLine ( 1, 3, width() - 2, height() - 4 ); 628 p. drawLine ( 1, 3, width() - 2, height() - 4 );
625 p. drawLine ( width() - 2, 2, 1, height() - 5 ); 629 p. drawLine ( width() - 2, 2, 1, height() - 5 );
626 p. drawLine ( width() - 2, 3, 1, height() - 4 ); 630 p. drawLine ( width() - 2, 3, 1, height() - 4 );
627 } 631 }
628} 632}
629 633
630 634