bump product version to 6.4.0.3
[LibreOffice.git] / vcl / inc / qt5 / Qt5Menu.hxx
blobefcfb8eeb81c15586b9ade308f02745d4c168e4f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #pragma once
12 #include <salmenu.hxx>
14 #include <QtCore/QObject>
16 #include <memory>
18 class MenuItemList;
19 class QAction;
20 class QActionGroup;
21 class QPushButton;
22 class QMenu;
23 class QMenuBar;
24 class Qt5MenuItem;
25 class Qt5Frame;
27 class Qt5Menu : public QObject, public SalMenu
29 Q_OBJECT
30 private:
31 std::vector<Qt5MenuItem*> maItems;
32 VclPtr<Menu> mpVCLMenu;
33 Qt5Menu* mpParentSalMenu;
34 Qt5Frame* mpFrame;
35 bool mbMenuBar;
36 QMenuBar* mpQMenuBar;
37 QMenu* mpQMenu;
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);
50 public:
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]; }
80 private slots:
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
89 public:
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: */