diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-05-23 17:39:44 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-06-01 10:06:32 +0200 |
commit | cd762c362e2de178d928d1cca52e291b9a1e8d70 (patch) | |
tree | b88916863a20d27f35501a336859431793cfc337 | |
parent | 5b02225ff7f963a79e0177150de8257626f0d2a1 (diff) |
Add shortcuts to native menu entries
something's wrong though, they don't really show
Change-Id: Id8559fd9b6a5d4b2b49442d179571d31a99b5b20
-rw-r--r-- | vcl/qt5/Qt5Menu.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx index 0575d5aab693..fd864e8b2422 100644 --- a/vcl/qt5/Qt5Menu.cxx +++ b/vcl/qt5/Qt5Menu.cxx @@ -95,6 +95,7 @@ void Qt5Menu::DoFullMenuUpdate( Menu* pMenuBar, QMenu* pParentMenu ) OUString aText = pVCLMenu->GetItemText( nId ); QMenu* pQMenu = pParentMenu; NativeItemText( aText ); + vcl::KeyCode nAccelKey = pVCLMenu->GetAccelKey( nId ); if (mbMenuBar && mpQMenuBar) // top-level menu @@ -109,8 +110,11 @@ void Qt5Menu::DoFullMenuUpdate( Menu* pMenuBar, QMenu* pParentMenu ) if ( pSalMenuItem->mnType == MenuItemType::SEPARATOR ) pQMenu->addSeparator(); else + { // leaf menu - pQMenu->addAction( toQString(aText) ); + QAction *pAction = pQMenu->addAction( toQString(aText) ); + pAction->setShortcut( toQString( nAccelKey.GetName(GetFrame()->GetWindow()) ) ); + } } } @@ -151,6 +155,15 @@ void Qt5Menu::GetSystemMenuData( SystemMenuData* pData ) { } +const Qt5Frame* Qt5Menu::GetFrame() const +{ + SolarMutexGuard aGuard; + const Qt5Menu* pMenu = this; + while( pMenu && ! pMenu->mpFrame ) + pMenu = pMenu->mpParentSalMenu; + return pMenu ? pMenu->mpFrame : nullptr; +} + void Qt5Menu::NativeItemText( OUString& rItemText ) { rItemText = rItemText.replace( '~', '&' ); |