Diffstat (limited to 'noncore/multimedia/opieplayer2/mediawidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index 7eb75e6..3533d74 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -60,24 +60,68 @@ void MediaWidget::paintEvent( QPaintEvent *pe ) QPainter p( &pix ); p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); paintAllButtons( p ); QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); paintAllButtons( p ); } } +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 ); + } + } + } +} + void MediaWidget::makeVisible() { } void MediaWidget::handleCommand( Command command, bool buttonDown ) { switch ( command ) { case Play: mediaPlayerState.togglePaused(); case Stop: mediaPlayerState.setPlaying(FALSE); return; case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; case Loop: mediaPlayerState.setLooping( buttonDown ); return; |