-rw-r--r-- | noncore/styles/theme/ogfxeffect.cpp | 22 | ||||
-rw-r--r-- | noncore/styles/theme/othemestyle.cpp | 6 |
2 files changed, 17 insertions, 11 deletions
diff --git a/noncore/styles/theme/ogfxeffect.cpp b/noncore/styles/theme/ogfxeffect.cpp index 2071a67..90b45fe 100644 --- a/noncore/styles/theme/ogfxeffect.cpp +++ b/noncore/styles/theme/ogfxeffect.cpp | |||
@@ -18,27 +18,28 @@ | |||
18 | #include <cmath> | 18 | #include <cmath> |
19 | 19 | ||
20 | //====================================================================== | 20 | //====================================================================== |
21 | // | 21 | // |
22 | // Gradient effects | 22 | // Gradient effects |
23 | // | 23 | // |
24 | //====================================================================== | 24 | //====================================================================== |
25 | 25 | ||
26 | 26 | ||
27 | QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, | 27 | QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, |
28 | const QColor &cb, GradientType eff, int ncols) | 28 | const QColor &cb, GradientType eff, int ncols) |
29 | { | 29 | { |
30 | QImage image = gradient(pixmap.size(), ca, cb, eff, ncols); | 30 | if ( !pixmap. isNull ( )) { |
31 | pixmap.convertFromImage(image); | 31 | QImage image = gradient(pixmap.size(), ca, cb, eff, ncols); |
32 | 32 | pixmap.convertFromImage(image); | |
33 | } | ||
33 | return pixmap; | 34 | return pixmap; |
34 | } | 35 | } |
35 | 36 | ||
36 | QImage OGfxEffect::gradient(const QSize &size, const QColor &ca, | 37 | QImage OGfxEffect::gradient(const QSize &size, const QColor &ca, |
37 | const QColor &cb, GradientType eff, int /*ncols*/) | 38 | const QColor &cb, GradientType eff, int /*ncols*/) |
38 | { | 39 | { |
39 | int rDiff, gDiff, bDiff; | 40 | int rDiff, gDiff, bDiff; |
40 | int rca, gca, bca, rcb, gcb, bcb; | 41 | int rca, gca, bca, rcb, gcb, bcb; |
41 | 42 | ||
42 | QImage image(size, 32); | 43 | QImage image(size, 32); |
43 | 44 | ||
44 | if (size.width() == 0 || size.height() == 0) { | 45 | if (size.width() == 0 || size.height() == 0) { |
@@ -271,33 +272,34 @@ QImage OGfxEffect::gradient(const QSize &size, const QColor &ca, | |||
271 | 272 | ||
272 | //====================================================================== | 273 | //====================================================================== |
273 | // | 274 | // |
274 | // Blend effects | 275 | // Blend effects |
275 | // | 276 | // |
276 | //====================================================================== | 277 | //====================================================================== |
277 | 278 | ||
278 | 279 | ||
279 | QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, | 280 | QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, |
280 | const QColor &bgnd, GradientType eff, | 281 | const QColor &bgnd, GradientType eff, |
281 | bool anti_dir, int /*ncols*/) | 282 | bool anti_dir, int /*ncols*/) |
282 | { | 283 | { |
283 | QImage image = pixmap.convertToImage(); | 284 | if ( !pixmap. isNull ( )) { |
284 | OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); | 285 | QImage image = pixmap.convertToImage(); |
285 | 286 | OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); | |
286 | if ( pixmap. depth ( ) <= 8 ) | ||
287 | image. convertDepth ( pixmap. depth ( )); | ||
288 | 287 | ||
289 | pixmap.convertFromImage(image); | 288 | if ( pixmap. depth ( ) <= 8 ) |
289 | image. convertDepth ( pixmap. depth ( )); | ||
290 | 290 | ||
291 | return pixmap; | 291 | pixmap.convertFromImage(image); |
292 | } | ||
293 | return pixmap; | ||
292 | } | 294 | } |
293 | 295 | ||
294 | 296 | ||
295 | QImage& OGfxEffect::blend(QImage &image, float initial_intensity, | 297 | QImage& OGfxEffect::blend(QImage &image, float initial_intensity, |
296 | const QColor &bgnd, GradientType eff, | 298 | const QColor &bgnd, GradientType eff, |
297 | bool anti_dir) | 299 | bool anti_dir) |
298 | { | 300 | { |
299 | if (image.width() == 0 || image.height() == 0) { | 301 | if (image.width() == 0 || image.height() == 0) { |
300 | qDebug ( "Invalid image\n" ); | 302 | qDebug ( "Invalid image\n" ); |
301 | return image; | 303 | return image; |
302 | } | 304 | } |
303 | 305 | ||
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp index a820efb..98e7253 100644 --- a/noncore/styles/theme/othemestyle.cpp +++ b/noncore/styles/theme/othemestyle.cpp | |||
@@ -240,24 +240,27 @@ bool OThemeStyle::eventFilter ( QObject *obj, QEvent *ev ) | |||
240 | if ( ev-> type ( ) == QEvent::Paint ) { | 240 | if ( ev-> type ( ) == QEvent::Paint ) { |
241 | HackProgressBar *pb = (HackProgressBar *) obj; | 241 | HackProgressBar *pb = (HackProgressBar *) obj; |
242 | pb-> paint ((QPaintEvent *) ev, this ); | 242 | pb-> paint ((QPaintEvent *) ev, this ); |
243 | return true; | 243 | return true; |
244 | } | 244 | } |
245 | return false; | 245 | return false; |
246 | } | 246 | } |
247 | 247 | ||
248 | void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, | 248 | void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, |
249 | const QColorGroup &g, bool sunken, bool | 249 | const QColorGroup &g, bool sunken, bool |
250 | rounded, WidgetType type, const QBrush * ) | 250 | rounded, WidgetType type, const QBrush * ) |
251 | { | 251 | { |
252 | if ( w <= 0 || h <= 0 ) | ||
253 | return; | ||
254 | |||
252 | int offset = borderPixmap( type ) ? 0 : decoWidth( type ); | 255 | int offset = borderPixmap( type ) ? 0 : decoWidth( type ); |
253 | QPen oldPen = p->pen(); | 256 | QPen oldPen = p->pen(); |
254 | 257 | ||
255 | // handle reverse bevel here since it uses decowidth differently | 258 | // handle reverse bevel here since it uses decowidth differently |
256 | if ( gradientHint( type ) == GrReverseBevel ) { | 259 | if ( gradientHint( type ) == GrReverseBevel ) { |
257 | int i; | 260 | int i; |
258 | bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, | 261 | bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, |
259 | Qt::CopyROP, true ); | 262 | Qt::CopyROP, true ); |
260 | p->setPen( g.text() ); | 263 | p->setPen( g.text() ); |
261 | for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) | 264 | for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) |
262 | p->drawRect( x, y, w, h ); | 265 | p->drawRect( x, y, w, h ); |
263 | } | 266 | } |
@@ -278,27 +281,28 @@ void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, | |||
278 | if ( isPixmap( type ) ) | 281 | if ( isPixmap( type ) ) |
279 | if ( rounded ) | 282 | if ( rounded ) |
280 | p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); | 283 | p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); |
281 | else | 284 | else |
282 | p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, | 285 | p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, |
283 | h - offset * 2, | 286 | h - offset * 2, |
284 | *scalePixmap( w - offset * 2, h - offset * 2, | 287 | *scalePixmap( w - offset * 2, h - offset * 2, |
285 | type ) ); | 288 | type ) ); |
286 | else | 289 | else |
287 | p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, | 290 | p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, |
288 | g.brush( QColorGroup::Button ) ); | 291 | g.brush( QColorGroup::Button ) ); |
289 | } | 292 | } |
290 | if ( borderPixmap( type ) ) | 293 | if ( borderPixmap( type ) ) { |
291 | bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, | 294 | bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, |
292 | Qt::CopyROP, false ); | 295 | Qt::CopyROP, false ); |
296 | } | ||
293 | else | 297 | else |
294 | drawShade( p, x, y, w, h, g, sunken, rounded, | 298 | drawShade( p, x, y, w, h, g, sunken, rounded, |
295 | highlightWidth( type ), borderWidth( type ), shade() ); | 299 | highlightWidth( type ), borderWidth( type ), shade() ); |
296 | } | 300 | } |
297 | p->setPen( oldPen ); | 301 | p->setPen( oldPen ); |
298 | } | 302 | } |
299 | 303 | ||
300 | void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, | 304 | void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, |
301 | const QColorGroup &g, bool sunken, | 305 | const QColorGroup &g, bool sunken, |
302 | const QBrush *fill ) | 306 | const QBrush *fill ) |
303 | { | 307 | { |
304 | drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? | 308 | drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? |