Introduce _breeze_menu_is_top property for drawing menus

This property, when set, will cause menus to drop their top border + their top corner rounding.
wilder-5.24
Jan Blackquill 5 years ago
parent cada4a724d
commit 3c70ee66be
  1. 16
      kstyle/breezehelper.cpp
  2. 2
      kstyle/breezehelper.h
  3. 1
      kstyle/breezepropertynames.cpp
  4. 1
      kstyle/breezepropertynames.h
  5. 5
      kstyle/breezestyle.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();
}
//______________________________________________________________________________

@ -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;

@ -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";
}

@ -22,6 +22,7 @@ namespace Breeze
static const char alteredBackground[];
static const char highlightNeutral[];
static const char noSeparator[];
static const char isTopMenu[];
};
}

@ -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;

Loading…
Cancel
Save