Mercurial > hg > svgui
diff widgets/LEDButton.cpp @ 1266:a34a2a25907c
Untabify
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 18:02:22 +0000 |
parents | 3f5c82034f9b |
children | d39db4673676 |
line wrap: on
line diff
--- a/widgets/LEDButton.cpp Thu Mar 01 14:43:53 2018 +0000 +++ b/widgets/LEDButton.cpp Thu Mar 01 18:02:22 2018 +0000 @@ -88,10 +88,10 @@ cerr << "LEDButton(" << this << ")::mousePressEvent" << endl; if (e->buttons() & Qt::LeftButton) { - toggle(); - bool newState = state(); - SVDEBUG << "emitting new state " << newState << endl; - emit stateChanged(newState); + toggle(); + bool newState = state(); + SVDEBUG << "emitting new state " << newState << endl; + emit stateChanged(newState); } } @@ -114,17 +114,17 @@ QColor color; QBrush brush; QPen pen; - + // First of all we want to know what area should be updated // Initialize coordinates, width, and height of the LED - int width = this->width(); + int width = this->width(); // Make sure the LED is round! if (width > this->height()) - width = this->height(); + width = this->height(); width -= 2; // leave one pixel border if (width < 0) - width = 0; + width = 0; paint.begin(this); @@ -154,25 +154,25 @@ int light_width = width; light_width *= 2; light_width /= 3; - + // Calculate the LEDīs "light factor": int light_quote = (130*2/(light_width?light_width:1))+100; // Now draw the bright spot on the LED: 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--; + 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--; } paint.drawPoint(pos, pos); @@ -192,13 +192,13 @@ color = palette().light().color(); for (int arc = 120; arc < 2880; arc += 240) { - pen.setColor(color); - paint.setPen(pen); - int w = width - pen.width()/2; - paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle + arc, 240); - paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle - arc, 240); - color = color.dark(110); //FIXME: this should somehow use the contrast value - } // end for ( angle = 720; angle < 6480; angle += 160 ) + pen.setColor(color); + paint.setPen(pen); + int w = width - pen.width()/2; + paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle + arc, 240); + paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle - arc, 240); + color = color.dark(110); //FIXME: this should somehow use the contrast value + } // end for ( angle = 720; angle < 6480; angle += 160 ) paint.end(); } @@ -220,8 +220,8 @@ { if (led_state != state) { - led_state = state; - update(); + led_state = state; + update(); } } @@ -237,9 +237,9 @@ LEDButton::setColor(const QColor& col) { if(led_color!=col) { - led_color = col; - d->offcolor = col.dark(d->dark_factor); - update(); + led_color = col; + d->offcolor = col.dark(d->dark_factor); + update(); } } @@ -247,9 +247,9 @@ LEDButton::setDarkFactor(int darkfactor) { if (d->dark_factor != darkfactor) { - d->dark_factor = darkfactor; - d->offcolor = led_color.dark(darkfactor); - update(); + d->dark_factor = darkfactor; + d->offcolor = led_color.dark(darkfactor); + update(); } }