author | simon <simon> | 2002-12-09 15:49:37 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 15:49:37 (UTC) |
commit | 743155915f659d701ad468eadcc2b2173b6e2770 (patch) (side-by-side diff) | |
tree | e95ff8ac9e8781865214e92e8a7e84bbdd04b645 | |
parent | aa766a6a0818ed0b756f8cd67fc4a1c85906f224 (diff) | |
download | opie-743155915f659d701ad468eadcc2b2173b6e2770.zip opie-743155915f659d701ad468eadcc2b2173b6e2770.tar.gz opie-743155915f659d701ad468eadcc2b2173b6e2770.tar.bz2 |
- less indexing in the mouse event handler
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 25 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 27 |
2 files changed, 29 insertions, 23 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index ef606ab..714509e 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -334,15 +334,18 @@ void AudioWidget::timerEvent( QTimerEvent * ) { void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { for ( unsigned int i = 0; i < buttons.count(); i++ ) { + + Button &button = buttons[ i ]; + 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, i ); - if ( isOnButton && !buttons[i].isHeld ) { - buttons[i].isHeld = TRUE; - toggleButton( buttons[ i ] ); + if ( isOnButton && !button.isHeld ) { + button.isHeld = TRUE; + toggleButton( button ); switch (i) { case VolumeUp: emit moreClicked(); return; @@ -355,20 +358,20 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { case Back: emit backClicked(); return; } - } else if ( !isOnButton && buttons[i].isHeld ) { - buttons[i].isHeld = FALSE; - toggleButton( buttons[ i ] ); + } else if ( !isOnButton && button.isHeld ) { + button.isHeld = FALSE; + toggleButton( button ); } } else { - if ( buttons[i].isHeld ) { - buttons[i].isHeld = FALSE; - if ( buttons[i].type != ToggleButton ) { - setToggleButton( buttons[ i ], FALSE ); + if ( button.isHeld ) { + button.isHeld = FALSE; + if ( button.type != ToggleButton ) { + setToggleButton( button, FALSE ); } qDebug("mouseEvent %d", i); - handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); + handleCommand( static_cast<Command>( i ), button.isDown ); } } } } diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 673c9e8..9782b68 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -243,15 +243,18 @@ void VideoWidget::updateSlider( long i, long max ) { } void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { for ( unsigned int i = 0; i < buttons.count(); i++ ) { + + Button &button = buttons[ i ]; + 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, i ); - if ( isOnButton && !buttons[i].isHeld ) { - buttons[i].isHeld = TRUE; - toggleButton( buttons[ i ] ); + if ( isOnButton && !button.isHeld ) { + button.isHeld = TRUE; + toggleButton( button ); switch (i) { case VideoVolUp: emit moreClicked(); @@ -259,29 +262,29 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { case VideoVolDown: emit lessClicked(); return; } - } else if ( !isOnButton && buttons[i].isHeld ) { - buttons[i].isHeld = FALSE; - toggleButton( buttons[ i ] ); + } else if ( !isOnButton && button.isHeld ) { + button.isHeld = FALSE; + toggleButton( button ); } } else { - if ( buttons[i].isHeld ) { - buttons[i].isHeld = FALSE; - if ( buttons[i].type != ToggleButton ) { - setToggleButton( buttons[ i ], FALSE ); + if ( button.isHeld ) { + button.isHeld = FALSE; + if ( button.type != ToggleButton ) { + setToggleButton( button, FALSE ); } switch(i) { case VideoPlay: { if( mediaPlayerState.isPaused() ) { - setToggleButton( buttons[ i ], FALSE ); + setToggleButton( button, FALSE ); mediaPlayerState.setPaused( FALSE ); return; } else if( !mediaPlayerState.isPaused() ) { - setToggleButton( buttons[ i ], TRUE ); + setToggleButton( button, TRUE ); mediaPlayerState.setPaused( TRUE ); return; } else { return; |