| 177 | Q_EMIT pMinimumChanged(); |
| 178 | Q_EMIT pMaximumChanged(); |
| 179 | Q_EMIT rangeChanged(min, max); |
| 180 | } |
| 181 | |
| 182 | void ElaProgressRing::paintEvent(QPaintEvent* event) |
| 183 | { |
| 184 | Q_D(ElaProgressRing); |
| 185 | QPainter painter(this); |
| 186 | painter.save(); |
| 187 | painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); |
| 188 | // 文字绘制 |
| 189 | if (d->_pIsDisplayValue && !d->_pIsBusying) |
| 190 | { |
| 191 | painter.setPen(ElaThemeColor(d->_themeMode, BasicText)); |
| 192 | QString valueText; |
| 193 | if (d->_pValueDisplayMode == ElaProgressRingType::ValueDisplayMode::Actual) |
| 194 | { |
| 195 | valueText = QString::number(d->_pValue); |
| 196 | } |
| 197 | else |
| 198 | { |
| 199 | valueText = QString::number(d->_pValue / (qreal)(d->_pMaximum - d->_pMinimum) * 100) + "%"; |
| 200 | } |
| 201 | painter.drawText(rect(), Qt::AlignCenter | Qt::TextSingleLine, valueText); |
| 202 | } |
| 203 | // Ring绘制 |
| 204 | QRect ringRect = rect().adjusted(1, 1, -1, -1); |
| 205 | // 遮罩 |
| 206 | QPainterPath basePath; |
| 207 | basePath.addEllipse(ringRect); |
| 208 | QPainterPath maskPath; |
| 209 | maskPath.addEllipse(ringRect.adjusted(d->_pBusyingWidth, d->_pBusyingWidth, -d->_pBusyingWidth, -d->_pBusyingWidth)); |
| 210 | painter.setClipPath(basePath.subtracted(maskPath)); |
| 211 | painter.setPen(Qt::NoPen); |
| 212 | // 底色 |
| 213 | if (!d->_pIsTransparent) |
| 214 | { |
| 215 | painter.setBrush(ElaColorAnimation::getColor(this, ElaThemeColor(d->_themeMode, BasicBaseAlpha), "Track")); |
| 216 | painter.drawEllipse(ringRect); |
| 217 | } |
| 218 | // 环 |
| 219 | painter.setBrush(ElaColorAnimation::getColor(this, ElaThemeColor(d->_themeMode, PrimaryNormal), "Progress")); |
| 220 | if (d->_pIsBusying) |
| 221 | { |
| 222 | painter.drawPie(ringRect, -d->_pBusyStartDeg * 16, d->_pBusyContentDeg * 16); |
| 223 | } |
| 224 | else |
| 225 | { |
| 226 | qreal valueDeg = d->_pValue / (qreal)(d->_pMaximum - d->_pMinimum) * 360; |
| 227 | painter.drawPie(ringRect, 90 * 16, -valueDeg * 16); |
| 228 | } |
| 229 | painter.restore(); |
| 230 | } |
nothing calls this directly
no outgoing calls
no test coverage detected