author | sandman <sandman> | 2002-06-27 22:03:59 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-27 22:03:59 (UTC) |
commit | 49710f20cf0e52ea3393027ed066f11e977e3457 (patch) (unidiff) | |
tree | 9840e5abb500042efdcd857ba837bdfe673e2485 | |
parent | c9871ef295afed6bc4f4cc5451f46bf3b6e8d462 (diff) | |
download | opie-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
-rw-r--r-- | core/applets/volumeapplet/oledbox.cpp | 11 |
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 | |||
@@ -140,24 +140,26 @@ void OLedBox::paintEvent ( QPaintEvent *e ) | |||
140 | p. drawPixmap ( 0, 0, *m_pix [ ind ] ); | 140 | p. drawPixmap ( 0, 0, *m_pix [ ind ] ); |
141 | } | 141 | } |
142 | 142 | ||
143 | // From KDE libkdeui / led.cpp | 143 | // From KDE libkdeui / led.cpp |
144 | 144 | ||
145 | void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp | 145 | void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNKEN led lamp |
146 | { | 146 | { |
147 | QPainter paint; | 147 | QPainter paint; |
148 | QColor color; | 148 | QColor color; |
149 | QBrush brush; | 149 | QBrush brush; |
150 | QPen pen; | 150 | QPen pen; |
151 | 151 | ||
152 | pix-> fill ( black ); | ||
153 | |||
152 | // First of all we want to know what area should be updated | 154 | // First of all we want to know what area should be updated |
153 | // Initialize coordinates, width, and height of the LED | 155 | // Initialize coordinates, width, and height of the LED |
154 | int width = pix-> width ( ); | 156 | int width = pix-> width ( ); |
155 | 157 | ||
156 | // Make sure the LED is round! | 158 | // Make sure the LED is round! |
157 | if ( width > pix-> height ( )) | 159 | if ( width > pix-> height ( )) |
158 | width = pix-> height ( ); | 160 | width = pix-> height ( ); |
159 | width -= 2; // leave one pixel border | 161 | width -= 2; // leave one pixel border |
160 | if ( width < 0 ) | 162 | if ( width < 0 ) |
161 | width = 0; | 163 | width = 0; |
162 | 164 | ||
163 | // maybe we could stop HERE, if width <=0 ? | 165 | // maybe we could stop HERE, if width <=0 ? |
@@ -210,25 +212,28 @@ void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNK | |||
210 | break; | 212 | break; |
211 | paint.drawEllipse( pos, pos, light_width, light_width ); | 213 | paint.drawEllipse( pos, pos, light_width, light_width ); |
212 | pos++; | 214 | pos++; |
213 | light_width--; | 215 | light_width--; |
214 | } | 216 | } |
215 | 217 | ||
216 | // Drawing of bright spot finished, now draw a thin border | 218 | // Drawing of bright spot finished, now draw a thin border |
217 | // around the LED which resembles a shadow with light coming | 219 | // around the LED which resembles a shadow with light coming |
218 | // from the upper left. | 220 | // from the upper left. |
219 | 221 | ||
220 | #ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC | 222 | #ifdef _QTE_IS_TOO_DUMB_TO_DRAW_AN_ARC |
221 | paint. drawPixmap ( 0, 0, *s_border_pix ); | 223 | paint. drawPixmap ( 0, 0, *s_border_pix ); |
222 | 224 | paint. end ( ); | |
225 | |||
226 | pix-> setMask ( pix-> createHeuristicMask ( )); | ||
227 | |||
223 | #else | 228 | #else |
224 | pen.setWidth( 3 ); | 229 | pen.setWidth( 3 ); |
225 | brush.setStyle( QBrush::NoBrush ); // Switch off the brush | 230 | brush.setStyle( QBrush::NoBrush ); // Switch off the brush |
226 | paint.setBrush( brush ); // This avoids filling of the ellipse | 231 | paint.setBrush( brush ); // This avoids filling of the ellipse |
227 | 232 | ||
228 | // Set the initial color value to 200 (bright) and start | 233 | // Set the initial color value to 200 (bright) and start |
229 | // drawing the shadow border at 45 (45*16 = 720). | 234 | // drawing the shadow border at 45 (45*16 = 720). |
230 | int shadow_color = 200, angle; | 235 | int shadow_color = 200, angle; |
231 | 236 | ||
232 | for ( angle = 720; angle < 6480; angle += 240 ) | 237 | for ( angle = 720; angle < 6480; angle += 240 ) |
233 | { | 238 | { |
234 | color.setRgb( shadow_color, shadow_color, shadow_color ); | 239 | color.setRgb( shadow_color, shadow_color, shadow_color ); |
@@ -244,27 +249,27 @@ void OLedBox::drawLed ( QPixmap *pix, const QColor &col ) // paint a ROUND SUNK | |||
244 | } | 249 | } |
245 | else if ( ( angle > 2320 ) && ( angle < 5760 ) ) { | 250 | else if ( ( angle > 2320 ) && ( angle < 5760 ) ) { |
246 | shadow_color += 25; // set color to a brighter value | 251 | shadow_color += 25; // set color to a brighter value |
247 | if ( shadow_color > 255 ) | 252 | if ( shadow_color > 255 ) |
248 | shadow_color = 255; | 253 | shadow_color = 255; |
249 | } | 254 | } |
250 | else { | 255 | else { |
251 | shadow_color -= 25; // set color to a darker value again | 256 | shadow_color -= 25; // set color to a darker value again |
252 | if ( shadow_color < 100 ) | 257 | if ( shadow_color < 100 ) |
253 | shadow_color = 100; | 258 | shadow_color = 100; |
254 | } // end if ( angle < 2320 ) | 259 | } // end if ( angle < 2320 ) |
255 | } // end for ( angle = 720; angle < 6480; angle += 160 ) | 260 | } // end for ( angle = 720; angle < 6480; angle += 160 ) |
256 | #endif | ||
257 | paint.end(); | 261 | paint.end(); |
258 | // | 262 | // |
259 | // painting done | 263 | // painting done |
260 | 264 | ||
261 | QBitmap mask ( pix-> width ( ), pix-> height ( ), true ); | 265 | QBitmap mask ( pix-> width ( ), pix-> height ( ), true ); |
262 | QPainter mp ( &mask ); | 266 | QPainter mp ( &mask ); |
263 | mp. setPen ( Qt::NoPen ); | 267 | mp. setPen ( Qt::NoPen ); |
264 | mp. setBrush ( Qt::color1 ); | 268 | mp. setBrush ( Qt::color1 ); |
265 | mp. drawEllipse ( 0, 0, width + 2, width + 2 ); | 269 | mp. drawEllipse ( 0, 0, width + 2, width + 2 ); |
266 | mp. end ( ); | 270 | mp. end ( ); |
267 | 271 | ||
268 | pix-> setMask ( mask ); | 272 | pix-> setMask ( mask ); |
273 | #endif | ||
269 | } | 274 | } |
270 | 275 | ||