summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp84
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h3
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
@@ -325,67 +325,75 @@ void AudioWidget::stopSkip() {
}
void AudioWidget::timerEvent( QTimerEvent * ) {
if ( skipDirection == +1 ) {
mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
} else if ( skipDirection == -1 ) {
mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
}
}
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");
+ e->accept();
break;
case Key_F10: //contacts
break;
case Key_F11: //menu
mediaPlayerState.toggleBlank();
+ e->accept();
break;
case Key_F12: //home
break;
case Key_F13: //mail
mediaPlayerState.toggleBlank();
+ e->accept();
break;
case Key_Space: {
+ e->accept();
mediaPlayerState.togglePaused();
}
break;
case Key_Down:
// toggleButton(6);
emit lessClicked();
emit lessReleased();
// toggleButton(6);
+ e->accept();
break;
case Key_Up:
// toggleButton(5);
emit moreClicked();
emit moreReleased();
// toggleButton(5);
+ e->accept();
break;
case Key_Right:
// toggleButton(3);
mediaPlayerState.setNext();
// toggleButton(3);
+ e->accept();
break;
case Key_Left:
// toggleButton(4);
mediaPlayerState.setPrev();
// toggleButton(4);
+ e->accept();
break;
case Key_Escape: {
}
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
@@ -24,49 +24,50 @@
#include <sys/ioctl.h>
#define FBIOBLANK 0x4611
MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
: QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
audioUI = 0;
videoUI = 0;
xineControl = 0;
recreateAudioAndVideoWidgets();
fd=-1;fl=-1;
playList.setCaption( tr( "OpiePlayer: Initializating" ) );
qApp->processEvents();
// QPEApplication::grabKeyboard(); // EVIL
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
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() ) );
connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
volControl = new VolumeControl;
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
}
MediaPlayer::~MediaPlayer() {
delete xineControl;
delete audioUI;
delete videoUI;
delete volControl;
}
void MediaPlayer::pauseCheck( bool b ) {
if ( b && !mediaPlayerState.isPlaying() ) {
mediaPlayerState.setPaused( FALSE );
}
}
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
@@ -48,110 +48,104 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
{
QPainter p( this );
if ( mediaPlayerState.isFullscreen() ) {
// Clear the background
p.setBrush( QBrush( Qt::black ) );
return;
}
if ( !pe->erased() ) {
// Combine with background and double buffer
QPixmap pix( pe->rect().size() );
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 );
- }
- }
- }
+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 );
}
void MediaWidget::makeVisible()
{
}
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;
case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
case Loop: mediaPlayerState.setLooping( buttonDown ); return;
case VolumeUp: emit moreReleased(); return;
case VolumeDown: emit lessReleased(); return;
case PlayList: mediaPlayerState.setList(); return;
case Forward: emit forwardReleased(); return;
case Back: emit backReleased(); return;
case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
default: assert( false );
}
}
bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
{
return ( position.x() > 0 && position.y() > 0 &&
position.x() < buttonMask.width() &&
position.y() < buttonMask.height() &&
buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
}
void MediaWidget::paintAllButtons( QPainter &p )
{
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
@@ -66,49 +66,50 @@ public:
MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
virtual ~MediaWidget();
public slots:
virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
virtual void setLength( long length ) = 0;
virtual void setPlaying( bool playing ) = 0;
signals:
void moreReleased();
void lessReleased();
void forwardReleased();
void backReleased();
void forwardClicked();
void backClicked();
void moreClicked();
void lessClicked();
protected:
virtual void closeEvent( QCloseEvent * );
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 );
virtual void makeVisible();
void handleCommand( Command command, bool buttonDown );
bool isOverButton( const QPoint &position, int buttonId ) const;
void paintAllButtons( QPainter &p );
void paintButton( const Button &button );
void paintButton( QPainter &p, const Button &button );
void setToggleButton( Button &button, bool down );
void setToggleButton( Command command, bool down );
void toggleButton( Button &button );
MediaPlayerState &mediaPlayerState;
PlayListWidget &playList;
ButtonVector buttons;
QImage buttonMask;