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 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);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
@ -145,7 +145,8 @@ void FlatButton::paintEvent(QPaintEvent *event)
|
|||
painter.setOpacity(haloOpacity);
|
||||
painter.setBrush(brush);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.drawEllipse(rect().center(), hs, hs);
|
||||
QPointF center = rect().center();
|
||||
painter.drawEllipse(center, hs, hs);
|
||||
}
|
||||
|
||||
QStylePainter style(this);
|
||||
|
|
|
@ -134,20 +134,26 @@ void RaisedButton::paintEvent(QPaintEvent *event)
|
|||
painter.save();
|
||||
|
||||
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();
|
||||
const qreal haloOpacity = d->delegate->focusHaloOpacity();
|
||||
if (isEnabled()) {
|
||||
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));
|
||||
painter.setBrush(brush);
|
||||
painter.setOpacity(haloOpacity);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.drawEllipse(rect().center(), hs, hs);
|
||||
if (isEnabled()) {
|
||||
const qreal hs = static_cast<qreal>(width())*d->delegate->focusHaloSize()/2;
|
||||
const qreal haloOpacity = d->delegate->focusHaloOpacity();
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ RaisedButtonExamples::RaisedButtonExamples(QWidget *parent)
|
|||
raisedButton->setRole(Material::Primary);
|
||||
raisedButton->setText("Press me!");
|
||||
|
||||
raisedButton->setDisabled(true);
|
||||
|
||||
//raisedButton->setFixedSize(400, 50);
|
||||
|
||||
layout->addWidget(raisedButton);
|
||||
|
|
Loading…
Reference in New Issue