Diffstat (limited to 'noncore/multimedia/opieplayer2/skin.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h index 58f1849..c15d9dc 100644 --- a/noncore/multimedia/opieplayer2/skin.h +++ b/noncore/multimedia/opieplayer2/skin.h | |||
@@ -1,50 +1,102 @@ | |||
1 | #ifndef SKIN_H | 1 | #ifndef SKIN_H |
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> | 6 | #include <qmap.h> |
7 | #include <qdict.h> | ||
7 | 8 | ||
8 | #include "mediawidget.h" | 9 | #include "mediawidget.h" |
10 | #include "threadutil.h" | ||
11 | #include "singleton.h" | ||
9 | 12 | ||
10 | class Skin | 13 | class Skin |
11 | { | 14 | { |
12 | public: | 15 | public: |
13 | Skin( const QString &name, const QString &fileNameInfix ); | 16 | Skin( const QString &name, const QString &fileNameInfix ); |
14 | Skin( const QString &fileNameInfix ); | 17 | Skin( const QString &fileNameInfix ); |
15 | 18 | ||
16 | void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ); | 19 | void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ); |
17 | 20 | ||
18 | QImage backgroundImage() const; | 21 | QImage backgroundImage() const; |
19 | QImage buttonUpImage() const; | 22 | QImage buttonUpImage() const; |
20 | QImage buttonDownImage() const; | 23 | QImage buttonDownImage() const; |
21 | 24 | ||
22 | QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const; | 25 | QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const; |
23 | 26 | ||
24 | QImage buttonMaskImage( const QString &fileName ) const; | 27 | QImage buttonMaskImage( const QString &fileName ) const; |
25 | 28 | ||
26 | static QString defaultSkinName(); | 29 | static QString defaultSkinName(); |
27 | 30 | ||
28 | private: | 31 | private: |
29 | void init( const QString &name ); | 32 | void init( const QString &name ); |
30 | 33 | ||
31 | void addButtonToMask( int tag, const QImage &maskImage ) const; | 34 | void addButtonToMask( int tag, const QImage &maskImage ) const; |
32 | 35 | ||
33 | QString m_fileNameInfix; | 36 | QString m_fileNameInfix; |
34 | QString m_skinPath; | 37 | QString m_skinPath; |
35 | 38 | ||
36 | typedef QMap<QString, QImage> ButtonMaskImageMap; | 39 | typedef QMap<QString, QImage> ButtonMaskImageMap; |
37 | 40 | ||
38 | mutable QImage m_backgroundImage; | 41 | mutable QImage m_backgroundImage; |
39 | mutable QImage m_buttonUpImage; | 42 | mutable QImage m_buttonUpImage; |
40 | mutable QImage m_buttonDownImage; | 43 | mutable QImage m_buttonDownImage; |
41 | mutable QImage m_buttonMask; | 44 | mutable QImage m_buttonMask; |
42 | mutable ButtonMaskImageMap m_buttonMasks; | 45 | mutable ButtonMaskImageMap m_buttonMasks; |
43 | 46 | ||
44 | Skin( const Skin & ); | 47 | Skin( const Skin & ); |
45 | Skin &operator=( const Skin & ); | 48 | Skin &operator=( const Skin & ); |
46 | }; | 49 | }; |
47 | 50 | ||
51 | class SkinCache : public Singleton<SkinCache> | ||
52 | { | ||
53 | public: | ||
54 | SkinCache(); | ||
55 | |||
56 | QImage loadImage( const QString &name ); | ||
57 | |||
58 | private: | ||
59 | typedef QDict<QImage> ImageCache; | ||
60 | |||
61 | ImageCache m_cache; | ||
62 | |||
63 | ThreadUtil::Mutex m_cacheGuard; | ||
64 | }; | ||
65 | |||
66 | class SkinLoader : public ThreadUtil::Thread | ||
67 | { | ||
68 | public: | ||
69 | SkinLoader(); | ||
70 | |||
71 | void schedule( const QString &skinName, const QString &fileNameInfix, | ||
72 | const MediaWidget::SkinButtonInfo *skinButtonInfo, const uint buttonCount ); | ||
73 | |||
74 | protected: | ||
75 | virtual void run(); | ||
76 | |||
77 | private: | ||
78 | struct Info | ||
79 | { | ||
80 | Info() : skinButtonInfo( 0 ), buttonCount( 0 ) {} | ||
81 | Info( const QString &_skinName, const QString &_fileNameInfix, | ||
82 | const MediaWidget::SkinButtonInfo *_skinButtonInfo, const uint _buttonCount ) | ||
83 | : skinName( _skinName ), fileNameInfix( _fileNameInfix ), | ||
84 | skinButtonInfo( _skinButtonInfo ), buttonCount( _buttonCount ) | ||
85 | {} | ||
86 | |||
87 | const QString skinName; | ||
88 | const QString fileNameInfix; | ||
89 | const MediaWidget::SkinButtonInfo *skinButtonInfo; | ||
90 | const uint buttonCount; | ||
91 | }; | ||
92 | typedef QValueList<Info> InfoList; | ||
93 | |||
94 | void load( const Info &nfo ); | ||
95 | |||
96 | InfoList pendingSkins; | ||
97 | ThreadUtil::Mutex guard; | ||
98 | }; | ||
99 | |||
48 | #endif // SKIN_H | 100 | #endif // SKIN_H |
49 | /* vim: et sw=4 ts=4 | 101 | /* vim: et sw=4 ts=4 |
50 | */ | 102 | */ |