summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 12:34:12 (UTC)
committer simon <simon>2002-12-11 12:34:12 (UTC)
commit6f5e269efd9d6a5910251ce26750134e841f7b14 (patch) (side-by-side diff)
treedce5253f8007272eae4260dbf4b75e5ef451e553
parentd24ad11763335834718485f14e90d8dab2611fa2 (diff)
downloadopie-6f5e269efd9d6a5910251ce26750134e841f7b14.zip
opie-6f5e269efd9d6a5910251ce26750134e841f7b14.tar.gz
opie-6f5e269efd9d6a5910251ce26750134e841f7b14.tar.bz2
- starting with skin preloading
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp31
-rw-r--r--noncore/multimedia/opieplayer2/skin.h12
2 files changed, 37 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
@@ -1,35 +1,54 @@
#include "skin.h"
#include <qpe/resource.h>
Skin::Skin( const QString &name, const QString &fileNameInfix )
: m_name( name ), m_fileNameInfix( fileNameInfix )
{
m_skinPath = "opieplayer2/skins/" + name;
}
+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;
}
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;
}
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;
}
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;
}
/* vim: et sw=4 ts=4
*/
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h
index f160b3c..9276a5b 100644
--- a/noncore/multimedia/opieplayer2/skin.h
+++ b/noncore/multimedia/opieplayer2/skin.h
@@ -1,29 +1,41 @@
#ifndef SKIN_H
#define SKIN_H
#include <qstring.h>
#include <qimage.h>
+#include <qmap.h>
+
+#include "mediawidget.h"
class Skin
{
public:
Skin( const QString &name, const QString &fileNameInfix );
+ void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount );
+
QImage backgroundImage() const;
QImage buttonUpImage() const;
QImage buttonDownImage() const;
QImage buttonMaskImage( const QString &fileName ) const;
private:
QString m_name;
QString m_fileNameInfix;
QString m_skinPath;
+ typedef QMap<QString, QImage> ButtonMaskImageMap;
+
+ mutable QImage m_backgroundImage;
+ mutable QImage m_buttonUpImage;
+ mutable QImage m_buttonDownImage;
+ mutable ButtonMaskImageMap m_buttonMasks;
+
Skin( const Skin & );
Skin &operator=( const Skin & );
};
#endif // SKIN_H
/* vim: et sw=4 ts=4
*/