[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5
Katarina Behrens
Katarina.Behrens at cib.de
Wed May 23 08:53:00 UTC 2018
vcl/inc/qt5/Qt5Menu.hxx | 6 +----
vcl/qt5/Qt5Menu.cxx | 50 ++++++++++++++++++++++++++++--------------------
2 files changed, 32 insertions(+), 24 deletions(-)
New commits:
commit 718982237e15948e4e3d45d63b8a25de049af271
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed May 23 10:51:30 2018 +0200
Native leaf menus and submenus are now visible
Change-Id: Ieaac0966b167d82c8bdeb60f3ce4b9cc8589ec62
diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index aa3948ce6d2d..38dcc3688b1f 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -12,6 +12,7 @@
#include <salmenu.hxx>
class MenuItemList;
+class QMenu;
class QMenuBar;
class Qt5MenuItem;
class Qt5Frame;
@@ -24,12 +25,9 @@ private:
Qt5Menu* mpParentSalMenu;
Qt5Frame* mpFrame;
bool mbMenuBar;
-
QMenuBar* mpQMenuBar;
- void ActivateAllSubMenus( Menu* pMenuBar );
- void Update();
-
+ void DoFullMenuUpdate( Menu* pMenuBar, QMenu* pParentMenu = nullptr );
void NativeItemText( OUString &rItemText );
public:
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 586130925356..65bf726252df 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -53,6 +53,16 @@ void Qt5Menu::RemoveItem( unsigned nPos )
void Qt5Menu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos )
{
+ SolarMutexGuard aGuard;
+ Qt5MenuItem *pItem = static_cast< Qt5MenuItem* >( pSalMenuItem );
+ Qt5Menu *pQSubMenu = static_cast< Qt5Menu* >( pSubMenu );
+
+ if ( pQSubMenu == nullptr )
+ return;
+
+ pQSubMenu->mpParentSalMenu = this;
+ pItem->mpSubMenu = pQSubMenu;
+
}
void Qt5Menu::SetFrame( const SalFrame* pFrame )
@@ -68,26 +78,10 @@ void Qt5Menu::SetFrame( const SalFrame* pFrame )
if( pMainWindow )
mpQMenuBar = pMainWindow->menuBar();
- ActivateAllSubMenus( mpVCLMenu );
-
- Update();
+ DoFullMenuUpdate( mpVCLMenu );
}
-void Qt5Menu::ActivateAllSubMenus( Menu* pMenuBar )
-{
- for (Qt5MenuItem* pSalItem : maItems)
- {
- if ( pSalItem->mpSubMenu != nullptr )
- {
- pMenuBar->HandleMenuActivateEvent(pSalItem->mpSubMenu->GetMenu());
- pSalItem->mpSubMenu->ActivateAllSubMenus(pMenuBar);
- pSalItem->mpSubMenu->Update();
- pMenuBar->HandleMenuDeActivateEvent(pSalItem->mpSubMenu->GetMenu());
- }
- }
-}
-
-void Qt5Menu::Update()
+void Qt5Menu::DoFullMenuUpdate( Menu* pMenuBar, QMenu* pParentMenu )
{
Menu* pVCLMenu = mpVCLMenu;
@@ -99,11 +93,27 @@ void Qt5Menu::Update()
Qt5MenuItem *pSalMenuItem = GetItemAtPos( nItem );
sal_uInt16 nId = pSalMenuItem->mnId;
OUString aText = pVCLMenu->GetItemText( nId );
+ QMenu* pQMenu = pParentMenu;
+ NativeItemText( aText );
if (mbMenuBar && mpQMenuBar)
+ // top-level menu
+ pQMenu = mpQMenuBar->addMenu( toQString(aText) );
+ else
+ {
+ if( pSalMenuItem->mpSubMenu )
+ // submenu
+ pQMenu = pQMenu->addMenu( toQString(aText) );
+ else
+ // leaf menu
+ pQMenu->addAction( toQString(aText) );
+ }
+
+ if ( pSalMenuItem->mpSubMenu != nullptr )
{
- NativeItemText( aText );
- mpQMenuBar->addMenu( toQString(aText) );
+ pMenuBar->HandleMenuActivateEvent(pSalMenuItem->mpSubMenu->GetMenu());
+ pSalMenuItem->mpSubMenu->DoFullMenuUpdate( pMenuBar, pQMenu );
+ pMenuBar->HandleMenuDeActivateEvent(pSalMenuItem->mpSubMenu->GetMenu());
}
}
}
More information about the Libreoffice-commits
mailing list