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