-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 22 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 2 |
2 files changed, 10 insertions, 14 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 7d85d63..089ef6a 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -87,37 +87,39 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); QString skinPath = "opieplayer2/skins/" + skin; pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); buttonMask.fill( 0 ); for ( int i = 0; i < 7; i++ ) { + Button &button = buttons[ i ]; + QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); - masks[i] = new QBitmap( filename ); + button.mask = QBitmap( filename ); - if ( !masks[i]->isNull() ) { - QImage imgMask = masks[i]->convertToImage(); + if ( !button.mask.isNull() ) { + QImage imgMask = button.mask.convertToImage(); uchar **dest = buttonMask.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; } @@ -126,42 +128,36 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye slider = new QSlider( Qt::Horizontal, this ); slider->setMinValue( 0 ); slider->setMaxValue( 1 ); slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); //slider->setFocusPolicy( QWidget::NoFocus ); resizeEvent( NULL ); setLength( mediaPlayerState.length() ); setPosition( mediaPlayerState.position() ); setFullscreen( mediaPlayerState.isFullscreen() ); setPlaying( mediaPlayerState.isPlaying() ); } VideoWidget::~VideoWidget() { - for ( int i = 0; i < 7; i++ ) { delete buttonPixUp[i]; delete buttonPixDown[i]; } - - 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 ); } QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { QPixmap *pixmap = new QPixmap( pix ); pixmap->setMask( mask ); return pixmap; } @@ -175,37 +171,39 @@ void VideoWidget::resizeEvent( QResizeEvent * ) { slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); slider->setBackgroundOrigin( QWidget::ParentOrigin ); slider->setFocusPolicy( QWidget::NoFocus ); slider->setBackgroundPixmap( pixBg ); upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; if(w>h) upperLeftOfButtonMask.ry() = 0; else upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; QPoint p = upperLeftOfButtonMask; QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); for ( int i = 0; i < 7; i++ ) { - if ( !masks[i]->isNull() ) { + Button &button = buttons[ i ]; + + if ( !button.mask.isNull() ) { delete buttonPixUp[i]; delete buttonPixDown[i]; - buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); - buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); + buttonPixUp[i] = maskVPixToMask( *pixUp, button.mask ); + buttonPixDown[i] = maskVPixToMask( *pixDn, button.mask ); } } delete pixUp; delete pixDn; } static bool videoSliderBeingMoved = FALSE; void VideoWidget::sliderPressed() { videoSliderBeingMoved = TRUE; } void VideoWidget::sliderReleased() { videoSliderBeingMoved = FALSE; if ( slider->width() == 0 ) { diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index cb6171c..fd301f9 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h @@ -87,37 +87,35 @@ signals: protected: void resizeEvent( QResizeEvent * ); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void keyReleaseEvent( QKeyEvent *e); private: // Ticker songInfo; QPixmap pixBg; QImage imgUp; QImage imgDn; - QBitmap *masks[7]; QPixmap *buttonPixUp[7]; QPixmap *buttonPixDown[7]; QString skin; -// QPixmap *pixmaps[4]; virtual void paintButton( QPainter &p, int i ); void setToggleButton( int, bool ); QString backgroundPix; QSlider *slider; QPixmap *pixmaps[3]; QImage *currentFrame; int scaledWidth; int scaledHeight; XineVideoWidget* videoFrame; }; #endif // VIDEO_WIDGET_H |