[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5
Katarina Behrens
Katarina.Behrens at cib.de
Fri May 25 14:06:11 UTC 2018
vcl/inc/qt5/Qt5Menu.hxx | 3 ++-
vcl/qt5/Qt5Menu.cxx | 21 ++++++++++++++++++---
2 files changed, 20 insertions(+), 4 deletions(-)
New commits:
commit 08c2927e0587428d2c242ffcdf142d39f23df092
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Fri May 25 16:04:24 2018 +0200
Dispatch commands from menus for real
Change-Id: I01997caa22e14c1350bd83100edb74397ebab5d7
diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index 408d97e76520..37887045506f 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -42,6 +42,7 @@ public:
virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ) override;
virtual void SetFrame( const SalFrame* pFrame ) override;
const Qt5Frame* GetFrame() const;
+ Qt5Menu* GetTopLevel();
virtual void CheckItem( unsigned nPos, bool bCheck ) override;
virtual void EnableItem( unsigned nPos, bool bEnable ) override;
virtual void ShowItem( unsigned nPos, bool bShow ) override;
@@ -56,7 +57,7 @@ public:
Qt5MenuItem* GetItemAtPos( unsigned nPos ) { return maItems[ nPos ]; }
private slots:
- void DispatchCommand();
+ void DispatchCommand( Qt5MenuItem* pQItem );
};
class Qt5MenuItem : public SalMenuItem
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index f7ebc5617d8c..91de0defccff 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -114,7 +114,8 @@ void Qt5Menu::DoFullMenuUpdate( Menu* pMenuBar, QMenu* pParentMenu )
// leaf menu
QAction *pAction = pQMenu->addAction( toQString(aText) );
pAction->setShortcut( toQString( nAccelKey.GetName(GetFrame()->GetWindow()) ) );
- connect( pAction, &QAction::triggered, this, &Qt5Menu::DispatchCommand );
+ connect( pAction, &QAction::triggered, this,
+ [this, pSalMenuItem]{ DispatchCommand(pSalMenuItem); } );
}
}
}
@@ -156,6 +157,14 @@ void Qt5Menu::GetSystemMenuData( SystemMenuData* pData )
{
}
+Qt5Menu* Qt5Menu::GetTopLevel()
+{
+ Qt5Menu *pMenu = this;
+ while (pMenu->mpParentSalMenu)
+ pMenu = pMenu->mpParentSalMenu;
+ return pMenu;
+}
+
const Qt5Frame* Qt5Menu::GetFrame() const
{
SolarMutexGuard aGuard;
@@ -165,9 +174,15 @@ const Qt5Frame* Qt5Menu::GetFrame() const
return pMenu ? pMenu->mpFrame : nullptr;
}
-void Qt5Menu::DispatchCommand()
+void Qt5Menu::DispatchCommand( Qt5MenuItem *pQItem )
{
- SAL_WARN("vcl.qt5", "menu triggered");
+ if ( pQItem )
+ {
+ Qt5Menu* pSalMenu = pQItem->mpParentMenu;
+ Qt5Menu* pTopLevel = pSalMenu->GetTopLevel();
+ pTopLevel->GetMenu()->HandleMenuCommandEvent(pSalMenu->GetMenu(), pQItem->mnId);
+ SAL_WARN("vcl.qt5", "menu triggered " << pQItem->mnId );
+ }
}
void Qt5Menu::NativeItemText( OUString& rItemText )
More information about the Libreoffice-commits
mailing list