-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 41 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 246 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 17 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 323 |
7 files changed, 384 insertions, 254 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index dc90a62..2ee9383 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -136,9 +136,9 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency - QString skinPath = "opieplayer/skins/" + skin; + QString skinPath = "opieplayer2/skins/" + skin; pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 135c67c..57b1c81 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp @@ -158,8 +158,11 @@ void MediaPlayerState::setPlaylist( bool b ) { emit playlistToggled(b); } void MediaPlayerState::setPaused( bool b ) { +if(b) qDebug("setPaused true"); + else qDebug("setPaused false"); + if ( isPaused == b ) { return; } isPaused = b; diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index b43d9f7..65458e7 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp @@ -9,8 +9,9 @@ #include <qpe/lnkproperties.h> #include <qpe/storage.h> #include <qpe/applnk.h> +#include <qpopupmenu.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/resource.h> #include <qaction.h> @@ -157,15 +158,21 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) pmPlayList->insertSeparator(-1); new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); - QPopupMenu *pmView = new QPopupMenu( this ); + + pmView = new QPopupMenu( this ); menu->insertItem( tr( "View" ), pmView ); + pmView->isCheckable(); + + pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), this, SLOT( toggleFull() ) ); - fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); - fullScreenButton->addTo(pmView); - scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); - //scaleButton->addTo(pmView); + 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() ) ); QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); @@ -241,10 +248,13 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) playLists->setMinimumSize(233,260); tabWidget->insertTab(LTab,tr("Lists")); connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); - connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); - connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); + +connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); + +// connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); + connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); @@ -265,9 +275,8 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); setCentralWidget( vbox5 ); - Config cfg( "OpiePlayer" ); readConfig( cfg ); QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); loadList(DocLnk( currentPlaylist)); setCaption(tr("OpiePlayer: ")+ currentPlaylist ); @@ -1208,4 +1217,20 @@ void PlayListWidget::readPls(const QString &filename) { i++; } } +void PlayListWidget::pmViewActivated(int index) { +qDebug("%d", index); +switch(index) { + case -16: + { + + mediaPlayerState->toggleFullscreen(); + bool b=mediaPlayerState->fullscreen(); + pmView->setItemChecked( index,b); + Config cfg( "OpiePlayer" ); + cfg.writeEntry("FullScreen", b); + + } + break; +}; +} diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index e44096b..fdfa666 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h @@ -6,8 +6,9 @@ #include <qpe/applnk.h> #include <qtabwidget.h> #include <qpe/fileselector.h> #include <qpushbutton.h> +#include <qpopupmenu.h> /* #include <qtimer.h> */ @@ -24,13 +25,15 @@ class PlayListWidget : public QMainWindow { public: PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); ~PlayListWidget(); QTabWidget * tabWidget; - QAction *fullScreenButton, *scaleButton; +// MenuItem *fullScreenButton, *scaleButton; +// QAction *fullScreenButton, *scaleButton; DocLnkSet files; DocLnkSet vFiles; QListView *audioView, *videoView, *playlistView; QLabel *libString; + QPopupMenu *pmView ; bool fromSetDocument; bool insanityBool; QString setDocFileRef; // retrieve the current playlist entry (media file link) @@ -66,8 +69,9 @@ private: PlayListWidgetPrivate *d; // Private implementation data void populateAudioView(); void populateVideoView(); private slots: + void pmViewActivated(int); void writem3u(); void scanForAudio(); void scanForVideo(); void openFile(); diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 188b18d..419c3ae 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -31,8 +31,9 @@ */ #include <qpe/resource.h> +#include <qpe/mediaplayerplugininterface.h> #include <qpe/config.h> #include <qwidget.h> #include <qpainter.h> @@ -57,64 +58,79 @@ static const int xo = 2; // movable x offset static const int yo = 0; // movable y offset struct MediaButton { - int xPos, yPos; bool isToggle, isHeld, isDown; - int controlType; }; - -// Layout information for the videoButtons (and if it is a toggle button or not) MediaButton videoButtons[] = { - { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous - { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop - { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play - { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause - { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next - { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist - { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen + { FALSE, FALSE, FALSE }, // previous + { FALSE, FALSE, FALSE }, // stop + { TRUE, FALSE, FALSE }, // play + { TRUE, FALSE, FALSE }, // pause + { FALSE, FALSE, FALSE }, // next + { FALSE, FALSE, FALSE }, // playlist + { 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)); VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : - QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { +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 & ))); + Config cfg("OpiePlayer"); cfg.setGroup("VideoWidget"); + skin = cfg.readEntry("Skin","default"); + + QString skinPath = "opieplayer2/skins/" + skin; + pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); + imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); + imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); + + imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); + imgButtonMask->fill( 0 ); + + for ( int i = 0; i < 7; i++ ) { + QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; + masks[i] = new QBitmap( filename ); + qDebug(filename); + if ( !masks[i]->isNull() ) { + QImage imgMask = masks[i]->convertToImage(); + uchar **dest = imgButtonMask->jumpTable(); + for ( int y = 0; y < imgUp->height(); y++ ) { + uchar *line = dest[y]; + for ( int x = 0; x < imgUp->width(); x++ ) { + if ( !qRed( imgMask.pixel( x, y ) ) ) + line[x] = i + 1; + } + } + } - QString Button0aPix, Button0bPix, controlsPix; - Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); - Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); - controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); + } - cfg.setGroup("AudioWidget"); - QString skin = cfg.readEntry("Skin","default"); - QString skinPath = "opieplayer/skins/" + skin; - backgroundPix = QString("%1/background").arg(skinPath) ; + for ( int i = 0; i < 7; i++ ) { + buttonPixUp[i] = NULL; + buttonPixDown[i] = NULL; + } - setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); - pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); - pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); - pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); - currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); + setBackgroundPixmap( *pixBg ); slider = new QSlider( Qt::Horizontal, this ); slider->setMinValue( 0 ); slider->setMaxValue( 1 ); - - slider->setBackgroundPixmap( *this->backgroundPixmap () ); //Resource::loadPixmap( backgroundPix ) ); - slider->setBackgroundOrigin( QWidget::ParentOrigin); + slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); slider->setFocusPolicy( QWidget::NoFocus ); slider->setGeometry( QRect( 7, 250, 220, 20 ) ); - videoFrame = new XineVideoWidget ( this, "Video frame" ); - - connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); - connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); @@ -123,34 +139,87 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 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) ) ); - // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); - setFullscreen( mediaPlayerState->fullscreen() ); + + ////////////////////////// FIXME +// setFullscreen( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); - + qDebug("finished videowidget"); } VideoWidget::~VideoWidget() { - for ( int i = 0; i < 3; i++ ) { - delete pixmaps[i]; + 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]; } - delete currentFrame; } +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 ); +} -static bool videoSliderBeingMoved = FALSE; +QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { + QPixmap *pixmap = new QPixmap( pix ); + pixmap->setMask( mask ); + return pixmap; +} + +void VideoWidget::resizeEvent( QResizeEvent * ) { + int h = height(); + int w = width(); + int Vh = 160; + //videoFrame->height(); + int Vw = 220; + //videoFrame->width(); +// songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); + + slider->setFixedWidth( w - 110 ); + slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); + slider->setBackgroundOrigin( QWidget::ParentOrigin ); +// time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); + xoff = 0;// ( imgUp->width() ) / 2; + yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; + QPoint p( xoff, yoff ); + + QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); + QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); + + for ( int i = 0; i < 7; i++ ) { + if ( !masks[i]->isNull() ) { + delete buttonPixUp[i]; + delete buttonPixDown[i]; + buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); + buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); + } + } + delete pixUp; + delete pixDn; +} + +static bool videoSliderBeingMoved = FALSE; void VideoWidget::sliderPressed() { videoSliderBeingMoved = TRUE; } - void VideoWidget::sliderReleased() { videoSliderBeingMoved = FALSE; if ( slider->width() == 0 ) { return; @@ -158,9 +227,8 @@ void VideoWidget::sliderReleased() { long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); mediaPlayerState->setPosition( val ); } - void VideoWidget::setPosition( long i ) { updateSlider( i, mediaPlayerState->length() ); } @@ -168,9 +236,8 @@ void VideoWidget::setPosition( long i ) { void VideoWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } - void VideoWidget::setView( char view ) { if ( view == 'v' ) { makeVisible(); } else { @@ -180,9 +247,8 @@ void VideoWidget::setView( char view ) { hide(); } } - void VideoWidget::updateSlider( long i, long max ) { // Will flicker too much if we don't do this if ( max == 0 ) { return; @@ -198,44 +264,37 @@ void VideoWidget::updateSlider( long i, long max ) { } } } - void VideoWidget::setToggleButton( int i, bool down ) { if ( down != videoButtons[i].isDown ) { toggleButton( i ); } } - void VideoWidget::toggleButton( int i ) { videoButtons[i].isDown = !videoButtons[i].isDown; QPainter p(this); paintButton ( &p, i ); } - void VideoWidget::paintButton( QPainter *p, int i ) { - int x = videoButtons[i].xPos; - int y = videoButtons[i].yPos; - int offset = 10 + videoButtons[i].isDown; - p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); - p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); -} + 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++ ) { - int x = videoButtons[i].xPos; - int y = videoButtons[i].yPos; if ( event->state() == QMouseEvent::LeftButton ) { - // The test to see if the mouse click is inside the circular button or not - // (compared with the radius squared to avoid a square-root of our distance) - int radius = 16; - QPoint center = QPoint( x + radius, y + radius ); - QPoint dXY = center - event->pos(); - int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); - bool isOnButton = dist <= (radius * radius); + // 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 ); if ( isOnButton != videoButtons[i].isHeld ) { videoButtons[i].isHeld = isOnButton; toggleButton(i); } @@ -243,11 +302,9 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { if ( videoButtons[i].isHeld ) { videoButtons[i].isHeld = FALSE; if ( !videoButtons[i].isToggle ) setToggleButton( i, FALSE ); - qDebug("button toggled3 %d",i); } - } switch (i) { case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; case VideoStop: mediaPlayerState->setPlaying(FALSE); return; @@ -260,14 +317,12 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { } } - void VideoWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); } - void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { if ( mediaPlayerState->fullscreen() ) { mediaPlayerState->setFullscreen( FALSE ); makeVisible(); @@ -282,9 +337,9 @@ void VideoWidget::makeVisible() { setBackgroundMode( QWidget::NoBackground ); showFullScreen(); resize( qApp->desktop()->size() ); slider->hide(); - videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); + videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); } else { setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); showNormal(); showMaximized(); @@ -293,38 +348,65 @@ void VideoWidget::makeVisible() { } } -void VideoWidget::paintEvent( QPaintEvent * ) { +void VideoWidget::paintEvent( QPaintEvent * pe) { QPainter p( this ); if ( mediaPlayerState->fullscreen() ) { - // Clear the background - p.setBrush( QBrush( Qt::black ) ); + // Clear the background + p.setBrush( QBrush( Qt::black ) ); // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); } else { - // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); - // draw the buttons - - for ( int i = 0; i < numButtons; i++ ) { - paintButton( &p, i ); + // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); + // 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++ ) + paintButton( &p, i ); + QPainter p2( this ); + p2.drawPixmap( pe->rect().topLeft(), pix ); + } else { + QPainter p( this ); + for ( int i = 0; i < numButtons; i++ ) + paintButton( &p, i ); } - // draw the slider - slider->repaint( TRUE ); - } +// for ( int i = 0; i < numButtons; i++ ) { +// paintButton( &p, i ); +// } +// // draw the slider +// slider->repaint( TRUE ); + } } void VideoWidget::closeEvent( QCloseEvent* ) { mediaPlayerState->setList(); } +bool VideoWidget::playVideo() { + bool result = FALSE; + + int stream = 0; + + int sw = 240; + int sh = 320; + int dd = QPixmap::defaultDepth(); + int w = height(); + int h = width(); -void VideoWidget::keyReleaseEvent( QKeyEvent *e) -{ + return true; +} + +void VideoWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: break; @@ -369,13 +451,13 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) break; }; } + XineVideoWidget* VideoWidget::vidWidget() { return videoFrame; } -void VideoWidget::setFullscreen ( bool b ) -{ - setToggleButton( VideoFullscreen, b ); +void VideoWidget::setFullscreen ( bool b ) { + setToggleButton( VideoFullscreen, b ); } diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 04e810e..830696e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -55,8 +55,9 @@ class VideoWidget : public QWidget { 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( ); @@ -70,19 +71,33 @@ public slots: void setView( char ); signals: void sliderMoved( long ); - void videoResized ( const QSize &s ); + void videoResized ( const QSize &s ); protected: + QString skin; + void resizeEvent( QResizeEvent * ); void paintEvent( QPaintEvent *pe ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void closeEvent( QCloseEvent *event ); void keyReleaseEvent( QKeyEvent *e); private: +// Ticker songInfo; + QPixmap *pixBg; + QImage *imgUp; + QImage *imgDn; + QImage *imgButtonMask; + QBitmap *masks[7]; + QPixmap *buttonPixUp[7]; + QPixmap *buttonPixDown[7]; +// QPixmap *pixmaps[4]; + int xoff, yoff; + + void paintButton( QPainter *p, int i ); void toggleButton( int ); void setToggleButton( int, bool ); diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 98446a0..d65006b 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp @@ -38,230 +38,231 @@ #include <qdirectpainter_qws.h> #include <qgfx_qws.h> #include <qsize.h> #include <qapplication.h> +#include <qpainter.h> #include <qpe/resource.h> #include "xinevideowidget.h" static inline void memcpy_rev ( void *dst, void *src, size_t len ) { - ((char *) src ) += len; + ((char *) src ) += len; - len >>= 1; - while ( len-- ) - *((short int *) dst )++ = *--((short int *) src ); + len >>= 1; + while ( len-- ) + *((short int *) dst )++ = *--((short int *) src ); } static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) { - len >>= 1; - while ( len-- ) { - *((short int *) dst )++ = *((short int *) src ); - ((char *) src ) += step; - } + len >>= 1; + while ( len-- ) { + *((short int *) dst )++ = *((short int *) src ); + ((char *) src ) += step; + } } static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) { - len >>= 1; - - ((char *) src ) += ( len * step ); - - while ( len-- ) { - ((char *) src ) -= step; - *((short int *) dst )++ = *((short int *) src ); - } + len >>= 1; + + ((char *) src ) += ( len * step ); + + while ( len-- ) { + ((char *) src ) -= step; + *((short int *) dst )++ = *((short int *) src ); + } } XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) - : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) + : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) { - setBackgroundMode ( NoBackground ); + setBackgroundMode ( NoBackground ); - m_image = 0; - m_buff = 0; - m_bytes_per_line_fb = qt_screen-> linestep ( ); - m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; - m_rotation = 0; + m_image = 0; + m_buff = 0; + m_bytes_per_line_fb = qt_screen-> linestep ( ); + m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; + m_rotation = 0; } XineVideoWidget::~XineVideoWidget ( ) { - delete m_image; + delete m_image; } void XineVideoWidget::clear ( ) { - m_buff = 0; - repaint ( false ); + m_buff = 0; + repaint ( false ); } void XineVideoWidget::paintEvent ( QPaintEvent * ) { - //qWarning( "painting <<<" ); - if ( m_buff == 0 ) { - QPainter p ( this ); - p. fillRect ( rect ( ), black ); - if ( m_image ) - p. drawImage ( 0, 0, *m_image ); - //qWarning ( "logo\n" ); - } - else { -// qWarning ( "paintevent\n" ); - - QArray <QRect> qt_bug_workaround_clip_rects; - - { - QDirectPainter dp ( this ); - - int rot = dp. transformOrientation ( ) + m_rotation; - - uchar *fb = dp. frameBuffer ( ); - uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; - - QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); - - qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); - - for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { - const QRect &clip = dp. rect ( i ); - - qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); - - uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); - uchar *src = frame; - - switch ( rot ) { - case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; - case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; - case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; - case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; - } - - uint leftfill = 0; - uint framefill = 0; - uint rightfill = 0; - uint clipwidth = clip. width ( ) * m_bytes_per_pixel; - - if ( clip. left ( ) < framerect. left ( )) - leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; - if ( clip. right ( ) > framerect. right ( )) - rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; - - framefill = clipwidth - ( leftfill + rightfill ); - - for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { - if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { - memset ( dst, 0, clipwidth ); - } - else { - if ( leftfill ) - memset ( dst, 0, leftfill ); - - if ( framefill ) { - switch ( rot ) { - case 0: memcpy ( dst + leftfill, src, framefill ); break; - case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; - case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; - case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; - } - } - if ( rightfill ) - memset ( dst + leftfill + framefill, 0, rightfill ); - } - - dst += m_bytes_per_line_fb; - - switch ( rot ) { - case 0: src += m_bytes_per_line_frame; break; - case 1: src -= m_bytes_per_pixel; break; - case 2: src -= m_bytes_per_line_frame; break; - case 3: src += m_bytes_per_pixel; break; - } - } - } - } - //qWarning ( " ||| painting |||" ); - { - // QVFB hack by MArtin Jones - QPainter p ( this ); - - for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { - p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); - } - } - } - //qWarning( "painting >>>" ); + //qWarning( "painting <<<" ); + if ( m_buff == 0 ) { + QPainter p ( this ); + p. fillRect ( rect ( ), black ); + if ( m_image ) + p. drawImage ( 0, 0, *m_image ); + //qWarning ( "logo\n" ); + } + else { +// qWarning ( "paintevent\n" ); + + QArray <QRect> qt_bug_workaround_clip_rects; + + { + QDirectPainter dp ( this ); + + int rot = dp. transformOrientation ( ) + m_rotation; + + uchar *fb = dp. frameBuffer ( ); + uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; + + QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); + + qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); + + for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { + const QRect &clip = dp. rect ( i ); + + qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); + + uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); + uchar *src = frame; + + switch ( rot ) { + case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break; + case 1: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ) ); break; + case 2: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ) ); break; + case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break; + } + + uint leftfill = 0; + uint framefill = 0; + uint rightfill = 0; + uint clipwidth = clip. width ( ) * m_bytes_per_pixel; + + if ( clip. left ( ) < framerect. left ( )) + leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; + if ( clip. right ( ) > framerect. right ( )) + rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; + + framefill = clipwidth - ( leftfill + rightfill ); + + for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { + if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { + memset ( dst, 0, clipwidth ); + } + else { + if ( leftfill ) + memset ( dst, 0, leftfill ); + + if ( framefill ) { + switch ( rot ) { + case 0: memcpy ( dst + leftfill, src, framefill ); break; + case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; + case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; + case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; + } + } + if ( rightfill ) + memset ( dst + leftfill + framefill, 0, rightfill ); + } + + dst += m_bytes_per_line_fb; + + switch ( rot ) { + case 0: src += m_bytes_per_line_frame; break; + case 1: src -= m_bytes_per_pixel; break; + case 2: src -= m_bytes_per_line_frame; break; + case 3: src += m_bytes_per_pixel; break; + } + } + } + } + //qWarning ( " ||| painting |||" ); + { + // QVFB hack by MArtin Jones + QPainter p ( this ); + + for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { + p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); + } + } + } + //qWarning( "painting >>>" ); } void XineVideoWidget::setImage ( QImage* image ) { - delete m_image; - m_image = image; + delete m_image; + m_image = image; } void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) { - bool rot90 = (( -m_rotation ) & 1 ); + bool rot90 = (( -m_rotation ) & 1 ); - if ( rot90 ) { - int d = w; - w = h; - h = d; - } + if ( rot90 ) { + int d = w; + w = h; + h = d; + } - m_lastframe = m_thisframe; - m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); + m_lastframe = m_thisframe; + m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); -// qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); +// qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); - m_buff = img; - m_bytes_per_line_frame = bpl; + m_buff = img; + m_bytes_per_line_frame = bpl; - repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); + repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); } void XineVideoWidget::resizeEvent ( QResizeEvent * ) { - QSize s = size ( ); - bool fs = ( s == qApp-> desktop ( )-> size ( )); - - m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; - - if ( fs && qt_screen-> isTransformed ( )) { - s = qt_screen-> mapToDevice ( s ); - } - -// qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); - - emit videoResized ( s ); + QSize s = size ( ); + bool fs = ( s == qApp-> desktop ( )-> size ( )); + + m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; + + if ( fs && qt_screen-> isTransformed ( )) { + s = qt_screen-> mapToDevice ( s ); + } + +// qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); + + emit videoResized ( s ); } void XineVideoWidget::mousePressEvent ( QMouseEvent *me ) { - QWidget *p = parentWidget ( ); - - if ( p ) { - QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); - - QApplication::sendEvent ( p, &pme ); - } + QWidget *p = parentWidget ( ); + + if ( p ) { + QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); + + QApplication::sendEvent ( p, &pme ); + } } void XineVideoWidget::mouseReleaseEvent ( QMouseEvent *me ) { - QWidget *p = parentWidget ( ); - - if ( p ) { - QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); - - QApplication::sendEvent ( p, &pme ); - } + QWidget *p = parentWidget ( ); + + if ( p ) { + QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); + + QApplication::sendEvent ( p, &pme ); + } } |