I'm introducing a setting that decides if disabled menu items should be hidden. Currently the code
is broken in the sense that items are hidden if disabled on all platforms and
UpdateApplicationSettings which theortically does that is a) counter-intuitive and b) not set by
platforms.
The patch sets the setting for KDE, KDE4 and OSX and uses it for the edit menu.
Future steps are to use the setting for other menus and I think UpdateApplicationSettings should
eventually be removed because it's completely mis-designed and confusing.
ciao,
Christian
From 3475f8f442ffed53df728acfd0e96b2bab1d18cd Mon Sep 17 00:00:00 2001
From: Christian Dywan <christian.dywan@lanedo.com>
Date: Thu, 21 Apr 2011 15:14:32 +0200
Subject: [PATCH] Introduce HideDisabledMenuItems style setting
The setting is enabled for KDE and OSX.
---
vcl/aqua/source/window/salframe.cxx | 1 +
vcl/inc/vcl/settings.hxx | 5 +++++
vcl/source/app/settings.cxx | 3 +++
vcl/source/control/edit.cxx | 4 +++-
vcl/unx/kde/salnativewidgets-kde.cxx | 1 +
vcl/unx/kde4/KDESalFrame.cxx | 1 +
6 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/vcl/aqua/source/window/salframe.cxx b/vcl/aqua/source/window/salframe.cxx
index f37182f..4b41148 100644
--- a/vcl/aqua/source/window/salframe.cxx
+++ b/vcl/aqua/source/window/salframe.cxx
@@ -1320,6 +1320,7 @@ void AquaSalFrame::UpdateSettings( AllSettings& rSettings )
// images in menus false for MacOSX
aStyleSettings.SetPreferredUseImagesInMenus( false );
+ aStyleSettings.SetHideDisabledMenuItems( sal_True );
aStyleSettings.SetAcceleratorsInContextMenus( sal_False );
rSettings.SetStyleSettings( aStyleSettings );
diff --git a/vcl/inc/vcl/settings.hxx b/vcl/inc/vcl/settings.hxx
index e5a824c..a6a9565 100644
--- a/vcl/inc/vcl/settings.hxx
+++ b/vcl/inc/vcl/settings.hxx
@@ -434,6 +434,7 @@ private:
sal_uLong mnSymbolsStyle;
sal_uLong mnPreferredSymbolsStyle;
sal_uInt16 mnSkipDisabledInMenus;
+ sal_Bool mbHideDisabledMenuItems;
sal_Bool mnAcceleratorsInContextMenus;
Wallpaper maWorkspaceGradient;
const void* mpFontOptions;
@@ -736,6 +737,10 @@ public:
{ CopyData(); mpData->mnSkipDisabledInMenus =
bSkipDisabledInMenus; }
sal_Bool GetSkipDisabledInMenus() const
{ return (sal_Bool) mpData->mnSkipDisabledInMenus; }
+ void SetHideDisabledMenuItems( sal_Bool
bHideDisabledMenuItems )
+ { CopyData(); mpData->mbHideDisabledMenuItems =
bHideDisabledMenuItems; }
+ sal_Bool GetHideDisabledMenuItems() const
+ { return mpData->mbHideDisabledMenuItems; }
void SetAcceleratorsInContextMenus(
sal_Bool bAcceleratorsInContextMenus )
{ CopyData(); mpData->mnAcceleratorsInContextMenus =
bAcceleratorsInContextMenus; }
sal_Bool GetAcceleratorsInContextMenus()
const
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index b256f04..388a043 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -529,6 +529,7 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
mnUseImagesInMenus = rData.mnUseImagesInMenus;
mbPreferredUseImagesInMenus = rData.mbPreferredUseImagesInMenus;
mnSkipDisabledInMenus = rData.mnSkipDisabledInMenus;
+ mbHideDisabledMenuItems = rData.mbHideDisabledMenuItems;
mnAcceleratorsInContextMenus = rData.mnAcceleratorsInContextMenus;
mnToolbarIconSize = rData.mnToolbarIconSize;
mnSymbolsStyle = rData.mnSymbolsStyle;
@@ -618,6 +619,7 @@ void ImplStyleData::SetStandardStyles()
mnUseFlatMenues = 0;
mbPreferredUseImagesInMenus = sal_True;
mnSkipDisabledInMenus = (sal_uInt16)sal_False;
+ mbHideDisabledMenuItems = sal_False;
mnAcceleratorsInContextMenus = sal_True;
Gradient aGrad( GRADIENT_LINEAR, DEFAULT_WORKSPACE_GRADIENT_START_COLOR,
DEFAULT_WORKSPACE_GRADIENT_END_COLOR );
@@ -1079,6 +1081,7 @@ sal_Bool StyleSettings::operator ==( const StyleSettings& rSet ) const
(mpData->mnUseImagesInMenus == rSet.mpData->mnUseImagesInMenus)
&&
(mpData->mbPreferredUseImagesInMenus == rSet.mpData->mbPreferredUseImagesInMenus) &&
(mpData->mnSkipDisabledInMenus == rSet.mpData->mnSkipDisabledInMenus)
&&
+ (mpData->mbHideDisabledMenuItems == rSet.mpData->mbHideDisabledMenuItems) &&
(mpData->mnAcceleratorsInContextMenus == rSet.mpData->mnAcceleratorsInContextMenus)
&&
(mpData->maFontColor == rSet.mpData->maFontColor ))
return sal_True;
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index fb352f3..ed2697b 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -2095,8 +2095,10 @@ void Edit::Command( const CommandEvent& rCEvt )
{
PopupMenu* pPopup = Edit::CreatePopupMenu();
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- if ( rStyleSettings.GetOptions() & STYLE_OPTION_HIDEDISABLED )
+ if ( rStyleSettings.GetHideDisabledMenuItems() )
pPopup->SetMenuFlags( MENU_FLAG_HIDEDISABLEDENTRIES );
+ else
+ pPopup->SetMenuFlags ( MENU_FLAG_ALWAYSSHOWDISABLEDENTRIES );
if ( !maSelection.Len() )
{
diff --git a/vcl/unx/kde/salnativewidgets-kde.cxx b/vcl/unx/kde/salnativewidgets-kde.cxx
index d0fa4a0..5707586 100644
--- a/vcl/unx/kde/salnativewidgets-kde.cxx
+++ b/vcl/unx/kde/salnativewidgets-kde.cxx
@@ -1970,6 +1970,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
// Menu
aStyleSettings.SetSkipDisabledInMenus( sal_True );
+ aStyleSettings.SetHideDisabledMenuItems( sal_True );
KMenuBar *pMenuBar = qMainWindow.menuBar();
if ( pMenuBar )
{
diff --git a/vcl/unx/kde4/KDESalFrame.cxx b/vcl/unx/kde4/KDESalFrame.cxx
index 8ed5078..68f9e5c 100644
--- a/vcl/unx/kde4/KDESalFrame.cxx
+++ b/vcl/unx/kde4/KDESalFrame.cxx
@@ -308,6 +308,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
// Menu
style.SetSkipDisabledInMenus( TRUE );
+ style.SetHideDisabledMenuItems( sal_True );
KMenuBar* pMenuBar = new KMenuBar();
if ( pMenuBar )
{
--
1.7.1
Context
- [Libreoffice] [PATCH] Introduce HideDisabledMenuItems style setting · Christian Dywan
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.