author | simon <simon> | 2002-12-11 17:18:17 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 17:18:17 (UTC) |
commit | 75f0ed4978579eb4b27cdece64c597741ed24b79 (patch) (unidiff) | |
tree | 6443323e08a9639ad0db7b5b1852d3804172e70a /noncore/multimedia/opieplayer2/skin.h | |
parent | 94461696cfdcf8cdbaabec1400300e546edc447e (diff) | |
download | opie-75f0ed4978579eb4b27cdece64c597741ed24b79.zip opie-75f0ed4978579eb4b27cdece64c597741ed24b79.tar.gz opie-75f0ed4978579eb4b27cdece64c597741ed24b79.tar.bz2 |
- added a skin cache and a threaded skin loader. looks like the latter
we have to disable though, because pure image loading with qt is
anything but threadsafe :(
Diffstat (limited to 'noncore/multimedia/opieplayer2/skin.h') (more/less context) (ignore 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,14 +1,17 @@ | |||
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 ); |
@@ -42,9 +45,58 @@ private: | |||
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 | */ |