summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediawidget.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediawidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index db16b44..d60dc0d 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,95 +1,98 @@
/*
Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
(C) 2002 Max Reiss <harlekin@handhelds.org>
(C) 2002 L. Potter <ljp@llornkcor.com>
(C) 2002 Holger Freyther <zecke@handhelds.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "mediawidget.h"
#include "playlistwidget.h"
MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
: QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
{
connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
this, SLOT( setLength( long ) ) );
connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
this, SLOT( setPlaying( bool ) ) );
}
MediaWidget::~MediaWidget()
{
}
void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
const QString &imagePrefix, const QSize &buttonAreaSize )
{
buttonMask = QImage( buttonAreaSize, 8, 255 );
buttonMask.fill( 0 );
+ buttons.clear();
+ buttons.reserve( buttonCount );
+
for ( uint i = 0; i < buttonCount; ++i ) {
Button button = setupButton( skinInfo[ i ], imagePrefix );
buttons.push_back( button );
}
}
MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix )
{
Button button;
button.command = buttonInfo.command;
button.type = buttonInfo.type;
QString fileName = imagePrefix + buttonInfo.fileName + ".png";
button.mask = setupButtonMask( button.command, fileName );
return button;
}
QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName )
{
QBitmap mask( fileName );
if ( mask.isNull() )
return mask;
QImage imgMask = mask.convertToImage();
uchar **dest = buttonMask.jumpTable();
for ( int y = 0; y < buttonMask.height(); y++ ) {
uchar *line = dest[y];
for ( int x = 0; x < buttonMask.width(); x++ )
if ( !qRed( imgMask.pixel( x, y ) ) )
line[x] = command + 1;
}
return mask;
}
void MediaWidget::closeEvent( QCloseEvent * )
{
mediaPlayerState.setList();
}
void MediaWidget::paintEvent( QPaintEvent *pe )
{
QPainter p( this );
if ( mediaPlayerState.isFullscreen() ) {
// Clear the background