Kaydet (Commit) 26bcf961 authored tarafından Katarina Behrens's avatar Katarina Behrens

Dispatch commands from menus for real

Change-Id: I01997caa22e14c1350bd83100edb74397ebab5d7
üst b971f2cc
......@@ -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
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment