summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/videowidget.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/videowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 238770b..c2080e6 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -63,49 +63,51 @@ struct MediaButton {
};
MediaButton videoButtons[] = {
{ FALSE, FALSE, FALSE }, // stop
{ TRUE, FALSE, FALSE }, // play
{ FALSE, FALSE, FALSE }, // previous
{ FALSE, FALSE, FALSE }, // next
{ 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 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 & )));
+ connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
Config cfg("OpiePlayer");
cfg.setGroup("Options");
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 );
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 ) ) )
@@ -322,97 +324,102 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
} else if ( !isOnButton && videoButtons[i].isHeld ) {
videoButtons[i].isHeld = FALSE;
toggleButton(i);
}
} else {
if ( videoButtons[i].isHeld ) {
videoButtons[i].isHeld = FALSE;
if ( !videoButtons[i].isToggle ) {
setToggleButton( i, FALSE );
}
switch(i) {
case VideoPlay: {
if( mediaPlayerState->isPaused ) {
setToggleButton( i, FALSE );
mediaPlayerState->setPaused( FALSE );
return;
} else if( !mediaPlayerState->isPaused ) {
setToggleButton( i, TRUE );
mediaPlayerState->setPaused( TRUE );
return;
} else {
- // setToggleButton( i, TRUE );
- // mediaPlayerState->setPlaying( videoButtons[i].isDown );
+ return;
}
}
case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
case VideoNext: mediaPlayerState->setNext(); return;
case VideoPrevious: mediaPlayerState->setPrev(); return;
case VideoVolUp: emit moreReleased(); return;
case VideoVolDown: emit lessReleased(); return;
case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
}
}
}
}
}
void VideoWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
if ( mediaPlayerState->fullscreen() ) {
mediaPlayerState->setFullscreen( FALSE );
makeVisible();
}
mouseMoveEvent( event );
}
void VideoWidget::showEvent( QShowEvent* ) {
QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
mouseMoveEvent( &event );
}
+ void VideoWidget::backToNormal() {
+ mediaPlayerState->setFullscreen( FALSE );
+ makeVisible();
+ }
+
void VideoWidget::makeVisible() {
- if ( mediaPlayerState->fullscreen() ) {
- setBackgroundMode( QWidget::NoBackground );
- showFullScreen();
- resize( qApp->desktop()->size() );
- slider->hide();
- videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
- } else {
- showNormal();
- showMaximized();
- slider->show();
- videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) );
- qApp->processEvents();
- }
+ if ( mediaPlayerState->fullscreen() ) {
+ setBackgroundMode( QWidget::NoBackground );
+ showFullScreen();
+ resize( qApp->desktop()->size() );
+ slider->hide();
+ videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
+
+ } else {
+ showNormal();
+ showMaximized();
+ slider->show();
+ videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
+ qApp->processEvents();
+ }
}
void VideoWidget::paintEvent( QPaintEvent * pe) {
QPainter p( this );
if ( mediaPlayerState->fullscreen() ) {
// Clear the background
p.setBrush( QBrush( Qt::black ) );
} else {
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 < numVButtons; i++ ) {
paintButton( &p, i );
}
QPainter p2( this );
p2.drawPixmap( pe->rect().topLeft(), pix );
} else {
QPainter p( this );
for ( int i = 0; i < numVButtons; i++ )