Changeset View
Changeset View
Standalone View
Standalone View
qt4/style/qtcurve.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 2688 Lines • ▼ Show 20 Line(s) | 2523 | #endif | |||
|---|---|---|---|---|---|
| 2689 | case QEvent::StyleChange: | 2689 | case QEvent::StyleChange: | ||
| 2690 | case QEvent::Show: | 2690 | case QEvent::Show: | ||
| 2691 | { | 2691 | { | ||
| 2692 | QProgressBar *bar = qobject_cast<QProgressBar*>(object); | 2692 | QProgressBar *bar = qobject_cast<QProgressBar*>(object); | ||
| 2693 | 2693 | | |||
| 2694 | if(bar) | 2694 | if(bar) | ||
| 2695 | { | 2695 | { | ||
| 2696 | m_progressBars.insert(bar); | 2696 | m_progressBars.insert(bar); | ||
| 2697 | if (1==m_progressBars.size()) | 2697 | if (!m_progressBarAnimateTimer) { | ||
| 2698 | { | 2698 | if (opts.animatedProgress || (0 == bar->minimum() && 0 == bar->maximum())) { | ||
| 2699 | // we know we'll need a timer, start it at once | ||||
| 2700 | if (m_timer.isNull()) { | ||||
| 2699 | m_timer.start(); | 2701 | m_timer.start(); | ||
| 2700 | m_progressBarAnimateTimer = startTimer(1000 / constProgressBarFps); | 2702 | } | ||
| 2703 | m_progressBarAnimateFps = constProgressBarFps; | ||||
| 2704 | m_progressBarAnimateTimer = startTimer(1000/m_progressBarAnimateFps); | ||||
| 2705 | } | ||||
yuyichao: Indent a bit strange? | |||||
| 2701 | } | 2706 | } | ||
| 2702 | } else if(!POPUP_MENUS_SQUARE(opts) && | 2707 | } else if(!POPUP_MENUS_SQUARE(opts) && | ||
| 2703 | object->inherits("QComboBoxPrivateContainer")) { | 2708 | object->inherits("QComboBoxPrivateContainer")) { | ||
| 2704 | QWidget *widget = static_cast<QWidget*>(object); | 2709 | QWidget *widget = static_cast<QWidget*>(object); | ||
| 2705 | if (Utils::hasAlphaChannel(widget)) { | 2710 | if (Utils::hasAlphaChannel(widget)) { | ||
| 2706 | widget->clearMask(); | 2711 | widget->clearMask(); | ||
| 2707 | } else { | 2712 | } else { | ||
| 2708 | widget->setMask(windowMask(widget->rect(), | 2713 | widget->setMask(windowMask(widget->rect(), | ||
| Show All 15 Lines | 2725 | if (widget && widget->isWindow() && | |||
| 2724 | 2729 | | |||
| 2725 | int opacity = (qtcIsDialog(widget) ? opts.dlgOpacity : | 2730 | int opacity = (qtcIsDialog(widget) ? opts.dlgOpacity : | ||
| 2726 | opts.bgndOpacity); | 2731 | opts.bgndOpacity); | ||
| 2727 | setOpacityProp(widget, (unsigned short)opacity); | 2732 | setOpacityProp(widget, (unsigned short)opacity); | ||
| 2728 | } | 2733 | } | ||
| 2729 | } | 2734 | } | ||
| 2730 | break; | 2735 | break; | ||
| 2731 | } | 2736 | } | ||
| 2737 | case QEvent::Close: | ||||
| 2732 | case QEvent::Destroy: | 2738 | case QEvent::Destroy: | ||
| 2733 | case QEvent::Hide: { | 2739 | case QEvent::Hide: { | ||
| 2734 | if((BLEND_TITLEBAR || opts.windowBorder&WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR || opts.menubarHiding&HIDE_KWIN) && | 2740 | if((BLEND_TITLEBAR || opts.windowBorder&WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR || opts.menubarHiding&HIDE_KWIN) && | ||
| 2735 | qobject_cast<QMenuBar*>(object)) | 2741 | qobject_cast<QMenuBar*>(object)) | ||
| 2736 | { | 2742 | { | ||
| 2737 | QMenuBar *mb=(QMenuBar*)object; | 2743 | QMenuBar *mb=(QMenuBar*)object; | ||
| 2738 | emitMenuSize((QMenuBar*)mb, 0); | 2744 | emitMenuSize((QMenuBar*)mb, 0); | ||
| 2739 | } | 2745 | } | ||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | |||||
| 2816 | } | 2822 | } | ||
| 2817 | 2823 | | |||
| 2818 | return BaseStyle::eventFilter(object, event); | 2824 | return BaseStyle::eventFilter(object, event); | ||
| 2819 | } | 2825 | } | ||
| 2820 | 2826 | | |||
| 2821 | void Style::timerEvent(QTimerEvent *event) | 2827 | void Style::timerEvent(QTimerEvent *event) | ||
| 2822 | { | 2828 | { | ||
| 2823 | if (event->timerId() == m_progressBarAnimateTimer) { | 2829 | if (event->timerId() == m_progressBarAnimateTimer) { | ||
| 2830 | bool hasAnimation = false; | ||||
| 2824 | m_animateStep = m_timer.elapsed() / (1000 / constProgressBarFps); | 2831 | m_animateStep = m_timer.elapsed() / (1000 / constProgressBarFps); | ||
| 2825 | foreach (QProgressBar *bar, const_(m_progressBars)) { | 2832 | foreach (QProgressBar *bar, const_(m_progressBars)) { | ||
| 2826 | if ((opts.animatedProgress && 0 == m_animateStep % 2 && | 2833 | if ((opts.animatedProgress && 0 == m_animateStep % 2 && | ||
| 2827 | bar->value() != bar->minimum() && | 2834 | bar->value() != bar->minimum() && | ||
| 2828 | bar->value() != bar->maximum()) || | 2835 | bar->value() != bar->maximum()) || | ||
| 2829 | (0 == bar->minimum() && 0 == bar->maximum())) { | 2836 | (0 == bar->minimum() && 0 == bar->maximum())) { | ||
| 2830 | bar->update(); | 2837 | bar->update(); | ||
| 2838 | hasAnimation = true; | ||||
| 2831 | } | 2839 | } | ||
| 2832 | } | 2840 | } | ||
| 2841 | if (Q_UNLIKELY(!hasAnimation && m_progressBarAnimateFps == constProgressBarFps)) { | ||||
| 2842 | // go back to "idling frequency" mode. | ||||
| 2843 | killTimer(m_progressBarAnimateTimer); | ||||
| 2844 | m_progressBarAnimateTimer = 0; | ||||
| 2845 | } | ||||
| 2833 | } | 2846 | } | ||
| 2834 | 2847 | | |||
| 2835 | event->ignore(); | 2848 | event->ignore(); | ||
| 2836 | } | 2849 | } | ||
| 2837 | 2850 | | |||
| 2838 | int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const | 2851 | int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const | ||
| 2839 | { | 2852 | { | ||
| 2840 | prePolish(widget); | 2853 | prePolish(widget); | ||
| ▲ Show 20 Lines • Show All 3069 Lines • ▼ Show 20 Line(s) | 5909 | if (auto bar = styleOptCast<QStyleOptionProgressBar>(option)) { | |||
| 5910 | 5923 | | |||
| 5911 | bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; | 5924 | bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; | ||
| 5912 | 5925 | | |||
| 5913 | if (inverted) | 5926 | if (inverted) | ||
| 5914 | reverse = !reverse; | 5927 | reverse = !reverse; | ||
| 5915 | 5928 | | |||
| 5916 | painter->save(); | 5929 | painter->save(); | ||
| 5917 | 5930 | | |||
| 5931 | if (!m_progressBarAnimateTimer && (opts.animatedProgress || indeterminate)) { | ||||
| 5932 | if (m_timer.isNull()) { | ||||
| 5933 | m_timer.start(); | ||||
| 5934 | } | ||||
| 5935 | // now we'll need a timer, start it at the regular frequency | ||||
| 5936 | m_progressBarAnimateFps = constProgressBarFps; | ||||
| 5937 | m_progressBarAnimateTimer = const_cast<Style*>(this)->startTimer(1000/m_progressBarAnimateFps); | ||||
| 5938 | } | ||||
| 5939 | | ||||
| 5918 | if(indeterminate) //Busy indicator | 5940 | if(indeterminate) //Busy indicator | ||
| 5919 | { | 5941 | { | ||
| 5920 | int chunkSize(PROGRESS_CHUNK_WIDTH*3.4), | 5942 | int chunkSize(PROGRESS_CHUNK_WIDTH*3.4), | ||
| 5921 | measure(vertical ? r.height() : r.width()); | 5943 | measure(vertical ? r.height() : r.width()); | ||
| 5922 | 5944 | | |||
| 5923 | if(chunkSize>(measure/2)) | 5945 | if(chunkSize>(measure/2)) | ||
| 5924 | chunkSize=measure/2; | 5946 | chunkSize=measure/2; | ||
| 5925 | 5947 | | |||
| ▲ Show 20 Lines • Show All 7646 Lines • Show Last 20 Lines | |||||
Indent a bit strange?