| 88 | QPushButton::mouseReleaseEvent(event); |
| 89 | } |
| 90 | |
| 91 | void ElaPushButton::paintEvent(QPaintEvent* event) |
| 92 | { |
| 93 | Q_D(ElaPushButton); |
| 94 | QPainter painter(this); |
| 95 | painter.setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing | QPainter::TextAntialiasing); |
| 96 | // 高性能阴影 |
| 97 | eTheme->drawEffectShadow(&painter, rect(), d->_shadowBorderWidth, d->_pBorderRadius); |
| 98 | |
| 99 | // 背景绘制 |
| 100 | painter.save(); |
| 101 | QRect foregroundRect(d->_shadowBorderWidth, d->_shadowBorderWidth, width() - 2 * (d->_shadowBorderWidth), height() - 2 * d->_shadowBorderWidth); |
| 102 | if (d->_themeMode == ElaThemeType::Light) |
| 103 | { |
| 104 | painter.setPen(ElaThemeColor(ElaThemeType::Light, BasicBorder)); |
| 105 | painter.setBrush(isEnabled() ? d->_isPressed ? d->_pLightPressColor : (underMouse() ? d->_pLightHoverColor : d->_pLightDefaultColor) : ElaThemeColor(d->_themeMode, BasicDisable)); |
| 106 | } |
| 107 | else |
| 108 | { |
| 109 | painter.setPen(Qt::NoPen); |
| 110 | painter.setBrush(isEnabled() ? d->_isPressed ? d->_pDarkPressColor : (underMouse() ? d->_pDarkHoverColor : d->_pDarkDefaultColor) : ElaThemeColor(d->_themeMode, BasicDisable)); |
| 111 | } |
| 112 | painter.drawRoundedRect(foregroundRect, d->_pBorderRadius, d->_pBorderRadius); |
| 113 | // 底边线绘制 |
| 114 | if (!d->_isPressed) |
| 115 | { |
| 116 | painter.setPen(ElaThemeColor(d->_themeMode, BasicBaseLine)); |
| 117 | painter.drawLine(foregroundRect.x() + d->_pBorderRadius, height() - d->_shadowBorderWidth, foregroundRect.width(), height() - d->_shadowBorderWidth); |
| 118 | } |
| 119 | //文字绘制 |
| 120 | painter.setPen(isEnabled() ? d->_themeMode == ElaThemeType::Light ? d->_lightTextColor : d->_darkTextColor : ElaThemeColor(d->_themeMode, BasicTextDisable)); |
| 121 | painter.drawText(foregroundRect, Qt::AlignCenter, text()); |
| 122 | painter.restore(); |
| 123 | } |
nothing calls this directly
no test coverage detected