summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/skin.h4
3 files changed, 10 insertions, 1 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
@@ -55,32 +55,33 @@ void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount
}
}
MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
{
Button button;
button.command = buttonInfo.command;
button.type = buttonInfo.type;
button.mask = skin.buttonMaskImage( buttonInfo.fileName );
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();
buttonUpImage = skin.buttonUpImage();
buttonDownImage = skin.buttonDownImage();
setupButtons( skinInfo, buttonCount, skin );
}
void MediaWidget::closeEvent( QCloseEvent * )
{
mediaPlayerState.setList();
}
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
@@ -64,37 +64,41 @@ private:
};
Skin::Skin( const QString &name, const QString &fileNameInfix )
: m_fileNameInfix( fileNameInfix )
{
init( name );
}
Skin::Skin( const QString &fileNameInfix )
: m_fileNameInfix( fileNameInfix )
{
init( defaultSkinName() );
}
Skin::~Skin()
{
- SkinCache::self().store( m_skinPath, m_fileNameInfix, d );
+ 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
{
if ( d->backgroundPixmap.isNull() )
d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) );
return d->backgroundPixmap;
}
QImage Skin::buttonUpImage() const
{
if ( d->buttonUpImage.isNull() )
d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) );
return d->buttonUpImage;
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
@@ -25,51 +25,55 @@
#include <qstring.h>
#include <qimage.h>
#include <qobject.h>
#include "mediawidget.h"
struct SkinData;
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;
QImage buttonMaskImage( const QString &fileName ) const;
static QString defaultSkinName();
private:
void init( const QString &name );
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 & );
};
class SkinLoader : public QObject
{
Q_OBJECT
public:
SkinLoader();
virtual ~SkinLoader();
void schedule( const MediaWidget::GUIInfo &guiInfo );
void schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo );