-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 84 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 3 |
4 files changed, 51 insertions, 47 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 5986a72..8e9bbf1 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -347,4 +347,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { hide(); // qDebug("Audio F9"); + e->accept(); break; case Key_F10: //contacts @@ -352,4 +353,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { case Key_F11: //menu mediaPlayerState.toggleBlank(); + e->accept(); break; case Key_F12: //home @@ -357,6 +359,8 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { case Key_F13: //mail mediaPlayerState.toggleBlank(); + e->accept(); break; case Key_Space: { + e->accept(); mediaPlayerState.togglePaused(); } @@ -367,4 +371,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { emit lessReleased(); // toggleButton(6); + e->accept(); break; case Key_Up: @@ -373,4 +378,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { emit moreReleased(); // toggleButton(5); + e->accept(); break; case Key_Right: @@ -378,4 +384,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { mediaPlayerState.setNext(); // toggleButton(3); + e->accept(); break; case Key_Left: @@ -383,4 +390,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { mediaPlayerState.setPrev(); // toggleButton(4); + e->accept(); break; case Key_Escape: { diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index ed7e37f..e1bfc2d 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -46,5 +46,6 @@ MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPla connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); - connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); +// What is pauseCheck good for? (Simon) +// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 439ba2e..4c4cead 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -70,56 +70,50 @@ void MediaWidget::paintEvent( QPaintEvent *pe ) } -void MediaWidget::mouseMoveEvent( QMouseEvent *event ) -{ - for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { - Button &button = *it; - Command command = button.command; - - if ( event->state() == QMouseEvent::LeftButton ) { - // The test to see if the mouse click is inside the button or not - bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); - - if ( isOnButton && !button.isHeld ) { - button.isHeld = TRUE; - toggleButton( button ); - switch ( command ) { - case VolumeUp: - emit moreClicked(); - return; - case VolumeDown: - emit lessClicked(); - return; - case Forward: - emit forwardClicked(); - return; - case Back: - emit backClicked(); - return; - default: break; - } - } else if ( !isOnButton && button.isHeld ) { - button.isHeld = FALSE; - toggleButton( button ); - } - } else { - if ( button.isHeld ) { - button.isHeld = FALSE; - if ( button.type != ToggleButton ) { - setToggleButton( button, FALSE ); - } - handleCommand( command, button.isDown ); - } - } - } +MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) +{ + if ( position.x() <= 0 || position.y() <= 0 || + position.x() >= buttonMask.width() || + position.y() >= buttonMask.height() ) + return 0; + + int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); + for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) + if ( it->command + 1 == pixelIdx ) + return &( *it ); + + return 0; } void MediaWidget::mousePressEvent( QMouseEvent *event ) { - mouseMoveEvent( event ); + Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); + + if ( !button ) { + QWidget::mousePressEvent( event ); + return; + } + + switch ( button->command ) { + case VolumeUp: emit moreClicked(); return; + case VolumeDown: emit lessClicked(); return; + case Back: emit backClicked(); return; + case Forward: emit forwardClicked(); return; + default: break; + } } void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) { - mouseMoveEvent( event ); + Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); + + if ( !button ) { + QWidget::mouseReleaseEvent( event ); + return; + } + + if ( button->type == ToggleButton ) + toggleButton( *button ); + + handleCommand( button->command, button->isDown ); } @@ -131,5 +125,5 @@ void MediaWidget::handleCommand( Command command, bool buttonDown ) { switch ( command ) { - case Play: mediaPlayerState.togglePaused(); + case Play: mediaPlayerState.togglePaused(); return; case Stop: mediaPlayerState.setPlaying(FALSE); return; case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 9042d5b..8031371 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -88,5 +88,6 @@ protected: virtual void paintEvent( QPaintEvent *pe ); - virtual void mouseMoveEvent( QMouseEvent *event ); + Button *buttonAt( const QPoint &position ); + virtual void mousePressEvent( QMouseEvent *event ); virtual void mouseReleaseEvent( QMouseEvent *event ); |