[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - 2 commits - vcl/qt5

Katarina Behrens Katarina.Behrens at cib.de
Wed May 23 15:40:41 UTC 2018


 vcl/qt5/Qt5Menu.cxx |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

New commits:
commit 46391493f6c28c86aa5c100fc0f490e74b083cd5
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Wed May 23 17:39:44 2018 +0200

    Add shortcuts to native menu entries
    
    something's wrong though, they don't really show
    
    Change-Id: Id8559fd9b6a5d4b2b49442d179571d31a99b5b20

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( '~', '&' );
commit 130e23a672383d220ebf2a8cf8715d6ecf52fe58
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Wed May 23 11:23:34 2018 +0200

    Insert separators into native menu
    
    Change-Id: I88bb70b1e443821cc8d1904039f2a8fb52df1ff9

diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 65bf726252df..0575d5aab693 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -105,8 +105,13 @@ void Qt5Menu::DoFullMenuUpdate( Menu* pMenuBar, QMenu* pParentMenu )
                 // submenu
                 pQMenu = pQMenu->addMenu( toQString(aText) );
             else
-                // leaf menu
-                pQMenu->addAction( toQString(aText) );
+            {
+                if ( pSalMenuItem->mnType == MenuItemType::SEPARATOR )
+                    pQMenu->addSeparator();
+                else
+                    // leaf menu
+                    pQMenu->addAction( toQString(aText) );
+            }
         }
 
         if ( pSalMenuItem->mpSubMenu != nullptr )
@@ -153,6 +158,7 @@ void Qt5Menu::NativeItemText( OUString& rItemText )
 
 Qt5MenuItem::Qt5MenuItem( const SalItemParams* pItemData ) :
     mnId( pItemData->nId ),
+    mnType( pItemData->eType ),
     mpVCLMenu( pItemData->pMenu ),
     mpParentMenu( nullptr ),
     mpSubMenu( nullptr )


More information about the Libreoffice-commits mailing list