Diffstat (limited to 'noncore/multimedia/opieplayer2/skin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index fb1c9c4..7d05d80 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp @@ -11,5 +11,16 @@ Skin::Skin( const QString &name, const QString &fileNameInfix ) +void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) +{ + backgroundImage(); + buttonUpImage(); + buttonDownImage(); + for ( uint i = 0; i < buttonCount; ++i ) + ( void )buttonMaskImage( skinButtonInfo[ i ].fileName ); +} + QImage Skin::backgroundImage() const { - return QImage( Resource::findPixmap( QString( "%1/background" ).arg( m_skinPath ) ) ); + if ( m_backgroundImage.isNull() ) + m_backgroundImage = QImage( Resource::findPixmap( QString( "%1/background" ).arg( m_skinPath ) ) ); + return m_backgroundImage; } @@ -18,3 +29,5 @@ QImage Skin::buttonUpImage() const { - return QImage( Resource::findPixmap( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); + if ( m_buttonUpImage.isNull() ) + m_buttonUpImage = QImage( Resource::findPixmap( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); + return m_buttonUpImage; } @@ -23,3 +36,5 @@ QImage Skin::buttonDownImage() const { - return QImage( Resource::findPixmap( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); + if ( m_buttonDownImage.isNull() ) + m_buttonDownImage = QImage( Resource::findPixmap( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); + return m_buttonDownImage; } @@ -28,5 +43,9 @@ QImage Skin::buttonMaskImage( const QString &fileName ) const { - QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); - QString path = prefix + fileName + ".png"; - return QImage( Resource::findPixmap( path ) ); + ButtonMaskImageMap::Iterator it = m_buttonMasks.find( fileName ); + if ( it == m_buttonMasks.end() ) { + QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); + QString path = prefix + fileName + ".png"; + it = m_buttonMasks.insert( fileName, QImage( Resource::findPixmap( path ) ) ); + } + return *it; } |