summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-06-17 11:04:40 (UTC)
committer llornkcor <llornkcor>2002-06-17 11:04:40 (UTC)
commit2917d7481dc8c1b053e3212a699e64948a90ec4c (patch) (unidiff)
tree159735f0ccf4371f254f9805f93bcb428d017c01
parentb646eee10051aa1065f60113066eb0028d17efc4 (diff)
downloadopie-2917d7481dc8c1b053e3212a699e64948a90ec4c.zip
opie-2917d7481dc8c1b053e3212a699e64948a90ec4c.tar.gz
opie-2917d7481dc8c1b053e3212a699e64948a90ec4c.tar.bz2
remove mute on popup left from experimenting
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 19e71c5..d871a35 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -1,452 +1,451 @@
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 21
22#include "volume.h" 22#include "volume.h"
23 23
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 27#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
28#include <qpe/qcopenvelope_qws.h> 28#include <qpe/qcopenvelope_qws.h>
29#endif 29#endif
30 30
31#include <qpainter.h> 31#include <qpainter.h>
32#include <qcheckbox.h> 32#include <qcheckbox.h>
33#include <qslider.h> 33#include <qslider.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qframe.h> 35#include <qframe.h>
36#include <qpixmap.h> 36#include <qpixmap.h>
37#include <qlabel.h> 37#include <qlabel.h>
38 38
39#include <qpushbutton.h> 39#include <qpushbutton.h>
40#include <qtimer.h> 40#include <qtimer.h>
41 41
42#define RATE_TIMER_INTERVAL 100 42#define RATE_TIMER_INTERVAL 100
43// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time 43// Ten times per second is fine (RATE_TIMER_INTERVAL 100). A shorter time
44// results in "hanging" buttons on the iPAQ due to quite high CPU consumption. 44// results in "hanging" buttons on the iPAQ due to quite high CPU consumption.
45 45
46VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name ) 46VolumeControl::VolumeControl( bool showMic, QWidget *parent, const char *name )
47 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) 47 : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
48{ 48{
49 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute
50 setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); 49 setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
51 createView(showMic); 50 createView(showMic);
52} 51}
53 52
54void VolumeControl::createView(bool showMic) 53void VolumeControl::createView(bool showMic)
55{ 54{
56 Config cfg("qpe"); 55 Config cfg("qpe");
57 cfg.setGroup("Volume"); 56 cfg.setGroup("Volume");
58//showMic = TRUE; 57//showMic = TRUE;
59 QHBoxLayout *hboxLayout = new QHBoxLayout(this); 58 QHBoxLayout *hboxLayout = new QHBoxLayout(this);
60 hboxLayout->setMargin( 3 ); 59 hboxLayout->setMargin( 3 );
61 hboxLayout->setSpacing( 0); 60 hboxLayout->setSpacing( 0);
62 61
63 QVBoxLayout *vboxButtons = new QVBoxLayout(this); 62 QVBoxLayout *vboxButtons = new QVBoxLayout(this);
64 upButton = new QPushButton( this ); 63 upButton = new QPushButton( this );
65 upButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 64 upButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
66 upButton->setPixmap( Resource::loadPixmap( "up" ) ); 65 upButton->setPixmap( Resource::loadPixmap( "up" ) );
67 downButton = new QPushButton( this ); 66 downButton = new QPushButton( this );
68 downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 67 downButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
69 downButton->setPixmap( Resource::loadPixmap( "down" ) ); 68 downButton->setPixmap( Resource::loadPixmap( "down" ) );
70 vboxButtons->setSpacing( 2 ); 69 vboxButtons->setSpacing( 2 );
71 70
72 upButton->setFixedHeight(26); 71 upButton->setFixedHeight(26);
73 downButton->setFixedHeight(26); 72 downButton->setFixedHeight(26);
74 73
75 vboxButtons->addWidget( upButton ); 74 vboxButtons->addWidget( upButton );
76 vboxButtons->addWidget( downButton ); 75 vboxButtons->addWidget( downButton );
77 76
78 QVBoxLayout *vbox = new QVBoxLayout( this ); 77 QVBoxLayout *vbox = new QVBoxLayout( this );
79 QHBoxLayout *hbox = NULL; 78 QHBoxLayout *hbox = NULL;
80 79
81 slider = new QSlider( this ); 80 slider = new QSlider( this );
82 slider->setRange( 0, 100 ); 81 slider->setRange( 0, 100 );
83 slider->setTickmarks( QSlider::Both ); 82 slider->setTickmarks( QSlider::Both );
84 slider->setTickInterval( 20 ); 83 slider->setTickInterval( 20 );
85 slider->setFocusPolicy( QWidget::NoFocus ); 84 slider->setFocusPolicy( QWidget::NoFocus );
86 slider->setValue(cfg.readNumEntry("VolumePercent")); 85 slider->setValue(cfg.readNumEntry("VolumePercent"));
87 86
88 QVBoxLayout *sbox = new QVBoxLayout(this); 87 QVBoxLayout *sbox = new QVBoxLayout(this);
89 sbox->setMargin( 3 ); 88 sbox->setMargin( 3 );
90 sbox->setSpacing( 3 ); 89 sbox->setSpacing( 3 );
91 sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); 90 sbox->addWidget( new QLabel("Vol", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter );
92 sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter ); 91 sbox->addWidget( slider, 0, Qt::AlignVCenter | Qt::AlignHCenter );
93 92
94// if (showMic == TRUE) { 93// if (showMic == TRUE) {
95 mic = new QSlider(this); 94 mic = new QSlider(this);
96 mic->setRange( 0, 100 ); 95 mic->setRange( 0, 100 );
97 mic->setTickmarks( QSlider::Both ); 96 mic->setTickmarks( QSlider::Both );
98 mic->setTickInterval( 20 ); 97 mic->setTickInterval( 20 );
99 mic->setFocusPolicy( QWidget::NoFocus ); 98 mic->setFocusPolicy( QWidget::NoFocus );
100 mic->setValue(cfg.readNumEntry("Mic")); 99 mic->setValue(cfg.readNumEntry("Mic"));
101 100
102 QVBoxLayout *mbox = new QVBoxLayout(this); 101 QVBoxLayout *mbox = new QVBoxLayout(this);
103 mbox->setMargin( 3 ); 102 mbox->setMargin( 3 );
104 mbox->setSpacing( 3 ); 103 mbox->setSpacing( 3 );
105 mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter ); 104 mbox->addWidget( new QLabel("Mic", this) , 0, Qt::AlignVCenter | Qt::AlignHCenter );
106 mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter ); 105 mbox->addWidget( mic, 0, Qt::AlignVCenter | Qt::AlignHCenter );
107 106
108 hbox = new QHBoxLayout( this ); 107 hbox = new QHBoxLayout( this );
109 hbox->setMargin( 3 ); 108 hbox->setMargin( 3 );
110 hbox->setSpacing( 3 ); 109 hbox->setSpacing( 3 );
111 hbox->addLayout( sbox, 1); 110 hbox->addLayout( sbox, 1);
112 hbox->addLayout( mbox, 1); 111 hbox->addLayout( mbox, 1);
113 // } 112 // }
114 113
115 muteBox = new QCheckBox( tr("Mute"), this ); 114 muteBox = new QCheckBox( tr("Mute"), this );
116 muteBox->setFocusPolicy( QWidget::NoFocus ); 115 muteBox->setFocusPolicy( QWidget::NoFocus );
117 116
118 QVBoxLayout *klbox = new QVBoxLayout(this); 117 QVBoxLayout *klbox = new QVBoxLayout(this);
119 118
120 QLabel *Label1; 119 QLabel *Label1;
121 Label1 = new QLabel( this, "Label1" ); 120 Label1 = new QLabel( this, "Label1" );
122 Label1->setText( tr( "Enable Sounds for:" )); 121 Label1->setText( tr( "Enable Sounds for:" ));
123 122
124 alarmSound = new QCheckBox( tr("Alarm Sound"), this ); 123 alarmSound = new QCheckBox( tr("Alarm Sound"), this );
125 alarmSound->setFocusPolicy( QWidget::NoFocus ); 124 alarmSound->setFocusPolicy( QWidget::NoFocus );
126 125
127 keyclicks = new QCheckBox( tr("Key Clicks"), this ); 126 keyclicks = new QCheckBox( tr("Key Clicks"), this );
128 keyclicks->setFocusPolicy( QWidget::NoFocus ); 127 keyclicks->setFocusPolicy( QWidget::NoFocus );
129 128
130 screentaps = new QCheckBox( tr("Screen taps"), this ); 129 screentaps = new QCheckBox( tr("Screen taps"), this );
131 screentaps->setFocusPolicy( QWidget::NoFocus ); 130 screentaps->setFocusPolicy( QWidget::NoFocus );
132 131
133 132
134 keyclicks->setChecked( cfg.readBoolEntry("KeySound",0)); 133 keyclicks->setChecked( cfg.readBoolEntry("KeySound",0));
135 screentaps->setChecked( cfg.readBoolEntry("TouchSound",0)); 134 screentaps->setChecked( cfg.readBoolEntry("TouchSound",0));
136 alarmSound->setChecked( cfg.readBoolEntry("AlarmSound",1)); 135 alarmSound->setChecked( cfg.readBoolEntry("AlarmSound",1));
137 136
138 klbox->setMargin( 3 ); 137 klbox->setMargin( 3 );
139 klbox->setSpacing( 0 ); 138 klbox->setSpacing( 0 );
140 klbox->addWidget( Label1, 1); 139 klbox->addWidget( Label1, 1);
141 klbox->addWidget( alarmSound, 1); 140 klbox->addWidget( alarmSound, 1);
142 klbox->addWidget( keyclicks, 1); 141 klbox->addWidget( keyclicks, 1);
143 klbox->addWidget( screentaps, 1); 142 klbox->addWidget( screentaps, 1);
144 vbox->setMargin( 3 ); 143 vbox->setMargin( 3 );
145 vbox->setSpacing( 0 ); 144 vbox->setSpacing( 0 );
146// if (showMic == TRUE) 145// if (showMic == TRUE)
147 vbox->addLayout( hbox, 1 ); 146 vbox->addLayout( hbox, 1 );
148// else 147// else
149// vbox->addLayout( sbox, 1); 148// vbox->addLayout( sbox, 1);
150 vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter ); 149 vbox->addWidget( muteBox, 0, Qt::AlignVCenter | Qt::AlignHCenter );
151 150
152 hboxLayout->addLayout( vboxButtons ); 151 hboxLayout->addLayout( vboxButtons );
153 hboxLayout->addLayout( vbox); 152 hboxLayout->addLayout( vbox);
154 hboxLayout->addLayout( klbox); 153 hboxLayout->addLayout( klbox);
155 154
156 155
157 setFixedHeight( 120); 156 setFixedHeight( 120);
158// setFixedWidth( sizeHint().width() ); 157// setFixedWidth( sizeHint().width() );
159 setFocusPolicy(QWidget::NoFocus); 158 setFocusPolicy(QWidget::NoFocus);
160 connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); 159 connect( upButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) );
161 connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); 160 connect( upButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) );
162 connect( downButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) ); 161 connect( downButton, SIGNAL( pressed() ), this, SLOT( ButtonChanged() ) );
163 connect( downButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) ); 162 connect( downButton, SIGNAL( released() ), this, SLOT( ButtonChanged() ) );
164 163
165 rateTimer = new QTimer(this); 164 rateTimer = new QTimer(this);
166 connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); 165 connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) );
167} 166}
168 167
169void VolumeControl::keyPressEvent( QKeyEvent *e) 168void VolumeControl::keyPressEvent( QKeyEvent *e)
170{ 169{
171 switch(e->key()) 170 switch(e->key())
172 { 171 {
173 case Key_Up: 172 case Key_Up:
174 slider->subtractStep(); 173 slider->subtractStep();
175 break; 174 break;
176 case Key_Down: 175 case Key_Down:
177 slider->addStep(); 176 slider->addStep();
178 break; 177 break;
179 case Key_Space: 178 case Key_Space:
180 muteBox->toggle(); 179 muteBox->toggle();
181 break; 180 break;
182 case Key_Escape: 181 case Key_Escape:
183 close(); 182 close();
184 break; 183 break;
185 } 184 }
186} 185}
187 186
188void VolumeControl::ButtonChanged() 187void VolumeControl::ButtonChanged()
189{ 188{
190 if ( upButton->isDown() || downButton->isDown() ) 189 if ( upButton->isDown() || downButton->isDown() )
191 { 190 {
192 rateTimerDone(); // Call it one time manually, otherwise it wont get 191 rateTimerDone(); // Call it one time manually, otherwise it wont get
193 // called at all when a button is pressed for a time 192 // called at all when a button is pressed for a time
194 // shorter than RATE_TIMER_INTERVAL. 193 // shorter than RATE_TIMER_INTERVAL.
195 rateTimer->start( RATE_TIMER_INTERVAL, false ); 194 rateTimer->start( RATE_TIMER_INTERVAL, false );
196 } 195 }
197 else 196 else
198 rateTimer->stop(); 197 rateTimer->stop();
199} 198}
200 199
201void VolumeControl::rateTimerDone() 200void VolumeControl::rateTimerDone()
202{ 201{
203 if ( upButton->isDown() ) 202 if ( upButton->isDown() )
204 slider->setValue( slider->value() - 2 ); 203 slider->setValue( slider->value() - 2 );
205 else // downButton->isDown() 204 else // downButton->isDown()
206 slider->setValue( slider->value() + 2 ); 205 slider->setValue( slider->value() + 2 );
207} 206}
208 207
209//=========================================================================== 208//===========================================================================
210 209
211VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 210VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
212 : QWidget( parent, name ) 211 : QWidget( parent, name )
213{ 212{
214 Config cfg("qpe"); 213 Config cfg("qpe");
215 cfg.setGroup("Volume"); 214 cfg.setGroup("Volume");
216 215
217 setFixedHeight( 18 ); 216 setFixedHeight( 18 );
218 setFixedWidth( 14 ); 217 setFixedWidth( 14 );
219 218
220 volumePixmap = Resource::loadPixmap( "volume" ); 219 volumePixmap = Resource::loadPixmap( "volume" );
221 220
222 volumePercent = cfg.readNumEntry("VolumePercent",50); 221 volumePercent = cfg.readNumEntry("VolumePercent",50);
223 micPercent = cfg.readNumEntry("Mic", 50); 222 micPercent = cfg.readNumEntry("Mic", 50);
224 muted = FALSE; // ### read from pref 223 muted = FALSE; // ### read from pref
225 micMuted = FALSE; // ### read from pref 224 micMuted = FALSE; // ### read from pref
226 225
227 advancedTimer = new QTimer(this); 226 advancedTimer = new QTimer(this);
228 227
229 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 228 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
230 connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); 229 connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) );
231 connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) ); 230 connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) );
232 231
233 writeSystemVolume(); 232 writeSystemVolume();
234 writeSystemMic(); 233 writeSystemMic();
235} 234}
236 235
237VolumeApplet::~VolumeApplet() 236VolumeApplet::~VolumeApplet()
238{ 237{
239} 238}
240 239
241void VolumeApplet::keyPressEvent ( QKeyEvent * e ) 240void VolumeApplet::keyPressEvent ( QKeyEvent * e )
242{ 241{
243 QString s; 242 QString s;
244 s.setNum(e->key()); 243 s.setNum(e->key());
245 qWarning(s); 244 qWarning(s);
246} 245}
247void VolumeApplet::mousePressEvent( QMouseEvent * ) 246void VolumeApplet::mousePressEvent( QMouseEvent * )
248{ 247{
249 advancedTimer->start( 750, TRUE ); 248 advancedTimer->start( 750, TRUE );
250} 249}
251 250
252void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) 251void VolumeApplet::mouseReleaseEvent( QMouseEvent * )
253{ 252{
254 showVolControl(FALSE); 253 showVolControl(FALSE);
255} 254}
256 255
257void VolumeApplet::advVolControl() 256void VolumeApplet::advVolControl()
258{ 257{
259 showVolControl(TRUE); 258 showVolControl(TRUE);
260} 259}
261 260
262void VolumeApplet::showVolControl(bool showMic) 261void VolumeApplet::showVolControl(bool showMic)
263{ 262{
264 Config cfg("qpe"); 263 Config cfg("qpe");
265 cfg.setGroup("Volume"); 264 cfg.setGroup("Volume");
266 volumePercent = cfg.readNumEntry("VolumePercent",50); 265 volumePercent = cfg.readNumEntry("VolumePercent",50);
267 micPercent = cfg.readNumEntry("Mic", 50); 266 micPercent = cfg.readNumEntry("Mic", 50);
268 267
269 // Create a small volume control window to adjust the volume with 268 // Create a small volume control window to adjust the volume with
270 VolumeControl *vc = new VolumeControl(showMic); 269 VolumeControl *vc = new VolumeControl(showMic);
271 vc->slider->setValue( 100 - volumePercent ); 270 vc->slider->setValue( 100 - volumePercent );
272// if (showMic) 271// if (showMic)
273// { 272// {
274 vc->mic->setValue( 100 - micPercent ); 273 vc->mic->setValue( 100 - micPercent );
275 connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); 274 connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) );
276// } 275// }
277 276
278 vc->muteBox->setChecked( muted ); 277 vc->muteBox->setChecked( muted );
279 connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); 278 connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) );
280 connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); 279 connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) );
281 280
282 Config config("qpe"); 281 Config config("qpe");
283 config.setGroup("Volume"); 282 config.setGroup("Volume");
284 283
285 vc->keyclicks->setChecked( config.readBoolEntry("KeySound",0)); 284 vc->keyclicks->setChecked( config.readBoolEntry("KeySound",0));
286 vc->screentaps->setChecked( config.readBoolEntry("TouchSound",0)); 285 vc->screentaps->setChecked( config.readBoolEntry("TouchSound",0));
287 vc->alarmSound->setChecked( config.readBoolEntry("AlarmSound",1)); 286 vc->alarmSound->setChecked( config.readBoolEntry("AlarmSound",1));
288 287
289 connect( vc->alarmSound, SIGNAL(toggled(bool)), this, SLOT( alarmSoundCheckToggled(bool))); 288 connect( vc->alarmSound, SIGNAL(toggled(bool)), this, SLOT( alarmSoundCheckToggled(bool)));
290 connect( vc->keyclicks, SIGNAL(toggled(bool)), this, SLOT( keyclicksCheckToggled(bool))); 289 connect( vc->keyclicks, SIGNAL(toggled(bool)), this, SLOT( keyclicksCheckToggled(bool)));
291 connect( vc->screentaps, SIGNAL(toggled(bool)), this, SLOT( screentapsCheckToggled(bool))); 290 connect( vc->screentaps, SIGNAL(toggled(bool)), this, SLOT( screentapsCheckToggled(bool)));
292 291
293 QPoint curPos = mapToGlobal( rect().topLeft() ); 292 QPoint curPos = mapToGlobal( rect().topLeft() );
294 vc->move( curPos.x()-(vc->sizeHint().width()/2+50), curPos.y() - 120 ); 293 vc->move( curPos.x()-(vc->sizeHint().width()/2+50), curPos.y() - 120 );
295 vc->show(); 294 vc->show();
296 295
297 advancedTimer->stop(); 296 advancedTimer->stop();
298} 297}
299 298
300void VolumeApplet::volumeChanged( bool nowMuted ) 299void VolumeApplet::volumeChanged( bool nowMuted )
301{ 300{
302 int previousVolume = volumePercent; 301 int previousVolume = volumePercent;
303 302
304 if ( !nowMuted ) 303 if ( !nowMuted )
305 readSystemVolume(); 304 readSystemVolume();
306 305
307 // Handle case where muting it toggled 306 // Handle case where muting it toggled
308 if ( muted != nowMuted ) { 307 if ( muted != nowMuted ) {
309 muted = nowMuted; 308 muted = nowMuted;
310 repaint( TRUE ); 309 repaint( TRUE );
311 return; 310 return;
312 } 311 }
313 312
314 // Avoid over repainting 313 // Avoid over repainting
315 if ( previousVolume != volumePercent ) 314 if ( previousVolume != volumePercent )
316 repaint( 2, height() - 3, width() - 4, 2, FALSE ); 315 repaint( 2, height() - 3, width() - 4, 2, FALSE );
317} 316}
318 317
319void VolumeApplet::micChanged( bool nowMuted ) 318void VolumeApplet::micChanged( bool nowMuted )
320{ 319{
321 if (!nowMuted) 320 if (!nowMuted)
322 readSystemMic(); 321 readSystemMic();
323 micMuted = nowMuted; 322 micMuted = nowMuted;
324} 323}
325 324
326void VolumeApplet::mute( bool toggled ) 325void VolumeApplet::mute( bool toggled )
327{ 326{
328 muted = toggled; 327 muted = toggled;
329 328
330 // clear if removing mute 329 // clear if removing mute
331 repaint( !toggled ); 330 repaint( !toggled );
332 writeSystemVolume(); 331 writeSystemVolume();
333 Config cfg("qpe"); 332 Config cfg("qpe");
334 cfg.setGroup("Volume"); 333 cfg.setGroup("Volume");
335 if(muted) 334 if(muted)
336 cfg.writeEntry("Mute", "TRUE"); 335 cfg.writeEntry("Mute", "TRUE");
337 else 336 else
338 cfg.writeEntry("Mute", "FALSE"); 337 cfg.writeEntry("Mute", "FALSE");
339 cfg.write(); 338 cfg.write();
340} 339}
341 340
342 341
343void VolumeApplet::sliderMoved( int percent ) 342void VolumeApplet::sliderMoved( int percent )
344{ 343{
345 setVolume( 100 - percent ); 344 setVolume( 100 - percent );
346} 345}
347 346
348void VolumeApplet::micMoved( int percent ) 347void VolumeApplet::micMoved( int percent )
349{ 348{
350 setMic( 100 - percent ); 349 setMic( 100 - percent );
351} 350}
352 351
353void VolumeApplet::readSystemVolume() 352void VolumeApplet::readSystemVolume()
354{ 353{
355 Config cfg("qpe"); 354 Config cfg("qpe");
356 cfg.setGroup("Volume"); 355 cfg.setGroup("Volume");
357 volumePercent = cfg.readNumEntry("VolumePercent"); 356 volumePercent = cfg.readNumEntry("VolumePercent");
358} 357}
359 358
360void VolumeApplet::readSystemMic() 359void VolumeApplet::readSystemMic()
361{ 360{
362 Config cfg("qpe"); 361 Config cfg("qpe");
363 cfg.setGroup("Volume"); 362 cfg.setGroup("Volume");
364 micPercent = cfg.readNumEntry("Mic"); 363 micPercent = cfg.readNumEntry("Mic");
365} 364}
366 365
367void VolumeApplet::setVolume( int percent ) 366void VolumeApplet::setVolume( int percent )
368{ 367{
369 // clamp volume percent to be between 0 and 100 368 // clamp volume percent to be between 0 and 100
370 volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); 369 volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent);
371 // repaint just the little volume rectangle 370 // repaint just the little volume rectangle
372 repaint( 2, height() - 3, width() - 4, 2, FALSE ); 371 repaint( 2, height() - 3, width() - 4, 2, FALSE );
373 writeSystemVolume(); 372 writeSystemVolume();
374} 373}
375 374
376void VolumeApplet::setMic( int percent ) 375void VolumeApplet::setMic( int percent )
377{ 376{
378 // clamp volume percent to be between 0 and 100 377 // clamp volume percent to be between 0 and 100
379 micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); 378 micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent);
380 writeSystemMic(); 379 writeSystemMic();
381} 380}
382 381
383void VolumeApplet::writeSystemVolume() 382void VolumeApplet::writeSystemVolume()
384{ 383{
385 { 384 {
386 Config cfg("qpe"); 385 Config cfg("qpe");
387 cfg.setGroup("Volume"); 386 cfg.setGroup("Volume");
388 cfg.writeEntry("VolumePercent",volumePercent); 387 cfg.writeEntry("VolumePercent",volumePercent);
389 } 388 }
390#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 389#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
391 // Send notification that the volume has changed 390 // Send notification that the volume has changed
392 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 391 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
393#endif 392#endif
394} 393}
395 394
396void VolumeApplet::writeSystemMic() 395void VolumeApplet::writeSystemMic()
397{ 396{
398 { 397 {
399 Config cfg("qpe"); 398 Config cfg("qpe");
400 cfg.setGroup("Volume"); 399 cfg.setGroup("Volume");
401 cfg.writeEntry("Mic",micPercent); 400 cfg.writeEntry("Mic",micPercent);
402 } 401 }
403#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 402#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
404 // Send notification that the volume has changed 403 // Send notification that the volume has changed
405 QCopEnvelope( "QPE/System", "micChange(bool)" ) << micMuted; 404 QCopEnvelope( "QPE/System", "micChange(bool)" ) << micMuted;
406#endif 405#endif
407} 406}
408 407
409void VolumeApplet::paintEvent( QPaintEvent* ) 408void VolumeApplet::paintEvent( QPaintEvent* )
410{ 409{
411 QPainter p(this); 410 QPainter p(this);
412 411
413 if (volumePixmap.isNull()) 412 if (volumePixmap.isNull())
414 volumePixmap = Resource::loadPixmap( "volume" ); 413 volumePixmap = Resource::loadPixmap( "volume" );
415 p.drawPixmap( 0, 1, volumePixmap ); 414 p.drawPixmap( 0, 1, volumePixmap );
416 p.setPen( darkGray ); 415 p.setPen( darkGray );
417 p.drawRect( 1, height() - 4, width() - 2, 4 ); 416 p.drawRect( 1, height() - 4, width() - 2, 4 );
418 417
419 int pixelsWide = volumePercent * (width() - 4) / 100; 418 int pixelsWide = volumePercent * (width() - 4) / 100;
420 p.fillRect( 2, height() - 3, pixelsWide, 2, red ); 419 p.fillRect( 2, height() - 3, pixelsWide, 2, red );
421 p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray ); 420 p.fillRect( pixelsWide + 2, height() - 3, width() - 4 - pixelsWide, 2, lightGray );
422 421
423 if ( muted ) { 422 if ( muted ) {
424 p.setPen( red ); 423 p.setPen( red );
425 p.drawLine( 1, 2, width() - 2, height() - 5 ); 424 p.drawLine( 1, 2, width() - 2, height() - 5 );
426 p.drawLine( 1, 3, width() - 2, height() - 4 ); 425 p.drawLine( 1, 3, width() - 2, height() - 4 );
427 p.drawLine( width() - 2, 2, 1, height() - 5 ); 426 p.drawLine( width() - 2, 2, 1, height() - 5 );
428 p.drawLine( width() - 2, 3, 1, height() - 4 ); 427 p.drawLine( width() - 2, 3, 1, height() - 4 );
429 } 428 }
430} 429}
431 430
432void VolumeApplet::screentapsCheckToggled(bool b) { 431void VolumeApplet::screentapsCheckToggled(bool b) {
433 Config cfg("qpe"); 432 Config cfg("qpe");
434 cfg.setGroup("Volume"); 433 cfg.setGroup("Volume");
435 cfg.writeEntry("TouchSound",b ); 434 cfg.writeEntry("TouchSound",b );
436 cfg.write(); 435 cfg.write();
437} 436}
438 437
439void VolumeApplet::keyclicksCheckToggled(bool b) { 438void VolumeApplet::keyclicksCheckToggled(bool b) {
440 Config cfg("qpe"); 439 Config cfg("qpe");
441 cfg.setGroup("Volume"); 440 cfg.setGroup("Volume");
442 cfg.writeEntry("KeySound",b); 441 cfg.writeEntry("KeySound",b);
443 cfg.write(); 442 cfg.write();
444} 443}
445 444
446void VolumeApplet::alarmSoundCheckToggled(bool b) { 445void VolumeApplet::alarmSoundCheckToggled(bool b) {
447 Config cfg("qpe"); 446 Config cfg("qpe");
448 cfg.setGroup("Volume"); 447 cfg.setGroup("Volume");
449 cfg.writeEntry("AlarmSound",b); 448 cfg.writeEntry("AlarmSound",b);
450 cfg.write(); 449 cfg.write();
451} 450}
452 451