diff --git a/kstyle/breeze.h b/kstyle/breeze.h --- a/kstyle/breeze.h +++ b/kstyle/breeze.h @@ -67,7 +67,8 @@ // menu items Menu_FrameWidth = 0, - MenuItem_MarginWidth = 3, + MenuItem_MarginWidth = 5, + MenuItem_MarginHeight = 3, MenuItem_ItemSpacing = 4, MenuItem_AcceleratorSpace = 16, MenuButton_IndicatorWidth = 20, diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -2749,7 +2749,7 @@ size.setHeight( qMax( size.height(), int(Metrics::MenuButton_IndicatorWidth) ) ); size.setHeight( qMax( size.height(), int(Metrics::CheckBox_Size) ) ); size.setHeight( qMax( size.height(), iconWidth ) ); - return expandSize( size, Metrics::MenuItem_MarginWidth ); + return expandSize( size, Metrics::MenuItem_MarginWidth, Metrics::MenuItem_MarginHeight ); } @@ -2759,7 +2759,7 @@ if( menuItemOption->text.isEmpty() && menuItemOption->icon.isNull() ) { - return expandSize( QSize(0,1), Metrics::MenuItem_MarginWidth ); + return expandSize( QSize(0,1), Metrics::MenuItem_MarginWidth, Metrics::MenuItem_MarginHeight ); } else { @@ -4692,7 +4692,7 @@ } // get rect available for contents - auto contentsRect( insideMargin( rect, Metrics::MenuItem_MarginWidth ) ); + auto contentsRect( insideMargin( rect, Metrics::MenuItem_MarginWidth, Metrics::MenuItem_MarginHeight ) ); // define relevant rectangles // checkbox @@ -4736,14 +4736,18 @@ const bool showIcon( showIconsInMenuItems() ); if( showIcon ) iconWidth = isQtQuickControl( option, widget ) ? qMax( pixelMetric(PM_SmallIconSize, option, widget ), menuItemOption->maxIconWidth ) : menuItemOption->maxIconWidth; - QRect iconRect( contentsRect.left(), contentsRect.top() + (contentsRect.height()-iconWidth)/2, iconWidth, iconWidth ); - contentsRect.setLeft( iconRect.right() + Metrics::MenuItem_ItemSpacing + 1 ); + QRect iconRect; + if( showIcon && iconWidth > 0 ) + { + iconRect = QRect( contentsRect.left(), contentsRect.top() + (contentsRect.height()-iconWidth)/2, iconWidth, iconWidth ); + contentsRect.setLeft( iconRect.right() + Metrics::MenuItem_ItemSpacing + 1 ); + const QSize iconSize( pixelMetric( PM_SmallIconSize, option, widget ), pixelMetric( PM_SmallIconSize, option, widget ) ); + iconRect = centerRect( iconRect, iconSize ); + } if( showIcon && !menuItemOption->icon.isNull() ) { - const QSize iconSize( pixelMetric( PM_SmallIconSize, option, widget ), pixelMetric( PM_SmallIconSize, option, widget ) ); - iconRect = centerRect( iconRect, iconSize ); iconRect = visualRect( option, iconRect ); // icon mode @@ -4785,7 +4789,6 @@ } - // text auto textRect = contentsRect; if( !menuItemOption->text.isEmpty() ) @@ -6659,12 +6662,12 @@ // render a separator at the bottom const auto& palette( option->palette ); const auto color( _helper->separatorColor( palette ) ); - _helper->renderSeparator( painter, QRect( option->rect.bottomLeft()-QPoint( 0, Metrics::MenuItem_MarginWidth), QSize( option->rect.width(), 1 ) ), color ); + _helper->renderSeparator( painter, QRect( option->rect.bottomLeft()-QPoint( 0, Metrics::MenuItem_MarginHeight), QSize( option->rect.width(), 1 ) ), color ); // render text in the center of the rect // icon is discarded on purpose painter->setFont( option->font ); - const auto contentsRect = insideMargin( option->rect, Metrics::MenuItem_MarginWidth ); + const auto contentsRect = insideMargin( option->rect, Metrics::MenuItem_MarginWidth, Metrics::MenuItem_MarginHeight ); drawItemText( painter, contentsRect, Qt::AlignCenter, palette, true, option->text, QPalette::WindowText ); }