diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2016-09-14 02:02:38 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2016-09-13 23:06:38 +0000 |
commit | 74fd959945dbbfbc3dcc331a08ff8fc7c6410295 (patch) | |
tree | dbabc8792b2d774cb8d7d456bb3b2765a73484e4 /svtools | |
parent | ebe46f14a266f7e538bc8b8fa6b9f7d78c5e308d (diff) |
tdf#74377 Keyboard shortcuts for context menus
Configurable through the options dialog. The default behavior
depends on the current vclplug (hide for gtk2/3 and OS X, show
otherwise).
Menus currently affected by this change:
- SfxDispatcher based context menus
- chart2 context menus
- vcl's Edit control context menu
- Several MenuBarManager based toolbar dropdowns.
Change-Id: Iad9fb99dc90e01c17cba9c07c1a2b262b920e11d
Reviewed-on: https://gerrit.libreoffice.org/28849
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Tested-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/config/menuoptions.cxx | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/svtools/source/config/menuoptions.cxx b/svtools/source/config/menuoptions.cxx index 9a561c7284e8..fffce29e0405 100644 --- a/svtools/source/config/menuoptions.cxx +++ b/svtools/source/config/menuoptions.cxx @@ -40,16 +40,19 @@ using namespace ::com::sun::star::uno ; #define DEFAULT_DONTHIDEDISABLEDENTRIES false #define DEFAULT_FOLLOWMOUSE true #define DEFAULT_MENUICONS TRISTATE_INDET +#define DEFAULT_CONTEXTMENUSHORTCUTS TRISTATE_INDET #define PROPERTYNAME_DONTHIDEDISABLEDENTRIES "DontHideDisabledEntry" #define PROPERTYNAME_FOLLOWMOUSE "FollowMouse" #define PROPERTYNAME_SHOWICONSINMENUES "ShowIconsInMenues" #define PROPERTYNAME_SYSTEMICONSINMENUES "IsSystemIconsInMenus" +#define PROPERTYNAME_SHORTCUTSINCONTEXMENU "ShortcutsInContextMenus" #define PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES 0 #define PROPERTYHANDLE_FOLLOWMOUSE 1 #define PROPERTYHANDLE_SHOWICONSINMENUES 2 #define PROPERTYHANDLE_SYSTEMICONSINMENUES 3 +#define PROPERTYHANDLE_SHORTCUTSINCONTEXMENU 4 #include <tools/link.hxx> @@ -64,6 +67,7 @@ class SvtMenuOptions_Impl : public ConfigItem bool m_bDontHideDisabledEntries ; /// cache "DontHideDisabledEntries" of Menu section bool m_bFollowMouse ; /// cache "FollowMouse" of Menu section TriState m_eMenuIcons ; /// cache "MenuIcons" of Menu section + TriState m_eContextMenuShortcuts ; /// cache "ShortcutsInContextMenus" of Menu section // public methods @@ -110,6 +114,16 @@ class SvtMenuOptions_Impl : public ConfigItem // tdf#93451: don't Commit() here, it's too early } + TriState GetContextMenuShortcuts() const + { return m_eContextMenuShortcuts; } + + void SetContextMenuShortcuts(TriState eState) + { + m_eContextMenuShortcuts = eState; + SetModified(); + Commit(); + } + // private methods private: @@ -135,6 +149,7 @@ SvtMenuOptions_Impl::SvtMenuOptions_Impl() , m_bDontHideDisabledEntries ( DEFAULT_DONTHIDEDISABLEDENTRIES ) , m_bFollowMouse ( DEFAULT_FOLLOWMOUSE ) , m_eMenuIcons ( DEFAULT_MENUICONS ) + , m_eContextMenuShortcuts ( DEFAULT_CONTEXTMENUSHORTCUTS ) { // Use our static list of configuration keys to get his values. Sequence< OUString > seqNames = impl_GetPropertyNames(); @@ -190,6 +205,13 @@ SvtMenuOptions_Impl::SvtMenuOptions_Impl() seqValues[nProperty] >>= bSystemMenuIcons; } break; + case PROPERTYHANDLE_SHORTCUTSINCONTEXMENU : { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShortcutsInContextMenus\"?" ); + sal_Int16 nContextMenuShortcuts; + if ( seqValues[nProperty] >>= nContextMenuShortcuts ) + m_eContextMenuShortcuts = static_cast<TriState>(nContextMenuShortcuts); + } + break; } } @@ -250,6 +272,13 @@ void SvtMenuOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames ) DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\IsSystemIconsInMenus\"?" ); bMenuSettingsChanged |= seqValues[nProperty] >>= bSystemMenuIcons; } + else if( seqPropertyNames[nProperty] == PROPERTYNAME_SHORTCUTSINCONTEXMENU ) + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShortcutsInContextMenus\"?" ); + sal_Int16 nContextMenuShortcuts; + if ( seqValues[nProperty] >>= nContextMenuShortcuts ) + m_eContextMenuShortcuts = static_cast<TriState>(nContextMenuShortcuts); + } else assert( false && "SvtMenuOptions_Impl::Notify()\nUnknown property detected ... I can't handle these!\n" ); } @@ -289,6 +318,10 @@ void SvtMenuOptions_Impl::ImplCommit() seqValues[nProperty] <<= bValue; } break; + case PROPERTYHANDLE_SHORTCUTSINCONTEXMENU : { + seqValues[nProperty] <<= static_cast<sal_Int16>(m_eContextMenuShortcuts); + } + break; } } // Set properties in configuration. @@ -303,7 +336,8 @@ Sequence< OUString > const & SvtMenuOptions_Impl::impl_GetPropertyNames() OUString(PROPERTYNAME_DONTHIDEDISABLEDENTRIES) , OUString(PROPERTYNAME_FOLLOWMOUSE) , OUString(PROPERTYNAME_SHOWICONSINMENUES) , - OUString(PROPERTYNAME_SYSTEMICONSINMENUES) + OUString(PROPERTYNAME_SYSTEMICONSINMENUES) , + OUString(PROPERTYNAME_SHORTCUTSINCONTEXMENU) }; return seqPropertyNames; } @@ -360,6 +394,18 @@ void SvtMenuOptions::SetMenuIconsState(TriState eState) m_pImpl->SetMenuIconsState(eState); } +TriState SvtMenuOptions::GetContextMenuShortcuts() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pImpl->GetContextMenuShortcuts(); +} + +void SvtMenuOptions::SetContextMenuShortcuts(TriState eState) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pImpl->SetContextMenuShortcuts(eState); +} + // private method Mutex& SvtMenuOptions::GetOwnStaticMutex() |