Mercurial > hg > svgui
changeset 987:3f7cdfc56dce 3.0-integration
Merge from branch osx-retina
author | Chris Cannam |
---|---|
date | Wed, 01 Jul 2015 13:21:08 +0100 |
parents | 98827470ada2 (current diff) e8949ccb4f4e (diff) |
children | 4f4f0e158ecf |
files | widgets/PropertyBox.cpp |
diffstat | 3 files changed, 18 insertions(+), 79 deletions(-) [+] |
line wrap: on
line diff
--- a/widgets/LEDButton.cpp Fri Jun 26 14:13:31 2015 +0100 +++ b/widgets/LEDButton.cpp Wed Jul 01 13:21:08 2015 +0100 @@ -38,8 +38,6 @@ int dark_factor; QColor offcolor; - QPixmap *off_map; - QPixmap *on_map; }; @@ -51,8 +49,6 @@ d = new LEDButton::LEDButtonPrivate; d->dark_factor = 300; d->offcolor = col.dark(300); - d->off_map = 0; - d->on_map = 0; setColor(col); } @@ -65,8 +61,6 @@ d = new LEDButton::LEDButtonPrivate; d->dark_factor = 300; d->offcolor = col.dark(300); - d->off_map = 0; - d->on_map = 0; setColor(col); } @@ -78,16 +72,12 @@ d = new LEDButton::LEDButtonPrivate; d->dark_factor = 300; d->offcolor = col.dark(300); - d->off_map = 0; - d->on_map = 0; setColor(col); } LEDButton::~LEDButton() { - delete d->off_map; - delete d->on_map; delete d; } @@ -135,40 +125,7 @@ if (width < 0) width = 0; - QPixmap *tmpMap = 0; - - if (led_state) { - if (d->on_map) { - if (d->on_map->size() == size()) { - paint.begin(this); - paint.drawPixmap(0, 0, *d->on_map); - paint.end(); - return; - } else { - delete d->on_map; - d->on_map = 0; - } - } - } else { - if (d->off_map) { - if (d->off_map->size() == size()) { - paint.begin(this); - paint.drawPixmap(0, 0, *d->off_map); - paint.end(); - return; - } else { - delete d->off_map; - d->off_map = 0; - } - } - } - - int scale = 1; - width *= scale; - - tmpMap = new QPixmap(width, width); - tmpMap->fill(palette().background().color()); - paint.begin(tmpMap); + paint.begin(this); paint.setRenderHint(QPainter::Antialiasing, true); @@ -182,14 +139,14 @@ paint.setBrush(brush); // Draws a "flat" LED with the given color: - paint.drawEllipse( scale, scale, width - scale*2, width - scale*2 ); + paint.drawEllipse( 1, 1, width - 2, width - 2 ); // Draw the bright light spot of the LED now, using modified "old" // painter routine taken from KDEUI´s LEDButton widget: // Setting the new width of the pen is essential to avoid "pixelized" // shadow like it can be observed with the old LED code - pen.setWidth( 2 * scale ); + pen.setWidth( 2 ); // shrink the light on the LED to a size about 2/3 of the complete LED int pos = width/5 + 1; @@ -217,12 +174,13 @@ pos++; light_width--; } + paint.drawPoint(pos, pos); + // Drawing of bright spot finished, now draw a thin border // around the LED which resembles a shadow with light coming // from the upper left. -// pen.setWidth( 2 * scale + 1 ); // ### shouldn't this value be smaller for smaller LEDs? - pen.setWidth(2 * scale); + pen.setWidth(2); brush.setStyle(Qt::NoBrush); paint.setBrush(brush); // This avoids filling of the ellipse @@ -235,36 +193,13 @@ for (int arc = 120; arc < 2880; arc += 240) { pen.setColor(color); paint.setPen(pen); - int w = width - pen.width()/2 - scale + 1; + 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(); - // - // painting done - - QPixmap *&dest = led_state ? d->on_map : d->off_map; - - if (scale > 1) { - - QImage i = tmpMap->toImage(); - width /= scale; - delete tmpMap; - dest = new QPixmap(QPixmap::fromImage - (i.scaled(width, width, - Qt::KeepAspectRatio, - Qt::SmoothTransformation))); - - } else { - - dest = tmpMap; - } - - paint.begin(this); - paint.drawPixmap(0, 0, *dest); - paint.end(); } bool @@ -303,10 +238,6 @@ if(led_color!=col) { led_color = col; d->offcolor = col.dark(d->dark_factor); - delete d->on_map; - d->on_map = 0; - delete d->off_map; - d->off_map = 0; update(); } }
--- a/widgets/PropertyBox.cpp Fri Jun 26 14:13:31 2015 +0100 +++ b/widgets/PropertyBox.cpp Wed Jul 01 13:21:08 2015 +0100 @@ -63,6 +63,12 @@ m_mainBox = new QVBoxLayout; setLayout(m_mainBox); +#ifdef Q_OS_MAC + QMargins mm = m_mainBox->contentsMargins(); + QMargins mmhalf(mm.left()/2, mm.top()/3, mm.right()/2, mm.bottom()/3); + m_mainBox->setContentsMargins(mmhalf); +#endif + // m_nameWidget = new QLabel; // m_mainBox->addWidget(m_nameWidget); // m_nameWidget->setText(container->objectName()); @@ -521,8 +527,10 @@ cb->blockSignals(false); #ifdef Q_OS_MAC - // Crashes on startup without this, for some reason - cb->setMinimumSize(QSize(10, 10)); + // Crashes on startup without this, for some reason; also + // prevents combo boxes from getting weirdly squished + // vertically + cb->setMinimumSize(QSize(10, cb->font().pixelSize() * 2)); #endif break;