1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 #include <salmenu.hxx>
14 #include <QtCore/QObject>
27 class Qt5Menu
: public QObject
, public SalMenu
31 std::vector
<Qt5MenuItem
*> maItems
;
32 VclPtr
<Menu
> mpVCLMenu
;
33 Qt5Menu
* mpParentSalMenu
;
38 QPushButton
* mpCloseButton
;
39 QMetaObject::Connection maCloseButtonConnection
;
41 void DoFullMenuUpdate(Menu
* pMenuBar
);
42 static void NativeItemText(OUString
& rItemText
);
44 void InsertMenuItem(Qt5MenuItem
* pSalMenuItem
, unsigned nPos
);
46 void ReinitializeActionGroup(unsigned nPos
);
47 void ResetAllActionGroups();
48 void UpdateActionGroupItem(const Qt5MenuItem
* pSalMenuItem
);
51 Qt5Menu(bool bMenuBar
);
53 virtual bool VisibleMenuBar() override
; // must return TRUE to actually DISPLAY native menu bars
55 virtual void InsertItem(SalMenuItem
* pSalMenuItem
, unsigned nPos
) override
;
56 virtual void RemoveItem(unsigned nPos
) override
;
57 virtual void SetSubMenu(SalMenuItem
* pSalMenuItem
, SalMenu
* pSubMenu
, unsigned nPos
) override
;
58 virtual void SetFrame(const SalFrame
* pFrame
) override
;
59 const Qt5Frame
* GetFrame() const;
60 virtual void ShowMenuBar(bool bVisible
) override
;
61 Qt5Menu
* GetTopLevel();
62 virtual void SetItemBits(unsigned nPos
, MenuItemBits nBits
) override
;
63 virtual void CheckItem(unsigned nPos
, bool bCheck
) override
;
64 virtual void EnableItem(unsigned nPos
, bool bEnable
) override
;
65 virtual void ShowItem(unsigned nPos
, bool bShow
) override
;
66 virtual void SetItemText(unsigned nPos
, SalMenuItem
* pSalMenuItem
,
67 const OUString
& rText
) override
;
68 virtual void SetItemImage(unsigned nPos
, SalMenuItem
* pSalMenuItem
,
69 const Image
& rImage
) override
;
70 virtual void SetAccelerator(unsigned nPos
, SalMenuItem
* pSalMenuItem
,
71 const vcl::KeyCode
& rKeyCode
, const OUString
& rKeyName
) override
;
72 virtual void GetSystemMenuData(SystemMenuData
* pData
) override
;
73 virtual void ShowCloseButton(bool bShow
) override
;
75 void SetMenu(Menu
* pMenu
) { mpVCLMenu
= pMenu
; }
76 Menu
* GetMenu() { return mpVCLMenu
; }
77 unsigned GetItemCount() const { return maItems
.size(); }
78 Qt5MenuItem
* GetItemAtPos(unsigned nPos
) { return maItems
[nPos
]; }
81 static void slotMenuTriggered(Qt5MenuItem
* pQItem
);
82 static void slotMenuAboutToShow(Qt5MenuItem
* pQItem
);
83 static void slotMenuAboutToHide(Qt5MenuItem
* pQItem
);
84 void slotCloseDocument();
87 class Qt5MenuItem
: public SalMenuItem
90 Qt5MenuItem(const SalItemParams
*);
92 QAction
* getAction() const;
94 Qt5Menu
* mpParentMenu
; // The menu into which this menu item is inserted
95 Qt5Menu
* mpSubMenu
; // Submenu of this item (if defined)
96 std::unique_ptr
<QAction
> mpAction
; // action corresponding to this item
97 std::unique_ptr
<QMenu
> mpMenu
; // menu corresponding to this item
98 std::shared_ptr
<QActionGroup
> mpActionGroup
; // empty if it's a separator element
99 sal_uInt16 mnId
; // Item ID
100 MenuItemType mnType
; // Item type
101 bool mbVisible
; // Item visibility.
102 bool mbEnabled
; // Item active.
103 Image maImage
; // Item image
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */