summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/volume.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/applets/volumeapplet/volume.cpp b/core/applets/volumeapplet/volume.cpp
index 344f86f..e393f0f 100644
--- a/core/applets/volumeapplet/volume.cpp
+++ b/core/applets/volumeapplet/volume.cpp
@@ -140,193 +140,194 @@ void VolumeControl::keyPressEvent( QKeyEvent *e)
140 { 140 {
141 case Key_Up: 141 case Key_Up:
142 slider->subtractStep(); 142 slider->subtractStep();
143 break; 143 break;
144 case Key_Down: 144 case Key_Down:
145 slider->addStep(); 145 slider->addStep();
146 break; 146 break;
147 case Key_Space: 147 case Key_Space:
148 muteBox->toggle(); 148 muteBox->toggle();
149 break; 149 break;
150 case Key_Escape: 150 case Key_Escape:
151 close(); 151 close();
152 break; 152 break;
153 } 153 }
154} 154}
155 155
156void VolumeControl::ButtonChanged() 156void VolumeControl::ButtonChanged()
157{ 157{
158 if ( upButton->isDown() || downButton->isDown() ) 158 if ( upButton->isDown() || downButton->isDown() )
159 { 159 {
160 rateTimerDone(); // Call it one time manually, otherwise it wont get 160 rateTimerDone(); // Call it one time manually, otherwise it wont get
161 // called at all when a button is pressed for a time 161 // called at all when a button is pressed for a time
162 // shorter than RATE_TIMER_INTERVAL. 162 // shorter than RATE_TIMER_INTERVAL.
163 rateTimer->start( RATE_TIMER_INTERVAL, false ); 163 rateTimer->start( RATE_TIMER_INTERVAL, false );
164 } 164 }
165 else 165 else
166 rateTimer->stop(); 166 rateTimer->stop();
167} 167}
168 168
169void VolumeControl::rateTimerDone() 169void VolumeControl::rateTimerDone()
170{ 170{
171 if ( upButton->isDown() ) 171 if ( upButton->isDown() )
172 slider->setValue( slider->value() - 2 ); 172 slider->setValue( slider->value() - 2 );
173 else // downButton->isDown() 173 else // downButton->isDown()
174 slider->setValue( slider->value() + 2 ); 174 slider->setValue( slider->value() + 2 );
175} 175}
176 176
177//=========================================================================== 177//===========================================================================
178 178
179VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) 179VolumeApplet::VolumeApplet( QWidget *parent, const char *name )
180 : QWidget( parent, name ) 180 : QWidget( parent, name )
181{ 181{
182 Config cfg("Sound"); 182 Config cfg("Sound");
183 cfg.setGroup("System"); 183 cfg.setGroup("System");
184 184
185 setFixedHeight( 18 ); 185 setFixedHeight( 18 );
186 setFixedWidth( 14 ); 186 setFixedWidth( 14 );
187 187
188 volumePixmap = Resource::loadPixmap( "volume" ); 188 volumePixmap = Resource::loadPixmap( "volume" );
189 189
190 volumePercent = cfg.readNumEntry("Volume",50); 190 volumePercent = cfg.readNumEntry("Volume",50);
191 micPercent = cfg.readNumEntry("Mic", 50); 191 micPercent = cfg.readNumEntry("Mic", 50);
192 muted = FALSE; // ### read from pref 192 muted = FALSE; // ### read from pref
193 micMuted = FALSE; // ### read from pref 193 micMuted = FALSE; // ### read from pref
194 194
195 advancedTimer = new QTimer(this); 195 advancedTimer = new QTimer(this);
196 196
197 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 197 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
198 connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); 198 connect( qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) );
199 connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) ); 199 connect( advancedTimer, SIGNAL( timeout() ),this, SLOT( advVolControl()) );
200 200
201 writeSystemVolume(); 201 writeSystemVolume();
202 writeSystemMic(); 202 writeSystemMic();
203} 203}
204 204
205VolumeApplet::~VolumeApplet() 205VolumeApplet::~VolumeApplet()
206{ 206{
207} 207}
208 208
209void VolumeApplet::keyPressEvent ( QKeyEvent * e ) 209void VolumeApplet::keyPressEvent ( QKeyEvent * e )
210{ 210{
211 QString s; 211 QString s;
212 s.setNum(e->key()); 212 s.setNum(e->key());
213 qWarning(s); 213 qWarning(s);
214} 214}
215void VolumeApplet::mousePressEvent( QMouseEvent * ) 215void VolumeApplet::mousePressEvent( QMouseEvent * )
216{ 216{
217 advancedTimer->start( 750, TRUE ); 217 advancedTimer->start( 750, TRUE );
218} 218}
219 219
220void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) 220void VolumeApplet::mouseReleaseEvent( QMouseEvent * )
221{ 221{
222 showVolControl(FALSE); 222 showVolControl(FALSE);
223} 223}
224 224
225void VolumeApplet::advVolControl() 225void VolumeApplet::advVolControl()
226{ 226{
227 showVolControl(TRUE); 227 showVolControl(TRUE);
228} 228}
229 229
230void VolumeApplet::showVolControl(bool showMic) 230void VolumeApplet::showVolControl(bool showMic)
231{ 231{
232 Config cfg("Sound"); 232 Config cfg("Sound");
233 cfg.setGroup("System"); 233 cfg.setGroup("System");
234 volumePercent = cfg.readNumEntry("Volume",50); 234 volumePercent = cfg.readNumEntry("Volume",50);
235 micPercent = cfg.readNumEntry("Mic", 50); 235 micPercent = cfg.readNumEntry("Mic", 50);
236 236 QString show = cfg.readEntry("ShowMic", "FALSE");
237 if(show == "TRUE") showMic = TRUE;
237 // Create a small volume control window to adjust the volume with 238 // Create a small volume control window to adjust the volume with
238 VolumeControl *vc = new VolumeControl(showMic); 239 VolumeControl *vc = new VolumeControl(showMic);
239 vc->slider->setValue( 100 - volumePercent ); 240 vc->slider->setValue( 100 - volumePercent );
240 if (showMic) 241 if (showMic)
241 { 242 {
242 vc->mic->setValue( 100 - micPercent ); 243 vc->mic->setValue( 100 - micPercent );
243 connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) ); 244 connect( vc->mic, SIGNAL( valueChanged( int ) ), this, SLOT( micMoved( int ) ) );
244 } 245 }
245 246
246 vc->muteBox->setChecked( muted ); 247 vc->muteBox->setChecked( muted );
247 connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) ); 248 connect( vc->slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderMoved( int ) ) );
248 connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) ); 249 connect( vc->muteBox, SIGNAL( toggled( bool ) ), this, SLOT( mute( bool ) ) );
249 QPoint curPos = mapToGlobal( rect().topLeft() ); 250 QPoint curPos = mapToGlobal( rect().topLeft() );
250 vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 120 ); 251 vc->move( curPos.x()-(vc->sizeHint().width()-width())/2, curPos.y() - 120 );
251 vc->show(); 252 vc->show();
252 253
253 advancedTimer->stop(); 254 advancedTimer->stop();
254} 255}
255 256
256void VolumeApplet::volumeChanged( bool nowMuted ) 257void VolumeApplet::volumeChanged( bool nowMuted )
257{ 258{
258 int previousVolume = volumePercent; 259 int previousVolume = volumePercent;
259 260
260 if ( !nowMuted ) 261 if ( !nowMuted )
261 readSystemVolume(); 262 readSystemVolume();
262 263
263 // Handle case where muting it toggled 264 // Handle case where muting it toggled
264 if ( muted != nowMuted ) { 265 if ( muted != nowMuted ) {
265 muted = nowMuted; 266 muted = nowMuted;
266 repaint( TRUE ); 267 repaint( TRUE );
267 return; 268 return;
268 } 269 }
269 270
270 // Avoid over repainting 271 // Avoid over repainting
271 if ( previousVolume != volumePercent ) 272 if ( previousVolume != volumePercent )
272 repaint( 2, height() - 3, width() - 4, 2, FALSE ); 273 repaint( 2, height() - 3, width() - 4, 2, FALSE );
273} 274}
274 275
275void VolumeApplet::micChanged( bool nowMuted ) 276void VolumeApplet::micChanged( bool nowMuted )
276{ 277{
277 if (!nowMuted) 278 if (!nowMuted)
278 readSystemMic(); 279 readSystemMic();
279 micMuted = nowMuted; 280 micMuted = nowMuted;
280} 281}
281 282
282void VolumeApplet::mute( bool toggled ) 283void VolumeApplet::mute( bool toggled )
283{ 284{
284 muted = toggled; 285 muted = toggled;
285 286
286 // clear if removing mute 287 // clear if removing mute
287 repaint( !toggled ); 288 repaint( !toggled );
288 writeSystemVolume(); 289 writeSystemVolume();
289} 290}
290 291
291 292
292void VolumeApplet::sliderMoved( int percent ) 293void VolumeApplet::sliderMoved( int percent )
293{ 294{
294 setVolume( 100 - percent ); 295 setVolume( 100 - percent );
295} 296}
296 297
297void VolumeApplet::micMoved( int percent ) 298void VolumeApplet::micMoved( int percent )
298{ 299{
299 setMic( 100 - percent ); 300 setMic( 100 - percent );
300} 301}
301 302
302void VolumeApplet::readSystemVolume() 303void VolumeApplet::readSystemVolume()
303{ 304{
304 Config cfg("Sound"); 305 Config cfg("Sound");
305 cfg.setGroup("System"); 306 cfg.setGroup("System");
306 volumePercent = cfg.readNumEntry("Volume"); 307 volumePercent = cfg.readNumEntry("Volume");
307} 308}
308 309
309void VolumeApplet::readSystemMic() 310void VolumeApplet::readSystemMic()
310{ 311{
311 Config cfg("Sound"); 312 Config cfg("Sound");
312 cfg.setGroup("System"); 313 cfg.setGroup("System");
313 micPercent = cfg.readNumEntry("Mic"); 314 micPercent = cfg.readNumEntry("Mic");
314} 315}
315 316
316void VolumeApplet::setVolume( int percent ) 317void VolumeApplet::setVolume( int percent )
317{ 318{
318 // clamp volume percent to be between 0 and 100 319 // clamp volume percent to be between 0 and 100
319 volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); 320 volumePercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent);
320 // repaint just the little volume rectangle 321 // repaint just the little volume rectangle
321 repaint( 2, height() - 3, width() - 4, 2, FALSE ); 322 repaint( 2, height() - 3, width() - 4, 2, FALSE );
322 writeSystemVolume(); 323 writeSystemVolume();
323} 324}
324 325
325void VolumeApplet::setMic( int percent ) 326void VolumeApplet::setMic( int percent )
326{ 327{
327 // clamp volume percent to be between 0 and 100 328 // clamp volume percent to be between 0 and 100
328 micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent); 329 micPercent = (percent < 0) ? 0 : ((percent > 100) ? 100 : percent);
329 writeSystemMic(); 330 writeSystemMic();
330} 331}
331 332
332void VolumeApplet::writeSystemVolume() 333void VolumeApplet::writeSystemVolume()