make halo animation use float precision
This commit is contained in:
parent
eab46ed72f
commit
f541a86301
|
@ -123,7 +123,7 @@ void FlatButton::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
const qreal bgOpacity = d->delegate->backgroundOpacity();
|
const qreal bgOpacity = d->delegate->backgroundOpacity();
|
||||||
const qreal haloOpacity = d->delegate->focusHaloOpacity();
|
const qreal haloOpacity = d->delegate->focusHaloOpacity();
|
||||||
const int hs = (width()/2)*d->delegate->focusHaloSize();
|
const qreal hs = static_cast<qreal>(width())*d->delegate->focusHaloSize()/2;
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
@ -145,7 +145,8 @@ void FlatButton::paintEvent(QPaintEvent *event)
|
||||||
painter.setOpacity(haloOpacity);
|
painter.setOpacity(haloOpacity);
|
||||||
painter.setBrush(brush);
|
painter.setBrush(brush);
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
painter.drawEllipse(rect().center(), hs, hs);
|
QPointF center = rect().center();
|
||||||
|
painter.drawEllipse(center, hs, hs);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStylePainter style(this);
|
QStylePainter style(this);
|
||||||
|
|
|
@ -134,20 +134,26 @@ void RaisedButton::paintEvent(QPaintEvent *event)
|
||||||
painter.save();
|
painter.save();
|
||||||
|
|
||||||
QBrush brush;
|
QBrush brush;
|
||||||
brush.setStyle(Qt::SolidPattern);
|
|
||||||
brush.setColor(palette().color(QPalette::Active, QPalette::Background));
|
|
||||||
painter.setBrush(brush);
|
|
||||||
painter.setPen(Qt::NoPen);
|
|
||||||
painter.drawRoundedRect(rect(), 3, 3);
|
|
||||||
|
|
||||||
const int hs = (width()/2)*d->delegate->focusHaloSize();
|
if (isEnabled()) {
|
||||||
const qreal haloOpacity = d->delegate->focusHaloOpacity();
|
brush.setStyle(Qt::SolidPattern);
|
||||||
|
brush.setColor(palette().color(QPalette::Active, QPalette::Background));
|
||||||
|
painter.setBrush(brush);
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.drawRoundedRect(rect(), 3, 3);
|
||||||
|
}
|
||||||
|
|
||||||
brush.setColor(palette().color(QPalette::Active, QPalette::ButtonText));
|
if (isEnabled()) {
|
||||||
painter.setBrush(brush);
|
const qreal hs = static_cast<qreal>(width())*d->delegate->focusHaloSize()/2;
|
||||||
painter.setOpacity(haloOpacity);
|
const qreal haloOpacity = d->delegate->focusHaloOpacity();
|
||||||
painter.setPen(Qt::NoPen);
|
|
||||||
painter.drawEllipse(rect().center(), hs, hs);
|
brush.setColor(palette().color(QPalette::Active, QPalette::ButtonText));
|
||||||
|
painter.setBrush(brush);
|
||||||
|
painter.setOpacity(haloOpacity);
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
QPointF center = rect().center();
|
||||||
|
painter.drawEllipse(center, hs, hs);
|
||||||
|
}
|
||||||
|
|
||||||
painter.restore();
|
painter.restore();
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ RaisedButtonExamples::RaisedButtonExamples(QWidget *parent)
|
||||||
raisedButton->setRole(Material::Primary);
|
raisedButton->setRole(Material::Primary);
|
||||||
raisedButton->setText("Press me!");
|
raisedButton->setText("Press me!");
|
||||||
|
|
||||||
|
raisedButton->setDisabled(true);
|
||||||
|
|
||||||
//raisedButton->setFixedSize(400, 50);
|
//raisedButton->setFixedSize(400, 50);
|
||||||
|
|
||||||
layout->addWidget(raisedButton);
|
layout->addWidget(raisedButton);
|
||||||
|
|
Loading…
Reference in New Issue