-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 21 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 19 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 99 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 11 |
6 files changed, 105 insertions, 50 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 8d8e4e5..a3238f0 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -26,17 +26,19 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { xineControl = new XineControl(); // 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 ) ) ); + connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); @@ -45,37 +47,36 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) } MediaPlayer::~MediaPlayer() { delete xineControl; delete volControl; } void MediaPlayer::pauseCheck( bool b ) { - // Only pause if playing - if ( b && !mediaPlayerState->playing() ) { - mediaPlayerState->setPaused( FALSE ); - } + if ( b && !mediaPlayerState->playing() ) { + mediaPlayerState->setPaused( FALSE ); + } } void MediaPlayer::play() { - mediaPlayerState->setPlaying( FALSE ); - mediaPlayerState->setPlaying( TRUE ); + mediaPlayerState->setPlaying( FALSE ); + mediaPlayerState->setPlaying( TRUE ); } void MediaPlayer::setPlaying( bool play ) { if ( !play ) { mediaPlayerState->setPaused( FALSE ); return; } - if ( mediaPlayerState->paused() ) { - mediaPlayerState->setPaused( FALSE ); - return; - } + if ( mediaPlayerState->paused() ) { + mediaPlayerState->setPaused( FALSE ); + return; + } const DocLnk *playListCurrent = playList->current(); if ( playListCurrent != NULL ) { currentFile = playListCurrent; } xineControl->play( currentFile->file() ); diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 57b1c81..bb8d905 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp @@ -48,18 +48,16 @@ void MediaPlayerState::writeConfig( Config& cfg ) const { cfg.writeEntry("FullScreen", isFullscreen ); cfg.writeEntry("Scaling", isScaled ); cfg.writeEntry("Looping", isLooping ); cfg.writeEntry("Shuffle", isShuffled ); cfg.writeEntry("UsePlayList", usePlaylist ); } - - // public stuff bool MediaPlayerState::streaming() { return isStreaming; } bool MediaPlayerState::fullscreen() { @@ -154,24 +152,23 @@ void MediaPlayerState::setPlaylist( bool b ) { if ( usePlaylist == b ) { return; } usePlaylist = b; emit playlistToggled(b); } void MediaPlayerState::setPaused( bool b ) { -if(b) qDebug("setPaused true"); - else qDebug("setPaused false"); - - if ( isPaused == b ) { - return; - } - isPaused = b; - emit pausedToggled(b); + if ( isPaused == b ) { + isPaused = FALSE; + emit pausedToggled(FALSE); + return; + } + isPaused = b; + emit pausedToggled(b); } void MediaPlayerState::setPlaying( bool b ) { if ( isPlaying == b ) { return; } isPlaying = b; isStoped = !b; @@ -255,17 +252,17 @@ void MediaPlayerState::toggleShuffled() { setShuffled( !isShuffled); } void MediaPlayerState::togglePlaylist() { setPlaylist( !usePlaylist); } void MediaPlayerState::togglePaused() { - setPaused( !isPaused); + setPaused( !isPaused); } void MediaPlayerState::togglePlaying() { setPlaying( !isPlaying); } diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 65458e7..27db464 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -159,24 +159,24 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); pmView = new QPopupMenu( this ); menu->insertItem( tr( "View" ), pmView ); pmView->isCheckable(); - pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), this, SLOT( toggleFull() ) ); + pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); Config cfg( "OpiePlayer" ); bool b= cfg.readBoolEntry("FullScreen", 0); mediaPlayerState->setFullscreen( b ); pmView->setItemChecked( -16, b ); - pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), this, SLOT(toggleScaled() ) ); + pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); tabWidget = new QTabWidget( hbox6, "tabWidget" ); // tabWidget->setTabShape(QTabWidget::Triangular); diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index fdfa666..dd49892 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h @@ -57,17 +57,16 @@ void keyReleaseEvent( QKeyEvent *e); void keyPressEvent( QKeyEvent *e); private: bool audioScan, videoScan; void doBlank(); void doUnblank(); void readm3u(const QString &); void readPls(const QString &); - void initializeStates(); void readConfig( Config& cfg ); void writeConfig( Config& cfg ) const; PlayListWidgetPrivate *d; // Private implementation data void populateAudioView(); void populateVideoView(); private slots: void pmViewActivated(int); diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 9b88299..33153d4 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -58,30 +58,30 @@ static const int xo = 2; // movable x offset static const int yo = 0; // movable y offset struct MediaButton { bool isToggle, isHeld, isDown; }; MediaButton videoButtons[] = { - { FALSE, FALSE, FALSE }, // previous { FALSE, FALSE, FALSE }, // stop { TRUE, FALSE, FALSE }, // play - { TRUE, FALSE, FALSE }, // pause + { FALSE, FALSE, FALSE }, // previous { FALSE, FALSE, FALSE }, // next - { FALSE, FALSE, FALSE }, // playlist + { FALSE, FALSE, FALSE }, // volUp + { FALSE, FALSE, FALSE }, // volDown { TRUE, FALSE, FALSE } // fullscreen }; const char *skinV_mask_file_names[7] = { "stop","play","back","fwd","up","down","full" }; -static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); +static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { setCaption( tr("OpiePlayer - Video") ); videoFrame = new XineVideoWidget ( this, "Video frame" ); connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); @@ -132,43 +132,46 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); + connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); ////////////////////////// FIXME // setFullscreen( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); qDebug("finished videowidget"); } VideoWidget::~VideoWidget() { + mediaPlayerState->setPlaying( FALSE ); for ( int i = 0; i < 7; i++ ) { delete buttonPixUp[i]; delete buttonPixDown[i]; } delete pixBg; delete imgUp; delete imgDn; delete imgButtonMask; for ( int i = 0; i < 7; i++ ) { delete masks[i]; } + } QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); QPainter p( &pix ); p.drawTiledPixmap( pix.rect(), bg, offset ); p.drawImage( 0, 0, img ); return new QPixmap( pix ); @@ -285,45 +288,90 @@ void VideoWidget::paintButton( QPainter *p, int i ) { if ( videoButtons[i].isDown ) p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); else p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); } void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { - for ( int i = 0; i < numButtons; i++ ) { + for ( int i = 0; i < numVButtons; i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not int x = event->pos().x() - xoff; int y = event->pos().y() - yoff; bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() - && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); + && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); if ( isOnButton != videoButtons[i].isHeld ) { videoButtons[i].isHeld = isOnButton; toggleButton(i); } + +// qDebug("mouseMove event switch1 %d", i); + if( isOnButton) + switch (i) { + case VideoStop:{ + setToggleButton( i, FALSE ); + mediaPlayerState->setStop(TRUE); + mediaPlayerState->setPlaying(FALSE); + return; + } + case VideoPlay: { + + if( mediaPlayerState->isPaused) { + setToggleButton( i, FALSE ); + mediaPlayerState->setPaused( FALSE); + return; + } + else if( mediaPlayerState->isPlaying) { + setToggleButton( i, TRUE ); + mediaPlayerState->setPaused( TRUE); + return; + } + else { + setToggleButton( i, FALSE ); + mediaPlayerState->setPlaying( videoButtons[i].isDown ); + return; + } + } + case VideoNext: qDebug("next"); mediaPlayerState->setNext(); return; + case VideoPrevious: qDebug("previous"); mediaPlayerState->setPrev(); return; + case VideoVolUp: return; + case VideoVolDown: return; + case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; + + }; + } else { if ( videoButtons[i].isHeld ) { videoButtons[i].isHeld = FALSE; - if ( !videoButtons[i].isToggle ) + if ( !videoButtons[i].isToggle ) { setToggleButton( i, FALSE ); + } +// qDebug("mouseMove event switch2 %d %d", i, VideoPlay); + switch (i) { + case VideoPlay: { + if( mediaPlayerState->isPaused) { + mediaPlayerState->setPaused( FALSE); return; } + else if( mediaPlayerState->isPlaying) { + mediaPlayerState->setPaused( TRUE); return; } + else + mediaPlayerState->setPlaying( TRUE /*videoButtons[i].isDown*/ ); return; + } + case VideoStop: mediaPlayerState->setPlaying(FALSE); return; +// case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; + case VideoNext: mediaPlayerState->setNext(); return; + case VideoPrevious: mediaPlayerState->setPrev(); return; + case VideoVolUp: return; + case VideoVolDown: return; + case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; + } } } - switch (i) { - case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; - case VideoStop: mediaPlayerState->setPlaying(FALSE); return; - case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; - case VideoNext: mediaPlayerState->setNext(); return; - case VideoPrevious: mediaPlayerState->setPrev(); return; - case VideoPlayList: mediaPlayerState->setList(); return; - case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; - } - } } void VideoWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { @@ -366,30 +414,30 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { // draw the buttons 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(), *pixBg, pe->rect().topLeft() ); - for ( int i = 0; i < numButtons; i++ ) + for ( int i = 0; i < numVButtons; i++ ) paintButton( &p, i ); QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); - for ( int i = 0; i < numButtons; i++ ) + for ( int i = 0; i < numVButtons; i++ ) paintButton( &p, i ); } // for ( int i = 0; i < numButtons; i++ ) { // paintButton( &p, i ); // } -// // draw the slider -// slider->repaint( TRUE ); + // draw the slider + slider->repaint( TRUE ); } } void VideoWidget::closeEvent( QCloseEvent* ) { mediaPlayerState->setList(); } @@ -459,8 +507,17 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) { XineVideoWidget* VideoWidget::vidWidget() { return videoFrame; } void VideoWidget::setFullscreen ( bool b ) { setToggleButton( VideoFullscreen, b ); } + +void VideoWidget::setPaused( bool b) { +// setToggleButton( VideoPause, b ); +} + +void VideoWidget::setPlaying( bool b) { + setToggleButton( VideoPlay, b ); +} + diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 830696e..92193a4 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -36,39 +36,40 @@ #include <qwidget.h> #include "xinevideowidget.h" class QPixmap; class QSlider; enum VideoButtons { - VideoPrevious, VideoStop, VideoPlay, - VideoPause, +// VideoPause, + VideoPrevious, VideoNext, - VideoPlayList, + VideoVolUp, + VideoVolDown, VideoFullscreen }; class VideoWidget : public QWidget { Q_OBJECT public: VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); ~VideoWidget(); bool playVideo(); XineVideoWidget* vidWidget(); public slots: void updateSlider( long, long ); void sliderPressed( ); void sliderReleased( ); - void setPaused( bool b) { setToggleButton( VideoPause, b ); } - void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } + void setPaused( bool b); + void setPlaying( bool b); void setFullscreen( bool b ); void makeVisible(); void setPosition( long ); void setLength( long ); void setView( char ); signals: void sliderMoved( long ); |