From 49d999b089455c572c3a8a3f3ceca4aa007081ca Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Mon, 8 Sep 2014 23:22:07 +0200 Subject: [PATCH] set special palette and special selection rendering for side panel views --- kstyle/breeze.h | 1 + kstyle/breezehelper.cpp | 9 +++++++++ kstyle/breezehelper.h | 3 +++ kstyle/breezestyle.cpp | 12 +++++++++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/kstyle/breeze.h b/kstyle/breeze.h index bab4cfb9..da168086 100644 --- a/kstyle/breeze.h +++ b/kstyle/breeze.h @@ -157,6 +157,7 @@ namespace Breeze // tree view ItemView_ArrowSize = 10, ItemView_ItemMarginWidth = 4, + SidePanel_ItemMarginWidth = 4, // splitter Splitter_SplitterWidth = 1, diff --git a/kstyle/breezehelper.cpp b/kstyle/breezehelper.cpp index f3223fa2..d00393de 100644 --- a/kstyle/breezehelper.cpp +++ b/kstyle/breezehelper.cpp @@ -116,6 +116,15 @@ namespace Breeze return copy; } + //____________________________________________________________________ + QPalette Helper::sideViewPalette( const QPalette& palette ) const + { + QPalette copy( palette ); + copy.setColor( QPalette::Active, QPalette::HighlightedText, palette.color( QPalette::Active, QPalette::Highlight ) ); + copy.setColor( QPalette::Inactive, QPalette::HighlightedText, palette.color( QPalette::Active, QPalette::Highlight ) ); + return copy; + } + //____________________________________________________________________ QColor Helper::arrowColor( const QPalette& palette, bool mouseOver, bool hasFocus, qreal opacity, AnimationMode mode ) const { diff --git a/kstyle/breezehelper.h b/kstyle/breezehelper.h index c3e46159..d66a6453 100644 --- a/kstyle/breezehelper.h +++ b/kstyle/breezehelper.h @@ -110,6 +110,9 @@ namespace Breeze //* return altered palette suitable for tinted frames QPalette framePalette( const QPalette& ) const; + //* return altered palette suitable for tinted frames + QPalette sideViewPalette( const QPalette& ) const; + //* arrow outline color, using animations QColor arrowColor( const QPalette&, bool mouseOver, bool hasFocus, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone ) const; diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index be51fc8d..d45c0606 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -306,11 +306,14 @@ namespace Breeze scrollArea->setFrameStyle( QFrame::NoFrame ); scrollArea->setBackgroundRole( QPalette::Window ); scrollArea->setForegroundRole( QPalette::WindowText ); + scrollArea->setPalette( _helper->sideViewPalette( scrollArea->palette() ) ); + scrollArea->setProperty( PropertyNames::sidePanelView, true ); if( QWidget *viewport = scrollArea->viewport() ) { viewport->setBackgroundRole( QPalette::Window ); viewport->setForegroundRole( QPalette::WindowText ); + viewport->setPalette( _helper->sideViewPalette( viewport->palette() ) ); } } @@ -3155,7 +3158,7 @@ namespace Breeze // store palette and rect const QPalette& palette( option->palette ); - const QRect& rect( option->rect ); + QRect rect( option->rect ); // store flags const State& state( option->state ); @@ -3238,6 +3241,13 @@ namespace Breeze } + const bool isSidePanel( widget && widget->property( PropertyNames::sidePanelView ).toBool() ); + if( isSidePanel ) + { + rect.setWidth( Metrics::SidePanel_ItemMarginWidth ); + rect = visualRect( option, rect ); + } + // render _helper->renderSelection( painter, rect, color, corners );