summaryrefslogtreecommitdiff
path: root/core
authorsandman <sandman>2002-06-27 22:03:59 (UTC)
committer sandman <sandman>2002-06-27 22:03:59 (UTC)
commit49710f20cf0e52ea3393027ed066f11e977e3457 (patch) (side-by-side diff)
tree9840e5abb500042efdcd857ba837bdfe673e2485 /core
parentc9871ef295afed6bc4f4cc5451f46bf3b6e8d462 (diff)
downloadopie-49710f20cf0e52ea3393027ed066f11e977e3457.zip
opie-49710f20cf0e52ea3393027ed066f11e977e3457.tar.gz
opie-49710f20cf0e52ea3393027ed066f11e977e3457.tar.bz2
Workaround for the "LEDs dont't show on 38xx" aka "Qt/E is too dumb to
draw a circle" bug
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/volumeapplet/oledbox.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/applets/volumeapplet/oledbox.cpp b/core/applets/volumeapplet/oledbox.cpp
index 3036929..7547287 100644
--- a/core/applets/volumeapplet/oledbox.cpp
+++ b/core/applets/volumeapplet/oledbox.cpp
@@ -128,48 +128,50 @@ void OLedBox::paintEvent ( QPaintEvent *e )
{
int ind = m_on ? 1 : 0;
if ( !m_pix [ ind ] ) {
m_pix [ ind ] = new QPixmap ( size ( ));
drawLed ( m_pix [ ind ], m_on ? m_color : m_color. dark ( 300 ) );
}
if ( !e-> erased ( ))
erase ( );
QPainter p ( this );
p. drawPixmap ( 0, 0, *m_pix [ ind ] );
}
// From KDE libkdeui / led.cpp
void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp
{
QPainter paint;
QColor color;
QBrush brush;
QPen pen;
+ pix-> fill ( black );
+
// First of all we want to know what area should be updated
// Initialize coordinates, width, and height of the LED
int width = pix-> width ( );
// Make sure the LED is round!
if ( width > pix-> height ( ))
width = pix-> height ( );
width -= 2; // leave one pixel border
if ( width < 0 )
width = 0;
// maybe we could stop HERE, if width <=0 ?
// start painting widget
//
paint.begin( pix );
// Set the color of the LED according to given parameters
color = col;
// Set the brush to SolidPattern, this fills the entire area
// of the ellipse which is drawn first
brush.setStyle( QBrush::SolidPattern );
brush.setColor( color );
@@ -198,73 +200,76 @@ void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNK
while ( light_width )
{
color = color.light( light_quote ); // make color lighter
pen.setColor( color ); // set color as pen color
paint.setPen( pen ); // select the pen for drawing
paint.drawEllipse( pos, pos, light_width, light_width ); // draw the ellipse (circle)
light_width--;
if ( !light_width )
break;
paint.drawEllipse( pos, pos, light_width, light_width );
light_width--;
if ( !light_width )
break;
paint.drawEllipse( pos, pos, light_width, light_width );
pos++;
light_width--;
}
// Drawing of bright spot finished, now draw a thin border
// around the LED which resembles a shadow with light coming
// from the upper left.
#ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC
paint. drawPixmap ( 0, 0, *s_border_pix );
-
+ paint. end ( );
+
+ pix-> setMask ( pix-> createHeuristicMask ( ));
+
#else
pen.setWidth( 3 );
brush.setStyle( QBrush::NoBrush ); // Switch off the brush
paint.setBrush( brush ); // This avoids filling of the ellipse
// Set the initial color value to 200 (bright) and start
// drawing the shadow border at 45 (45*16 = 720).
int shadow_color = 200, angle;
for ( angle = 720; angle < 6480; angle += 240 )
{
color.setRgb( shadow_color, shadow_color, shadow_color );
pen.setColor( color );
paint.setPen( pen );
paint.drawArc( 0, 0, width+2, width+2, angle, 240 );
paint.drawArc( 1, 1, width, width, angle, 240 );
paint.drawArc( 2, 2, width-2, width-2, angle, 240 );
if ( angle < 2320 ) {
shadow_color -= 25; // set color to a darker value
if ( shadow_color < 100 )
shadow_color = 100;
}
else if ( ( angle > 2320 ) && ( angle < 5760 ) ) {
shadow_color += 25; // set color to a brighter value
if ( shadow_color > 255 )
shadow_color = 255;
}
else {
shadow_color -= 25; // set color to a darker value again
if ( shadow_color < 100 )
shadow_color = 100;
} // end if ( angle < 2320 )
} // end for ( angle = 720; angle < 6480; angle += 160 )
-#endif
paint.end();
//
// painting done
QBitmap mask ( pix-> width ( ), pix-> height ( ), true );
QPainter mp ( &mask );
mp. setPen ( Qt::NoPen );
mp. setBrush ( Qt::color1 );
mp. drawEllipse ( 0, 0, width + 2, width + 2 );
mp. end ( );
-
+
pix-> setMask ( mask );
+#endif
}