summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/skin.h2
2 files changed, 0 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp
index d6f4080..a8f4ae9 100644
--- a/noncore/multimedia/opieplayer2/skin.cpp
+++ b/noncore/multimedia/opieplayer2/skin.cpp
@@ -57,72 +57,64 @@ private:
57 typedef QCache<QPixmap> BackgroundPixmapCache; 57 typedef QCache<QPixmap> BackgroundPixmapCache;
58 58
59 template <class CacheType> 59 template <class CacheType>
60 void store( const QCache<CacheType> &cache, const QString &key, CacheType *data ); 60 void store( const QCache<CacheType> &cache, const QString &key, CacheType *data );
61 61
62 DataCache m_cache; 62 DataCache m_cache;
63 BackgroundPixmapCache m_backgroundPixmapCache; 63 BackgroundPixmapCache m_backgroundPixmapCache;
64}; 64};
65 65
66Skin::Skin( const QString &name, const QString &fileNameInfix ) 66Skin::Skin( const QString &name, const QString &fileNameInfix )
67 : m_fileNameInfix( fileNameInfix ) 67 : m_fileNameInfix( fileNameInfix )
68{ 68{
69 init( name ); 69 init( name );
70} 70}
71 71
72Skin::Skin( const QString &fileNameInfix ) 72Skin::Skin( const QString &fileNameInfix )
73 : m_fileNameInfix( fileNameInfix ) 73 : m_fileNameInfix( fileNameInfix )
74{ 74{
75 init( defaultSkinName() ); 75 init( defaultSkinName() );
76} 76}
77 77
78Skin::~Skin() 78Skin::~Skin()
79{ 79{
80 SkinCache::self().store( m_skinPath, m_fileNameInfix, d ); 80 SkinCache::self().store( m_skinPath, m_fileNameInfix, d );
81} 81}
82 82
83void Skin::init( const QString &name ) 83void Skin::init( const QString &name )
84{ 84{
85 m_skinPath = "opieplayer2/skins/" + name; 85 m_skinPath = "opieplayer2/skins/" + name;
86 d = SkinCache::self().lookupAndTake( m_skinPath, m_fileNameInfix ); 86 d = SkinCache::self().lookupAndTake( m_skinPath, m_fileNameInfix );
87} 87}
88 88
89void Skin::preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount )
90{
91 backgroundPixmap();
92 buttonUpImage();
93 buttonDownImage();
94 ( void )buttonMask( skinButtonInfo, buttonCount );
95}
96
97QPixmap Skin::backgroundPixmap() const 89QPixmap Skin::backgroundPixmap() const
98{ 90{
99 if ( d->backgroundPixmap.isNull() ) 91 if ( d->backgroundPixmap.isNull() )
100 d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) ); 92 d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) );
101 return d->backgroundPixmap; 93 return d->backgroundPixmap;
102} 94}
103 95
104QImage Skin::buttonUpImage() const 96QImage Skin::buttonUpImage() const
105{ 97{
106 if ( d->buttonUpImage.isNull() ) 98 if ( d->buttonUpImage.isNull() )
107 d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); 99 d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) );
108 return d->buttonUpImage; 100 return d->buttonUpImage;
109} 101}
110 102
111QImage Skin::buttonDownImage() const 103QImage Skin::buttonDownImage() const
112{ 104{
113 if ( d->buttonDownImage.isNull() ) 105 if ( d->buttonDownImage.isNull() )
114 d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); 106 d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) );
115 return d->buttonDownImage; 107 return d->buttonDownImage;
116} 108}
117 109
118QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const 110QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const
119{ 111{
120 if ( !d->buttonMask.isNull() ) 112 if ( !d->buttonMask.isNull() )
121 return d->buttonMask; 113 return d->buttonMask;
122 114
123 QSize buttonAreaSize = buttonUpImage().size(); 115 QSize buttonAreaSize = buttonUpImage().size();
124 116
125 d->buttonMask = QImage( buttonAreaSize, 8, 255 ); 117 d->buttonMask = QImage( buttonAreaSize, 8, 255 );
126 d->buttonMask.fill( 0 ); 118 d->buttonMask.fill( 0 );
127 119
128 for ( uint i = 0; i < buttonCount; ++i ) 120 for ( uint i = 0; i < buttonCount; ++i )
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h
index 90062c2..bafebd3 100644
--- a/noncore/multimedia/opieplayer2/skin.h
+++ b/noncore/multimedia/opieplayer2/skin.h
@@ -9,66 +9,64 @@
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details. 15 General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to 18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef SKIN_H 23#ifndef SKIN_H
24#define SKIN_H 24#define SKIN_H
25 25
26#include <qstring.h> 26#include <qstring.h>
27#include <qimage.h> 27#include <qimage.h>
28#include <qobject.h> 28#include <qobject.h>
29 29
30#include "mediawidget.h" 30#include "mediawidget.h"
31 31
32struct SkinData; 32struct SkinData;
33 33
34class Skin 34class Skin
35{ 35{
36public: 36public:
37 Skin( const QString &name, const QString &fileNameInfix ); 37 Skin( const QString &name, const QString &fileNameInfix );
38 Skin( const QString &fileNameInfix ); 38 Skin( const QString &fileNameInfix );
39 ~Skin(); 39 ~Skin();
40 40
41 void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount );
42
43 QPixmap backgroundPixmap() const; 41 QPixmap backgroundPixmap() const;
44 QImage buttonUpImage() const; 42 QImage buttonUpImage() const;
45 QImage buttonDownImage() const; 43 QImage buttonDownImage() const;
46 44
47 QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const; 45 QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const;
48 46
49 QImage buttonMaskImage( const QString &fileName ) const; 47 QImage buttonMaskImage( const QString &fileName ) const;
50 48
51 static QString defaultSkinName(); 49 static QString defaultSkinName();
52 50
53private: 51private:
54 void init( const QString &name ); 52 void init( const QString &name );
55 53
56 void addButtonToMask( int tag, const QImage &maskImage ) const; 54 void addButtonToMask( int tag, const QImage &maskImage ) const;
57 55
58 static QImage loadImage( const QString &fileName ); 56 static QImage loadImage( const QString &fileName );
59 57
60 QString m_fileNameInfix; 58 QString m_fileNameInfix;
61 QString m_skinPath; 59 QString m_skinPath;
62 60
63 SkinData *d; 61 SkinData *d;
64 62
65 Skin( const Skin & ); 63 Skin( const Skin & );
66 Skin &operator=( const Skin & ); 64 Skin &operator=( const Skin & );
67}; 65};
68 66
69class SkinLoader : public QObject 67class SkinLoader : public QObject
70{ 68{
71 Q_OBJECT 69 Q_OBJECT
72public: 70public:
73 SkinLoader(); 71 SkinLoader();
74 virtual ~SkinLoader(); 72 virtual ~SkinLoader();