author | simon <simon> | 2002-12-11 01:24:05 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 01:24:05 (UTC) |
commit | 3ec7f32d0924c737664a6ad4dfb43dc3c20605d0 (patch) (side-by-side diff) | |
tree | bb9a9dcef582754293be5e1f7367c64e178c8243 | |
parent | d67ad1a6ef93d358beab268153cf2b0694e5f633 (diff) | |
download | opie-3ec7f32d0924c737664a6ad4dfb43dc3c20605d0.zip opie-3ec7f32d0924c737664a6ad4dfb43dc3c20605d0.tar.gz opie-3ec7f32d0924c737664a6ad4dfb43dc3c20605d0.tar.bz2 |
- make more use of the Resource::* api for loading the data
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index c9d7db8..865ff91 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -27,130 +27,130 @@ #include <qpe/config.h> #include <qpe/qpeapplication.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 ); + QBitmap mask( Resource::findPixmap( 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::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) { Config cfg( "OpiePlayer" ); cfg.setGroup( "Options" ); QString skin = cfg.readEntry( "Skin","default" ); loadSkin( skinInfo, buttonCount, skin, fileNameInfix ); } void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &name, const QString &fileNameInfix ) { QString skinPath = "opieplayer2/skins/" + name; backgroundPixmap = QPixmap( Resource::loadPixmap( QString( "%1/background" ).arg( skinPath ) ) ); buttonUpImage = QImage( Resource::loadImage( QString( "%1/skin%2_up" ).arg( skinPath ).arg( fileNameInfix ) ) ); buttonDownImage = QImage( Resource::loadImage( QString( "%1/skin%2_down" ).arg( skinPath ).arg( fileNameInfix ) ) ); setupButtons( skinInfo, buttonCount, - QPEApplication::qpeDir() + "/pics/" + skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( fileNameInfix ), buttonUpImage.size() ); + skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( fileNameInfix ), buttonUpImage.size() ); } void MediaWidget::closeEvent( QCloseEvent * ) { mediaPlayerState.setList(); } 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 ); } } 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 ) |