-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 @@ #include <cmath> //====================================================================== // // Gradient effects // //====================================================================== QPixmap& OGfxEffect::gradient(QPixmap &pixmap, const QColor &ca, const QColor &cb, GradientType eff, int ncols) { - QImage image = gradient(pixmap.size(), ca, cb, eff, ncols); - pixmap.convertFromImage(image); - + if ( !pixmap. isNull ( )) { + QImage image = gradient(pixmap.size(), ca, cb, eff, ncols); + pixmap.convertFromImage(image); + } return pixmap; } QImage OGfxEffect::gradient(const QSize &size, const QColor &ca, const QColor &cb, GradientType eff, int /*ncols*/) { int rDiff, gDiff, bDiff; int rca, gca, bca, rcb, gcb, bcb; QImage image(size, 32); if (size.width() == 0 || size.height() == 0) { @@ -271,33 +272,34 @@ QImage OGfxEffect::gradient(const QSize &size, const QColor &ca, //====================================================================== // // Blend effects // //====================================================================== QPixmap& OGfxEffect::blend(QPixmap &pixmap, float initial_intensity, const QColor &bgnd, GradientType eff, bool anti_dir, int /*ncols*/) { - QImage image = pixmap.convertToImage(); - OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); - - if ( pixmap. depth ( ) <= 8 ) - image. convertDepth ( pixmap. depth ( )); + if ( !pixmap. isNull ( )) { + QImage image = pixmap.convertToImage(); + OGfxEffect::blend(image, initial_intensity, bgnd, eff, anti_dir); - pixmap.convertFromImage(image); + if ( pixmap. depth ( ) <= 8 ) + image. convertDepth ( pixmap. depth ( )); - return pixmap; + pixmap.convertFromImage(image); + } + return pixmap; } QImage& OGfxEffect::blend(QImage &image, float initial_intensity, const QColor &bgnd, GradientType eff, bool anti_dir) { if (image.width() == 0 || image.height() == 0) { qDebug ( "Invalid image\n" ); return image; } 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 ) if ( ev-> type ( ) == QEvent::Paint ) { HackProgressBar *pb = (HackProgressBar *) obj; pb-> paint ((QPaintEvent *) ev, this ); return true; } return false; } void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, bool rounded, WidgetType type, const QBrush * ) { + if ( w <= 0 || h <= 0 ) + return; + int offset = borderPixmap( type ) ? 0 : decoWidth( type ); QPen oldPen = p->pen(); // handle reverse bevel here since it uses decowidth differently if ( gradientHint( type ) == GrReverseBevel ) { int i; bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h, Qt::CopyROP, true ); p->setPen( g.text() ); for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 ) p->drawRect( x, y, w, h ); } @@ -278,27 +281,28 @@ void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h, if ( isPixmap( type ) ) if ( rounded ) p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) ); else p->drawTiledPixmap( x + offset, y + offset, w - offset * 2, h - offset * 2, *scalePixmap( w - offset * 2, h - offset * 2, type ) ); else p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2, g.brush( QColorGroup::Button ) ); } - if ( borderPixmap( type ) ) + if ( borderPixmap( type ) ) { bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h, Qt::CopyROP, false ); + } else drawShade( p, x, y, w, h, g, sunken, rounded, highlightWidth( type ), borderWidth( type ), shade() ); } p->setPen( oldPen ); } void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, bool sunken, const QBrush *fill ) { drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ? |