Changeset View
Changeset View
Standalone View
Standalone View
qt5/style/qtcurve_api.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 1307 Lines • ▼ Show 20 Line(s) | 1149 | #endif | |||
|---|---|---|---|---|---|
| 1308 | case QEvent::StyleChange: | 1308 | case QEvent::StyleChange: | ||
| 1309 | case QEvent::Show: | 1309 | case QEvent::Show: | ||
| 1310 | { | 1310 | { | ||
| 1311 | QProgressBar *bar = qobject_cast<QProgressBar *>(object); | 1311 | QProgressBar *bar = qobject_cast<QProgressBar *>(object); | ||
| 1312 | 1312 | | |||
| 1313 | if(bar) | 1313 | if(bar) | ||
| 1314 | { | 1314 | { | ||
| 1315 | m_progressBars.insert(bar); | 1315 | m_progressBars.insert(bar); | ||
| 1316 | if (1==m_progressBars.size()) | 1316 | if (!m_progressBarAnimateTimer) { | ||
| 1317 | { | 1317 | if (opts.animatedProgress || (0 == bar->minimum() && 0 == bar->maximum())) { | ||
| 1318 | // we know we'll need a timer, start it at once | ||||
| 1319 | if (m_timer.isNull()) { | ||||
| 1318 | m_timer.start(); | 1320 | m_timer.start(); | ||
| 1319 | m_progressBarAnimateTimer = startTimer(1000 / constProgressBarFps); | 1321 | } | ||
| 1322 | m_progressBarAnimateFps = constProgressBarFps; | ||||
| 1323 | m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); | ||||
| 1324 | } | ||||
| 1320 | } | 1325 | } | ||
| 1321 | } else if (!(opts.square & SQUARE_POPUP_MENUS) && | 1326 | } else if (!(opts.square & SQUARE_POPUP_MENUS) && | ||
| 1322 | object->inherits("QComboBoxPrivateContainer")) { | 1327 | object->inherits("QComboBoxPrivateContainer")) { | ||
| 1323 | QWidget *widget = static_cast<QWidget*>(object); | 1328 | QWidget *widget = static_cast<QWidget*>(object); | ||
| 1324 | if (Utils::hasAlphaChannel(widget)) { | 1329 | if (Utils::hasAlphaChannel(widget)) { | ||
| 1325 | widget->clearMask(); | 1330 | widget->clearMask(); | ||
| 1326 | } else { | 1331 | } else { | ||
| 1327 | widget->setMask(windowMask(widget->rect(), | 1332 | widget->setMask(windowMask(widget->rect(), | ||
| Show All 18 Lines | 1350 | setBgndProp(widget, opts.bgndAppearance, | |||
| 1346 | IMG_NONE != opts.bgndImage.type); | 1351 | IMG_NONE != opts.bgndImage.type); | ||
| 1347 | int opacity = (qtcIsDialog(widget) ? opts.dlgOpacity : | 1352 | int opacity = (qtcIsDialog(widget) ? opts.dlgOpacity : | ||
| 1348 | opts.bgndOpacity); | 1353 | opts.bgndOpacity); | ||
| 1349 | setOpacityProp(widget, (unsigned short)opacity); | 1354 | setOpacityProp(widget, (unsigned short)opacity); | ||
| 1350 | } | 1355 | } | ||
| 1351 | } | 1356 | } | ||
| 1352 | break; | 1357 | break; | ||
| 1353 | } | 1358 | } | ||
| 1359 | case QEvent::Close: | ||||
| 1354 | case QEvent::Destroy: | 1360 | case QEvent::Destroy: | ||
| 1355 | case QEvent::Hide: { | 1361 | case QEvent::Hide: { | ||
| 1356 | if ((BLEND_TITLEBAR || | 1362 | if ((BLEND_TITLEBAR || | ||
| 1357 | opts.windowBorder & | 1363 | opts.windowBorder & | ||
| 1358 | WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR || | 1364 | WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR || | ||
| 1359 | opts.menubarHiding & HIDE_KWIN) && | 1365 | opts.menubarHiding & HIDE_KWIN) && | ||
| 1360 | qobject_cast<QMenuBar*>(object)) { | 1366 | qobject_cast<QMenuBar*>(object)) { | ||
| 1361 | QMenuBar *mb = (QMenuBar*)object; | 1367 | QMenuBar *mb = (QMenuBar*)object; | ||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
| 1415 | } | 1421 | } | ||
| 1416 | 1422 | | |||
| 1417 | return ParentStyleClass::eventFilter(object, event); | 1423 | return ParentStyleClass::eventFilter(object, event); | ||
| 1418 | } | 1424 | } | ||
| 1419 | 1425 | | |||
| 1420 | void Style::timerEvent(QTimerEvent *event) | 1426 | void Style::timerEvent(QTimerEvent *event) | ||
| 1421 | { | 1427 | { | ||
| 1422 | if (event->timerId() == m_progressBarAnimateTimer) { | 1428 | if (event->timerId() == m_progressBarAnimateTimer) { | ||
| 1429 | bool hasAnimation = false; | ||||
| 1423 | m_animateStep = m_timer.elapsed() / (1000 / constProgressBarFps); | 1430 | m_animateStep = m_timer.elapsed() / (1000 / constProgressBarFps); | ||
| 1424 | for (QProgressBar *bar: const_(m_progressBars)) { | 1431 | for (QProgressBar *bar: const_(m_progressBars)) { | ||
| 1425 | if ((opts.animatedProgress && 0 == m_animateStep % 2 && | 1432 | if ((opts.animatedProgress && 0 == m_animateStep % 2 && | ||
| 1426 | bar->value() != bar->minimum() && | 1433 | bar->value() != bar->minimum() && | ||
| 1427 | bar->value() != bar->maximum()) || | 1434 | bar->value() != bar->maximum()) || | ||
| 1428 | (0 == bar->minimum() && 0 == bar->maximum())) { | 1435 | (0 == bar->minimum() && 0 == bar->maximum())) { | ||
| 1429 | bar->update(); | 1436 | bar->update(); | ||
| 1437 | hasAnimation = true; | ||||
| 1430 | } | 1438 | } | ||
| 1431 | } | 1439 | } | ||
| 1440 | if (Q_UNLIKELY(!hasAnimation && m_progressBarAnimateFps == constProgressBarFps)) { | ||||
| 1441 | // go back to "idling frequency" mode. | ||||
| 1442 | killTimer(m_progressBarAnimateTimer); | ||||
| 1443 | m_progressBarAnimateTimer = 0; | ||||
| 1444 | } | ||||
| 1432 | } | 1445 | } | ||
| 1433 | 1446 | | |||
| 1434 | event->ignore(); | 1447 | event->ignore(); | ||
| 1435 | } | 1448 | } | ||
| 1436 | 1449 | | |||
| 1437 | int | 1450 | int | ||
| 1438 | Style::pixelMetric(PixelMetric metric, const QStyleOption *option, | 1451 | Style::pixelMetric(PixelMetric metric, const QStyleOption *option, | ||
| 1439 | const QWidget *widget) const | 1452 | const QWidget *widget) const | ||
| ▲ Show 20 Lines • Show All 1371 Lines • ▼ Show 20 Line(s) | 2810 | if (auto bar = styleOptCast<QStyleOptionProgressBar>(option)) { | |||
| 2811 | bool reverse = ((!vertical && (bar->direction == Qt::RightToLeft)) || | 2824 | bool reverse = ((!vertical && (bar->direction == Qt::RightToLeft)) || | ||
| 2812 | vertical); | 2825 | vertical); | ||
| 2813 | 2826 | | |||
| 2814 | if (inverted) | 2827 | if (inverted) | ||
| 2815 | reverse = !reverse; | 2828 | reverse = !reverse; | ||
| 2816 | 2829 | | |||
| 2817 | painter->save(); | 2830 | painter->save(); | ||
| 2818 | 2831 | | |||
| 2832 | if (!m_progressBarAnimateTimer && (opts.animatedProgress || indeterminate)) { | ||||
| 2833 | if (m_timer.isNull()) { | ||||
| 2834 | m_timer.start(); | ||||
| 2835 | } | ||||
| 2836 | // now we'll need a timer, start it at the regular frequency | ||||
| 2837 | m_progressBarAnimateFps = constProgressBarFps; | ||||
| 2838 | m_progressBarAnimateTimer = const_cast<Style*>(this)->startTimer(1000/m_progressBarAnimateFps); | ||||
| 2839 | } | ||||
| 2840 | | ||||
| 2819 | if (indeterminate) { | 2841 | if (indeterminate) { | ||
| 2820 | //Busy indicator | 2842 | //Busy indicator | ||
| 2821 | int chunkSize = PROGRESS_CHUNK_WIDTH * 3.4; | 2843 | int chunkSize = PROGRESS_CHUNK_WIDTH * 3.4; | ||
| 2822 | int measure = vertical ? r.height() : r.width(); | 2844 | int measure = vertical ? r.height() : r.width(); | ||
| 2823 | 2845 | | |||
| 2824 | if (chunkSize > measure / 2) | 2846 | if (chunkSize > measure / 2) | ||
| 2825 | chunkSize = measure / 2; | 2847 | chunkSize = measure / 2; | ||
| 2826 | 2848 | | |||
| ▲ Show 20 Lines • Show All 4294 Lines • Show Last 20 Lines | |||||