Commit 98781f18 authored by Noah Davis's avatar Noah Davis 🌵
Browse files

Always render checkbox/radiobutton background

Summary:
QQC2/Kirigami checkboxes and radio buttons can turn invisible when rendered over a selected item because their background isn't rendered and they don't have any hacks to detect when they're being rendered over a selected list item.

While the problem isn't technically a Breeze QStyle problem and a hack could be made for QQC2/Kirigami, I don't think there's any great style benefit to not rendering a background for the checkbox. I suppose there is a performance benefit to not rendering a checkbox background except for when the background is different from normal. In my testing with GammaRay's paint analyzer, the checkbox background has a cost less than 5%. The radiobutton background has a cost of 15-20% (maybe it can be improved?).

Reviewers: #vdg, #breeze, #plasma, hpereiradacosta, ngraham

Reviewed By: #vdg, hpereiradacosta, ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26572
parent d9edbe05
......@@ -3839,28 +3839,16 @@ namespace Breeze
if( state & State_NoChange ) checkBoxState = CheckPartial;
else if( state & State_On ) checkBoxState = CheckOn;
// detect checkboxes in lists
const bool isSelectedItem( this->isSelectedItem( widget, rect.center() ) );
// animation state
_animations->widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
_animations->widgetStateEngine().updateState( widget, AnimationPressed, checkBoxState != CheckOff );
if( _animations->widgetStateEngine().isAnimated( widget, AnimationPressed ) ) checkBoxState = CheckAnimated;
const qreal animation( _animations->widgetStateEngine().opacity( widget, AnimationPressed ) );
QColor color;
if( isSelectedItem ) {
color = _helper->checkBoxIndicatorColor( palette, false, enabled && active );
_helper->renderCheckBoxBackground( painter, rect, palette.color( QPalette::Base ), sunken );
} else {
const AnimationMode mode( _animations->widgetStateEngine().isAnimated( widget, AnimationHover ) ? AnimationHover:AnimationNone );
const qreal opacity( _animations->widgetStateEngine().opacity( widget, AnimationHover ) );
color = _helper->checkBoxIndicatorColor( palette, mouseOver, enabled && active, opacity, mode );
}
QColor color = _helper->checkBoxIndicatorColor( palette, mouseOver, enabled && active, opacity, mode );
// render
const auto shadow( _helper->shadowColor( palette ) );
......@@ -3887,9 +3875,6 @@ namespace Breeze
// radio button state
RadioButtonState radioButtonState( state & State_On ? RadioOn:RadioOff );
// detect radiobuttons in lists
const bool isSelectedItem( this->isSelectedItem( widget, rect.center() ) );
// animation state
_animations->widgetStateEngine().updateState( widget, AnimationHover, mouseOver );
_animations->widgetStateEngine().updateState( widget, AnimationPressed, radioButtonState != RadioOff );
......@@ -3898,20 +3883,10 @@ namespace Breeze
// colors
const auto shadow( _helper->shadowColor( palette ) );
QColor color;
if( isSelectedItem )
{
color = _helper->checkBoxIndicatorColor( palette, false, enabled && checked );
_helper->renderRadioButtonBackground( painter, rect, palette.color( QPalette::Base ), sunken );
} else {
const AnimationMode mode( _animations->widgetStateEngine().isAnimated( widget, AnimationHover ) ? AnimationHover:AnimationNone );
const qreal opacity( _animations->widgetStateEngine().opacity( widget, AnimationHover ) );
color = _helper->checkBoxIndicatorColor( palette, mouseOver, enabled && checked, opacity, mode );
}
QColor color = _helper->checkBoxIndicatorColor( palette, mouseOver, enabled && checked, opacity, mode );
_helper->renderRadioButtonBackground( painter, rect, palette.color( QPalette::Base ), sunken );
// render
_helper->renderRadioButton( painter, rect, color, shadow, sunken, radioButtonState, animation );
......@@ -4818,9 +4793,7 @@ namespace Breeze
// checkbox state
if( useStrongFocus && ( selected || sunken ) )
{ _helper->renderCheckBoxBackground( painter, checkBoxRect, palette.color( QPalette::Window ), sunken ); }
_helper->renderCheckBoxBackground( painter, checkBoxRect, palette.color( QPalette::Window ), sunken );
CheckBoxState state( menuItemOption->checked ? CheckOn : CheckOff );
const bool active( menuItemOption->checked );
const auto shadow( _helper->shadowColor( palette ) );
......@@ -4831,9 +4804,7 @@ namespace Breeze
checkBoxRect = visualRect( option, checkBoxRect );
if( useStrongFocus && ( selected || sunken ) )
{ _helper->renderRadioButtonBackground( painter, checkBoxRect, palette.color( QPalette::Window ), sunken ); }
_helper->renderRadioButtonBackground( painter, checkBoxRect, palette.color( QPalette::Window ), sunken );
const bool active( menuItemOption->checked );
const auto shadow( _helper->shadowColor( palette ) );
const auto color( _helper->checkBoxIndicatorColor( palette, false, enabled && active ) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment