0001-Add-Property-to-disable-drawing-of-menu-arrow-indica.patch

File Metadata

Author
hallas
Created
Apr 14 2019, 5:47 PM

0001-Add-Property-to-disable-drawing-of-menu-arrow-indica.patch

From 69ae58eb16ca204013595ba4badc8a137ca18b6d Mon Sep 17 00:00:00 2001
From: David Hallas <david@davidhallas.dk>
Date: Sun, 14 Apr 2019 19:46:29 +0200
Subject: [PATCH] Add Property to disable drawing of menu arrow indicators
Summary:
Add Property to disable drawing of menu arrow indicators. This is useful
for navigation type Tool Buttons.
Test Plan:
Reviewers:
---
kstyle/breezepropertynames.cpp | 1 +
kstyle/breezepropertynames.h | 1 +
kstyle/breezestyle.cpp | 35 ++++++++++++++++++----------------
3 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/kstyle/breezepropertynames.cpp b/kstyle/breezepropertynames.cpp
index 2c1ccb8d..32eccf14 100644
--- a/kstyle/breezepropertynames.cpp
+++ b/kstyle/breezepropertynames.cpp
@@ -29,6 +29,7 @@ namespace Breeze
const char PropertyNames::netWMSkipShadow[] = "_KDE_NET_WM_SKIP_SHADOW";
const char PropertyNames::sidePanelView[] = "_kde_side_panel_view";
const char PropertyNames::toolButtonAlignment[] = "_kde_toolButton_alignment";
+ const char PropertyNames::toolButtonNoMenuArrow[] = "_kde_toolButton_noMenuArrow";
const char PropertyNames::menuTitle[] = "_breeze_toolButton_menutitle";
const char PropertyNames::alteredBackground[] = "_breeze_altered_background";
diff --git a/kstyle/breezepropertynames.h b/kstyle/breezepropertynames.h
index 94a04085..4efc50bf 100644
--- a/kstyle/breezepropertynames.h
+++ b/kstyle/breezepropertynames.h
@@ -32,6 +32,7 @@ namespace Breeze
static const char netWMSkipShadow[];
static const char sidePanelView[];
static const char toolButtonAlignment[];
+ static const char toolButtonNoMenuArrow[];
static const char menuTitle[];
static const char alteredBackground[];
};
diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp
index ed7d29b2..dc7e0560 100644
--- a/kstyle/breezestyle.cpp
+++ b/kstyle/breezestyle.cpp
@@ -150,6 +150,19 @@ namespace BreezePrivate
{ return option && ( (option->state & QStyle::State_Horizontal ) || option->orientation == Qt::Horizontal ); }
#endif
+ bool hasPopupMenu(const QStyleOptionToolButton* toolButtonOption)
+ {
+ return toolButtonOption->features & QStyleOptionToolButton::MenuButtonPopup;
+ }
+ bool hasInlineIndicator(const QStyleOptionToolButton* toolButtonOption, const QWidget* toolButton)
+ {
+ return
+ (toolButton->property( Breeze::PropertyNames::toolButtonNoMenuArrow ).toBool() == false)
+ && toolButtonOption->features&QStyleOptionToolButton::HasMenu
+ && toolButtonOption->features&QStyleOptionToolButton::PopupDelay
+ && !hasPopupMenu(toolButtonOption);
+ }
+
}
namespace Breeze
@@ -2134,11 +2147,8 @@ namespace Breeze
const auto toolButtonOption = qstyleoption_cast<const QStyleOptionToolButton*>( option );
if( !toolButtonOption ) return ParentStyleClass::subControlRect( CC_ToolButton, option, subControl, widget );
- const bool hasPopupMenu( toolButtonOption->features & QStyleOptionToolButton::MenuButtonPopup );
- const bool hasInlineIndicator(
- toolButtonOption->features&QStyleOptionToolButton::HasMenu
- && toolButtonOption->features&QStyleOptionToolButton::PopupDelay
- && !hasPopupMenu );
+ const bool hasPopupMenu( BreezePrivate::hasPopupMenu(toolButtonOption) );
+ const bool hasInlineIndicator( BreezePrivate::hasInlineIndicator(toolButtonOption, widget) );
// store rect
const auto& rect( option->rect );
@@ -2713,7 +2723,7 @@ namespace Breeze
}
//______________________________________________________________
- QSize Style::toolButtonSizeFromContents( const QStyleOption* option, const QSize& contentsSize, const QWidget* ) const
+ QSize Style::toolButtonSizeFromContents( const QStyleOption* option, const QSize& contentsSize, const QWidget* widget) const
{
// cast option and check
@@ -2726,11 +2736,7 @@ namespace Breeze
// get relevant state flags
const State& state( option->state );
const bool autoRaise( state & State_AutoRaise );
- const bool hasPopupMenu( toolButtonOption->features & QStyleOptionToolButton::MenuButtonPopup );
- const bool hasInlineIndicator(
- toolButtonOption->features&QStyleOptionToolButton::HasMenu
- && toolButtonOption->features&QStyleOptionToolButton::PopupDelay
- && !hasPopupMenu );
+ const bool hasInlineIndicator( BreezePrivate::hasInlineIndicator(toolButtonOption, widget) );
const int marginWidth( autoRaise ? Metrics::ToolButton_MarginWidth : Metrics::Button_MarginWidth + Metrics::Frame_FrameWidth );
@@ -6068,11 +6074,8 @@ namespace Breeze
// copy option and alter palette
QStyleOptionToolButton copy( *toolButtonOption );
- const bool hasPopupMenu( toolButtonOption->features & QStyleOptionToolButton::MenuButtonPopup );
- const bool hasInlineIndicator(
- toolButtonOption->features&QStyleOptionToolButton::HasMenu
- && toolButtonOption->features&QStyleOptionToolButton::PopupDelay
- && !hasPopupMenu );
+ const bool hasPopupMenu( BreezePrivate::hasPopupMenu(toolButtonOption) );
+ const bool hasInlineIndicator( BreezePrivate::hasInlineIndicator(toolButtonOption, widget) );
const auto buttonRect( subControlRect( CC_ToolButton, option, SC_ToolButton, widget ) );
const auto menuRect( subControlRect( CC_ToolButton, option, SC_ToolButtonMenu, widget ) );
--
2.21.0