Diffstat (limited to 'noncore/multimedia/opieplayer2/skin.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/skin.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/noncore/multimedia/opieplayer2/skin.cpp b/noncore/multimedia/opieplayer2/skin.cpp index 7c38983..84f5f87 100644 --- a/noncore/multimedia/opieplayer2/skin.cpp +++ b/noncore/multimedia/opieplayer2/skin.cpp | |||
@@ -157,166 +157,166 @@ QString Skin::defaultSkinName() | |||
157 | return cfg.readEntry( "Skin", "default" ); | 157 | return cfg.readEntry( "Skin", "default" ); |
158 | } | 158 | } |
159 | 159 | ||
160 | QImage Skin::loadImage( const QString &fileName ) | 160 | QImage Skin::loadImage( const QString &fileName ) |
161 | { | 161 | { |
162 | return QImage( Resource::findPixmap( fileName ) ); | 162 | return QImage( Resource::findPixmap( fileName ) ); |
163 | } | 163 | } |
164 | 164 | ||
165 | SkinCache::SkinCache() | 165 | SkinCache::SkinCache() |
166 | { | 166 | { |
167 | // let's say we cache two skins (audio+video) at maximum | 167 | // let's say we cache two skins (audio+video) at maximum |
168 | m_cache.setMaxCost( 2 ); | 168 | m_cache.setMaxCost( 2 ); |
169 | // ... and one background pixmap | 169 | // ... and one background pixmap |
170 | m_backgroundPixmapCache.setMaxCost( 1 ); | 170 | m_backgroundPixmapCache.setMaxCost( 1 ); |
171 | } | 171 | } |
172 | 172 | ||
173 | SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) | 173 | SkinData *SkinCache::lookupAndTake( const QString &skinPath, const QString &fileNameInfix ) |
174 | { | 174 | { |
175 | QString key = skinPath + fileNameInfix; | 175 | QString key = skinPath + fileNameInfix; |
176 | 176 | ||
177 | SkinData *data = m_cache.take( key ); | 177 | SkinData *data = m_cache.take( key ); |
178 | if ( !data ) | 178 | if ( !data ) |
179 | data = new SkinData; | 179 | data = new SkinData; |
180 | else | 180 | else |
181 | qDebug( "SkinCache: hit" ); | 181 | odebug << "SkinCache: hit" << oendl; |
182 | 182 | ||
183 | QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath ); | 183 | QPixmap *bgPixmap = m_backgroundPixmapCache.find( skinPath ); |
184 | if ( bgPixmap ) { | 184 | if ( bgPixmap ) { |
185 | qDebug( "SkinCache: hit on bgpixmap" ); | 185 | odebug << "SkinCache: hit on bgpixmap" << oendl; |
186 | data->backgroundPixmap = *bgPixmap; | 186 | data->backgroundPixmap = *bgPixmap; |
187 | } | 187 | } |
188 | else | 188 | else |
189 | data->backgroundPixmap = QPixmap(); | 189 | data->backgroundPixmap = QPixmap(); |
190 | 190 | ||
191 | return data; | 191 | return data; |
192 | } | 192 | } |
193 | 193 | ||
194 | void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ) | 194 | void SkinCache::store( const QString &skinPath, const QString &fileNameInfix, SkinData *data ) |
195 | { | 195 | { |
196 | QPixmap *backgroundPixmap = new QPixmap( data->backgroundPixmap ); | 196 | QPixmap *backgroundPixmap = new QPixmap( data->backgroundPixmap ); |
197 | 197 | ||
198 | data->backgroundPixmap = QPixmap(); | 198 | data->backgroundPixmap = QPixmap(); |
199 | 199 | ||
200 | QString key = skinPath + fileNameInfix; | 200 | QString key = skinPath + fileNameInfix; |
201 | 201 | ||
202 | if ( m_cache.find( key, false /*ref*/ ) != 0 || | 202 | if ( m_cache.find( key, false /*ref*/ ) != 0 || |
203 | !m_cache.insert( key, data ) ) | 203 | !m_cache.insert( key, data ) ) |
204 | delete data; | 204 | delete data; |
205 | 205 | ||
206 | if ( m_backgroundPixmapCache.find( skinPath, false /*ref*/ ) != 0 || | 206 | if ( m_backgroundPixmapCache.find( skinPath, false /*ref*/ ) != 0 || |
207 | !m_backgroundPixmapCache.insert( skinPath, backgroundPixmap ) ) | 207 | !m_backgroundPixmapCache.insert( skinPath, backgroundPixmap ) ) |
208 | delete backgroundPixmap; | 208 | delete backgroundPixmap; |
209 | } | 209 | } |
210 | 210 | ||
211 | SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info ) | 211 | SkinLoader::IncrementalLoader::IncrementalLoader( const Info &info ) |
212 | : m_skin( info.skinName, info.fileNameInfix ), m_info( info ) | 212 | : m_skin( info.skinName, info.fileNameInfix ), m_info( info ) |
213 | { | 213 | { |
214 | m_currentState = LoadBackgroundPixmap; | 214 | m_currentState = LoadBackgroundPixmap; |
215 | } | 215 | } |
216 | 216 | ||
217 | SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadStep() | 217 | SkinLoader::IncrementalLoader::LoaderResult SkinLoader::IncrementalLoader::loadStep() |
218 | { | 218 | { |
219 | switch ( m_currentState ) { | 219 | switch ( m_currentState ) { |
220 | case LoadBackgroundPixmap: | 220 | case LoadBackgroundPixmap: |
221 | qDebug( "load bgpixmap" ); | 221 | odebug << "load bgpixmap" << oendl; |
222 | m_skin.backgroundPixmap(); | 222 | m_skin.backgroundPixmap(); |
223 | m_currentState = LoadButtonUpImage; | 223 | m_currentState = LoadButtonUpImage; |
224 | break; | 224 | break; |
225 | case LoadButtonUpImage: | 225 | case LoadButtonUpImage: |
226 | qDebug( "load upimage" ); | 226 | odebug << "load upimage" << oendl; |
227 | m_skin.buttonUpImage(); | 227 | m_skin.buttonUpImage(); |
228 | m_currentState = LoadButtonDownImage; | 228 | m_currentState = LoadButtonDownImage; |
229 | break; | 229 | break; |
230 | case LoadButtonDownImage: | 230 | case LoadButtonDownImage: |
231 | qDebug( "load downimage" ); | 231 | odebug << "load downimage" << oendl; |
232 | m_skin.buttonDownImage(); | 232 | m_skin.buttonDownImage(); |
233 | m_currentState = LoadButtonMasks; | 233 | m_currentState = LoadButtonMasks; |
234 | m_currentButton = 0; | 234 | m_currentButton = 0; |
235 | break; | 235 | break; |
236 | case LoadButtonMasks: | 236 | case LoadButtonMasks: |
237 | qDebug( "load button masks %i", m_currentButton ); | 237 | odebug << "load button masks " << m_currentButton << "" << oendl; |
238 | m_skin.buttonMaskImage( m_info.buttonInfo[ m_currentButton ].fileName ); | 238 | m_skin.buttonMaskImage( m_info.buttonInfo[ m_currentButton ].fileName ); |
239 | 239 | ||
240 | m_currentButton++; | 240 | m_currentButton++; |
241 | if ( m_currentButton >= m_info.buttonCount ) | 241 | if ( m_currentButton >= m_info.buttonCount ) |
242 | m_currentState = LoadButtonMask; | 242 | m_currentState = LoadButtonMask; |
243 | 243 | ||
244 | break; | 244 | break; |
245 | case LoadButtonMask: | 245 | case LoadButtonMask: |
246 | qDebug( "load whole mask" ); | 246 | odebug << "load whole mask" << oendl; |
247 | m_skin.buttonMask( m_info.buttonInfo, m_info.buttonCount ); | 247 | m_skin.buttonMask( m_info.buttonInfo, m_info.buttonCount ); |
248 | return LoadingCompleted; | 248 | return LoadingCompleted; |
249 | } | 249 | } |
250 | 250 | ||
251 | return MoreToCome; | 251 | return MoreToCome; |
252 | } | 252 | } |
253 | 253 | ||
254 | SkinLoader::SkinLoader() | 254 | SkinLoader::SkinLoader() |
255 | : m_currentLoader( 0 ), m_timerId( -1 ) | 255 | : m_currentLoader( 0 ), m_timerId( -1 ) |
256 | { | 256 | { |
257 | } | 257 | } |
258 | 258 | ||
259 | SkinLoader::~SkinLoader() | 259 | SkinLoader::~SkinLoader() |
260 | { | 260 | { |
261 | qDebug( "SkinLoader::~SkinLoader()" ); | 261 | odebug << "SkinLoader::~SkinLoader()" << oendl; |
262 | killTimers(); | 262 | killTimers(); |
263 | delete m_currentLoader; | 263 | delete m_currentLoader; |
264 | } | 264 | } |
265 | 265 | ||
266 | void SkinLoader::schedule( const MediaWidget::GUIInfo &guiInfo ) | 266 | void SkinLoader::schedule( const MediaWidget::GUIInfo &guiInfo ) |
267 | { | 267 | { |
268 | schedule( Skin::defaultSkinName(), guiInfo ); | 268 | schedule( Skin::defaultSkinName(), guiInfo ); |
269 | } | 269 | } |
270 | 270 | ||
271 | void SkinLoader::schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo ) | 271 | void SkinLoader::schedule( const QString &skinName, const MediaWidget::GUIInfo &guiInfo ) |
272 | { | 272 | { |
273 | pendingSkins << Info( skinName, guiInfo ); | 273 | pendingSkins << Info( skinName, guiInfo ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void SkinLoader::start() | 276 | void SkinLoader::start() |
277 | { | 277 | { |
278 | assert( m_timerId == -1 ); | 278 | assert( m_timerId == -1 ); |
279 | m_timerId = startTimer( 100 /* ms */ ); | 279 | m_timerId = startTimer( 100 /* ms */ ); |
280 | qDebug( "SkinLoader::start() %d jobs", pendingSkins.count() ); | 280 | odebug << "SkinLoader::start() " << pendingSkins.count() << " jobs" << oendl; |
281 | } | 281 | } |
282 | 282 | ||
283 | void SkinLoader::timerEvent( QTimerEvent *ev ) | 283 | void SkinLoader::timerEvent( QTimerEvent *ev ) |
284 | { | 284 | { |
285 | if ( ev->timerId() != m_timerId ) { | 285 | if ( ev->timerId() != m_timerId ) { |
286 | QObject::timerEvent( ev ); | 286 | QObject::timerEvent( ev ); |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | 289 | ||
290 | if ( !m_currentLoader ) { | 290 | if ( !m_currentLoader ) { |
291 | 291 | ||
292 | if ( pendingSkins.isEmpty() ) { | 292 | if ( pendingSkins.isEmpty() ) { |
293 | qDebug( "all jobs done" ); | 293 | odebug << "all jobs done" << oendl; |
294 | killTimer( m_timerId ); | 294 | killTimer( m_timerId ); |
295 | m_timerId = -1; | 295 | m_timerId = -1; |
296 | // ### qt3: use deleteLater(); | 296 | // ### qt3: use deleteLater(); |
297 | QTimer::singleShot( 0, this, SLOT( deleteMe() ) ); | 297 | QTimer::singleShot( 0, this, SLOT( deleteMe() ) ); |
298 | return; | 298 | return; |
299 | } | 299 | } |
300 | 300 | ||
301 | Info nfo = *pendingSkins.begin(); | 301 | Info nfo = *pendingSkins.begin(); |
302 | pendingSkins.remove( pendingSkins.begin() ); | 302 | pendingSkins.remove( pendingSkins.begin() ); |
303 | 303 | ||
304 | m_currentLoader = new IncrementalLoader( nfo ); | 304 | m_currentLoader = new IncrementalLoader( nfo ); |
305 | qDebug( "new loader %i jobs left", pendingSkins.count() ); | 305 | odebug << "new loader " << pendingSkins.count() << " jobs left" << oendl; |
306 | } | 306 | } |
307 | 307 | ||
308 | if ( m_currentLoader->loadStep() == IncrementalLoader::LoadingCompleted ) { | 308 | if ( m_currentLoader->loadStep() == IncrementalLoader::LoadingCompleted ) { |
309 | delete m_currentLoader; | 309 | delete m_currentLoader; |
310 | m_currentLoader = 0; | 310 | m_currentLoader = 0; |
311 | } | 311 | } |
312 | 312 | ||
313 | qDebug( "finished step" ); | 313 | odebug << "finished step" << oendl; |
314 | } | 314 | } |
315 | 315 | ||
316 | void SkinLoader::deleteMe() | 316 | void SkinLoader::deleteMe() |
317 | { | 317 | { |
318 | delete this; | 318 | delete this; |
319 | } | 319 | } |
320 | 320 | ||
321 | /* vim: et sw=4 ts=4 | 321 | /* vim: et sw=4 ts=4 |
322 | */ | 322 | */ |