summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/skin.h
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/skin.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/skin.h53
1 files changed, 36 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.h b/noncore/multimedia/opieplayer2/skin.h
index 9180067..a43a1d0 100644
--- a/noncore/multimedia/opieplayer2/skin.h
+++ b/noncore/multimedia/opieplayer2/skin.h
@@ -4,102 +4,121 @@
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This program is free software; you can redistribute it and/or 7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public 8 modify it under the terms of the GNU General Public
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 29
29#include "mediawidget.h" 30#include "mediawidget.h"
30#include "threadutil.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 ); 41 void preload( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount );
42 42
43 QImage backgroundImage() const; 43 QImage backgroundImage() const;
44 QImage buttonUpImage() const; 44 QImage buttonUpImage() const;
45 QImage buttonDownImage() const; 45 QImage buttonDownImage() const;
46 46
47 QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const; 47 QImage buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const;
48 48
49 QImage buttonMaskImage( const QString &fileName ) const; 49 QImage buttonMaskImage( const QString &fileName ) const;
50 50
51 static QString defaultSkinName(); 51 static QString defaultSkinName();
52 52
53private: 53private:
54 void init( const QString &name ); 54 void init( const QString &name );
55 55
56 void addButtonToMask( int tag, const QImage &maskImage ) const; 56 void addButtonToMask( int tag, const QImage &maskImage ) const;
57 57
58 static QImage loadImage( const QString &fileName ); 58 static QImage loadImage( const QString &fileName );
59 59
60 QString m_fileNameInfix; 60 QString m_fileNameInfix;
61 QString m_skinPath; 61 QString m_skinPath;
62 62
63 SkinData *d; 63 SkinData *d;
64 64
65 Skin( const Skin & ); 65 Skin( const Skin & );
66 Skin &operator=( const Skin & ); 66 Skin &operator=( const Skin & );
67}; 67};
68 68
69class SkinLoader : public ThreadUtil::Thread 69class SkinLoader : public QObject
70{ 70{
71 Q_OBJECT
71public: 72public:
72 SkinLoader(); 73 SkinLoader();
74 virtual ~SkinLoader();
73 75
74 void schedule( const QString &skinName, const QString &fileNameInfix, 76 void schedule( const MediaWidget::GUIInfo &guiInfo );
75 const MediaWidget::SkinButtonInfo *skinButtonInfo, const uint buttonCount ); 77 void schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo );
78
79 void start();
76 80
77protected: 81protected:
78 virtual void run(); 82 virtual void timerEvent( QTimerEvent *ev );
83
84private slots:
85 void deleteMe();
79 86
80private: 87private:
81 struct Info 88 struct Info : public MediaWidget::GUIInfo
82 { 89 {
83 Info() : skinButtonInfo( 0 ), buttonCount( 0 ) {} 90 Info() {}
84 Info( const QString &_skinName, const QString &_fileNameInfix, 91 Info( const QString &_skinName, const MediaWidget::GUIInfo &guiInfo )
85 const MediaWidget::SkinButtonInfo *_skinButtonInfo, const uint _buttonCount ) 92 : MediaWidget::GUIInfo( guiInfo ), skinName( _skinName )
86 : skinName( _skinName ), fileNameInfix( _fileNameInfix ),
87 skinButtonInfo( _skinButtonInfo ), buttonCount( _buttonCount )
88 {} 93 {}
89 94
90 const QString skinName; 95 QString skinName;
91 const QString fileNameInfix;
92 const MediaWidget::SkinButtonInfo *skinButtonInfo;
93 const uint buttonCount;
94 }; 96 };
95 typedef QValueList<Info> InfoList; 97 typedef QValueList<Info> InfoList;
96 98
97 void load( const Info &nfo ); 99 class IncrementalLoader
100 {
101 public:
102 enum LoaderResult { LoadingCompleted, MoreToCome };
103
104 IncrementalLoader( const Info &info );
105
106 LoaderResult loadStep();
107
108 private:
109 enum State { LoadBackgroundImage, LoadButtonUpImage, LoadButtonDownImage, LoadButtonMasks, LoadButtonMask };
110
111 Skin m_skin;
112 Info m_info;
113 State m_currentState;
114 uint m_currentButton;
115 };
98 116
99 InfoList pendingSkins; 117 InfoList pendingSkins;
100 ThreadUtil::Mutex guard; 118 IncrementalLoader *m_currentLoader;
119 int m_timerId;
101}; 120};
102 121
103#endif // SKIN_H 122#endif // SKIN_H
104/* vim: et sw=4 ts=4 123/* vim: et sw=4 ts=4
105 */ 124 */