diff --git a/kstyle/oxygenstyle.cpp b/kstyle/oxygenstyle.cpp --- a/kstyle/oxygenstyle.cpp +++ b/kstyle/oxygenstyle.cpp @@ -3348,7 +3348,13 @@ } else if( isQtQuickControl( option, widget ) ) { // QtQuick Control case - _helper->drawFloatFrame( painter, option->rect, option->palette.window().color(), true ); + const QPalette& palette( option->palette ); + const QColor background( _helper->frameBackgroundColor( palette ) ); + const QColor outline( _helper->frameOutlineColor( palette ) ); + + const bool hasAlpha( _helper->hasAlphaChannel( widget ) ); + _helper->renderMenuFrame( painter, option->rect, background, outline, hasAlpha ); + } return true; @@ -5642,6 +5648,19 @@ return true; } + case QFrame::StyledPanel: + { + + if( isQtQuickControl( option, widget ) ) + { + + // ComboBox popup frame + drawFrameMenuPrimitive( option, painter, widget ); + return true; + + } else break; + } + default: break; } diff --git a/kstyle/oxygenstylehelper.h b/kstyle/oxygenstylehelper.h --- a/kstyle/oxygenstylehelper.h +++ b/kstyle/oxygenstylehelper.h @@ -24,6 +24,7 @@ #include "oxygenhelper.h" #include "oxygen.h" +#include "oxygenanimationdata.h" #include @@ -90,6 +91,16 @@ QColor frameGlowColor( const QPalette& palette, StyleOptions options, qreal opacity, AnimationMode mode ) const { return frameGlowColor( palette.currentColorGroup(), options, opacity, mode ); } + //* frame outline color, using animations + QColor frameOutlineColor( const QPalette&, bool mouseOver = false, bool hasFocus = false, qreal opacity = AnimationData::OpacityInvalid, AnimationMode = AnimationNone ) const; + + //* frame background color + QColor frameBackgroundColor( const QPalette& palette ) const + { return frameBackgroundColor( palette, palette.currentColorGroup() ); } + + //* frame background color + QColor frameBackgroundColor( const QPalette&, QPalette::ColorGroup ) const; + //* glow color for arrows (mouse-over takes precedence over focus) QColor arrowColor( const QPalette& palette, StyleOptions options, qreal opacity, AnimationMode mode ) const; @@ -175,6 +186,9 @@ //* debug frame void renderDebugFrame( QPainter*, const QRect& ) const; + //* menu frame + void renderMenuFrame( QPainter*, const QRect&, const QColor& color, const QColor& outline, bool roundCorners = true ) const; + //*@name holes //@{ @@ -223,6 +237,10 @@ //@} + //* frame radius + qreal frameRadius( qreal bias = 0 ) const + { return std::max( qreal( Metrics::Frame_FrameRadius ) - 0.5 + bias, 0.0 ); } + protected: //*@name holes diff --git a/kstyle/oxygenstylehelper.cpp b/kstyle/oxygenstylehelper.cpp --- a/kstyle/oxygenstylehelper.cpp +++ b/kstyle/oxygenstylehelper.cpp @@ -172,6 +172,46 @@ } + //____________________________________________________________________ + QColor StyleHelper::frameOutlineColor( const QPalette& palette, bool mouseOver, bool hasFocus, qreal opacity, AnimationMode mode ) const + { + + QColor outline( KColorUtils::mix( palette.color( QPalette::Window ), palette.color( QPalette::WindowText ), 0.25 ) ); + + // focus takes precedence over hover + if( mode == AnimationFocus ) + { + + const QColor focus( focusColor( palette ) ); + const QColor hover( hoverColor( palette ) ); + + if( mouseOver ) outline = KColorUtils::mix( hover, focus, opacity ); + else outline = KColorUtils::mix( outline, focus, opacity ); + + } else if( hasFocus ) { + + outline = focusColor( palette ); + + } else if( mode == AnimationHover ) { + + const QColor hover( hoverColor( palette ) ); + outline = KColorUtils::mix( outline, hover, opacity ); + + } else if( mouseOver ) { + + outline = hoverColor( palette ); + + } + + return outline; + + } + + + //____________________________________________________________________ + QColor StyleHelper::frameBackgroundColor( const QPalette& palette, QPalette::ColorGroup group ) const + { return KColorUtils::mix( palette.color( group, QPalette::Window ), palette.color( group, QPalette::Base ), 0.3 ); } + //____________________________________________________________________________________ QColor StyleHelper::arrowColor( const QPalette& palette, StyleOptions options, qreal opacity, AnimationMode mode ) const { @@ -775,6 +815,54 @@ painter->restore(); } + //______________________________________________________________________________ + void StyleHelper::renderMenuFrame( + QPainter* painter, const QRect& rect, + const QColor& color, const QColor& outline, bool roundCorners ) const + { + + // set brush + if( color.isValid() ) painter->setBrush( color ); + else painter->setBrush( Qt::NoBrush ); + + if( roundCorners ) + { + + painter->setRenderHint( QPainter::Antialiasing ); + QRectF frameRect( rect ); + qreal radius( frameRadius() ); + + // set pen + if( outline.isValid() ) + { + + painter->setPen( outline ); + frameRect.adjust( 0.5, 0.5, -0.5, -0.5 ); + radius = qMax( radius - 1, qreal( 0.0 ) ); + + } else painter->setPen( Qt::NoPen ); + + // render + painter->drawRoundedRect( frameRect, radius, radius ); + + } else { + + painter->setRenderHint( QPainter::Antialiasing, false ); + QRect frameRect( rect ); + if( outline.isValid() ) + { + + painter->setPen( outline ); + frameRect.adjust( 0, 0, -1, -1 ); + + } else painter->setPen( Qt::NoPen ); + + painter->drawRect( frameRect ); + + } + + } + //________________________________________________________________________________________________________ void StyleHelper::fillHole( QPainter& painter, const QRect& rect, int offset ) const { painter.drawRoundedRect( rect.adjusted( offset, offset, -offset, -offset ), 4 - offset, 4 - offset ); }