Skip to content

Commit

Permalink
[QStyle] Make menu titles look less like menu items
Browse files Browse the repository at this point in the history
Summary:
The look of Breeze menu titles has always slightly bothered me since they have the same
visual style and weighting as items, so they look clickable even though they aren't, and
they don't really do a very good job of separating sections, as seems to be their purpose.
This patch my my attempt to remedy the situation by making them look more "title-like"
and have greater visual distinctiveness from the items above and below them.

Test Plan:
Plasma Task Manager item context menu, before: {F8252758}
Plasma Task Manager context menu, after: {F8253825}

KMoreTools menu, before: {F8252757}
KMoreTools menu, after: {F8253827}

Reviewers: #vdg, #breeze, niccolove, ndavis

Reviewed By: #vdg, #breeze, niccolove, ndavis

Subscribers: cblack, cfeck, ndavis, niccolove, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D29081
Pointedstick committed May 19, 2020
1 parent d3159ee commit 073f475
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions kstyle/breezestyle.cpp
Original file line number Diff line number Diff line change
@@ -6655,14 +6655,19 @@ namespace Breeze
void Style::renderMenuTitle( const QStyleOptionToolButton* option, QPainter* painter, const QWidget* ) const
{

// render a separator at the bottom
// render a background rect for the title
const auto& palette( option->palette );
const auto color( _helper->separatorColor( palette ) );
_helper->renderSeparator( painter, QRect( option->rect.bottomLeft()-QPoint( 0, Metrics::MenuItem_MarginHeight), QSize( option->rect.width(), 1 ) ), color );
QColor bgColor = palette.color( QPalette::Text );
bgColor.setAlphaF(0.04);
const auto separatorColor( _helper->separatorColor( palette ) );
_helper->renderMenuFrame( painter, option->rect, bgColor, separatorColor, true );

// render text in the center of the rect
// icon is discarded on purpose
painter->setFont( option->font );
// make text the same size as a level 4 heading so it looks more title-ish
auto font = option->font;
font.setPointSize( qRound( font.pointSize() * 1.1 ) );
painter->setFont( font );
const auto contentsRect = insideMargin( option->rect, Metrics::MenuItem_MarginWidth, Metrics::MenuItem_MarginHeight );
drawItemText( painter, contentsRect, Qt::AlignCenter, palette, true, option->text, QPalette::WindowText );

0 comments on commit 073f475

Please sign in to comment.