diff --git a/kstyle/breezehelper.cpp b/kstyle/breezehelper.cpp index 3b53f7b4..288b4480 100644 --- a/kstyle/breezehelper.cpp +++ b/kstyle/breezehelper.cpp @@ -594,14 +594,22 @@ namespace Breeze //______________________________________________________________________________ void Helper::renderMenuFrame( QPainter* painter, const QRect& rect, - const QColor& color, const QColor& outline, bool roundCorners ) const + const QColor& color, const QColor& outline, bool roundCorners, bool isTopMenu ) const { + painter->save(); + // set brush if( color.isValid() ) painter->setBrush( color ); else painter->setBrush( Qt::NoBrush ); + // We simulate being able to independently adjust corner radii by + // setting a clip region and then extending the rectangle beyond it. + if ( isTopMenu ) { + painter->setClipRect( rect ); + } + if( roundCorners ) { @@ -609,6 +617,8 @@ namespace Breeze QRectF frameRect( rect ); qreal radius( frameRadius( PenWidth::NoPen ) ); + if( isTopMenu ) frameRect.adjust(0, -radius, 0, 0); + // set pen if( outline.isValid() ) { @@ -626,6 +636,8 @@ namespace Breeze painter->setRenderHint( QPainter::Antialiasing, false ); QRect frameRect( rect ); + if( isTopMenu ) frameRect.adjust(0, 1, 0, 0); + if( outline.isValid() ) { @@ -638,6 +650,8 @@ namespace Breeze } + painter->restore(); + } //______________________________________________________________________________ diff --git a/kstyle/breezehelper.h b/kstyle/breezehelper.h index dedf4a90..b22d4c4e 100644 --- a/kstyle/breezehelper.h +++ b/kstyle/breezehelper.h @@ -171,7 +171,7 @@ namespace Breeze void renderSidePanelFrame( QPainter*, const QRect&, const QColor& outline, Side ) const; //* menu frame - void renderMenuFrame( QPainter*, const QRect&, const QColor& color, const QColor& outline, bool roundCorners = true ) const; + void renderMenuFrame( QPainter*, const QRect&, const QColor& color, const QColor& outline, bool roundCorners = true, bool isTopMenu = false ) const; //* button frame void renderButtonFrame( QPainter*, const QRect&, const QColor& color, const QColor& outline, const QColor& shadow, bool focus, bool sunken ) const; diff --git a/kstyle/breezepropertynames.cpp b/kstyle/breezepropertynames.cpp index 3450b484..d1cf1601 100644 --- a/kstyle/breezepropertynames.cpp +++ b/kstyle/breezepropertynames.cpp @@ -19,5 +19,6 @@ namespace Breeze const char PropertyNames::alteredBackground[] = "_breeze_altered_background"; const char PropertyNames::highlightNeutral[] = "_kde_highlight_neutral"; const char PropertyNames::noSeparator[] = "_breeze_no_separator"; + const char PropertyNames::isTopMenu[] = "_breeze_menu_is_top"; } diff --git a/kstyle/breezepropertynames.h b/kstyle/breezepropertynames.h index 64b231af..4ef2600c 100644 --- a/kstyle/breezepropertynames.h +++ b/kstyle/breezepropertynames.h @@ -22,6 +22,7 @@ namespace Breeze static const char alteredBackground[]; static const char highlightNeutral[]; static const char noSeparator[]; + static const char isTopMenu[]; }; } diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index 413f6a59..8d7a935a 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -3748,6 +3748,7 @@ namespace Breeze const auto& palette( option->palette ); const bool hasAlpha( _helper->hasAlphaChannel( widget ) ); + const bool isTopMenu( widget != nullptr && widget->property(PropertyNames::isTopMenu).toBool() ); auto background( _helper->frameBackgroundColor( palette ) ); auto outline( _helper->frameOutlineColor( palette ) ); @@ -3761,7 +3762,7 @@ namespace Breeze outline = _helper->alphaColor( palette.color( QPalette::WindowText ), 0.25 ); } - _helper->renderMenuFrame( painter, option->rect, background, outline, hasAlpha ); + _helper->renderMenuFrame( painter, option->rect, background, outline, hasAlpha, isTopMenu ); painter->restore(); @@ -4822,7 +4823,7 @@ namespace Breeze Sides sides; if( !menuItemOption->menuRect.isNull() ) { - if( rect.top() <= menuItemOption->menuRect.top() ) sides |= SideTop; + if( rect.top() <= menuItemOption->menuRect.top() && !(widget && widget->property(PropertyNames::isTopMenu).toBool()) ) sides |= SideTop; if( rect.bottom() >= menuItemOption->menuRect.bottom() ) sides |= SideBottom; if( rect.left() <= menuItemOption->menuRect.left() ) sides |= SideLeft; if( rect.right() >= menuItemOption->menuRect.right() ) sides |= SideRight;