-rw-r--r-- | core/applets/volumeapplet/volume.cpp | 3 |
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 | |||
@@ -172,129 +172,130 @@ void VolumeControl::rateTimerDone() | |||
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 | ||
179 | VolumeApplet::VolumeApplet( QWidget *parent, const char *name ) | 179 | VolumeApplet::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 | ||
205 | VolumeApplet::~VolumeApplet() | 205 | VolumeApplet::~VolumeApplet() |
206 | { | 206 | { |
207 | } | 207 | } |
208 | 208 | ||
209 | void VolumeApplet::keyPressEvent ( QKeyEvent * e ) | 209 | void 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 | } |
215 | void VolumeApplet::mousePressEvent( QMouseEvent * ) | 215 | void VolumeApplet::mousePressEvent( QMouseEvent * ) |
216 | { | 216 | { |
217 | advancedTimer->start( 750, TRUE ); | 217 | advancedTimer->start( 750, TRUE ); |
218 | } | 218 | } |
219 | 219 | ||
220 | void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) | 220 | void VolumeApplet::mouseReleaseEvent( QMouseEvent * ) |
221 | { | 221 | { |
222 | showVolControl(FALSE); | 222 | showVolControl(FALSE); |
223 | } | 223 | } |
224 | 224 | ||
225 | void VolumeApplet::advVolControl() | 225 | void VolumeApplet::advVolControl() |
226 | { | 226 | { |
227 | showVolControl(TRUE); | 227 | showVolControl(TRUE); |
228 | } | 228 | } |
229 | 229 | ||
230 | void VolumeApplet::showVolControl(bool showMic) | 230 | void 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 | ||
256 | void VolumeApplet::volumeChanged( bool nowMuted ) | 257 | void 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 | ||
275 | void VolumeApplet::micChanged( bool nowMuted ) | 276 | void 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 | ||
282 | void VolumeApplet::mute( bool toggled ) | 283 | void 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 | ||
292 | void VolumeApplet::sliderMoved( int percent ) | 293 | void VolumeApplet::sliderMoved( int percent ) |
293 | { | 294 | { |
294 | setVolume( 100 - percent ); | 295 | setVolume( 100 - percent ); |
295 | } | 296 | } |
296 | 297 | ||
297 | void VolumeApplet::micMoved( int percent ) | 298 | void VolumeApplet::micMoved( int percent ) |
298 | { | 299 | { |
299 | setMic( 100 - percent ); | 300 | setMic( 100 - percent ); |
300 | } | 301 | } |