summaryrefslogtreecommitdiff
path: root/noncore
authorsimon <simon>2002-12-09 15:49:37 (UTC)
committer simon <simon>2002-12-09 15:49:37 (UTC)
commit743155915f659d701ad468eadcc2b2173b6e2770 (patch) (side-by-side diff)
treee95ff8ac9e8781865214e92e8a7e84bbdd04b645 /noncore
parentaa766a6a0818ed0b756f8cd67fc4a1c85906f224 (diff)
downloadopie-743155915f659d701ad468eadcc2b2173b6e2770.zip
opie-743155915f659d701ad468eadcc2b2173b6e2770.tar.gz
opie-743155915f659d701ad468eadcc2b2173b6e2770.tar.bz2
- less indexing in the mouse event handler
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp27
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
@@ -290,129 +290,132 @@ void AudioWidget::updateSlider( long i, long max ) {
if ( max == 0 ) {
return;
}
// Will flicker too much if we don't do this
// Scale to something reasonable
int width = slider.width();
int val = int((double)i * width / max);
if ( !audioSliderBeingMoved ) {
if ( slider.value() != val ) {
slider.setValue( val );
}
if ( slider.maxValue() != width ) {
slider.setMaxValue( width );
}
}
}
void AudioWidget::skipFor() {
skipDirection = +1;
startTimer( 50 );
mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
}
void AudioWidget::skipBack() {
skipDirection = -1;
startTimer( 50 );
mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
void AudioWidget::stopSkip() {
killTimers();
}
void AudioWidget::timerEvent( QTimerEvent * ) {
if ( skipDirection == +1 ) {
mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
} else if ( skipDirection == -1 ) {
mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
}
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;
case VolumeDown:
emit lessClicked();
return;
case Forward:
emit forwardClicked();
return;
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 );
}
}
}
}
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::showEvent( QShowEvent* ) {
QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
mouseMoveEvent( &event );
}
void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
hide();
// qDebug("Audio F9");
break;
case Key_F10: //contacts
break;
case Key_F11: //menu
mediaPlayerState.toggleBlank();
break;
case Key_F12: //home
break;
case Key_F13: //mail
mediaPlayerState.toggleBlank();
break;
case Key_Space: {
mediaPlayerState.togglePaused();
}
break;
case Key_Down:
// toggleButton(6);
emit lessClicked();
emit lessReleased();
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
@@ -199,133 +199,136 @@ void VideoWidget::sliderReleased() {
if ( slider->width() == 0 ) {
return;
}
long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
mediaPlayerState.setPosition( val );
}
void VideoWidget::setPosition( long i ) {
updateSlider( i, mediaPlayerState.length() );
}
void VideoWidget::setLength( long max ) {
updateSlider( mediaPlayerState.position(), max );
}
void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
{
if ( displayType == MediaPlayerState::Video ) {
makeVisible();
return;
}
// Effectively blank the view next time we show it so it looks nicer
scaledWidth = 0;
scaledHeight = 0;
hide();
}
void VideoWidget::updateSlider( long i, long max ) {
// Will flicker too much if we don't do this
if ( max == 0 ) {
return;
}
int width = slider->width();
int val = int((double)i * width / max);
if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
if ( slider->value() != val ) {
slider->setValue( val );
}
if ( slider->maxValue() != width ) {
slider->setMaxValue( width );
}
}
}
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();
return;
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;
}
}
case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
case VideoVolUp: emit moreReleased(); return;
case VideoVolDown: emit lessReleased(); return;
case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
}
}
}
}
}
void VideoWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
if ( mediaPlayerState.isFullscreen() ) {
mediaPlayerState.setFullscreen( FALSE );
makeVisible();
}
mouseMoveEvent( event );
}
void VideoWidget::showEvent( QShowEvent* ) {
QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
mouseMoveEvent( &event );
}
void VideoWidget::backToNormal() {
mediaPlayerState.setFullscreen( FALSE );
makeVisible();
}
void VideoWidget::makeVisible() {
if ( mediaPlayerState.isFullscreen() ) {
setBackgroundMode( QWidget::NoBackground );
showFullScreen();
resize( qApp->desktop()->size() );
videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));