Diffstat (limited to 'noncore/styles/theme/othemebase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/styles/theme/othemebase.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/styles/theme/othemebase.cpp b/noncore/styles/theme/othemebase.cpp index d2226e6..4275dd6 100644 --- a/noncore/styles/theme/othemebase.cpp +++ b/noncore/styles/theme/othemebase.cpp | |||
@@ -213,193 +213,193 @@ void OThemeBase::copyWidgetConfig( int sourceID, int destID, QString *pixnames, | |||
213 | pixmaps[ destID ] = NULL; | 213 | pixmaps[ destID ] = NULL; |
214 | images[ destID ] = NULL; | 214 | images[ destID ] = NULL; |
215 | if ( !pixnames[ destID ].isEmpty() ) { | 215 | if ( !pixnames[ destID ].isEmpty() ) { |
216 | if ( scaleHints[ sourceID ] == TileScale && blends[ sourceID ] == 0.0 ) { | 216 | if ( scaleHints[ sourceID ] == TileScale && blends[ sourceID ] == 0.0 ) { |
217 | pixmaps[ destID ] = pixmaps[ sourceID ]; | 217 | pixmaps[ destID ] = pixmaps[ sourceID ]; |
218 | duplicate[ destID ] = true; | 218 | duplicate[ destID ] = true; |
219 | } | 219 | } |
220 | if ( !duplicate[ destID ] ) { | 220 | if ( !duplicate[ destID ] ) { |
221 | pixmaps[ destID ] = loadPixmap( pixnames[ destID ] ); | 221 | pixmaps[ destID ] = loadPixmap( pixnames[ destID ] ); |
222 | if ( scaleHints[ destID ] == TileScale && blends[ destID ] == 0.0 ) | 222 | if ( scaleHints[ destID ] == TileScale && blends[ destID ] == 0.0 ) |
223 | images[ destID ] = NULL; | 223 | images[ destID ] = NULL; |
224 | else | 224 | else |
225 | images[ destID ] = loadImage( pixnames[ destID ] ); | 225 | images[ destID ] = loadImage( pixnames[ destID ] ); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | // border pixmap | 229 | // border pixmap |
230 | pbDuplicate[ destID ] = false; | 230 | pbDuplicate[ destID ] = false; |
231 | pbPixmaps[ destID ] = NULL; | 231 | pbPixmaps[ destID ] = NULL; |
232 | pbWidth[ destID ] = pbWidth[ sourceID ]; | 232 | pbWidth[ destID ] = pbWidth[ sourceID ]; |
233 | brdnames[ destID ] = brdnames[ sourceID ]; | 233 | brdnames[ destID ] = brdnames[ sourceID ]; |
234 | if ( !brdnames[ destID ].isEmpty() ) { | 234 | if ( !brdnames[ destID ].isEmpty() ) { |
235 | pbPixmaps[ destID ] = pbPixmaps[ sourceID ]; | 235 | pbPixmaps[ destID ] = pbPixmaps[ sourceID ]; |
236 | pbDuplicate[ destID ] = true; | 236 | pbDuplicate[ destID ] = true; |
237 | } | 237 | } |
238 | 238 | ||
239 | if ( sourceID == ActiveTab && destID == InactiveTab ) | 239 | if ( sourceID == ActiveTab && destID == InactiveTab ) |
240 | aTabLine = iTabLine; | 240 | aTabLine = iTabLine; |
241 | else if ( sourceID == InactiveTab && destID == ActiveTab ) | 241 | else if ( sourceID == InactiveTab && destID == ActiveTab ) |
242 | iTabLine = aTabLine; | 242 | iTabLine = aTabLine; |
243 | } | 243 | } |
244 | 244 | ||
245 | void OThemeBase::readConfig( Qt::GUIStyle /*style*/ ) | 245 | void OThemeBase::readConfig( Qt::GUIStyle /*style*/ ) |
246 | { | 246 | { |
247 | #define PREBLEND_ITEMS 12 | 247 | #define PREBLEND_ITEMS 12 |
248 | static WidgetType preBlend[] = {Slider, IndicatorOn, IndicatorOff, | 248 | static WidgetType preBlend[] = {Slider, IndicatorOn, IndicatorOff, |
249 | ExIndicatorOn, ExIndicatorOff, HScrollDeco, VScrollDeco, HScrollDecoDown, | 249 | ExIndicatorOn, ExIndicatorOff, HScrollDeco, VScrollDeco, HScrollDecoDown, |
250 | VScrollDecoDown, ComboDeco, ComboDecoDown, CheckMark}; | 250 | VScrollDecoDown, ComboDeco, ComboDecoDown, CheckMark}; |
251 | 251 | ||
252 | int i; | 252 | int i; |
253 | QString tmpStr; | 253 | QString tmpStr; |
254 | QString copyfrom[ WIDGETS ]; | 254 | QString copyfrom[ WIDGETS ]; |
255 | QString pixnames[ WIDGETS ]; // used for duplicate check | 255 | QString pixnames[ WIDGETS ]; // used for duplicate check |
256 | QString brdnames[ WIDGETS ]; | 256 | QString brdnames[ WIDGETS ]; |
257 | bool loaded[ WIDGETS ]; // used for preloading for CopyWidget | 257 | bool loaded[ WIDGETS ]; // used for preloading for CopyWidget |
258 | 258 | ||
259 | if ( configFileName.isEmpty() ) { | 259 | if ( configFileName.isEmpty() ) { |
260 | Config cfg ( "qpe" ); | 260 | Config cfg ( "qpe" ); |
261 | cfg. setGroup ( "Appearance" ); | 261 | cfg. setGroup ( "Appearance" ); |
262 | 262 | ||
263 | configFileName = cfg. readEntry ( "Theme", "default" ); | 263 | configFileName = cfg. readEntry ( "Theme", "default" ); |
264 | } | 264 | } |
265 | Config config( configFilePath + "/themes/" + configFileName + ".themerc" , Config::File ); | 265 | Config config( configFilePath + "/themes/" + configFileName + ".themerc" , Config::File ); |
266 | 266 | ||
267 | // Are we initalized? | 267 | // Are we initalized? |
268 | applyMiscResourceGroup( &config ); | 268 | applyMiscResourceGroup( &config ); |
269 | for ( i = 0; i < INHERIT_ITEMS; ++i ) { | 269 | for ( i = 0; i < INHERIT_ITEMS; ++i ) { |
270 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); | 270 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); |
271 | } | 271 | } |
272 | for ( ; i < INHERIT_ITEMS*2; ++i ) { | 272 | for ( ; i < INHERIT_ITEMS*2; ++i ) { |
273 | if ( config.hasGroup( QString( widgetEntries[ i ] ) ) ) { | 273 | if ( config.hasGroup( QString( widgetEntries[ i ] ) ) ) { |
274 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); | 274 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); |
275 | } | 275 | } |
276 | else { | 276 | else { |
277 | copyfrom [ i ] = widgetEntries[ i - INHERIT_ITEMS ]; | 277 | copyfrom [ i ] = widgetEntries[ i - INHERIT_ITEMS ]; |
278 | } | 278 | } |
279 | } | 279 | } |
280 | for ( ; i < WIDGETS; ++i ) { | 280 | for ( ; i < WIDGETS; ++i ) { |
281 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); | 281 | applyResourceGroup( &config, i, copyfrom, pixnames, brdnames ); |
282 | } | 282 | } |
283 | 283 | ||
284 | // initalize defaults that may not be read | 284 | // initalize defaults that may not be read |
285 | for ( i = 0; i < WIDGETS; ++i ) | 285 | for ( i = 0; i < WIDGETS; ++i ) |
286 | loaded[ i ] = false; | 286 | loaded[ i ] = false; |
287 | btnXShift = btnYShift = focus3DOffset = 0; | 287 | btnXShift = btnYShift = focus3DOffset = 0; |
288 | aTabLine = iTabLine = true; | 288 | aTabLine = iTabLine = true; |
289 | roundedButton = roundedCombo = roundedSlider = focus3D = false; | 289 | roundedButton = roundedCombo = roundedSlider = focus3D = false; |
290 | splitterWidth = 10; | 290 | splitterWidth = 10; |
291 | 291 | ||
292 | for ( i = 0; i < WIDGETS; ++i ) { | 292 | for ( i = 0; i < WIDGETS; ++i ) { |
293 | readResourceGroup( i, copyfrom, pixnames, brdnames, loaded ); | 293 | readResourceGroup( i, copyfrom, pixnames, brdnames, loaded ); |
294 | } | 294 | } |
295 | 295 | ||
296 | // misc items | 296 | // misc items |
297 | readMiscResourceGroup(); | 297 | readMiscResourceGroup(); |
298 | 298 | ||
299 | // Handle preblend items | 299 | // Handle preblend items |
300 | for ( i = 0; i < PREBLEND_ITEMS; ++i ) { | 300 | for ( i = 0; i < PREBLEND_ITEMS; ++i ) { |
301 | if ( pixmaps[ preBlend[ i ] ] != NULL && blends[ preBlend[ i ] ] != 0.0 ) | 301 | if ( pixmaps[ preBlend[ i ] ] != NULL && blends[ preBlend[ i ] ] != 0.0 ) |
302 | blend( preBlend[ i ] ); | 302 | blend( preBlend[ i ] ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | OThemeBase::OThemeBase( const QString & configFile ) | 306 | OThemeBase::OThemeBase( const QString & configFile ) |
307 | : QWindowsStyle() | 307 | : QWindowsStyle() |
308 | { | 308 | { |
309 | configFilePath = QPEApplication::qpeDir ( ) + "/plugins/styles/"; | 309 | configFilePath = QPEApplication::qpeDir ( ) + "plugins/styles/"; |
310 | configFileName = configFile; | 310 | configFileName = configFile; |
311 | 311 | ||
312 | readConfig( Qt::WindowsStyle ); | 312 | readConfig( Qt::WindowsStyle ); |
313 | cache = new OThemeCache( cacheSize ); | 313 | cache = new OThemeCache( cacheSize ); |
314 | } | 314 | } |
315 | 315 | ||
316 | void OThemeBase::applyConfigFile( const QString &/*file*/ ) | 316 | void OThemeBase::applyConfigFile( const QString &/*file*/ ) |
317 | { | 317 | { |
318 | #if 0 | 318 | #if 0 |
319 | // handle std color scheme | 319 | // handle std color scheme |
320 | Config inConfig( file, Config::File ); | 320 | Config inConfig( file, Config::File ); |
321 | Config globalConfig ( "qpe" ); | 321 | Config globalConfig ( "qpe" ); |
322 | 322 | ||
323 | globalConfig. setGroup ( "Apperance" ); | 323 | globalConfig. setGroup ( "Apperance" ); |
324 | inConfig. setGroup( "General" ); | 324 | inConfig. setGroup( "General" ); |
325 | 325 | ||
326 | if ( inConfig.hasKey( "foreground" ) ) | 326 | if ( inConfig.hasKey( "foreground" ) ) |
327 | globalConfig.writeEntry( "Text", inConfig.readEntry( "foreground", " " ) ); | 327 | globalConfig.writeEntry( "Text", inConfig.readEntry( "foreground", " " ) ); |
328 | if ( inConfig.hasKey( "background" ) ) | 328 | if ( inConfig.hasKey( "background" ) ) |
329 | globalConfig.writeEntry( "Background", inConfig.readEntry( "background", " " ) ); | 329 | globalConfig.writeEntry( "Background", inConfig.readEntry( "background", " " ) ); |
330 | if ( inConfig.hasKey( "selectForeground" ) ) | 330 | if ( inConfig.hasKey( "selectForeground" ) ) |
331 | globalConfig.writeEntry( "HighlightedText", inConfig.readEntry( "selectForeground", " " ) ); | 331 | globalConfig.writeEntry( "HighlightedText", inConfig.readEntry( "selectForeground", " " ) ); |
332 | if ( inConfig.hasKey( "selectBackground" ) ) | 332 | if ( inConfig.hasKey( "selectBackground" ) ) |
333 | globalConfig.writeEntry( "Highlight", inConfig.readEntry( "selectBackground", " " ) ); | 333 | globalConfig.writeEntry( "Highlight", inConfig.readEntry( "selectBackground", " " ) ); |
334 | if ( inConfig.hasKey( "windowForeground" ) ) | 334 | if ( inConfig.hasKey( "windowForeground" ) ) |
335 | globalConfig.writeEntry( "Text", inConfig.readEntry( "windowForeground", " " ) ); | 335 | globalConfig.writeEntry( "Text", inConfig.readEntry( "windowForeground", " " ) ); |
336 | if ( inConfig.hasKey( "windowBackground" ) ) | 336 | if ( inConfig.hasKey( "windowBackground" ) ) |
337 | globalConfig.writeEntry( "Base", inConfig.readEntry( "windowBackground", " " ) ); | 337 | globalConfig.writeEntry( "Base", inConfig.readEntry( "windowBackground", " " ) ); |
338 | 338 | ||
339 | // Keep track of the current theme so that we can select the right one | 339 | // Keep track of the current theme so that we can select the right one |
340 | // in the KControl module. | 340 | // in the KControl module. |
341 | globalConfig.writeEntry ( "CurrentTheme", file ); | 341 | globalConfig.writeEntry ( "CurrentTheme", file ); |
342 | 342 | ||
343 | globalConfig.write(); | 343 | globalConfig.write(); |
344 | #endif | 344 | #endif |
345 | } | 345 | } |
346 | 346 | ||
347 | OThemeBase::~OThemeBase() | 347 | OThemeBase::~OThemeBase() |
348 | { | 348 | { |
349 | int i; | 349 | int i; |
350 | for ( i = 0; i < WIDGETS; ++i ) { | 350 | for ( i = 0; i < WIDGETS; ++i ) { |
351 | if ( !duplicate[ i ] ) { | 351 | if ( !duplicate[ i ] ) { |
352 | if ( images[ i ] ) | 352 | if ( images[ i ] ) |
353 | delete images[ i ]; | 353 | delete images[ i ]; |
354 | if ( pixmaps[ i ] ) | 354 | if ( pixmaps[ i ] ) |
355 | delete pixmaps[ i ]; | 355 | delete pixmaps[ i ]; |
356 | } | 356 | } |
357 | if ( !pbDuplicate[ i ] && pbPixmaps[ i ] ) | 357 | if ( !pbDuplicate[ i ] && pbPixmaps[ i ] ) |
358 | delete pbPixmaps[ i ]; | 358 | delete pbPixmaps[ i ]; |
359 | if ( colors[ i ] ) | 359 | if ( colors[ i ] ) |
360 | delete( colors[ i ] ); | 360 | delete( colors[ i ] ); |
361 | if ( grLowColors[ i ] ) | 361 | if ( grLowColors[ i ] ) |
362 | delete( grLowColors[ i ] ); | 362 | delete( grLowColors[ i ] ); |
363 | if ( grHighColors[ i ] ) | 363 | if ( grHighColors[ i ] ) |
364 | delete( grHighColors[ i ] ); | 364 | delete( grHighColors[ i ] ); |
365 | } | 365 | } |
366 | delete cache; | 366 | delete cache; |
367 | } | 367 | } |
368 | 368 | ||
369 | QImage* OThemeBase::loadImage( QString &name ) | 369 | QImage* OThemeBase::loadImage( QString &name ) |
370 | { | 370 | { |
371 | QImage * image = new QImage; | 371 | QImage * image = new QImage; |
372 | QString path = configFilePath + "/pixmaps/" + name; | 372 | QString path = configFilePath + "/pixmaps/" + name; |
373 | image->load( path ); | 373 | image->load( path ); |
374 | if ( !image->isNull() ) | 374 | if ( !image->isNull() ) |
375 | return ( image ); | 375 | return ( image ); |
376 | odebug << "OThemeBase: Unable to load image " << name.ascii ( ) << oendl; | 376 | odebug << "OThemeBase: Unable to load image " << name.ascii ( ) << oendl; |
377 | delete image; | 377 | delete image; |
378 | return ( NULL ); | 378 | return ( NULL ); |
379 | } | 379 | } |
380 | 380 | ||
381 | OThemePixmap* OThemeBase::loadPixmap( QString &name ) | 381 | OThemePixmap* OThemeBase::loadPixmap( QString &name ) |
382 | { | 382 | { |
383 | OThemePixmap * pixmap = new OThemePixmap( false ); | 383 | OThemePixmap * pixmap = new OThemePixmap( false ); |
384 | QString path = configFilePath + "/pixmaps/" + name; | 384 | QString path = configFilePath + "/pixmaps/" + name; |
385 | pixmap->load( path ); | 385 | pixmap->load( path ); |
386 | if ( !pixmap->isNull() ) | 386 | if ( !pixmap->isNull() ) |
387 | return pixmap; | 387 | return pixmap; |
388 | odebug << "OThemeBase: Unable to load pixmap " << name.ascii() << oendl; | 388 | odebug << "OThemeBase: Unable to load pixmap " << name.ascii() << oendl; |
389 | delete pixmap; | 389 | delete pixmap; |
390 | return ( NULL ); | 390 | return ( NULL ); |
391 | } | 391 | } |
392 | 392 | ||
393 | OThemePixmap* OThemeBase::scale( int w, int h, WidgetType widget ) | 393 | OThemePixmap* OThemeBase::scale( int w, int h, WidgetType widget ) |
394 | { | 394 | { |
395 | if ( scaleHints[ widget ] == FullScale ) { | 395 | if ( scaleHints[ widget ] == FullScale ) { |
396 | if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || | 396 | if ( !pixmaps[ widget ] || pixmaps[ widget ] ->width() != w || |
397 | pixmaps[ widget ] ->height() != h ) { | 397 | pixmaps[ widget ] ->height() != h ) { |
398 | OThemePixmap * cachePix = cache->pixmap( w, h, widget ); | 398 | OThemePixmap * cachePix = cache->pixmap( w, h, widget ); |
399 | if ( cachePix ) { | 399 | if ( cachePix ) { |
400 | cachePix = new OThemePixmap( *cachePix ); | 400 | cachePix = new OThemePixmap( *cachePix ); |
401 | if ( pixmaps[ widget ] ) | 401 | if ( pixmaps[ widget ] ) |
402 | cache->insert( pixmaps[ widget ], OThemeCache::FullScale, | 402 | cache->insert( pixmaps[ widget ], OThemeCache::FullScale, |
403 | widget ); | 403 | widget ); |
404 | else | 404 | else |
405 | odebug << "We would have inserted a null pixmap!\n" << oendl; | 405 | odebug << "We would have inserted a null pixmap!\n" << oendl; |