Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezestyle.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 4950 Lines • ▼ Show 20 Line(s) | 4932 | { | |||
---|---|---|---|---|---|
4951 | 4951 | | |||
4952 | // check focus from relevant parent | 4952 | // check focus from relevant parent | ||
4953 | const QWidget* parent( scrollBarParent( widget ) ); | 4953 | const QWidget* parent( scrollBarParent( widget ) ); | ||
4954 | const bool hasFocus( enabled && parent && parent->hasFocus() ); | 4954 | const bool hasFocus( enabled && parent && parent->hasFocus() ); | ||
4955 | 4955 | | |||
4956 | // enable animation state | 4956 | // enable animation state | ||
4957 | const bool handleActive( sliderOption->activeSubControls & SC_ScrollBarSlider ); | 4957 | const bool handleActive( sliderOption->activeSubControls & SC_ScrollBarSlider ); | ||
4958 | _animations->scrollBarEngine().updateState( widget, AnimationFocus, hasFocus ); | 4958 | _animations->scrollBarEngine().updateState( widget, AnimationFocus, hasFocus ); | ||
4959 | | ||||
4959 | _animations->scrollBarEngine().updateState( widget, AnimationHover, mouseOver && handleActive ); | 4960 | _animations->scrollBarEngine().updateState( widget, AnimationHover, mouseOver && handleActive ); | ||
4961 | | ||||
4960 | const AnimationMode mode( _animations->scrollBarEngine().animationMode( widget, SC_ScrollBarSlider ) ); | 4962 | const AnimationMode mode( _animations->scrollBarEngine().animationMode( widget, SC_ScrollBarSlider ) ); | ||
4961 | const qreal opacity( _animations->scrollBarEngine().opacity( widget, SC_ScrollBarSlider ) ); | 4963 | const qreal opacity( _animations->scrollBarEngine().opacity( widget, SC_ScrollBarSlider ) ); | ||
4964 | const QColor color = _helper->scrollBarHandleColor( palette, mouseOver, hasFocus, opacity, mode ); | ||||
hpereiradacosta: can be made a const again, right ? | |||||
4962 | 4965 | | |||
4963 | const QColor color( _helper->scrollBarHandleColor( palette, mouseOver, hasFocus, opacity, mode ) ); | | |||
4964 | _helper->renderScrollBarHandle( painter, handleRect, color ); | 4966 | _helper->renderScrollBarHandle( painter, handleRect, color ); | ||
this entire block can go, right ? hpereiradacosta: this entire block can go, right ?
In fact my compiler complains about unused variable | |||||
4965 | | ||||
4966 | return true; | 4967 | return true; | ||
4967 | } | 4968 | } | ||
4968 | 4969 | | |||
4969 | //___________________________________________________________________________________ | 4970 | //___________________________________________________________________________________ | ||
4970 | bool Style::drawScrollBarAddLineControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 4971 | bool Style::drawScrollBarAddLineControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
4971 | { | 4972 | { | ||
4972 | 4973 | | |||
4973 | // do nothing if no buttons are defined | 4974 | // do nothing if no buttons are defined | ||
▲ Show 20 Lines • Show All 1378 Lines • ▼ Show 20 Line(s) | 6280 | { | |||
6352 | } | 6353 | } | ||
6353 | 6354 | | |||
6354 | return true; | 6355 | return true; | ||
6355 | } | 6356 | } | ||
6356 | 6357 | | |||
6357 | //______________________________________________________________ | 6358 | //______________________________________________________________ | ||
6358 | bool Style::drawScrollBarComplexControl( const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget ) const | 6359 | bool Style::drawScrollBarComplexControl( const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget ) const | ||
6359 | { | 6360 | { | ||
6361 | //the animation for QStyle::SC_ScrollBarGroove is special: it will animate | ||||
6362 | //the opacity of everything else as well, included slider and arrows | ||||
6363 | qreal opacity( _animations->scrollBarEngine().opacity( widget, QStyle::SC_ScrollBarGroove ) ); | ||||
6364 | const bool animated( StyleConfigData::scrollBarShowOnMouseOver() && _animations->scrollBarEngine().isAnimated( widget, AnimationHover, QStyle::SC_ScrollBarGroove ) ); | ||||
6365 | const bool mouseOver( option->state & State_MouseOver ); | ||||
6366 | | ||||
6367 | if( opacity == AnimationData::OpacityInvalid ) opacity = 1; | ||||
hpereiradacosta: you could use AnimationData::OpacityInvalid instead of -1
| |||||
6360 | 6368 | | |||
6361 | // render full groove directly, rather than using the addPage and subPage control element methods | 6369 | // render full groove directly, rather than using the addPage and subPage control element methods | ||
6362 | if( option->subControls & SC_ScrollBarGroove ) | 6370 | if( (mouseOver || animated) && option->subControls & SC_ScrollBarGroove ) | ||
6363 | { | 6371 | { | ||
6364 | // retrieve groove rectangle | 6372 | // retrieve groove rectangle | ||
6365 | QRect grooveRect( subControlRect( CC_ScrollBar, option, SC_ScrollBarGroove, widget ) ); | 6373 | QRect grooveRect( subControlRect( CC_ScrollBar, option, SC_ScrollBarGroove, widget ) ); | ||
6366 | 6374 | | |||
6367 | const QPalette& palette( option->palette ); | 6375 | const QPalette& palette( option->palette ); | ||
6368 | const QColor color( _helper->alphaColor( palette.color( QPalette::WindowText ), 0.3 ) ); | 6376 | const QColor color( _helper->alphaColor( palette.color( QPalette::WindowText ), 0.3 * (animated ? opacity : 1) ) ); | ||
6369 | const State& state( option->state ); | 6377 | const State& state( option->state ); | ||
6370 | const bool horizontal( state & State_Horizontal ); | 6378 | const bool horizontal( state & State_Horizontal ); | ||
6371 | 6379 | | |||
6372 | if( horizontal ) grooveRect = centerRect( grooveRect, grooveRect.width(), Metrics::ScrollBar_SliderWidth ); | 6380 | if( horizontal ) grooveRect = centerRect( grooveRect, grooveRect.width(), Metrics::ScrollBar_SliderWidth ); | ||
6373 | else grooveRect = centerRect( grooveRect, Metrics::ScrollBar_SliderWidth, grooveRect.height() ); | 6381 | else grooveRect = centerRect( grooveRect, Metrics::ScrollBar_SliderWidth, grooveRect.height() ); | ||
6374 | 6382 | | |||
6375 | // render | 6383 | // render | ||
6376 | _helper->renderScrollBarGroove( painter, grooveRect, color ); | 6384 | _helper->renderScrollBarGroove( painter, grooveRect, color ); | ||
6377 | | ||||
6378 | } | 6385 | } | ||
6379 | 6386 | | |||
6380 | // call base class primitive | 6387 | // call base class primitive | ||
6381 | ParentStyleClass::drawComplexControl( CC_ScrollBar, option, painter, widget ); | 6388 | ParentStyleClass::drawComplexControl( CC_ScrollBar, option, painter, widget ); | ||
6389 | | ||||
6382 | return true; | 6390 | return true; | ||
6383 | } | 6391 | } | ||
6384 | 6392 | | |||
6385 | //______________________________________________________________ | 6393 | //______________________________________________________________ | ||
6386 | bool Style::drawTitleBarComplexControl( const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget ) const | 6394 | bool Style::drawTitleBarComplexControl( const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget ) const | ||
6387 | { | 6395 | { | ||
6388 | 6396 | | |||
6389 | // cast option and check | 6397 | // cast option and check | ||
▲ Show 20 Lines • Show All 243 Lines • ▼ Show 20 Line(s) | |||||
6633 | //______________________________________________________________________________ | 6641 | //______________________________________________________________________________ | ||
6634 | QColor Style::scrollBarArrowColor( const QStyleOptionSlider* option, const SubControl& control, const QWidget* widget ) const | 6642 | QColor Style::scrollBarArrowColor( const QStyleOptionSlider* option, const SubControl& control, const QWidget* widget ) const | ||
6635 | { | 6643 | { | ||
6636 | 6644 | | |||
6637 | const QRect& rect( option->rect ); | 6645 | const QRect& rect( option->rect ); | ||
6638 | const QPalette& palette( option->palette ); | 6646 | const QPalette& palette( option->palette ); | ||
6639 | QColor color( _helper->arrowColor( palette, QPalette::WindowText ) ); | 6647 | QColor color( _helper->arrowColor( palette, QPalette::WindowText ) ); | ||
6640 | 6648 | | |||
6649 | bool widgetMouseOver; | ||||
6650 | if( widget ) widgetMouseOver = widget->underMouse(); | ||||
6651 | // in case this QStyle is used by QQuickControls QStyle wrapper | ||||
6652 | else if( option->styleObject ) widgetMouseOver = option->styleObject->property("hover").toBool(); | ||||
6653 | | ||||
6641 | // check enabled state | 6654 | // check enabled state | ||
6642 | const bool enabled( option->state & State_Enabled ); | 6655 | const bool enabled( option->state & State_Enabled ); | ||
6643 | if( !enabled ) return color; | 6656 | if( !enabled ) { | ||
6657 | if( StyleConfigData::scrollBarShowOnMouseOver() ) { | ||||
6658 | // finally, global opacity when ScrollBarShowOnMouseOver | ||||
6659 | const qreal globalOpacity( _animations->scrollBarEngine().opacity( widget, QStyle::SC_ScrollBarGroove ) ); | ||||
6660 | if( globalOpacity >= 0 ) color.setAlphaF( globalOpacity ); | ||||
6661 | // no mouse over and no animation in progress, don't draw arrows at all | ||||
6662 | else if( !widgetMouseOver ) return Qt::transparent; | ||||
6663 | } | ||||
6664 | return color; | ||||
6665 | } | ||||
6644 | 6666 | | |||
6645 | if( | 6667 | if( | ||
6646 | ( control == SC_ScrollBarSubLine && option->sliderValue == option->minimum ) || | 6668 | ( control == SC_ScrollBarSubLine && option->sliderValue == option->minimum ) || | ||
6647 | ( control == SC_ScrollBarAddLine && option->sliderValue == option->maximum ) ) | 6669 | ( control == SC_ScrollBarAddLine && option->sliderValue == option->maximum ) ) | ||
6648 | { | 6670 | { | ||
6649 | 6671 | | |||
6650 | // manually disable arrow, to indicate that scrollbar is at limit | 6672 | // manually disable arrow, to indicate that scrollbar is at limit | ||
6651 | return _helper->arrowColor( palette, QPalette::Disabled, QPalette::WindowText ); | 6673 | color = _helper->arrowColor( palette, QPalette::Disabled, QPalette::WindowText ); | ||
6652 | 6674 | if( StyleConfigData::scrollBarShowOnMouseOver() ) { | |||
6675 | // finally, global opacity when ScrollBarShowOnMouseOver | ||||
6676 | const qreal globalOpacity( _animations->scrollBarEngine().opacity( widget, QStyle::SC_ScrollBarGroove ) ); | ||||
6677 | if( globalOpacity >= 0 ) color.setAlphaF( globalOpacity ); | ||||
6678 | // no mouse over and no animation in progress, don't draw arrows at all | ||||
6679 | else if( !widgetMouseOver ) return Qt::transparent; | ||||
6680 | } | ||||
6681 | return color; | ||||
6653 | } | 6682 | } | ||
6654 | 6683 | | |||
6655 | const bool mouseOver( _animations->scrollBarEngine().isHovered( widget, control ) ); | 6684 | const bool mouseOver( _animations->scrollBarEngine().isHovered( widget, control ) ); | ||
6656 | const bool animated( _animations->scrollBarEngine().isAnimated( widget, AnimationHover, control ) ); | 6685 | const bool animated( _animations->scrollBarEngine().isAnimated( widget, AnimationHover, control ) ); | ||
6657 | const qreal opacity( _animations->scrollBarEngine().opacity( widget, control ) ); | 6686 | const qreal opacity( _animations->scrollBarEngine().opacity( widget, control ) ); | ||
6658 | 6687 | | |||
6659 | // retrieve mouse position from engine | 6688 | // retrieve mouse position from engine | ||
6660 | QPoint position( mouseOver ? _animations->scrollBarEngine().position( widget ) : QPoint( -1, -1 ) ); | 6689 | QPoint position( mouseOver ? _animations->scrollBarEngine().position( widget ) : QPoint( -1, -1 ) ); | ||
Show All 18 Lines | 6701 | { | |||
6679 | } else if( mouseOver ) { | 6708 | } else if( mouseOver ) { | ||
6680 | 6709 | | |||
6681 | color = highlight; | 6710 | color = highlight; | ||
6682 | 6711 | | |||
6683 | } | 6712 | } | ||
6684 | 6713 | | |||
6685 | } | 6714 | } | ||
6686 | 6715 | | |||
6716 | if( StyleConfigData::scrollBarShowOnMouseOver() ) { | ||||
6717 | const bool mouseOver( ( option->state & State_MouseOver ) ); | ||||
6718 | // finally, global opacity when ScrollBarShowOnMouseOver | ||||
6719 | const qreal globalOpacity( _animations->scrollBarEngine().opacity( widget, QStyle::SC_ScrollBarGroove ) ); | ||||
6720 | if( globalOpacity >= 0 ) color.setAlphaF( globalOpacity ); | ||||
6721 | // no mouse over and no animation in progress, don't draw arrows at all | ||||
6722 | else if( !widgetMouseOver ) return Qt::transparent; | ||||
6723 | } | ||||
6724 | | ||||
6687 | return color; | 6725 | return color; | ||
6688 | 6726 | | |||
6689 | } | 6727 | } | ||
6690 | 6728 | | |||
6691 | //____________________________________________________________________________________ | 6729 | //____________________________________________________________________________________ | ||
6692 | void Style::setTranslucentBackground( QWidget* widget ) const | 6730 | void Style::setTranslucentBackground( QWidget* widget ) const | ||
6693 | { | 6731 | { | ||
6694 | widget->setAttribute( Qt::WA_TranslucentBackground ); | 6732 | widget->setAttribute( Qt::WA_TranslucentBackground ); | ||
▲ Show 20 Lines • Show All 322 Lines • Show Last 20 Lines |
can be made a const again, right ?