Diffstat (limited to 'noncore/multimedia/opieplayer2/skin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.cpp | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index cef3259..9ad5f3f 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp @@ -29,2 +29,13 @@ +struct SkinData +{ + typedef QMap<QString, QImage> ButtonMaskImageMap; + + QImage backgroundImage; + QImage buttonUpImage; + QImage buttonDownImage; + QImage buttonMask; + ButtonMaskImageMap buttonMasks; +}; + Skin::Skin( const QString &name, const QString &fileNameInfix ) @@ -41,2 +52,7 @@ Skin::Skin( const QString &fileNameInfix ) +Skin::~Skin() +{ + delete d; +} + void Skin::init( const QString &name ) @@ -44,2 +60,3 @@ void Skin::init( const QString &name ) m_skinPath = "opieplayer2/skins/" + name; + d = new SkinData; } @@ -56,5 +73,5 @@ QImage Skin::backgroundImage() const { - if ( m_backgroundImage.isNull() ) - m_backgroundImage = SkinCache::self().loadImage( QString( "%1/background" ).arg( m_skinPath ) ); - return m_backgroundImage; + if ( d->backgroundImage.isNull() ) + d->backgroundImage = SkinCache::self().loadImage( QString( "%1/background" ).arg( m_skinPath ) ); + return d->backgroundImage; } @@ -63,5 +80,5 @@ QImage Skin::buttonUpImage() const { - if ( m_buttonUpImage.isNull() ) - m_buttonUpImage = SkinCache::self().loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); - return m_buttonUpImage; + if ( d->buttonUpImage.isNull() ) + d->buttonUpImage = SkinCache::self().loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); + return d->buttonUpImage; } @@ -70,5 +87,5 @@ QImage Skin::buttonDownImage() const { - if ( m_buttonDownImage.isNull() ) - m_buttonDownImage = SkinCache::self().loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); - return m_buttonDownImage; + if ( d->buttonDownImage.isNull() ) + d->buttonDownImage = SkinCache::self().loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); + return d->buttonDownImage; } @@ -77,4 +94,4 @@ QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint { - if ( !m_buttonMask.isNull() ) - return m_buttonMask; + if ( !d->buttonMask.isNull() ) + return d->buttonMask; @@ -82,4 +99,4 @@ QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint - m_buttonMask = QImage( buttonAreaSize, 8, 255 ); - m_buttonMask.fill( 0 ); + d->buttonMask = QImage( buttonAreaSize, 8, 255 ); + d->buttonMask.fill( 0 ); @@ -88,3 +105,3 @@ QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint - return m_buttonMask; + return d->buttonMask; } @@ -96,6 +113,6 @@ void Skin::addButtonToMask( int tag, const QImage &maskImage ) const - uchar **dest = m_buttonMask.jumpTable(); - for ( int y = 0; y < m_buttonMask.height(); y++ ) { + uchar **dest = d->buttonMask.jumpTable(); + for ( int y = 0; y < d->buttonMask.height(); y++ ) { uchar *line = dest[y]; - for ( int x = 0; x < m_buttonMask.width(); x++ ) + for ( int x = 0; x < d->buttonMask.width(); x++ ) if ( !qRed( maskImage.pixel( x, y ) ) ) @@ -107,7 +124,7 @@ QImage Skin::buttonMaskImage( const QString &fileName ) const { - ButtonMaskImageMap::Iterator it = m_buttonMasks.find( fileName ); - if ( it == m_buttonMasks.end() ) { + SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName ); + if ( it == d->buttonMasks.end() ) { QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); QString path = prefix + fileName + ".png"; - it = m_buttonMasks.insert( fileName, SkinCache::self().loadImage( path ) ); + it = d->buttonMasks.insert( fileName, SkinCache::self().loadImage( path ) ); } |