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 1283 Lines • ▼ Show 20 Line(s) | 1266 | { | |||
---|---|---|---|---|---|
1284 | 1284 | | |||
1285 | // frame | 1285 | // frame | ||
1286 | drawControl(QStyle::CE_PushButton, &option, &painter, button ); | 1286 | drawControl(QStyle::CE_PushButton, &option, &painter, button ); | ||
1287 | 1287 | | |||
1288 | // offset | 1288 | // offset | ||
1289 | const int margin( Metrics::Button_MarginWidth + Metrics::Frame_FrameWidth ); | 1289 | const int margin( Metrics::Button_MarginWidth + Metrics::Frame_FrameWidth ); | ||
1290 | QPoint offset( margin, margin ); | 1290 | QPoint offset( margin, margin ); | ||
1291 | 1291 | | |||
1292 | if( button->isDown() && !isFlat ) painter.translate( 1, 1 ); | | |||
1293 | { offset += QPoint( 1, 1 ); } | | |||
1294 | | ||||
1295 | // state | 1292 | // state | ||
1296 | const State& state( option.state ); | 1293 | const State& state( option.state ); | ||
1297 | const bool enabled( state & State_Enabled ); | 1294 | const bool enabled( state & State_Enabled ); | ||
1298 | bool mouseOver( enabled && ( state & State_MouseOver ) ); | 1295 | bool mouseOver( enabled && ( state & State_MouseOver ) ); | ||
1299 | bool hasFocus( enabled && ( state & State_HasFocus ) ); | 1296 | bool hasFocus( enabled && ( state & State_HasFocus ) ); | ||
1300 | 1297 | | |||
1301 | // icon | 1298 | // icon | ||
1302 | if( !button->icon().isNull() ) | 1299 | if( !button->icon().isNull() ) | ||
▲ Show 20 Lines • Show All 2239 Lines • ▼ Show 20 Line(s) | 3536 | { | |||
3542 | palette.setColor( QPalette::Button, KColorUtils::mix( button, base, 0.7 ) ); | 3539 | palette.setColor( QPalette::Button, KColorUtils::mix( button, base, 0.7 ) ); | ||
3543 | } | 3540 | } | ||
3544 | 3541 | | |||
3545 | const auto shadow( _helper->shadowColor( palette ) ); | 3542 | const auto shadow( _helper->shadowColor( palette ) ); | ||
3546 | const auto outline( _helper->buttonOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) ); | 3543 | const auto outline( _helper->buttonOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) ); | ||
3547 | const auto background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocus, sunken, opacity, mode ) ); | 3544 | const auto background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocus, sunken, opacity, mode ) ); | ||
3548 | 3545 | | |||
3549 | // render | 3546 | // render | ||
3550 | _helper->renderButtonFrame( painter, rect, background, outline, shadow, hasFocus, sunken ); | 3547 | _helper->renderButton( painter, rect, background, outline, shadow, hasFocus, sunken ); | ||
3551 | 3548 | | |||
3552 | } | 3549 | } | ||
3553 | 3550 | | |||
3554 | return true; | 3551 | return true; | ||
3555 | 3552 | | |||
3556 | } | 3553 | } | ||
3557 | 3554 | | |||
3558 | //______________________________________________________________ | 3555 | //______________________________________________________________ | ||
Show All 35 Lines | 3579 | { | |||
3594 | if( hasPopupMenu ) | 3591 | if( hasPopupMenu ) | ||
3595 | { | 3592 | { | ||
3596 | painter->setClipRect( rect ); | 3593 | painter->setClipRect( rect ); | ||
3597 | rect.adjust( 0, 0, Metrics::Frame_FrameRadius + 2, 0 ); | 3594 | rect.adjust( 0, 0, Metrics::Frame_FrameRadius + 2, 0 ); | ||
3598 | rect = visualRect( option, rect ); | 3595 | rect = visualRect( option, rect ); | ||
3599 | } | 3596 | } | ||
3600 | 3597 | | |||
3601 | // render | 3598 | // render | ||
3602 | _helper->renderButtonFrame( painter, rect, background, outline, shadow, hasFocus, sunken ); | 3599 | _helper->renderButton( painter, rect, background, outline, shadow, hasFocus, sunken ); | ||
3603 | 3600 | | |||
3604 | } else { | 3601 | } else { | ||
3605 | 3602 | | |||
3606 | const auto color( _helper->toolButtonColor( palette, mouseOver, hasFocus, sunken, opacity, mode ) ); | 3603 | const auto color( _helper->toolButtonColor( palette, mouseOver, hasFocus, sunken, opacity, mode ) ); | ||
3607 | _helper->renderToolButtonFrame( painter, rect, color, sunken ); | 3604 | _helper->renderToolButtonFrame( painter, rect, color, sunken ); | ||
3608 | 3605 | | |||
3609 | } | 3606 | } | ||
3610 | 3607 | | |||
▲ Show 20 Lines • Show All 350 Lines • ▼ Show 20 Line(s) | 3924 | { | |||
3961 | const auto background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocus, false, opacity, mode ) ); | 3958 | const auto background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocus, false, opacity, mode ) ); | ||
3962 | 3959 | | |||
3963 | auto frameRect( rect ); | 3960 | auto frameRect( rect ); | ||
3964 | painter->setClipRect( rect ); | 3961 | painter->setClipRect( rect ); | ||
3965 | frameRect.adjust( -Metrics::Frame_FrameRadius - 1, 0, 0, 0 ); | 3962 | frameRect.adjust( -Metrics::Frame_FrameRadius - 1, 0, 0, 0 ); | ||
3966 | frameRect = visualRect( option, frameRect ); | 3963 | frameRect = visualRect( option, frameRect ); | ||
3967 | 3964 | | |||
3968 | // render | 3965 | // render | ||
3969 | _helper->renderButtonFrame( painter, frameRect, background, outline, shadow, hasFocus, sunken ); | 3966 | _helper->renderButton( painter, frameRect, background, outline, shadow, hasFocus, sunken ); | ||
3970 | 3967 | | |||
3971 | // also render separator | 3968 | // also render separator | ||
3972 | auto separatorRect( rect.adjusted( 0, 2, -2, -2 ) ); | 3969 | auto separatorRect( rect.adjusted( 0, 2, -2, -2 ) ); | ||
3973 | separatorRect.setWidth( 1 ); | 3970 | separatorRect.setWidth( 1 ); | ||
3974 | separatorRect = visualRect( option, separatorRect ); | 3971 | separatorRect = visualRect( option, separatorRect ); | ||
3975 | if( sunken ) separatorRect.translate( 1, 1 ); | | |||
3976 | _helper->renderSeparator( painter, separatorRect, outline, true ); | 3972 | _helper->renderSeparator( painter, separatorRect, outline, true ); | ||
3977 | 3973 | | |||
3978 | return true; | 3974 | return true; | ||
3979 | 3975 | | |||
3980 | } | 3976 | } | ||
3981 | 3977 | | |||
3982 | //___________________________________________________________________________________ | 3978 | //___________________________________________________________________________________ | ||
3983 | bool Style::drawIndicatorTabClosePrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 3979 | bool Style::drawIndicatorTabClosePrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
▲ Show 20 Lines • Show All 259 Lines • ▼ Show 20 Line(s) | 4223 | { | |||
4243 | const bool flat( buttonOption->features & QStyleOptionButton::Flat ); | 4239 | const bool flat( buttonOption->features & QStyleOptionButton::Flat ); | ||
4244 | 4240 | | |||
4245 | // content | 4241 | // content | ||
4246 | const bool hasText( !buttonOption->text.isEmpty() ); | 4242 | const bool hasText( !buttonOption->text.isEmpty() ); | ||
4247 | const bool hasIcon( (showIconsOnPushButtons() || flat || !hasText ) && !buttonOption->icon.isNull() ); | 4243 | const bool hasIcon( (showIconsOnPushButtons() || flat || !hasText ) && !buttonOption->icon.isNull() ); | ||
4248 | 4244 | | |||
4249 | // contents | 4245 | // contents | ||
4250 | auto contentsRect( rect ); | 4246 | auto contentsRect( rect ); | ||
4251 | if( sunken && !flat ) contentsRect.translate( 1, 1 ); | | |||
4252 | 4247 | | |||
4253 | // color role | 4248 | // color role | ||
4254 | QPalette::ColorRole textRole; | 4249 | QPalette::ColorRole textRole; | ||
4255 | if( flat ) | 4250 | if( flat ) | ||
4256 | { | 4251 | { | ||
4257 | 4252 | | |||
4258 | if( hasFocus && sunken ) textRole = QPalette::HighlightedText; | 4253 | if( hasFocus && sunken ) textRole = QPalette::HighlightedText; | ||
4259 | else textRole = QPalette::WindowText; | 4254 | else textRole = QPalette::WindowText; | ||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 4342 | { | |||
4366 | else hasFocus = enabled && !mouseOver && (option->state & (State_HasFocus|State_Sunken) ); | 4361 | else hasFocus = enabled && !mouseOver && (option->state & (State_HasFocus|State_Sunken) ); | ||
4367 | 4362 | | |||
4368 | const bool hasArrow( toolButtonOption->features & QStyleOptionToolButton::Arrow ); | 4363 | const bool hasArrow( toolButtonOption->features & QStyleOptionToolButton::Arrow ); | ||
4369 | const bool hasIcon( !( hasArrow || toolButtonOption->icon.isNull() ) ); | 4364 | const bool hasIcon( !( hasArrow || toolButtonOption->icon.isNull() ) ); | ||
4370 | const bool hasText( !toolButtonOption->text.isEmpty() ); | 4365 | const bool hasText( !toolButtonOption->text.isEmpty() ); | ||
4371 | 4366 | | |||
4372 | // contents | 4367 | // contents | ||
4373 | auto contentsRect( rect ); | 4368 | auto contentsRect( rect ); | ||
4374 | if( sunken && !flat ) contentsRect.translate( 1, 1 ); | | |||
4375 | 4369 | | |||
4376 | // icon size | 4370 | // icon size | ||
4377 | const QSize iconSize( toolButtonOption->iconSize ); | 4371 | const QSize iconSize( toolButtonOption->iconSize ); | ||
4378 | 4372 | | |||
4379 | // text size | 4373 | // text size | ||
4380 | int textFlags( _mnemonics->textFlags() ); | 4374 | int textFlags( _mnemonics->textFlags() ); | ||
4381 | const QSize textSize( option->fontMetrics.size( textFlags, toolButtonOption->text ) ); | 4375 | const QSize textSize( option->fontMetrics.size( textFlags, toolButtonOption->text ) ); | ||
4382 | 4376 | | |||
▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Line(s) | 4555 | if( flat ) { | |||
4564 | else textRole = QPalette::WindowText; | 4558 | else textRole = QPalette::WindowText; | ||
4565 | 4559 | | |||
4566 | } else if( hasFocus ) textRole = QPalette::HighlightedText; | 4560 | } else if( hasFocus ) textRole = QPalette::HighlightedText; | ||
4567 | else textRole = QPalette::ButtonText; | 4561 | else textRole = QPalette::ButtonText; | ||
4568 | 4562 | | |||
4569 | // change pen color directly | 4563 | // change pen color directly | ||
4570 | painter->setPen( QPen( option->palette.color( textRole ), 1 ) ); | 4564 | painter->setPen( QPen( option->palette.color( textRole ), 1 ) ); | ||
4571 | 4565 | | |||
4572 | // translate painter for pressed down comboboxes | | |||
4573 | if( sunken && !flat ) | | |||
4574 | { painter->translate( 1, 1 ); } | | |||
4575 | | ||||
4576 | #if QT_VERSION >= 0x050000 | 4566 | #if QT_VERSION >= 0x050000 | ||
4577 | if (const auto cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) | 4567 | if (const auto cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) | ||
4578 | { | 4568 | { | ||
4579 | auto editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); | 4569 | auto editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); | ||
4580 | painter->save(); | 4570 | painter->save(); | ||
4581 | painter->setClipRect(editRect); | 4571 | painter->setClipRect(editRect); | ||
4582 | if (!cb->currentIcon.isNull()) { | 4572 | if (!cb->currentIcon.isNull()) { | ||
4583 | QIcon::Mode mode; | 4573 | QIcon::Mode mode; | ||
▲ Show 20 Lines • Show All 1519 Lines • ▼ Show 20 Line(s) | 6040 | { | |||
6103 | 6093 | | |||
6104 | // arrow | 6094 | // arrow | ||
6105 | if( hasPopupMenu ) | 6095 | if( hasPopupMenu ) | ||
6106 | { | 6096 | { | ||
6107 | 6097 | | |||
6108 | copy.rect = menuRect; | 6098 | copy.rect = menuRect; | ||
6109 | if( !flat ) drawPrimitive( PE_IndicatorButtonDropDown, ©, painter, widget ); | 6099 | if( !flat ) drawPrimitive( PE_IndicatorButtonDropDown, ©, painter, widget ); | ||
6110 | 6100 | | |||
6111 | if( sunken && !flat ) copy.rect.translate( 1, 1 ); | | |||
6112 | drawPrimitive( PE_IndicatorArrowDown, ©, painter, widget ); | 6101 | drawPrimitive( PE_IndicatorArrowDown, ©, painter, widget ); | ||
6113 | 6102 | | |||
6114 | } else if( hasInlineIndicator ) { | 6103 | } else if( hasInlineIndicator ) { | ||
6115 | 6104 | | |||
6116 | copy.rect = menuRect; | 6105 | copy.rect = menuRect; | ||
6117 | 6106 | | |||
6118 | if( sunken && !flat ) copy.rect.translate( 1, 1 ); | | |||
6119 | drawPrimitive( PE_IndicatorArrowDown, ©, painter, widget ); | 6107 | drawPrimitive( PE_IndicatorArrowDown, ©, painter, widget ); | ||
6120 | 6108 | | |||
6121 | } | 6109 | } | ||
6122 | 6110 | | |||
6123 | // contents | 6111 | // contents | ||
6124 | { | 6112 | { | ||
6125 | 6113 | | |||
6126 | // restore state | 6114 | // restore state | ||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | 6194 | } else { | |||
6221 | } else { | 6209 | } else { | ||
6222 | 6210 | | |||
6223 | // define colors | 6211 | // define colors | ||
6224 | const auto shadow( _helper->shadowColor( palette ) ); | 6212 | const auto shadow( _helper->shadowColor( palette ) ); | ||
6225 | const auto outline( _helper->buttonOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) ); | 6213 | const auto outline( _helper->buttonOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) ); | ||
6226 | const auto background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocus, false, opacity, mode ) ); | 6214 | const auto background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocus, false, opacity, mode ) ); | ||
6227 | 6215 | | |||
6228 | // render | 6216 | // render | ||
6229 | _helper->renderButtonFrame( painter, rect, background, outline, shadow, hasFocus, sunken ); | 6217 | _helper->renderButton( painter, rect, background, outline, shadow, hasFocus, sunken ); | ||
6230 | 6218 | | |||
6231 | } | 6219 | } | ||
6232 | 6220 | | |||
6233 | } | 6221 | } | ||
6234 | 6222 | | |||
6235 | } | 6223 | } | ||
6236 | 6224 | | |||
6237 | // arrow | 6225 | // arrow | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 6227 | { | |||
6281 | 6269 | | |||
6282 | } else if( empty || !enabled ) arrowColor = _helper->arrowColor( palette, QPalette::Disabled, QPalette::ButtonText ); | 6270 | } else if( empty || !enabled ) arrowColor = _helper->arrowColor( palette, QPalette::Disabled, QPalette::ButtonText ); | ||
6283 | else if( hasFocus && !mouseOver ) arrowColor = palette.color( QPalette::HighlightedText ); | 6271 | else if( hasFocus && !mouseOver ) arrowColor = palette.color( QPalette::HighlightedText ); | ||
6284 | else arrowColor = _helper->arrowColor( palette, QPalette::ButtonText ); | 6272 | else arrowColor = _helper->arrowColor( palette, QPalette::ButtonText ); | ||
6285 | 6273 | | |||
6286 | // arrow rect | 6274 | // arrow rect | ||
6287 | auto arrowRect( subControlRect( CC_ComboBox, option, SC_ComboBoxArrow, widget ) ); | 6275 | auto arrowRect( subControlRect( CC_ComboBox, option, SC_ComboBoxArrow, widget ) ); | ||
6288 | 6276 | | |||
6289 | // translate for non editable, non flat, sunken comboboxes | | |||
6290 | if( sunken && !flat && !editable ) arrowRect.translate( 1, 1 ); | | |||
6291 | | ||||
6292 | // render | 6277 | // render | ||
6293 | _helper->renderArrow( painter, arrowRect, arrowColor, ArrowDown ); | 6278 | _helper->renderArrow( painter, arrowRect, arrowColor, ArrowDown ); | ||
6294 | 6279 | | |||
6295 | } | 6280 | } | ||
6296 | 6281 | | |||
6297 | return true; | 6282 | return true; | ||
6298 | 6283 | | |||
6299 | } | 6284 | } | ||
▲ Show 20 Lines • Show All 977 Lines • Show Last 20 Lines |