summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 16:01:03 (UTC)
committer simon <simon>2002-12-09 16:01:03 (UTC)
commitd8aead05894e6a28b5aab45807ff2e6f27620f97 (patch) (side-by-side diff)
tree25b03bab434e42d3f8a134441b468ae5108e712a
parentf676d71c1fe40539ceb0c0708fdaefcc9b5e1800 (diff)
downloadopie-d8aead05894e6a28b5aab45807ff2e6f27620f97.zip
opie-d8aead05894e6a28b5aab45807ff2e6f27620f97.tar.gz
opie-d8aead05894e6a28b5aab45807ff2e6f27620f97.tar.bz2
- less hardcoding of numbers
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index f59772e..8409e5c 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -54,174 +54,175 @@
namespace
{
const int xo = 2; // movable x offset
const int yo = 0; // movable y offset
const char * const skinV_mask_file_names[7] = {
"play","stop","fwd","back","up","down","full"
};
}
VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
: MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 )
{
setCaption( tr("OpiePlayer - Video") );
Button defaultButton;
Button toggleButton = defaultButton;
toggleButton.type = ToggleButton;
buttons.push_back( toggleButton ); // play
buttons.push_back( toggleButton ); // stop
buttons.push_back( toggleButton ); // next
buttons.push_back( toggleButton ); // previous
buttons.push_back( toggleButton ); // volUp
buttons.push_back( toggleButton ); // volDown
buttons.push_back( toggleButton ); // fullscreen
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;
backgroundPixmap = 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 ];
+ uint i = 0;
+ for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it, ++i ) {
+ Button &button = *it;
QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
button.mask = QBitmap( filename );
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;
}
}
}
}
setBackgroundPixmap( backgroundPixmap );
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()
{
}
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 * ) {
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( imgUp, backgroundPixmap, p );
QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p );
- for ( int i = 0; i < 7; i++ ) {
- Button &button = buttons[ i ];
+ 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;
}
static bool videoSliderBeingMoved = FALSE;
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 );
}
void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
{
if ( displayType == MediaPlayerState::Video ) {
makeVisible();
return;
}
// Effectively blank the view next time we show it so it looks nicer
scaledWidth = 0;
scaledHeight = 0;
hide();
}