summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 18:34:16 (UTC)
committer simon <simon>2002-12-11 18:34:16 (UTC)
commitb8db7cfea977d20f2d491b0a208a237efb15019a (patch) (unidiff)
treefe9d4a5613af7fc3bb202b679af6021c3b95db08
parentf3d21af83a2846d1c20fc845cf88329ff1f2b1a9 (diff)
downloadopie-b8db7cfea977d20f2d491b0a208a237efb15019a.zip
opie-b8db7cfea977d20f2d491b0a208a237efb15019a.tar.gz
opie-b8db7cfea977d20f2d491b0a208a237efb15019a.tar.bz2
- moved the skin cache into the .cpp file
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/skin.cpp16
-rw-r--r--noncore/multimedia/opieplayer2/skin.h16
2 files changed, 16 insertions, 16 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp
index 9ad5f3f..06453f9 100644
--- a/noncore/multimedia/opieplayer2/skin.cpp
+++ b/noncore/multimedia/opieplayer2/skin.cpp
@@ -12,41 +12,57 @@
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#include "skin.h" 23#include "skin.h"
24#include "singleton.h"
24 25
25#include <qpe/resource.h> 26#include <qpe/resource.h>
26#include <qpe/config.h> 27#include <qpe/config.h>
27 28
28#include <assert.h> 29#include <assert.h>
29 30
30struct SkinData 31struct SkinData
31{ 32{
32 typedef QMap<QString, QImage> ButtonMaskImageMap; 33 typedef QMap<QString, QImage> ButtonMaskImageMap;
33 34
34 QImage backgroundImage; 35 QImage backgroundImage;
35 QImage buttonUpImage; 36 QImage buttonUpImage;
36 QImage buttonDownImage; 37 QImage buttonDownImage;
37 QImage buttonMask; 38 QImage buttonMask;
38 ButtonMaskImageMap buttonMasks; 39 ButtonMaskImageMap buttonMasks;
39}; 40};
40 41
42class SkinCache : public Singleton<SkinCache>
43{
44public:
45 SkinCache();
46
47 QImage loadImage( const QString &name );
48
49private:
50 typedef QDict<QImage> ImageCache;
51
52 ImageCache m_cache;
53
54 ThreadUtil::Mutex m_cacheGuard;
55};
56
41Skin::Skin( const QString &name, const QString &fileNameInfix ) 57Skin::Skin( const QString &name, const QString &fileNameInfix )
42 : m_fileNameInfix( fileNameInfix ) 58 : m_fileNameInfix( fileNameInfix )
43{ 59{
44 init( name ); 60 init( name );
45} 61}
46 62
47Skin::Skin( const QString &fileNameInfix ) 63Skin::Skin( const QString &fileNameInfix )
48 : m_fileNameInfix( fileNameInfix ) 64 : m_fileNameInfix( fileNameInfix )
49{ 65{
50 init( defaultSkinName() ); 66 init( defaultSkinName() );
51} 67}
52 68
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h
index 5ab6574..060ff73 100644
--- a/noncore/multimedia/opieplayer2/skin.h
+++ b/noncore/multimedia/opieplayer2/skin.h
@@ -21,25 +21,24 @@
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 <qmap.h> 28#include <qmap.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include "mediawidget.h" 31#include "mediawidget.h"
32#include "threadutil.h" 32#include "threadutil.h"
33#include "singleton.h"
34 33
35struct SkinData; 34struct SkinData;
36 35
37class Skin 36class Skin
38{ 37{
39public: 38public:
40 Skin( const QString &name, const QString &fileNameInfix ); 39 Skin( const QString &name, const QString &fileNameInfix );
41 Skin( const QString &fileNameInfix ); 40 Skin( const QString &fileNameInfix );
42 ~Skin(); 41 ~Skin();
43 42
44 void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ); 43 void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount );
45 44
@@ -58,39 +57,24 @@ private:
58 57
59 void addButtonToMask( int tag, const QImage &maskImage ) const; 58 void addButtonToMask( int tag, const QImage &maskImage ) const;
60 59
61 QString m_fileNameInfix; 60 QString m_fileNameInfix;
62 QString m_skinPath; 61 QString m_skinPath;
63 62
64 SkinData *d; 63 SkinData *d;
65 64
66 Skin( const Skin & ); 65 Skin( const Skin & );
67 Skin &operator=( const Skin & ); 66 Skin &operator=( const Skin & );
68}; 67};
69 68
70class SkinCache : public Singleton<SkinCache>
71{
72public:
73 SkinCache();
74
75 QImage loadImage( const QString &name );
76
77private:
78 typedef QDict<QImage> ImageCache;
79
80 ImageCache m_cache;
81
82 ThreadUtil::Mutex m_cacheGuard;
83};
84
85class SkinLoader : public ThreadUtil::Thread 69class SkinLoader : public ThreadUtil::Thread
86{ 70{
87public: 71public:
88 SkinLoader(); 72 SkinLoader();
89 73
90 void schedule( const QString &skinName, const QString &fileNameInfix, 74 void schedule( const QString &skinName, const QString &fileNameInfix,
91 const MediaWidget::SkinButtonInfo *skinButtonInfo, const uint buttonCount ); 75 const MediaWidget::SkinButtonInfo *skinButtonInfo, const uint buttonCount );
92 76
93protected: 77protected:
94 virtual void run(); 78 virtual void run();
95 79
96private: 80private: