Commit a75c986f authored by Cyril Rossi's avatar Cyril Rossi
Browse files

Add _kde_highlight_neutral property to allow widgets highlight with neutral color

Task related : Figure out a good UI for the "show which settings have been changed" feature https://phabricator.kde.org/T13008

This patch introduces a new property to allow to highlight some widgets when we want to draw user's attention on specific widgets.
parent 5d2b7fd7
......@@ -55,6 +55,7 @@ namespace Breeze
_viewFocusBrush = KStatefulBrush( KColorScheme::View, KColorScheme::FocusColor );
_viewHoverBrush = KStatefulBrush( KColorScheme::View, KColorScheme::HoverColor );
_viewNegativeTextBrush = KStatefulBrush( KColorScheme::View, KColorScheme::NegativeText );
_viewNeutralTextBrush = KStatefulBrush( KColorScheme::View, KColorScheme::NeutralText );
const QPalette palette( QApplication::palette() );
const KConfigGroup group( _config->group( "WM" ) );
......
......@@ -73,6 +73,10 @@ namespace Breeze
QColor negativeText( const QPalette& palette ) const
{ return _viewNegativeTextBrush.brush( palette ).color(); }
//* neutral text color
QColor neutralText( const QPalette& palette ) const
{ return _viewNeutralTextBrush.brush( palette ).color(); }
//* shadow
QColor shadowColor( const QPalette& palette ) const
{ return alphaColor( palette.color( QPalette::Shadow ), 0.15 ); }
......@@ -302,6 +306,7 @@ namespace Breeze
KStatefulBrush _viewFocusBrush;
KStatefulBrush _viewHoverBrush;
KStatefulBrush _viewNegativeTextBrush;
KStatefulBrush _viewNeutralTextBrush;
//@}
//*@name windeco colors
......
......@@ -31,5 +31,6 @@ namespace Breeze
const char PropertyNames::toolButtonAlignment[] = "_kde_toolButton_alignment";
const char PropertyNames::menuTitle[] = "_breeze_toolButton_menutitle";
const char PropertyNames::alteredBackground[] = "_breeze_altered_background";
const char PropertyNames::highlightNeutral[] = "_kde_highlight_neutral";
}
......@@ -34,6 +34,7 @@ namespace Breeze
static const char toolButtonAlignment[];
static const char menuTitle[];
static const char alteredBackground[];
static const char highlightNeutral[];
};
}
......
......@@ -3097,7 +3097,7 @@ namespace Breeze
// render
const auto &background = palette.color( QPalette::Base );
const auto outline( _helper->frameOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) );
const auto outline( hasHighlightNeutral( widget, option, mouseOver, hasFocus ) ? _helper->neutralText( palette ) : _helper->frameOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) );
_helper->renderFrame( painter, rect, background, outline );
}
......@@ -3794,7 +3794,7 @@ namespace Breeze
const AnimationMode mode( _animations->widgetStateEngine().isAnimated( widget, AnimationHover ) ? AnimationHover:AnimationNone );
const qreal opacity( _animations->widgetStateEngine().opacity( widget, AnimationHover ) );
QColor background = itemViewParent( widget ) ? palette.color( QPalette::Base ) : palette.color( QPalette::Window );
QColor color = _helper->checkBoxIndicatorColor( palette, mouseOver, enabled && active, opacity, mode );
QColor color = hasHighlightNeutral( widget, option, mouseOver ) ? _helper->neutralText( palette ) : _helper->checkBoxIndicatorColor( palette, mouseOver, enabled && active, opacity, mode );
// render
_helper->renderCheckBoxBackground( painter, rect, background, sunken );
......@@ -3832,7 +3832,7 @@ namespace Breeze
const AnimationMode mode( _animations->widgetStateEngine().isAnimated( widget, AnimationHover ) ? AnimationHover:AnimationNone );
const qreal opacity( _animations->widgetStateEngine().opacity( widget, AnimationHover ) );
QColor background = itemViewParent( widget ) ? palette.color( QPalette::Base ) : palette.color( QPalette::Window );
QColor color = _helper->checkBoxIndicatorColor( palette, mouseOver, enabled && checked, opacity, mode );
QColor color = hasHighlightNeutral( widget, option, mouseOver ) ? _helper->neutralText( palette ) : _helper->checkBoxIndicatorColor( palette, mouseOver, enabled && checked, opacity, mode );
// render
_helper->renderRadioButtonBackground( painter, rect, background, sunken );
......@@ -6101,14 +6101,14 @@ namespace Breeze
if( flat ) {
// define colors and render
const auto color( _helper->toolButtonColor( palette, mouseOver, hasFocus, sunken, opacity, mode ) );
const auto color( hasHighlightNeutral( widget, option, mouseOver, hasFocus ) ? _helper->neutralText( palette ) : _helper->toolButtonColor( palette, mouseOver, hasFocus, sunken, opacity, mode ) );
_helper->renderToolButtonFrame( painter, rect, color, sunken );
} else {
// define colors
const auto shadow( _helper->shadowColor( palette ) );
const auto outline( _helper->buttonOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) );
const auto outline( hasHighlightNeutral( widget, option, mouseOver, hasFocus ) ? _helper->neutralText( palette ) : _helper->buttonOutlineColor( palette, mouseOver, hasFocus, opacity, mode ) );
const auto background( _helper->buttonBackgroundColor( palette, mouseOver, hasFocus, false, opacity, mode ) );
// render
......@@ -6278,7 +6278,7 @@ namespace Breeze
// colors
const auto base( _helper->separatorColor( palette ) );
const auto &highlight = palette.color( QPalette::Highlight );
const auto &highlight = hasHighlightNeutral( widget, option, mouseOver, hasFocus ) ? _helper->neutralText( palette ) : palette.color( QPalette::Highlight );
while( current <= sliderOption->maximum )
{
......@@ -6320,7 +6320,7 @@ namespace Breeze
auto handleRect( subControlRect( CC_Slider, sliderOption, SC_SliderHandle, widget ) );
// highlight color
const auto &highlight = palette.color( QPalette::Highlight );
const auto &highlight = hasHighlightNeutral( widget, option, mouseOver, hasFocus ) ? _helper->neutralText( palette ) : palette.color( QPalette::Highlight );
if( sliderOption->orientation == Qt::Horizontal )
{
......@@ -7177,4 +7177,26 @@ namespace Breeze
}
bool Style::hasHighlightNeutral( const QObject* widget, const QStyleOption* option, bool mouseOver, bool focus) const
{
if ( !widget && ( !option || !option->styleObject ) ) {
return false;
}
if ( mouseOver || focus ) {
return false;
}
const QObject* styleObject = widget;
if (!styleObject) {
styleObject = option->styleObject;
}
const QVariant property( styleObject->property( PropertyNames::highlightNeutral ) );
if ( property.isValid() ) {
return property.toBool();
}
return false;
}
}
......@@ -469,6 +469,13 @@ namespace Breeze
//* return true if passed widget is a menu title (KMenu::addTitle)
bool hasAlteredBackground( const QWidget* ) const;
/*
* return true if the widget should be highlighted with neutral color
* if widget is null, check for the styleObject in option
* return false if the widget has the mouse hover or is focused.
*/
bool hasHighlightNeutral( const QObject* widget, const QStyleOption* option, bool mouseOver, bool focus = false ) const;
//*@name scrollbar button types (for addLine and subLine )
//@{
ScrollBarButtonType _addLineButtons = SingleButton;
......
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