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 144 Lines • ▼ Show 20 Line(s) | 68 | { | |||
---|---|---|---|---|---|
145 | 145 | | |||
146 | //_______________________________________________________________ | 146 | //_______________________________________________________________ | ||
147 | 147 | | |||
148 | #if !BREEZE_USE_KDE4 | 148 | #if !BREEZE_USE_KDE4 | ||
149 | bool isProgressBarHorizontal( const QStyleOptionProgressBar* option ) | 149 | bool isProgressBarHorizontal( const QStyleOptionProgressBar* option ) | ||
150 | { return option && ( (option->state & QStyle::State_Horizontal ) || option->orientation == Qt::Horizontal ); } | 150 | { return option && ( (option->state & QStyle::State_Horizontal ) || option->orientation == Qt::Horizontal ); } | ||
151 | #endif | 151 | #endif | ||
152 | 152 | | |||
153 | bool hasPopupMenu(const QStyleOptionToolButton* toolButtonOption) | ||||
154 | { | ||||
155 | return toolButtonOption->features & QStyleOptionToolButton::MenuButtonPopup; | ||||
156 | } | ||||
157 | bool hasInlineIndicator(const QStyleOptionToolButton* toolButtonOption, const QWidget* toolButton) | ||||
158 | { | ||||
159 | return | ||||
160 | (toolButton->property( Breeze::PropertyNames::toolButtonNoMenuArrow ).toBool() == false) | ||||
161 | && toolButtonOption->features&QStyleOptionToolButton::HasMenu | ||||
162 | && toolButtonOption->features&QStyleOptionToolButton::PopupDelay | ||||
163 | && !hasPopupMenu(toolButtonOption); | ||||
164 | } | ||||
165 | | ||||
153 | } | 166 | } | ||
154 | 167 | | |||
155 | namespace Breeze | 168 | namespace Breeze | ||
156 | { | 169 | { | ||
157 | 170 | | |||
158 | //______________________________________________________________ | 171 | //______________________________________________________________ | ||
159 | Style::Style(): | 172 | Style::Style(): | ||
160 | _addLineButtons( SingleButton ) | 173 | _addLineButtons( SingleButton ) | ||
▲ Show 20 Lines • Show All 1970 Lines • ▼ Show 20 Line(s) | 215 | #endif | |||
2131 | //___________________________________________________________________________________________________________________ | 2144 | //___________________________________________________________________________________________________________________ | ||
2132 | QRect Style::toolButtonSubControlRect( const QStyleOptionComplex* option, SubControl subControl, const QWidget* widget ) const | 2145 | QRect Style::toolButtonSubControlRect( const QStyleOptionComplex* option, SubControl subControl, const QWidget* widget ) const | ||
2133 | { | 2146 | { | ||
2134 | 2147 | | |||
2135 | // cast option and check | 2148 | // cast option and check | ||
2136 | const auto toolButtonOption = qstyleoption_cast<const QStyleOptionToolButton*>( option ); | 2149 | const auto toolButtonOption = qstyleoption_cast<const QStyleOptionToolButton*>( option ); | ||
2137 | if( !toolButtonOption ) return ParentStyleClass::subControlRect( CC_ToolButton, option, subControl, widget ); | 2150 | if( !toolButtonOption ) return ParentStyleClass::subControlRect( CC_ToolButton, option, subControl, widget ); | ||
2138 | 2151 | | |||
2139 | const bool hasPopupMenu( toolButtonOption->features & QStyleOptionToolButton::MenuButtonPopup ); | 2152 | const bool hasPopupMenu( BreezePrivate::hasPopupMenu(toolButtonOption) ); | ||
2140 | const bool hasInlineIndicator( | 2153 | const bool hasInlineIndicator( BreezePrivate::hasInlineIndicator(toolButtonOption, widget) ); | ||
2141 | toolButtonOption->features&QStyleOptionToolButton::HasMenu | | |||
2142 | && toolButtonOption->features&QStyleOptionToolButton::PopupDelay | | |||
2143 | && !hasPopupMenu ); | | |||
2144 | 2154 | | |||
2145 | // store rect | 2155 | // store rect | ||
2146 | const auto& rect( option->rect ); | 2156 | const auto& rect( option->rect ); | ||
2147 | const int menuButtonWidth( Metrics::MenuButton_IndicatorWidth ); | 2157 | const int menuButtonWidth( Metrics::MenuButton_IndicatorWidth ); | ||
2148 | switch( subControl ) | 2158 | switch( subControl ) | ||
2149 | { | 2159 | { | ||
2150 | case SC_ToolButtonMenu: | 2160 | case SC_ToolButtonMenu: | ||
2151 | { | 2161 | { | ||
▲ Show 20 Lines • Show All 558 Lines • ▼ Show 20 Line(s) | 2656 | { | |||
2710 | { size.setWidth( qMax( size.width(), int( Metrics::Button_MinWidth ) ) ); } | 2720 | { size.setWidth( qMax( size.width(), int( Metrics::Button_MinWidth ) ) ); } | ||
2711 | 2721 | | |||
2712 | // finally add frame margins | 2722 | // finally add frame margins | ||
2713 | return expandSize( size, Metrics::Frame_FrameWidth ); | 2723 | return expandSize( size, Metrics::Frame_FrameWidth ); | ||
2714 | 2724 | | |||
2715 | } | 2725 | } | ||
2716 | 2726 | | |||
2717 | //______________________________________________________________ | 2727 | //______________________________________________________________ | ||
2718 | QSize Style::toolButtonSizeFromContents( const QStyleOption* option, const QSize& contentsSize, const QWidget* ) const | 2728 | QSize Style::toolButtonSizeFromContents( const QStyleOption* option, const QSize& contentsSize, const QWidget* widget) const | ||
2719 | { | 2729 | { | ||
2720 | 2730 | | |||
2721 | // cast option and check | 2731 | // cast option and check | ||
2722 | const auto toolButtonOption = qstyleoption_cast<const QStyleOptionToolButton*>( option ); | 2732 | const auto toolButtonOption = qstyleoption_cast<const QStyleOptionToolButton*>( option ); | ||
2723 | if( !toolButtonOption ) return contentsSize; | 2733 | if( !toolButtonOption ) return contentsSize; | ||
2724 | 2734 | | |||
2725 | // copy size | 2735 | // copy size | ||
2726 | QSize size = contentsSize; | 2736 | QSize size = contentsSize; | ||
2727 | 2737 | | |||
2728 | // get relevant state flags | 2738 | // get relevant state flags | ||
2729 | const State& state( option->state ); | 2739 | const State& state( option->state ); | ||
2730 | const bool autoRaise( state & State_AutoRaise ); | 2740 | const bool autoRaise( state & State_AutoRaise ); | ||
2731 | const bool hasPopupMenu( toolButtonOption->features & QStyleOptionToolButton::MenuButtonPopup ); | 2741 | const bool hasInlineIndicator( BreezePrivate::hasInlineIndicator(toolButtonOption, widget) ); | ||
2732 | const bool hasInlineIndicator( | | |||
2733 | toolButtonOption->features&QStyleOptionToolButton::HasMenu | | |||
2734 | && toolButtonOption->features&QStyleOptionToolButton::PopupDelay | | |||
2735 | && !hasPopupMenu ); | | |||
2736 | 2742 | | |||
2737 | const int marginWidth( autoRaise ? Metrics::ToolButton_MarginWidth : Metrics::Button_MarginWidth + Metrics::Frame_FrameWidth ); | 2743 | const int marginWidth( autoRaise ? Metrics::ToolButton_MarginWidth : Metrics::Button_MarginWidth + Metrics::Frame_FrameWidth ); | ||
2738 | 2744 | | |||
2739 | if( hasInlineIndicator ) size.rwidth() += Metrics::ToolButton_InlineIndicatorWidth; | 2745 | if( hasInlineIndicator ) size.rwidth() += Metrics::ToolButton_InlineIndicatorWidth; | ||
2740 | size = expandSize( size, marginWidth ); | 2746 | size = expandSize( size, marginWidth ); | ||
2741 | 2747 | | |||
2742 | return size; | 2748 | return size; | ||
2743 | 2749 | | |||
▲ Show 20 Lines • Show All 3321 Lines • ▼ Show 20 Line(s) | 6065 | { | |||
6065 | // render | 6071 | // render | ||
6066 | renderMenuTitle( ©, painter, widget ); | 6072 | renderMenuTitle( ©, painter, widget ); | ||
6067 | return true; | 6073 | return true; | ||
6068 | } | 6074 | } | ||
6069 | 6075 | | |||
6070 | // copy option and alter palette | 6076 | // copy option and alter palette | ||
6071 | QStyleOptionToolButton copy( *toolButtonOption ); | 6077 | QStyleOptionToolButton copy( *toolButtonOption ); | ||
6072 | 6078 | | |||
6073 | const bool hasPopupMenu( toolButtonOption->features & QStyleOptionToolButton::MenuButtonPopup ); | 6079 | const bool hasPopupMenu( BreezePrivate::hasPopupMenu(toolButtonOption) ); | ||
6074 | const bool hasInlineIndicator( | 6080 | const bool hasInlineIndicator( BreezePrivate::hasInlineIndicator(toolButtonOption, widget) ); | ||
6075 | toolButtonOption->features&QStyleOptionToolButton::HasMenu | | |||
6076 | && toolButtonOption->features&QStyleOptionToolButton::PopupDelay | | |||
6077 | && !hasPopupMenu ); | | |||
6078 | 6081 | | |||
6079 | const auto buttonRect( subControlRect( CC_ToolButton, option, SC_ToolButton, widget ) ); | 6082 | const auto buttonRect( subControlRect( CC_ToolButton, option, SC_ToolButton, widget ) ); | ||
6080 | const auto menuRect( subControlRect( CC_ToolButton, option, SC_ToolButtonMenu, widget ) ); | 6083 | const auto menuRect( subControlRect( CC_ToolButton, option, SC_ToolButtonMenu, widget ) ); | ||
6081 | 6084 | | |||
6082 | // frame | 6085 | // frame | ||
6083 | if( toolButtonOption->subControls & SC_ToolButton ) | 6086 | if( toolButtonOption->subControls & SC_ToolButton ) | ||
6084 | { | 6087 | { | ||
6085 | if( inTabBar ) drawTabBarPanelButtonToolPrimitive( ©, painter, widget ); | 6088 | if( inTabBar ) drawTabBarPanelButtonToolPrimitive( ©, painter, widget ); | ||
▲ Show 20 Lines • Show All 1173 Lines • Show Last 20 Lines |