Kaydet (Commit) 8645239c authored tarafından Isamu Mogi's avatar Isamu Mogi Kaydeden (comit) David Tardon

vcl: Check SH_MenuBar_MouseTracking when menubar is drawn on KDE

If QStyle::SH_MenuBar_MouseTracking is 0, it makes a mouse rollover
effect minimize. By this, a menubar item of CDE and Motif styles becomes
closer to standard behavior.

Change-Id: I87dccbd30bf7b9f0d82d1a6e67355c1b25d22dc8
Reviewed-on: https://gerrit.libreoffice.org/4018Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst 97852d41
...@@ -777,7 +777,8 @@ sal_Bool WidgetPainter::drawStyledWidget( QWidget *pWidget, ...@@ -777,7 +777,8 @@ sal_Bool WidgetPainter::drawStyledWidget( QWidget *pWidget,
int nMenuItem = ( nStyle & QStyle::Style_Enabled )? m_nMenuBarEnabledItem: m_nMenuBarDisabledItem; int nMenuItem = ( nStyle & QStyle::Style_Enabled )? m_nMenuBarEnabledItem: m_nMenuBarDisabledItem;
QMenuItem *pMenuItem = static_cast<QMenuBar*>( pWidget )->findItem( nMenuItem ); QMenuItem *pMenuItem = static_cast<QMenuBar*>( pWidget )->findItem( nMenuItem );
if ( nStyle & QStyle::Style_MouseOver ) if ( ( nStyle & QStyle::Style_MouseOver )
&& kapp->style().styleHint( QStyle::SH_MenuBar_MouseTracking ) )
nStyle |= QStyle::Style_Active; nStyle |= QStyle::Style_Active;
if ( nStyle & QStyle::Style_Selected ) if ( nStyle & QStyle::Style_Selected )
...@@ -1984,9 +1985,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings ) ...@@ -1984,9 +1985,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
aStyleSettings.SetMenuBarTextColor( aMenuFore ); aStyleSettings.SetMenuBarTextColor( aMenuFore );
aStyleSettings.SetMenuColor( aMenuBack ); aStyleSettings.SetMenuColor( aMenuBack );
aStyleSettings.SetMenuBarColor( aMenuBack ); aStyleSettings.SetMenuBarColor( aMenuBack );
aStyleSettings.SetMenuHighlightColor( toColor ( qMenuCG.highlight() ) ); aStyleSettings.SetMenuHighlightColor( toColor ( qMenuCG.highlight() ) );
aStyleSettings.SetMenuBarRolloverColor( toColor ( qMenuCG.highlight() ) );
// Menu items higlight text color, theme specific // Menu items higlight text color, theme specific
if ( kapp->style().inherits( "HighContrastStyle" ) || if ( kapp->style().inherits( "HighContrastStyle" ) ||
...@@ -2002,15 +2001,22 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings ) ...@@ -2002,15 +2001,22 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
// set special menubar higlight text color // set special menubar higlight text color
if ( kapp->style().inherits( "HighContrastStyle" ) ) if ( kapp->style().inherits( "HighContrastStyle" ) )
{
ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = toColor( qMenuCG.highlightedText() ); ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = toColor( qMenuCG.highlightedText() );
aStyleSettings.SetMenuBarRolloverTextColor( toColor( qMenuCG.highlightedText() ) ); else
ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore;
// set menubar rollover color
if ( kapp->style().styleHint( QStyle::SH_MenuBar_MouseTracking ) )
{
aStyleSettings.SetMenuBarRolloverColor( toColor ( qMenuCG.highlight() ) );
aStyleSettings.SetMenuBarRolloverTextColor( ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor );
} }
else else
{ {
ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore; aStyleSettings.SetMenuBarRolloverColor( aMenuBack );
aStyleSettings.SetMenuBarRolloverTextColor( aMenuFore ); aStyleSettings.SetMenuBarRolloverTextColor( aMenuFore );
} }
// Font // Font
aFont = toFont( pMenuBar->font(), rSettings.GetUILanguageTag().getLocale() ); aFont = toFont( pMenuBar->font(), rSettings.GetUILanguageTag().getLocale() );
aStyleSettings.SetMenuFont( aFont ); aStyleSettings.SetMenuFont( aFont );
......
...@@ -301,21 +301,24 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings ) ...@@ -301,21 +301,24 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
style.SetMenuBarTextColor( aMenuFore ); style.SetMenuBarTextColor( aMenuFore );
style.SetMenuColor( aMenuBack ); style.SetMenuColor( aMenuBack );
style.SetMenuBarColor( aMenuBack ); style.SetMenuBarColor( aMenuBack );
style.SetMenuHighlightColor( toColor ( qMenuCG.color( QPalette::Highlight ) ) ); style.SetMenuHighlightColor( toColor ( qMenuCG.color( QPalette::Highlight ) ) );
style.SetMenuBarRolloverColor( toColor ( qMenuCG.color( QPalette::Highlight ) ) );
style.SetMenuHighlightTextColor( aMenuFore ); style.SetMenuHighlightTextColor( aMenuFore );
// set special menubar higlight text color // set special menubar higlight text color
if ( kapp->style()->inherits( "HighContrastStyle" ) ) if ( kapp->style()->inherits( "HighContrastStyle" ) )
{
ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = toColor( qMenuCG.color( QPalette::HighlightedText ) ); ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = toColor( qMenuCG.color( QPalette::HighlightedText ) );
style.SetMenuBarRolloverTextColor( toColor( qMenuCG.color( QPalette::HighlightedText ) ) ); else
ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore;
// set menubar rollover color
if ( pMenuBar->style()->styleHint( QStyle::SH_MenuBar_MouseTracking ) )
{
style.SetMenuBarRolloverColor( toColor ( qMenuCG.color( QPalette::Highlight ) ) );
style.SetMenuBarRolloverTextColor( ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor );
} }
else else
{ {
ImplGetSVData()->maNWFData.maMenuBarHighlightTextColor = aMenuFore; style.SetMenuBarRolloverColor( aMenuBack );
style.SetMenuBarRolloverTextColor( aMenuFore ); style.SetMenuBarRolloverTextColor( aMenuFore );
} }
......
...@@ -297,7 +297,8 @@ sal_Bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part, ...@@ -297,7 +297,8 @@ sal_Bool KDESalGraphics::drawNativeControl( ControlType type, ControlPart part,
if (part == PART_MENU_ITEM) if (part == PART_MENU_ITEM)
{ {
QStyleOptionMenuItem option; QStyleOptionMenuItem option;
if ( nControlState & CTRL_STATE_ROLLOVER ) if ( ( nControlState & CTRL_STATE_ROLLOVER )
&& kapp->style()->styleHint( QStyle::SH_MenuBar_MouseTracking ) )
option.state |= QStyle::State_Selected; option.state |= QStyle::State_Selected;
if ( nControlState & CTRL_STATE_SELECTED ) // Passing State_Sunken is currently not documented. if ( nControlState & CTRL_STATE_SELECTED ) // Passing State_Sunken is currently not documented.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment