-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index a3d34f4..2cb1385 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -345,116 +345,115 @@ void AudioWidget::updateSlider( long i, long max ) { | |||
345 | } | 345 | } |
346 | // Will flicker too much if we don't do this | 346 | // Will flicker too much if we don't do this |
347 | // Scale to something reasonable | 347 | // Scale to something reasonable |
348 | int width = slider.width(); | 348 | int width = slider.width(); |
349 | int val = int((double)i * width / max); | 349 | int val = int((double)i * width / max); |
350 | if ( !audioSliderBeingMoved ) { | 350 | if ( !audioSliderBeingMoved ) { |
351 | if ( slider.value() != val ) { | 351 | if ( slider.value() != val ) { |
352 | slider.setValue( val ); | 352 | slider.setValue( val ); |
353 | } | 353 | } |
354 | 354 | ||
355 | if ( slider.maxValue() != width ) { | 355 | if ( slider.maxValue() != width ) { |
356 | slider.setMaxValue( width ); | 356 | slider.setMaxValue( width ); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | 361 | ||
362 | void AudioWidget::setToggleButton( int i, bool down ) { | 362 | void AudioWidget::setToggleButton( int i, bool down ) { |
363 | if ( down != audioButtons[i].isDown ) { | 363 | if ( down != audioButtons[i].isDown ) { |
364 | toggleButton( i ); | 364 | toggleButton( i ); |
365 | } | 365 | } |
366 | } | 366 | } |
367 | 367 | ||
368 | 368 | ||
369 | void AudioWidget::toggleButton( int i ) { | 369 | void AudioWidget::toggleButton( int i ) { |
370 | audioButtons[i].isDown = !audioButtons[i].isDown; | 370 | audioButtons[i].isDown = !audioButtons[i].isDown; |
371 | QPainter p(this); | 371 | QPainter p(this); |
372 | paintButton ( &p, i ); | 372 | paintButton ( &p, i ); |
373 | } | 373 | } |
374 | 374 | ||
375 | 375 | ||
376 | void AudioWidget::paintButton( QPainter *p, int i ) { | 376 | void AudioWidget::paintButton( QPainter *p, int i ) { |
377 | if ( audioButtons[i].isDown ) | 377 | if ( audioButtons[i].isDown ) { |
378 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 378 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
379 | else | 379 | } else { |
380 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 380 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
381 | } | ||
381 | } | 382 | } |
382 | 383 | ||
383 | 384 | ||
384 | void AudioWidget::skipFor() { | 385 | void AudioWidget::skipFor() { |
385 | skipDirection = +1; | 386 | skipDirection = +1; |
386 | startTimer( 50 ); | 387 | startTimer( 50 ); |
387 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 388 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
388 | } | 389 | } |
389 | 390 | ||
390 | void AudioWidget::skipBack() { | 391 | void AudioWidget::skipBack() { |
391 | skipDirection = -1; | 392 | skipDirection = -1; |
392 | startTimer( 50 ); | 393 | startTimer( 50 ); |
393 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 394 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
394 | } | 395 | } |
395 | 396 | ||
396 | 397 | ||
397 | 398 | ||
398 | void AudioWidget::stopSkip() { | 399 | void AudioWidget::stopSkip() { |
399 | killTimers(); | 400 | killTimers(); |
400 | } | 401 | } |
401 | 402 | ||
402 | 403 | ||
403 | void AudioWidget::timerEvent( QTimerEvent * ) { | 404 | void AudioWidget::timerEvent( QTimerEvent * ) { |
404 | if ( skipDirection == +1 ) { | 405 | if ( skipDirection == +1 ) { |
405 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 406 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
406 | } else if ( skipDirection == -1 ) { | 407 | } else if ( skipDirection == -1 ) { |
407 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 408 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
408 | } | 409 | } |
409 | } | 410 | } |
410 | 411 | ||
411 | 412 | ||
412 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 413 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
413 | for ( int i = 0; i < numButtons; i++ ) { | 414 | for ( int i = 0; i < numButtons; i++ ) { |
414 | if ( event->state() == QMouseEvent::LeftButton ) { | 415 | if ( event->state() == QMouseEvent::LeftButton ) { |
415 | 416 | // The test to see if the mouse click is inside the button or not | |
416 | // The test to see if the mouse click is inside the button or not | ||
417 | int x = event->pos().x() - xoff; | 417 | int x = event->pos().x() - xoff; |
418 | int y = event->pos().y() - yoff; | 418 | int y = event->pos().y() - yoff; |
419 | 419 | ||
420 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 420 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
421 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 421 | && y < imgButtonMask->height() |
422 | 422 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | |
423 | if ( isOnButton && i == AudioVolumeUp ) | ||
424 | qDebug("on up"); | ||
425 | 423 | ||
426 | if ( isOnButton && !audioButtons[i].isHeld ) { | 424 | if ( isOnButton && !audioButtons[i].isHeld ) { |
427 | audioButtons[i].isHeld = TRUE; | 425 | audioButtons[i].isHeld = TRUE; |
428 | toggleButton(i); | 426 | toggleButton(i); |
427 | |||
429 | switch (i) { | 428 | switch (i) { |
430 | case AudioVolumeUp: | 429 | case AudioVolumeUp: |
431 | qDebug("more clicked"); | 430 | qDebug("more clicked"); |
432 | emit moreClicked(); | 431 | emit moreClicked(); |
433 | return; | 432 | return; |
434 | case AudioVolumeDown: | 433 | case AudioVolumeDown: |
435 | emit lessClicked(); | 434 | emit lessClicked(); |
436 | return; | 435 | return; |
437 | case AudioForward: | 436 | case AudioForward: |
438 | emit forwardClicked(); | 437 | emit forwardClicked(); |
439 | return; | 438 | return; |
440 | case AudioBack: | 439 | case AudioBack: |
441 | emit backClicked(); | 440 | emit backClicked(); |
442 | return; | 441 | return; |
443 | } | 442 | } |
444 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 443 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
445 | audioButtons[i].isHeld = FALSE; | 444 | audioButtons[i].isHeld = FALSE; |
446 | toggleButton(i); | 445 | toggleButton(i); |
447 | } | 446 | } |
448 | } else { | 447 | } else { |
449 | if ( audioButtons[i].isHeld ) { | 448 | if ( audioButtons[i].isHeld ) { |
450 | audioButtons[i].isHeld = FALSE; | 449 | audioButtons[i].isHeld = FALSE; |
451 | if ( !audioButtons[i].isToggle ) { | 450 | if ( !audioButtons[i].isToggle ) { |
452 | setToggleButton( i, FALSE ); | 451 | setToggleButton( i, FALSE ); |
453 | qDebug("button toggled3 %d",i); | 452 | qDebug("button toggled3 %d",i); |
454 | } | 453 | } |
455 | switch (i) { | 454 | switch (i) { |
456 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; | 455 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; |
457 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 456 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
458 | case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return; | 457 | case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return; |
459 | case AudioNext: mediaPlayerState->setNext(); return; | 458 | case AudioNext: mediaPlayerState->setNext(); return; |
460 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 459 | case AudioPrevious: mediaPlayerState->setPrev(); return; |