author | simon <simon> | 2002-12-09 20:02:52 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 20:02:52 (UTC) |
commit | 2d2d57e3b7988f4246319cdfd0dc7fa90110db8e (patch) (side-by-side diff) | |
tree | fb4dfb832e2630e7da1cc57e92ba6c62ead22dee | |
parent | 046f040efcb0f313818d1dbb1dc1db9021678175 (diff) | |
download | opie-2d2d57e3b7988f4246319cdfd0dc7fa90110db8e.zip opie-2d2d57e3b7988f4246319cdfd0dc7fa90110db8e.tar.gz opie-2d2d57e3b7988f4246319cdfd0dc7fa90110db8e.tar.bz2 |
- reworked the mouse event handling to be much simpler
- fixed missing return in Play case in handleCommand, which accidentially
broke pausing
- accept the key events we receive in the audioWidget
- commented out suspicious connect to pauseCheck in mediaplayer, which
broke pausing via space bar
-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 @@ -348,2 +348,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { // qDebug("Audio F9"); + e->accept(); break; @@ -353,2 +354,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { mediaPlayerState.toggleBlank(); + e->accept(); break; @@ -358,4 +360,6 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { mediaPlayerState.toggleBlank(); + e->accept(); break; case Key_Space: { + e->accept(); mediaPlayerState.togglePaused(); @@ -368,2 +372,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { // toggleButton(6); + e->accept(); break; @@ -374,2 +379,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { // toggleButton(5); + e->accept(); break; @@ -379,2 +385,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { // toggleButton(3); + e->accept(); break; @@ -384,2 +391,3 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { // toggleButton(4); + e->accept(); break; 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 @@ -47,3 +47,4 @@ MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPla - connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); +// What is pauseCheck good for? (Simon) +// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 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 @@ -71,44 +71,15 @@ 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; } @@ -117,3 +88,16 @@ 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; + } } @@ -122,3 +106,13 @@ 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 ); } @@ -132,3 +126,3 @@ void MediaWidget::handleCommand( Command command, bool buttonDown ) switch ( command ) { - case Play: mediaPlayerState.togglePaused(); + case Play: mediaPlayerState.togglePaused(); return; case Stop: mediaPlayerState.setPlaying(FALSE); 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 @@ -89,3 +89,4 @@ protected: - virtual void mouseMoveEvent( QMouseEvent *event ); + Button *buttonAt( const QPoint &position ); + virtual void mousePressEvent( QMouseEvent *event ); |