summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 12:34:12 (UTC)
committer simon <simon>2002-12-11 12:34:12 (UTC)
commit6f5e269efd9d6a5910251ce26750134e841f7b14 (patch) (unidiff)
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
@@ -8,28 +8,47 @@ Skin::Skin( const QString &name, const QString &fileNameInfix )
8{ 8{
9 m_skinPath = "opieplayer2/skins/" + name; 9 m_skinPath = "opieplayer2/skins/" + name;
10} 10}
11 11
12void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount )
13{
14 backgroundImage();
15 buttonUpImage();
16 buttonDownImage();
17 for ( uint i = 0; i < buttonCount; ++i )
18 ( void )buttonMaskImage( skinButtonInfo[ i ].fileName );
19}
20
12QImage Skin::backgroundImage() const 21QImage Skin::backgroundImage() const
13{ 22{
14 return QImage( Resource::findPixmap( QString( "%1/background" ).arg( m_skinPath ) ) ); 23 if ( m_backgroundImage.isNull() )
24 m_backgroundImage = QImage( Resource::findPixmap( QString( "%1/background" ).arg( m_skinPath ) ) );
25 return m_backgroundImage;
15} 26}
16 27
17QImage Skin::buttonUpImage() const 28QImage Skin::buttonUpImage() const
18{ 29{
19 return QImage( Resource::findPixmap( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); 30 if ( m_buttonUpImage.isNull() )
31 m_buttonUpImage = QImage( Resource::findPixmap( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) );
32 return m_buttonUpImage;
20} 33}
21 34
22QImage Skin::buttonDownImage() const 35QImage Skin::buttonDownImage() const
23{ 36{
24 return QImage( Resource::findPixmap( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) ); 37 if ( m_buttonDownImage.isNull() )
38 m_buttonDownImage = QImage( Resource::findPixmap( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ) );
39 return m_buttonDownImage;
25} 40}
26 41
27QImage Skin::buttonMaskImage( const QString &fileName ) const 42QImage Skin::buttonMaskImage( const QString &fileName ) const
28{ 43{
29 QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); 44 ButtonMaskImageMap::Iterator it = m_buttonMasks.find( fileName );
30 QString path = prefix + fileName + ".png"; 45 if ( it == m_buttonMasks.end() ) {
31 return QImage( Resource::findPixmap( path ) ); 46 QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix );
47 QString path = prefix + fileName + ".png";
48 it = m_buttonMasks.insert( fileName, QImage( Resource::findPixmap( path ) ) );
49 }
50 return *it;
32} 51}
33 52
34/* vim: et sw=4 ts=4 53/* vim: et sw=4 ts=4
35 */ 54 */
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
@@ -2,14 +2,19 @@
2#define SKIN_H 2#define SKIN_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qimage.h> 5#include <qimage.h>
6#include <qmap.h>
7
8#include "mediawidget.h"
6 9
7class Skin 10class Skin
8{ 11{
9public: 12public:
10 Skin( const QString &name, const QString &fileNameInfix ); 13 Skin( const QString &name, const QString &fileNameInfix );
11 14
15 void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount );
16
12 QImage backgroundImage() const; 17 QImage backgroundImage() const;
13 QImage buttonUpImage() const; 18 QImage buttonUpImage() const;
14 QImage buttonDownImage() const; 19 QImage buttonDownImage() const;
15 20
@@ -19,8 +24,15 @@ private:
19 QString m_name; 24 QString m_name;
20 QString m_fileNameInfix; 25 QString m_fileNameInfix;
21 QString m_skinPath; 26 QString m_skinPath;
22 27
28 typedef QMap<QString, QImage> ButtonMaskImageMap;
29
30 mutable QImage m_backgroundImage;
31 mutable QImage m_buttonUpImage;
32 mutable QImage m_buttonDownImage;
33 mutable ButtonMaskImageMap m_buttonMasks;
34
23 Skin( const Skin & ); 35 Skin( const Skin & );
24 Skin &operator=( const Skin & ); 36 Skin &operator=( const Skin & );
25}; 37};
26 38