summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp33
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp32
4 files changed, 42 insertions, 41 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index bb686f1..bb07882 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -109,71 +109,62 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
AudioWidget::~AudioWidget() {
// mediaPlayerState->setPlaying(false);
}
namespace {
QPixmap combineImageWithBackground( 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 pix;
}
QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) {
QPixmap pixmap( pix );
pixmap.setMask( mask );
return pixmap;
}
};
-void AudioWidget::resizeEvent( QResizeEvent * ) {
+void AudioWidget::resizeEvent( QResizeEvent *e ) {
int h = height();
int w = width();
songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
slider.setFixedWidth( w - 110 );
slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
slider.setBackgroundOrigin( QWidget::ParentOrigin );
time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2;
upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10;
- QPoint p = upperLeftOfButtonMask;
- QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, p );
- QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, p );
-
- for ( uint i = 0; i < buttons.size(); i++ ) {
- if ( !buttons[i].mask.isNull() ) {
- buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
- buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
- }
- }
+ MediaWidget::resizeEvent( e );
}
void AudioWidget::sliderPressed() {
audioSliderBeingMoved = TRUE;
}
void AudioWidget::sliderReleased() {
audioSliderBeingMoved = FALSE;
if ( slider.width() == 0 )
return;
long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
mediaPlayerState.setPosition( val );
}
void AudioWidget::setPosition( long i ) {
// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
updateSlider( i, mediaPlayerState.length() );
}
void AudioWidget::setLength( long max ) {
updateSlider( mediaPlayerState.position(), max );
}
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index ab23aa8..ab2ec50 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -88,48 +88,65 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
{
QPainter p( this );
if ( mediaPlayerState.isFullscreen() ) {
// Clear the background
p.setBrush( QBrush( Qt::black ) );
return;
}
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(), backgroundPixmap, pe->rect().topLeft() );
paintAllButtons( p );
QPainter p2( this );
p2.drawPixmap( pe->rect().topLeft(), pix );
} else {
QPainter p( this );
paintAllButtons( p );
}
}
+void MediaWidget::resizeEvent( QResizeEvent *e )
+{
+ QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
+ QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
+
+ for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
+ Button &button = *it;
+
+ if ( button.mask.isNull() )
+ continue;
+ button.pixUp = addMaskToPixmap( pixUp, button.mask );
+ button.pixDown = addMaskToPixmap( pixDn, button.mask );
+ }
+
+ QWidget::resizeEvent( e );
+}
+
MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
{
if ( position.x() <= 0 || position.y() <= 0 ||
position.x() >= buttonMask.width() ||
position.y() >= buttonMask.height() )
return 0;
int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
if ( it->command + 1 == pixelIdx )
return &( *it );
return 0;
}
void MediaWidget::mousePressEvent( QMouseEvent *event )
{
Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
if ( !button ) {
QWidget::mousePressEvent( event );
return;
}
@@ -209,26 +226,42 @@ void MediaWidget::paintButton( QPainter &p, const Button &button )
}
void MediaWidget::setToggleButton( Command command, bool down )
{
for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
if ( it->command == command ) {
setToggleButton( *it, down );
return;
}
}
void MediaWidget::setToggleButton( Button &button, bool down )
{
if ( down != button.isDown )
toggleButton( button );
}
void MediaWidget::toggleButton( Button &button )
{
button.isDown = !button.isDown;
paintButton( button );
}
+QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset )
+{
+ QPixmap pix( image.size() );
+ QPainter p( &pix );
+ p.drawTiledPixmap( pix.rect(), background, offset );
+ p.drawImage( 0, 0, image );
+ return pix;
+}
+
+QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask )
+{
+ QPixmap result( pix );
+ result.setMask( mask );
+ return result;
+}
+
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 9f13677..4599637 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -91,60 +91,65 @@ public slots:
virtual void loadSkin() = 0;
signals:
void moreReleased();
void lessReleased();
void forwardReleased();
void backReleased();
void forwardClicked();
void backClicked();
void moreClicked();
void lessClicked();
protected:
void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
const Skin &skin );
Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin );
void loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix = QString::null );
void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin );
virtual void closeEvent( QCloseEvent * );
virtual void paintEvent( QPaintEvent *pe );
+ virtual void resizeEvent( QResizeEvent *e );
+
Button *buttonAt( const QPoint &position );
virtual void mousePressEvent( QMouseEvent *event );
virtual void mouseReleaseEvent( QMouseEvent *event );
virtual void makeVisible();
void handleCommand( Command command, bool buttonDown );
bool isOverButton( const QPoint &position, int buttonId ) const;
void paintAllButtons( QPainter &p );
void paintButton( const Button &button );
void paintButton( QPainter &p, const Button &button );
void setToggleButton( Button &button, bool down );
void setToggleButton( Command command, bool down );
void toggleButton( Button &button );
MediaPlayerState &mediaPlayerState;
PlayListWidget &playList;
ButtonVector buttons;
QImage buttonMask;
QPoint upperLeftOfButtonMask;
QPixmap backgroundPixmap;
QImage buttonUpImage;
QImage buttonDownImage;
+
+ static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset );
+ static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask );
};
#endif // MEDIAWIDGET_H
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index bc47717..a8ff540 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -78,95 +78,67 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
: MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false )
{
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() ) );
slider = 0;
loadSkin();
setLength( mediaPlayerState.length() );
setPosition( mediaPlayerState.position() );
setFullscreen( mediaPlayerState.isFullscreen() );
setPlaying( mediaPlayerState.isPlaying() );
}
VideoWidget::~VideoWidget()
{
}
-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( pix );
- pixmap.setMask( mask );
- return pixmap;
-}
-
-void VideoWidget::resizeEvent( QResizeEvent * ) {
+void VideoWidget::resizeEvent( QResizeEvent *e ) {
int h = height();
int w = width();
//int Vh = 160;
//int Vw = 220;
slider->setFixedWidth( w - 20 );
slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
slider->setBackgroundOrigin( QWidget::ParentOrigin );
slider->setFocusPolicy( QWidget::NoFocus );
slider->setBackgroundPixmap( backgroundPixmap );
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( buttonUpImage, backgroundPixmap, p );
- QPixmap *pixDn = combineVImageWithBackground( buttonDownImage, backgroundPixmap, p );
-
- for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
- Button &button = *it;
-
- if ( !button.mask.isNull() ) {
- button.pixUp = maskVPixToMask( *pixUp, button.mask );
- button.pixDown = maskVPixToMask( *pixDn, button.mask );
- }
- }
- delete pixUp;
- delete pixDn;
+ MediaWidget::resizeEvent( e );
}
void VideoWidget::sliderPressed() {
videoSliderBeingMoved = TRUE;
}
void VideoWidget::sliderReleased() {
videoSliderBeingMoved = FALSE;
if ( slider->width() == 0 ) {
return;
}
long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
mediaPlayerState.setPosition( val );
}
void VideoWidget::setPosition( long i ) {
updateSlider( i, mediaPlayerState.length() );
}
void VideoWidget::setLength( long max ) {
updateSlider( mediaPlayerState.position(), max );
}