author | llornkcor <llornkcor> | 2002-08-10 17:41:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-10 17:41:15 (UTC) |
commit | b488752cf2149443dcebcc8f7ad21c1ba47070fa (patch) (side-by-side diff) | |
tree | 461adc8345f14d495466e5082f36651a844bde67 | |
parent | fb46a101bab9348ebfb68094b7c6cf54e56ea774 (diff) | |
download | opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.zip opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.gz opie-b488752cf2149443dcebcc8f7ad21c1ba47070fa.tar.bz2 |
added skins to videowidget, fixed fullscreen menu. Still needs work on buttonmask.
-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 | 226 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 15 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 1 |
7 files changed, 212 insertions, 82 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 @@ -139,3 +139,3 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : - QString skinPath = "opieplayer/skins/" + skin; + QString skinPath = "opieplayer2/skins/" + skin; pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").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 @@ -161,2 +161,5 @@ void MediaPlayerState::setPlaylist( bool b ) { void MediaPlayerState::setPaused( bool b ) { +if(b) qDebug("setPaused true"); + else qDebug("setPaused false"); + if ( 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 @@ -12,2 +12,3 @@ #include <qpe/applnk.h> +#include <qpopupmenu.h> #include <qpe/config.h> @@ -160,9 +161,15 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) - 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() ) ); + + Config cfg( "OpiePlayer" ); + bool b= cfg.readBoolEntry("FullScreen", 0); + mediaPlayerState->setFullscreen( b ); + pmView->setItemChecked( -16, b ); - 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); + pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), this, SLOT(toggleScaled() ) ); @@ -244,4 +251,7 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 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)), @@ -268,3 +278,2 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) - Config cfg( "OpiePlayer" ); readConfig( cfg ); @@ -1211 +1220,17 @@ void PlayListWidget::readPls(const QString &filename) { +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 @@ -9,2 +9,3 @@ #include <qpushbutton.h> +#include <qpopupmenu.h> @@ -27,3 +28,4 @@ public: QTabWidget * tabWidget; - QAction *fullScreenButton, *scaleButton; +// MenuItem *fullScreenButton, *scaleButton; +// QAction *fullScreenButton, *scaleButton; DocLnkSet files; @@ -32,2 +34,3 @@ public: QLabel *libString; + QPopupMenu *pmView ; bool fromSetDocument; @@ -69,2 +72,3 @@ private: private slots: + void pmViewActivated(int); void writem3u(); 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 @@ -34,2 +34,3 @@ #include <qpe/resource.h> +#include <qpe/mediaplayerplugininterface.h> #include <qpe/config.h> @@ -60,19 +61,18 @@ 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" +}; @@ -84,20 +84,42 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 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 Button0aPix, Button0bPix, controlsPix; - Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); - Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); - controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); + 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) ) ); - cfg.setGroup("AudioWidget"); - QString skin = cfg.readEntry("Skin","default"); - QString skinPath = "opieplayer/skins/" + skin; - backgroundPix = QString("%1/background").arg(skinPath) ; + imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); + imgButtonMask->fill( 0 ); - 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 ); + 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; + } + } + } + + } + + for ( int i = 0; i < 7; i++ ) { + buttonPixUp[i] = NULL; + buttonPixDown[i] = NULL; + } + + setBackgroundPixmap( *pixBg ); @@ -106,5 +128,3 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : slider->setMaxValue( 1 ); - - slider->setBackgroundPixmap( *this->backgroundPixmap () ); //Resource::loadPixmap( backgroundPix ) ); - slider->setBackgroundOrigin( QWidget::ParentOrigin); + slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); slider->setFocusPolicy( QWidget::NoFocus ); @@ -112,6 +132,2 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : - videoFrame = new XineVideoWidget ( this, "Video frame" ); - - connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); - connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); @@ -126,9 +142,10 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : - // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); - setFullscreen( mediaPlayerState->fullscreen() ); + + ////////////////////////// FIXME +// setFullscreen( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); - + qDebug("finished videowidget"); } @@ -137,11 +154,64 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 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; @@ -151,3 +221,2 @@ void VideoWidget::sliderPressed() { - void VideoWidget::sliderReleased() { @@ -161,3 +230,2 @@ void VideoWidget::sliderReleased() { - void VideoWidget::setPosition( long i ) { @@ -171,3 +239,2 @@ void VideoWidget::setLength( long max ) { - void VideoWidget::setView( char view ) { @@ -183,3 +250,2 @@ void VideoWidget::setView( char view ) { - void VideoWidget::updateSlider( long i, long max ) { @@ -201,3 +267,2 @@ void VideoWidget::updateSlider( long i, long max ) { - void VideoWidget::setToggleButton( int i, bool down ) { @@ -208,3 +273,2 @@ void VideoWidget::setToggleButton( int i, bool down ) { - void VideoWidget::toggleButton( int i ) { @@ -215,11 +279,9 @@ void VideoWidget::toggleButton( int 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] ); +} @@ -227,12 +289,9 @@ 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 ) { @@ -246,5 +305,3 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { setToggleButton( i, FALSE ); - qDebug("button toggled3 %d",i); } - } @@ -263,3 +320,2 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { - void VideoWidget::mousePressEvent( QMouseEvent *event ) { @@ -268,3 +324,2 @@ void VideoWidget::mousePressEvent( QMouseEvent *event ) { - void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { @@ -296,3 +351,3 @@ void VideoWidget::makeVisible() { -void VideoWidget::paintEvent( QPaintEvent * ) { +void VideoWidget::paintEvent( QPaintEvent * pe) { QPainter p( this ); @@ -309,7 +364,22 @@ void VideoWidget::paintEvent( QPaintEvent * ) { - for ( int i = 0; i < numButtons; i++ ) { + 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 ); } @@ -323,5 +393,17 @@ void VideoWidget::closeEvent( QCloseEvent* ) { +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() ) { @@ -372,2 +454,3 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) } + XineVideoWidget* VideoWidget::vidWidget() { @@ -377,4 +460,3 @@ XineVideoWidget* VideoWidget::vidWidget() { -void VideoWidget::setFullscreen ( bool 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 @@ -58,2 +58,3 @@ public: + bool playVideo(); XineVideoWidget* vidWidget(); @@ -76,2 +77,4 @@ signals: protected: + QString skin; + void resizeEvent( QResizeEvent * ); void paintEvent( QPaintEvent *pe ); @@ -84,2 +87,14 @@ protected: 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 ); 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 @@ -41,2 +41,3 @@ #include <qapplication.h> +#include <qpainter.h> |