author | drw <drw> | 2005-06-03 23:48:20 (UTC) |
---|---|---|
committer | drw <drw> | 2005-06-03 23:48:20 (UTC) |
commit | 0fcaa971ee658effa1dc36205df6dfbc43a6b0ad (patch) (unidiff) | |
tree | 1c491aa1cad74935d52312520b32892b303a99e3 | |
parent | 89422e1c42f39e576002e15e1a5a1d51f6053c74 (diff) | |
download | opie-0fcaa971ee658effa1dc36205df6dfbc43a6b0ad.zip opie-0fcaa971ee658effa1dc36205df6dfbc43a6b0ad.tar.gz opie-0fcaa971ee658effa1dc36205df6dfbc43a6b0ad.tar.bz2 |
Fix compile error...sorry Mickey...finally remembered to do this...
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index b95c544..bd176e3 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp | |||
@@ -1,329 +1,329 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <simon@lst.de> | 2 | Copyright (C) 2002 Simon Hausmann <simon@lst.de> |
3 | (C) 2002 Max Reiss <harlekin@handhelds.org> | 3 | (C) 2002 Max Reiss <harlekin@handhelds.org> |
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 | #include "skin.h" | 23 | #include "skin.h" |
24 | #include "singleton.h" | 24 | #include "singleton.h" |
25 | 25 | ||
26 | /* OPIE */ | 26 | /* OPIE */ |
27 | #include <opie2/odebug.h> | 27 | #include <opie2/odebug.h> |
28 | #include <opie2/oresource.h> | 28 | #include <opie2/oresource.h> |
29 | using namespace Opie::Core; | 29 | using namespace Opie::Core; |
30 | #include <qpe/config.h> | 30 | #include <qpe/config.h> |
31 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
32 | 32 | ||
33 | /* QT */ | 33 | /* QT */ |
34 | #include <qcache.h> | 34 | #include <qcache.h> |
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | 36 | ||
37 | /* STD */ | 37 | /* STD */ |
38 | #include <assert.h> | 38 | #include <assert.h> |
39 | 39 | ||
40 | struct SkinData | 40 | struct SkinData |
41 | { | 41 | { |
42 | typedef QMap<QString, QImage> ButtonMaskImageMap; | 42 | typedef QMap<QString, QImage> ButtonMaskImageMap; |
43 | 43 | ||
44 | QPixmap backgroundPixmap; | 44 | QPixmap backgroundPixmap; |
45 | QImage buttonUpImage; | 45 | QImage buttonUpImage; |
46 | QImage buttonDownImage; | 46 | QImage buttonDownImage; |
47 | QImage buttonMask; | 47 | QImage buttonMask; |
48 | ButtonMaskImageMap buttonMasks; | 48 | ButtonMaskImageMap buttonMasks; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | class SkinCache : public Singleton<SkinCache> | 51 | class SkinCache : public Singleton<SkinCache> |
52 | { | 52 | { |
53 | public: | 53 | public: |
54 | SkinCache(); | 54 | SkinCache(); |
55 | 55 | ||
56 | SkinData *lookupAndTake( const QString &skinPath, const QString &fileNameInfix ); | 56 | SkinData *lookupAndTake( const QString &skinPath, const QString &fileNameInfix ); |
57 | 57 | ||
58 | void store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ); | 58 | void store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ); |
59 | 59 | ||
60 | private: | 60 | private: |
61 | typedef QCache<SkinData> DataCache; | 61 | typedef QCache<SkinData> DataCache; |
62 | typedef QCache<QPixmap> BackgroundPixmapCache; | 62 | typedef QCache<QPixmap> BackgroundPixmapCache; |
63 | 63 | ||
64 | template <class CacheType> | 64 | template <class CacheType> |
65 | void store( const QCache<CacheType> &cache, const QString &key, CacheType *data ); | 65 | void store( const QCache<CacheType> &cache, const QString &key, CacheType *data ); |
66 | 66 | ||
67 | DataCache m_cache; | 67 | DataCache m_cache; |
68 | BackgroundPixmapCache m_backgroundPixmapCache; | 68 | BackgroundPixmapCache m_backgroundPixmapCache; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | Skin::Skin( const QString &name, const QString &fileNameInfix ) | 71 | Skin::Skin( const QString &name, const QString &fileNameInfix ) |
72 | : m_fileNameInfix( fileNameInfix ) | 72 | : m_fileNameInfix( fileNameInfix ) |
73 | { | 73 | { |
74 | init( name ); | 74 | init( name ); |
75 | } | 75 | } |
76 | 76 | ||
77 | Skin::Skin( const QString &fileNameInfix ) | 77 | Skin::Skin( const QString &fileNameInfix ) |
78 | : m_fileNameInfix( fileNameInfix ) | 78 | : m_fileNameInfix( fileNameInfix ) |
79 | { | 79 | { |
80 | init( defaultSkinName() ); | 80 | init( defaultSkinName() ); |
81 | } | 81 | } |
82 | 82 | ||
83 | Skin::~Skin() | 83 | Skin::~Skin() |
84 | { | 84 | { |
85 | if ( m_isCachable ) | 85 | if ( m_isCachable ) |
86 | SkinCache::self().store( m_skinPath, m_fileNameInfix, d ); | 86 | SkinCache::self().store( m_skinPath, m_fileNameInfix, d ); |
87 | else | 87 | else |
88 | delete d; | 88 | delete d; |
89 | } | 89 | } |
90 | 90 | ||
91 | void Skin::init( const QString &name ) | 91 | void Skin::init( const QString &name ) |
92 | { | 92 | { |
93 | m_isCachable = true; | 93 | m_isCachable = true; |
94 | m_skinPath = "opieplayer2/skins/" + name; | 94 | m_skinPath = "opieplayer2/skins/" + name; |
95 | d = SkinCache::self().lookupAndTake( m_skinPath, m_fileNameInfix ); | 95 | d = SkinCache::self().lookupAndTake( m_skinPath, m_fileNameInfix ); |
96 | } | 96 | } |
97 | 97 | ||
98 | QPixmap Skin::backgroundPixmap() const | 98 | QPixmap Skin::backgroundPixmap() const |
99 | { | 99 | { |
100 | if ( d->backgroundPixmap.isNull() ) | 100 | if ( d->backgroundPixmap.isNull() ) |
101 | d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) ); | 101 | d->backgroundPixmap = loadImage( QString( "%1/background" ).arg( m_skinPath ) ); |
102 | return d->backgroundPixmap; | 102 | return d->backgroundPixmap; |
103 | } | 103 | } |
104 | 104 | ||
105 | QImage Skin::buttonUpImage() const | 105 | QImage Skin::buttonUpImage() const |
106 | { | 106 | { |
107 | if ( d->buttonUpImage.isNull() ) | 107 | if ( d->buttonUpImage.isNull() ) |
108 | d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); | 108 | d->buttonUpImage = loadImage( QString( "%1/skin%2_up" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); |
109 | return d->buttonUpImage; | 109 | return d->buttonUpImage; |
110 | } | 110 | } |
111 | 111 | ||
112 | QImage Skin::buttonDownImage() const | 112 | QImage Skin::buttonDownImage() const |
113 | { | 113 | { |
114 | if ( d->buttonDownImage.isNull() ) | 114 | if ( d->buttonDownImage.isNull() ) |
115 | d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); | 115 | d->buttonDownImage = loadImage( QString( "%1/skin%2_down" ).arg( m_skinPath ).arg( m_fileNameInfix ) ); |
116 | return d->buttonDownImage; | 116 | return d->buttonDownImage; |
117 | } | 117 | } |
118 | 118 | ||
119 | QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const | 119 | QImage Skin::buttonMask( const MediaWidget::SkinButtonInfo *skinButtonInfo, uint buttonCount ) const |
120 | { | 120 | { |
121 | if ( !d->buttonMask.isNull() ) | 121 | if ( !d->buttonMask.isNull() ) |
122 | return d->buttonMask; | 122 | return d->buttonMask; |
123 | 123 | ||
124 | QSize buttonAreaSize = buttonUpImage().size(); | 124 | QSize buttonAreaSize = buttonUpImage().size(); |
125 | 125 | ||
126 | d->buttonMask = QImage( buttonAreaSize, 8, 255 ); | 126 | d->buttonMask = QImage( buttonAreaSize, 8, 255 ); |
127 | d->buttonMask.fill( 0 ); | 127 | d->buttonMask.fill( 0 ); |
128 | 128 | ||
129 | for ( uint i = 0; i < buttonCount; ++i ) | 129 | for ( uint i = 0; i < buttonCount; ++i ) |
130 | addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); | 130 | addButtonToMask( skinButtonInfo[ i ].command + 1, buttonMaskImage( skinButtonInfo[ i ].fileName ) ); |
131 | 131 | ||
132 | return d->buttonMask; | 132 | return d->buttonMask; |
133 | } | 133 | } |
134 | 134 | ||
135 | void Skin::addButtonToMask( int tag, const QImage &maskImage ) const | 135 | void Skin::addButtonToMask( int tag, const QImage &maskImage ) const |
136 | { | 136 | { |
137 | if ( maskImage.isNull() ) | 137 | if ( maskImage.isNull() ) |
138 | return; | 138 | return; |
139 | 139 | ||
140 | uchar **dest = d->buttonMask.jumpTable(); | 140 | uchar **dest = d->buttonMask.jumpTable(); |
141 | for ( int y = 0; y < d->buttonMask.height(); y++ ) { | 141 | for ( int y = 0; y < d->buttonMask.height(); y++ ) { |
142 | uchar *line = dest[y]; | 142 | uchar *line = dest[y]; |
143 | for ( int x = 0; x < d->buttonMask.width(); x++ ) | 143 | for ( int x = 0; x < d->buttonMask.width(); x++ ) |
144 | if ( !qRed( maskImage.pixel( x, y ) ) ) | 144 | if ( !qRed( maskImage.pixel( x, y ) ) ) |
145 | line[x] = tag; | 145 | line[x] = tag; |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | QImage Skin::buttonMaskImage( const QString &fileName ) const | 149 | QImage Skin::buttonMaskImage( const QString &fileName ) const |
150 | { | 150 | { |
151 | SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName ); | 151 | SkinData::ButtonMaskImageMap::Iterator it = d->buttonMasks.find( fileName ); |
152 | if ( it == d->buttonMasks.end() ) { | 152 | if ( it == d->buttonMasks.end() ) { |
153 | QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); | 153 | QString prefix = m_skinPath + QString::fromLatin1( "/skin%1_mask_" ).arg( m_fileNameInfix ); |
154 | QString path = prefix + fileName; | 154 | QString path = prefix + fileName; |
155 | it = d->buttonMasks.insert( fileName, loadImage( path ) ); | 155 | it = d->buttonMasks.insert( fileName, loadImage( path ) ); |
156 | } | 156 | } |
157 | return *it; | 157 | return *it; |
158 | } | 158 | } |
159 | 159 | ||
160 | QString Skin::defaultSkinName() | 160 | QString Skin::defaultSkinName() |
161 | { | 161 | { |
162 | Config cfg( "OpiePlayer" ); | 162 | Config cfg( "OpiePlayer" ); |
163 | cfg.setGroup( "Options" ); | 163 | cfg.setGroup( "Options" ); |
164 | return cfg.readEntry( "Skin", "default" ); | 164 | return cfg.readEntry( "Skin", "default" ); |
165 | } | 165 | } |
166 | 166 | ||
167 | QImage Skin::loadImage( const QString &fileName ) | 167 | QImage Skin::loadImage( const QString &fileName ) |
168 | { | 168 | { |
169 | return QImage( OResource::findPixmap( fileName ) ); | 169 | return QImage( Opie::Core::OResource::findPixmap( fileName ) ); |
170 | } | 170 | } |
171 | 171 | ||
172 | SkinCache::SkinCache() | 172 | SkinCache::SkinCache() |
173 | { | 173 | { |
174 | // let's say we cache two skins (audio+video) at maximum | 174 | // let's say we cache two skins (audio+video) at maximum |
175 | m_cache.setMaxCost( 2 ); | 175 | m_cache.setMaxCost( 2 ); |
176 | // ... and one background pixmap | 176 | // ... and one background pixmap |
177 | m_backgroundPixmapCache.setMaxCost( 1 ); | 177 | m_backgroundPixmapCache.setMaxCost( 1 ); |
178 | } | 178 | } |
179 | 179 | ||
180 | SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) | 180 | SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) |
181 | { | 181 | { |
182 | QString key = skinPath + fileNameInfix; | 182 | QString key = skinPath + fileNameInfix; |
183 | 183 | ||
184 | SkinData *data = m_cache.take( key ); | 184 | SkinData *data = m_cache.take( key ); |
185 | if ( !data ) | 185 | if ( !data ) |
186 | data = new SkinData; | 186 | data = new SkinData; |
187 | else | 187 | else |
188 | odebug << "SkinCache: hit" << oendl; | 188 | odebug << "SkinCache: hit" << oendl; |
189 | 189 | ||
190 | QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath ); | 190 | QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath ); |
191 | if ( bgPixmap ) { | 191 | if ( bgPixmap ) { |
192 | odebug << "SkinCache: hit on bgpixmap" << oendl; | 192 | odebug << "SkinCache: hit on bgpixmap" << oendl; |
193 | data->backgroundPixmap = *bgPixmap; | 193 | data->backgroundPixmap = *bgPixmap; |
194 | } | 194 | } |
195 | else | 195 | else |
196 | data->backgroundPixmap = QPixmap(); | 196 | data->backgroundPixmap = QPixmap(); |
197 | 197 | ||
198 | return data; | 198 | return data; |
199 | } | 199 | } |
200 | 200 | ||
201 | void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ) | 201 | void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ) |
202 | { | 202 | { |
203 | QPixmap *backgroundPixmap = new QPixmap( data->backgroundPixmap ); | 203 | QPixmap *backgroundPixmap = new QPixmap( data->backgroundPixmap ); |
204 | 204 | ||
205 | data->backgroundPixmap = QPixmap(); | 205 | data->backgroundPixmap = QPixmap(); |
206 | 206 | ||
207 | QString key = skinPath + fileNameInfix; | 207 | QString key = skinPath + fileNameInfix; |
208 | 208 | ||
209 | if ( m_cache.find( key, false /*ref*/ ) != 0 || | 209 | if ( m_cache.find( key, false /*ref*/ ) != 0 || |
210 | !m_cache.insert( key, data ) ) | 210 | !m_cache.insert( key, data ) ) |
211 | delete data; | 211 | delete data; |
212 | 212 | ||
213 | if ( m_backgroundPixmapCache.find( skinPath, false /*ref*/ ) != 0 || | 213 | if ( m_backgroundPixmapCache.find( skinPath, false /*ref*/ ) != 0 || |
214 | !m_backgroundPixmapCache.insert( skinPath, backgroundPixmap ) ) | 214 | !m_backgroundPixmapCache.insert( skinPath, backgroundPixmap ) ) |
215 | delete backgroundPixmap; | 215 | delete backgroundPixmap; |
216 | } | 216 | } |
217 | 217 | ||
218 | SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info ) | 218 | SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info ) |
219 | : m_skin( info.skinName, info.fileNameInfix ), m_info( info ) | 219 | : m_skin( info.skinName, info.fileNameInfix ), m_info( info ) |
220 | { | 220 | { |
221 | m_currentState = LoadBackgroundPixmap; | 221 | m_currentState = LoadBackgroundPixmap; |
222 | } | 222 | } |
223 | 223 | ||
224 | SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadStep() | 224 | SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadStep() |
225 | { | 225 | { |
226 | switch ( m_currentState ) { | 226 | switch ( m_currentState ) { |
227 | case LoadBackgroundPixmap: | 227 | case LoadBackgroundPixmap: |
228 | odebug << "load bgpixmap" << oendl; | 228 | odebug << "load bgpixmap" << oendl; |
229 | m_skin.backgroundPixmap(); | 229 | m_skin.backgroundPixmap(); |
230 | m_currentState = LoadButtonUpImage; | 230 | m_currentState = LoadButtonUpImage; |
231 | break; | 231 | break; |
232 | case LoadButtonUpImage: | 232 | case LoadButtonUpImage: |
233 | odebug << "load upimage" << oendl; | 233 | odebug << "load upimage" << oendl; |
234 | m_skin.buttonUpImage(); | 234 | m_skin.buttonUpImage(); |
235 | m_currentState = LoadButtonDownImage; | 235 | m_currentState = LoadButtonDownImage; |
236 | break; | 236 | break; |
237 | case LoadButtonDownImage: | 237 | case LoadButtonDownImage: |
238 | odebug << "load downimage" << oendl; | 238 | odebug << "load downimage" << oendl; |
239 | m_skin.buttonDownImage(); | 239 | m_skin.buttonDownImage(); |
240 | m_currentState = LoadButtonMasks; | 240 | m_currentState = LoadButtonMasks; |
241 | m_currentButton = 0; | 241 | m_currentButton = 0; |
242 | break; | 242 | break; |
243 | case LoadButtonMasks: | 243 | case LoadButtonMasks: |
244 | odebug << "load button masks " << m_currentButton << "" << oendl; | 244 | odebug << "load button masks " << m_currentButton << "" << oendl; |
245 | m_skin.buttonMaskImage( m_info.buttonInfo[ m_currentButton ].fileName ); | 245 | m_skin.buttonMaskImage( m_info.buttonInfo[ m_currentButton ].fileName ); |
246 | 246 | ||
247 | m_currentButton++; | 247 | m_currentButton++; |
248 | if ( m_currentButton >= m_info.buttonCount ) | 248 | if ( m_currentButton >= m_info.buttonCount ) |
249 | m_currentState = LoadButtonMask; | 249 | m_currentState = LoadButtonMask; |
250 | 250 | ||
251 | break; | 251 | break; |
252 | case LoadButtonMask: | 252 | case LoadButtonMask: |
253 | odebug << "load whole mask" << oendl; | 253 | odebug << "load whole mask" << oendl; |
254 | m_skin.buttonMask( m_info.buttonInfo, m_info.buttonCount ); | 254 | m_skin.buttonMask( m_info.buttonInfo, m_info.buttonCount ); |
255 | return LoadingCompleted; | 255 | return LoadingCompleted; |
256 | } | 256 | } |
257 | 257 | ||
258 | return MoreToCome; | 258 | return MoreToCome; |
259 | } | 259 | } |
260 | 260 | ||
261 | SkinLoader::SkinLoader() | 261 | SkinLoader::SkinLoader() |
262 | : m_currentLoader( 0 ), m_timerId( -1 ) | 262 | : m_currentLoader( 0 ), m_timerId( -1 ) |
263 | { | 263 | { |
264 | } | 264 | } |
265 | 265 | ||
266 | SkinLoader::~SkinLoader() | 266 | SkinLoader::~SkinLoader() |
267 | { | 267 | { |
268 | Global::statusMessage( tr( "Loading of Skin finished" ) ); | 268 | Global::statusMessage( tr( "Loading of Skin finished" ) ); |
269 | killTimers(); | 269 | killTimers(); |
270 | delete m_currentLoader; | 270 | delete m_currentLoader; |
271 | } | 271 | } |
272 | 272 | ||
273 | void SkinLoader::schedule( const MediaWidget::GUIInfo &guiInfo ) | 273 | void SkinLoader::schedule( const MediaWidget::GUIInfo &guiInfo ) |
274 | { | 274 | { |
275 | schedule( Skin::defaultSkinName(), guiInfo ); | 275 | schedule( Skin::defaultSkinName(), guiInfo ); |
276 | } | 276 | } |
277 | 277 | ||
278 | void SkinLoader::schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo ) | 278 | void SkinLoader::schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo ) |
279 | { | 279 | { |
280 | pendingSkins << Info( skinName, guiInfo ); | 280 | pendingSkins << Info( skinName, guiInfo ); |
281 | } | 281 | } |
282 | 282 | ||
283 | void SkinLoader::start() | 283 | void SkinLoader::start() |
284 | { | 284 | { |
285 | assert( m_timerId == -1 ); | 285 | assert( m_timerId == -1 ); |
286 | m_timerId = startTimer( 100 /* ms */ ); | 286 | m_timerId = startTimer( 100 /* ms */ ); |
287 | odebug << "SkinLoader::start() " << pendingSkins.count() << " jobs" << oendl; | 287 | odebug << "SkinLoader::start() " << pendingSkins.count() << " jobs" << oendl; |
288 | } | 288 | } |
289 | 289 | ||
290 | void SkinLoader::timerEvent( QTimerEvent *ev ) | 290 | void SkinLoader::timerEvent( QTimerEvent *ev ) |
291 | { | 291 | { |
292 | if ( ev->timerId() != m_timerId ) { | 292 | if ( ev->timerId() != m_timerId ) { |
293 | QObject::timerEvent( ev ); | 293 | QObject::timerEvent( ev ); |
294 | return; | 294 | return; |
295 | } | 295 | } |
296 | 296 | ||
297 | if ( !m_currentLoader ) { | 297 | if ( !m_currentLoader ) { |
298 | 298 | ||
299 | if ( pendingSkins.isEmpty() ) { | 299 | if ( pendingSkins.isEmpty() ) { |
300 | odebug << "all jobs done" << oendl; | 300 | odebug << "all jobs done" << oendl; |
301 | killTimer( m_timerId ); | 301 | killTimer( m_timerId ); |
302 | m_timerId = -1; | 302 | m_timerId = -1; |
303 | // ### qt3: use deleteLater(); | 303 | // ### qt3: use deleteLater(); |
304 | QTimer::singleShot( 0, this, SLOT( deleteMe() ) ); | 304 | QTimer::singleShot( 0, this, SLOT( deleteMe() ) ); |
305 | return; | 305 | return; |
306 | } | 306 | } |
307 | 307 | ||
308 | Info nfo = *pendingSkins.begin(); | 308 | Info nfo = *pendingSkins.begin(); |
309 | pendingSkins.remove( pendingSkins.begin() ); | 309 | pendingSkins.remove( pendingSkins.begin() ); |
310 | 310 | ||
311 | m_currentLoader = new IncrementalLoader( nfo ); | 311 | m_currentLoader = new IncrementalLoader( nfo ); |
312 | odebug << "new loader " << pendingSkins.count() << " jobs left" << oendl; | 312 | odebug << "new loader " << pendingSkins.count() << " jobs left" << oendl; |
313 | } | 313 | } |
314 | 314 | ||
315 | if ( m_currentLoader->loadStep() == IncrementalLoader::LoadingCompleted ) { | 315 | if ( m_currentLoader->loadStep() == IncrementalLoader::LoadingCompleted ) { |
316 | delete m_currentLoader; | 316 | delete m_currentLoader; |
317 | m_currentLoader = 0; | 317 | m_currentLoader = 0; |
318 | } | 318 | } |
319 | 319 | ||
320 | odebug << "finished step" << oendl; | 320 | odebug << "finished step" << oendl; |
321 | } | 321 | } |
322 | 322 | ||
323 | void SkinLoader::deleteMe() | 323 | void SkinLoader::deleteMe() |
324 | { | 324 | { |
325 | delete this; | 325 | delete this; |
326 | } | 326 | } |
327 | 327 | ||
328 | /* vim: et sw=4 ts=4 | 328 | /* vim: et sw=4 ts=4 |
329 | */ | 329 | */ |