-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.h | 4 |
3 files changed, 9 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index edef2a7..46e7b6e 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp @@ -65,12 +65,13 @@ MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, return button; } void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo ) { Skin skin( guiInfo.fileNameInfix ); + skin.setCachable( false ); loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin ); } void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) { backgroundPixmap = skin.backgroundPixmap(); diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index a8f4ae9..44f5ca2 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp @@ -74,17 +74,21 @@ Skin::Skin( const QString &fileNameInfix ) { init( defaultSkinName() ); } Skin::~Skin() { + if ( m_isCachable ) SkinCache::self().store( m_skinPath, m_fileNameInfix, d ); + else + delete d; } void Skin::init( const QString &name ) { + m_isCachable = true; m_skinPath = "opieplayer2/skins/" + name; d = SkinCache::self().lookupAndTake( m_skinPath, m_fileNameInfix ); } QPixmap Skin::backgroundPixmap() const { diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h index bafebd3..067b6c4 100644 --- a/noncore/multimedia/opieplayer2/skin.h +++ b/noncore/multimedia/opieplayer2/skin.h @@ -35,12 +35,15 @@ class Skin { public: Skin( const QString &name, const QString &fileNameInfix ); Skin( const QString &fileNameInfix ); ~Skin(); + bool isCachable() const { return m_isCachable; } + void setCachable( bool cachable ) { m_isCachable = cachable; } + QPixmap backgroundPixmap() const; QImage buttonUpImage() const; QImage buttonDownImage() const; QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const; @@ -54,12 +57,13 @@ private: void addButtonToMask( int tag, const QImage &maskImage ) const; static QImage loadImage( const QString &fileName ); QString m_fileNameInfix; QString m_skinPath; + bool m_isCachable : 1; SkinData *d; Skin( const Skin & ); Skin &operator=( const Skin & ); }; |