| 91 | } |
| 92 | |
| 93 | void ElaMessageButton::paintEvent(QPaintEvent* event) |
| 94 | { |
| 95 | Q_D(ElaMessageButton); |
| 96 | QPainter painter(this); |
| 97 | painter.setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing | QPainter::TextAntialiasing); |
| 98 | // 高性能阴影 |
| 99 | eTheme->drawEffectShadow(&painter, rect(), d->_shadowBorderWidth, d->_pBorderRadius); |
| 100 | |
| 101 | // 背景绘制 |
| 102 | painter.save(); |
| 103 | QRect foregroundRect(d->_penBorderWidth + d->_shadowBorderWidth, d->_penBorderWidth + d->_shadowBorderWidth, width() - 2 * (d->_penBorderWidth + d->_shadowBorderWidth), height() - 2 * (d->_penBorderWidth + d->_shadowBorderWidth)); |
| 104 | painter.setPen(QPen(ElaThemeColor(d->_themeMode, BasicBorder), d->_penBorderWidth)); |
| 105 | painter.setBrush(isEnabled() ? underMouse() ? ElaThemeColor(d->_themeMode, BasicHover) : ElaThemeColor(d->_themeMode, BasicBase) : ElaThemeColor(d->_themeMode, BasicDisable)); |
| 106 | painter.drawRoundedRect(foregroundRect, d->_pBorderRadius, d->_pBorderRadius); |
| 107 | |
| 108 | //文字绘制 |
| 109 | painter.setPen(isEnabled() ? d->_isLeftButtonPress ? ElaThemeColor(d->_themeMode, BasicTextPress) : ElaThemeColor(d->_themeMode, BasicText) : ElaThemeColor(d->_themeMode, BasicTextDisable)); |
| 110 | painter.drawText(rect(), Qt::AlignCenter, text()); |
| 111 | painter.restore(); |
| 112 | } |
nothing calls this directly
no test coverage detected