LibreOffice Module vcl (master)
1
vcl
inc
qt5
qt5/QtMenu.hxx
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
* This file is part of the LibreOffice project.
4
*
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
*/
9
10
#pragma once
11
12
#include <
salmenu.hxx
>
13
14
#include <QtCore/QObject>
15
16
#include <memory>
17
18
class
MenuItemList
;
19
class
QAbstractButton;
20
class
QAction;
21
class
QActionGroup;
22
class
QButtonGroup;
23
class
QMenu;
24
class
QMenuBar;
25
class
QPushButton;
26
class
QtMenuItem
;
27
class
QtFrame
;
28
29
/*
30
* QtMenu can represent
31
* (1) the top-level menu of a menubar, in which case 'mbMenuBar' is true and
32
* 'mpQMenuBar' refers to the corresponding QMenuBar
33
* (2) another kind of menu (like a PopupMenu), in which case the corresponding QMenu
34
* object is instantiated and owned by this QtMenu (held in 'mpOwnedQMenu').
35
* (3) a "submenu" in an existing menu (like (1)), in which case the corresponding
36
* QMenu object is owned by the corresponding QtMenuItem.
37
*
38
* For (2) and (3), member 'mpQMenu' points to the corresponding QMenu object.
39
*/
40
class
QtMenu
:
public
QObject,
public
SalMenu
41
{
42
Q_OBJECT
43
private
:
44
std::vector<QtMenuItem*>
maItems
;
45
VclPtr<Menu>
mpVCLMenu
;
46
QtMenu
*
mpParentSalMenu
;
47
QtFrame
*
mpFrame
;
48
bool
mbMenuBar
;
49
QMenuBar*
mpQMenuBar
;
50
// self-created QMenu that this QtMenu represents, if applicable (s. comment for class)
51
std::unique_ptr<QMenu>
mpOwnedQMenu
;
52
// pointer to QMenu owned by the corresponding QtMenuItem or self (-> mpOwnedQMenu)
53
QMenu*
mpQMenu
;
54
QButtonGroup*
m_pButtonGroup
;
55
56
void
DoFullMenuUpdate
(
Menu
* pMenuBar);
57
static
void
NativeItemText
(OUString& rItemText);
58
59
void
InsertMenuItem
(
QtMenuItem
* pSalMenuItem,
unsigned
nPos);
60
61
void
ReinitializeActionGroup
(
unsigned
nPos);
62
void
ResetAllActionGroups
();
63
void
UpdateActionGroupItem
(
const
QtMenuItem
* pSalMenuItem);
64
bool
validateQMenuBar
()
const
;
65
QPushButton*
ImplAddMenuBarButton
(
const
QIcon& rIcon,
const
QString& rToolTip,
int
nId);
66
void
ImplRemoveMenuBarButton
(
int
nId);
67
void
adjustButtonSizes
();
68
69
public
:
70
QtMenu
(
bool
bMenuBar);
71
72
virtual
bool
VisibleMenuBar
()
override
;
// must return TRUE to actually DISPLAY native menu bars
73
74
virtual
void
InsertItem
(
SalMenuItem
* pSalMenuItem,
unsigned
nPos)
override
;
75
virtual
void
RemoveItem
(
unsigned
nPos)
override
;
76
virtual
void
SetSubMenu
(
SalMenuItem
* pSalMenuItem,
SalMenu
* pSubMenu,
unsigned
nPos)
override
;
77
virtual
void
SetFrame
(
const
SalFrame
* pFrame)
override
;
78
const
QtFrame
*
GetFrame
()
const
;
79
virtual
void
ShowMenuBar
(
bool
bVisible)
override
;
80
virtual
bool
ShowNativePopupMenu
(
FloatingWindow
* pWin,
const
tools::Rectangle
& rRect,
81
FloatWinPopupFlags
nFlags)
override
;
82
QtMenu
*
GetTopLevel
();
83
virtual
void
SetItemBits
(
unsigned
nPos,
MenuItemBits
nBits)
override
;
84
virtual
void
CheckItem
(
unsigned
nPos,
bool
bCheck)
override
;
85
virtual
void
EnableItem
(
unsigned
nPos,
bool
bEnable)
override
;
86
virtual
void
ShowItem
(
unsigned
nPos,
bool
bShow)
override
;
87
virtual
void
SetItemText
(
unsigned
nPos,
SalMenuItem
* pSalMenuItem,
88
const
OUString& rText)
override
;
89
virtual
void
SetItemImage
(
unsigned
nPos,
SalMenuItem
* pSalMenuItem,
90
const
Image
& rImage)
override
;
91
virtual
void
SetAccelerator
(
unsigned
nPos,
SalMenuItem
* pSalMenuItem,
92
const
vcl::KeyCode
& rKeyCode,
const
OUString& rKeyName)
override
;
93
virtual
void
GetSystemMenuData
(
SystemMenuData
* pData)
override
;
94
virtual
void
ShowCloseButton
(
bool
bShow)
override
;
95
virtual
bool
AddMenuBarButton
(
const
SalMenuButtonItem
&)
override
;
96
virtual
void
RemoveMenuBarButton
(sal_uInt16 nId)
override
;
97
virtual
tools::Rectangle
GetMenuBarButtonRectPixel
(sal_uInt16 nId,
SalFrame
*)
override
;
98
virtual
int
GetMenuBarHeight
()
const override
;
99
100
void
SetMenu
(
Menu
* pMenu) {
mpVCLMenu
= pMenu; }
101
Menu
*
GetMenu
() {
return
mpVCLMenu
; }
102
unsigned
GetItemCount
()
const
{
return
maItems
.size(); }
103
QtMenuItem
*
GetItemAtPos
(
unsigned
nPos) {
return
maItems
[
nPos
]; }
104
105
private
slots:
106
static
void
slotMenuTriggered
(
QtMenuItem
* pQItem);
107
static
void
slotMenuAboutToShow
(
QtMenuItem
* pQItem);
108
static
void
slotMenuAboutToHide
(
QtMenuItem
* pQItem);
109
void
slotCloseDocument
();
110
void
slotMenuBarButtonClicked
(QAbstractButton*);
111
};
112
113
class
QtMenuItem
:
public
SalMenuItem
114
{
115
public
:
116
QtMenuItem
(
const
SalItemParams
*);
117
118
QAction*
getAction
()
const
;
119
120
QtMenu
*
mpParentMenu
;
// The menu into which this menu item is inserted
121
QtMenu
*
mpSubMenu
;
// Submenu of this item (if defined)
122
std::unique_ptr<QAction>
mpAction
;
// action corresponding to this item
123
std::unique_ptr<QMenu>
mpMenu
;
// menu corresponding to this item
124
std::shared_ptr<QActionGroup>
mpActionGroup
;
// empty if it's a separator element
125
sal_uInt16
mnId
;
// Item ID
126
MenuItemType
mnType
;
// Item type
127
bool
mbVisible
;
// Item visibility.
128
bool
mbEnabled
;
// Item active.
129
Image
maImage
;
// Item image
130
};
131
132
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FloatingWindow
Definition:
floatwin.hxx:57
Image
Definition:
image.hxx:40
MenuItemList
Definition:
menuitemlist.hxx:104
Menu
Definition:
menu.hxx:116
QtFrame
Definition:
qt5/QtFrame.hxx:69
QtMenuItem
Definition:
qt5/QtMenu.hxx:114
QtMenuItem::mnId
sal_uInt16 mnId
Definition:
qt5/QtMenu.hxx:125
QtMenuItem::mpAction
std::unique_ptr< QAction > mpAction
Definition:
qt5/QtMenu.hxx:122
QtMenuItem::mpSubMenu
QtMenu * mpSubMenu
Definition:
qt5/QtMenu.hxx:121
QtMenuItem::mpActionGroup
std::shared_ptr< QActionGroup > mpActionGroup
Definition:
qt5/QtMenu.hxx:124
QtMenuItem::mpParentMenu
QtMenu * mpParentMenu
Definition:
qt5/QtMenu.hxx:120
QtMenuItem::mbEnabled
bool mbEnabled
Definition:
qt5/QtMenu.hxx:128
QtMenuItem::maImage
Image maImage
Definition:
qt5/QtMenu.hxx:129
QtMenuItem::mnType
MenuItemType mnType
Definition:
qt5/QtMenu.hxx:126
QtMenuItem::mpMenu
std::unique_ptr< QMenu > mpMenu
Definition:
qt5/QtMenu.hxx:123
QtMenuItem::getAction
QAction * getAction() const
QtMenuItem::mbVisible
bool mbVisible
Definition:
qt5/QtMenu.hxx:127
QtMenuItem::QtMenuItem
QtMenuItem(const SalItemParams *)
QtMenu
Definition:
qt5/QtMenu.hxx:41
QtMenu::GetMenuBarButtonRectPixel
virtual tools::Rectangle GetMenuBarButtonRectPixel(sal_uInt16 nId, SalFrame *) override
QtMenu::slotCloseDocument
void slotCloseDocument()
QtMenu::ShowNativePopupMenu
virtual bool ShowNativePopupMenu(FloatingWindow *pWin, const tools::Rectangle &rRect, FloatWinPopupFlags nFlags) override
QtMenu::UpdateActionGroupItem
void UpdateActionGroupItem(const QtMenuItem *pSalMenuItem)
QtMenu::GetTopLevel
QtMenu * GetTopLevel()
QtMenu::ShowItem
virtual void ShowItem(unsigned nPos, bool bShow) override
QtMenu::CheckItem
virtual void CheckItem(unsigned nPos, bool bCheck) override
QtMenu::ShowMenuBar
virtual void ShowMenuBar(bool bVisible) override
QtMenu::RemoveMenuBarButton
virtual void RemoveMenuBarButton(sal_uInt16 nId) override
QtMenu::mpQMenu
QMenu * mpQMenu
Definition:
qt5/QtMenu.hxx:53
QtMenu::ShowCloseButton
virtual void ShowCloseButton(bool bShow) override
QtMenu::mpQMenuBar
QMenuBar * mpQMenuBar
Definition:
qt5/QtMenu.hxx:49
QtMenu::InsertItem
virtual void InsertItem(SalMenuItem *pSalMenuItem, unsigned nPos) override
QtMenu::EnableItem
virtual void EnableItem(unsigned nPos, bool bEnable) override
QtMenu::DoFullMenuUpdate
void DoFullMenuUpdate(Menu *pMenuBar)
QtMenu::ReinitializeActionGroup
void ReinitializeActionGroup(unsigned nPos)
QtMenu::mbMenuBar
bool mbMenuBar
Definition:
qt5/QtMenu.hxx:48
QtMenu::mpFrame
QtFrame * mpFrame
Definition:
qt5/QtMenu.hxx:47
QtMenu::GetFrame
const QtFrame * GetFrame() const
QtMenu::QtMenu
QtMenu(bool bMenuBar)
QtMenu::SetAccelerator
virtual void SetAccelerator(unsigned nPos, SalMenuItem *pSalMenuItem, const vcl::KeyCode &rKeyCode, const OUString &rKeyName) override
QtMenu::VisibleMenuBar
virtual bool VisibleMenuBar() override
QtMenu::SetSubMenu
virtual void SetSubMenu(SalMenuItem *pSalMenuItem, SalMenu *pSubMenu, unsigned nPos) override
QtMenu::GetItemCount
unsigned GetItemCount() const
Definition:
qt5/QtMenu.hxx:102
QtMenu::InsertMenuItem
void InsertMenuItem(QtMenuItem *pSalMenuItem, unsigned nPos)
QtMenu::mpOwnedQMenu
std::unique_ptr< QMenu > mpOwnedQMenu
Definition:
qt5/QtMenu.hxx:51
QtMenu::adjustButtonSizes
void adjustButtonSizes()
QtMenu::mpParentSalMenu
QtMenu * mpParentSalMenu
Definition:
qt5/QtMenu.hxx:46
QtMenu::ImplAddMenuBarButton
QPushButton * ImplAddMenuBarButton(const QIcon &rIcon, const QString &rToolTip, int nId)
QtMenu::slotMenuAboutToHide
static void slotMenuAboutToHide(QtMenuItem *pQItem)
QtMenu::validateQMenuBar
bool validateQMenuBar() const
QtMenu::mpVCLMenu
VclPtr< Menu > mpVCLMenu
Definition:
qt5/QtMenu.hxx:45
QtMenu::m_pButtonGroup
QButtonGroup * m_pButtonGroup
Definition:
qt5/QtMenu.hxx:54
QtMenu::GetSystemMenuData
virtual void GetSystemMenuData(SystemMenuData *pData) override
QtMenu::GetMenuBarHeight
virtual int GetMenuBarHeight() const override
QtMenu::SetItemText
virtual void SetItemText(unsigned nPos, SalMenuItem *pSalMenuItem, const OUString &rText) override
QtMenu::ImplRemoveMenuBarButton
void ImplRemoveMenuBarButton(int nId)
QtMenu::GetItemAtPos
QtMenuItem * GetItemAtPos(unsigned nPos)
Definition:
qt5/QtMenu.hxx:103
QtMenu::slotMenuTriggered
static void slotMenuTriggered(QtMenuItem *pQItem)
QtMenu::slotMenuAboutToShow
static void slotMenuAboutToShow(QtMenuItem *pQItem)
QtMenu::SetItemBits
virtual void SetItemBits(unsigned nPos, MenuItemBits nBits) override
QtMenu::SetMenu
void SetMenu(Menu *pMenu)
Definition:
qt5/QtMenu.hxx:100
QtMenu::slotMenuBarButtonClicked
void slotMenuBarButtonClicked(QAbstractButton *)
QtMenu::SetFrame
virtual void SetFrame(const SalFrame *pFrame) override
QtMenu::ResetAllActionGroups
void ResetAllActionGroups()
QtMenu::AddMenuBarButton
virtual bool AddMenuBarButton(const SalMenuButtonItem &) override
QtMenu::NativeItemText
static void NativeItemText(OUString &rItemText)
QtMenu::maItems
std::vector< QtMenuItem * > maItems
Definition:
qt5/QtMenu.hxx:44
QtMenu::GetMenu
Menu * GetMenu()
Definition:
qt5/QtMenu.hxx:101
QtMenu::RemoveItem
virtual void RemoveItem(unsigned nPos) override
QtMenu::SetItemImage
virtual void SetItemImage(unsigned nPos, SalMenuItem *pSalMenuItem, const Image &rImage) override
SalFrame
A SalFrame is a system window (e.g. an X11 window).
Definition:
salframe.hxx:115
SalMenuItem
Definition:
salmenu.hxx:53
SalMenu
Definition:
salmenu.hxx:59
VclPtr< Menu >
tools::Rectangle
vcl::KeyCode
Definition:
keycod.hxx:35
nPos
sal_uInt16 nPos
salmenu.hxx
SalItemParams
Definition:
salmenu.hxx:32
SalMenuButtonItem
Definition:
salmenu.hxx:42
SystemMenuData
Definition:
sysdata.hxx:134
MenuItemType
MenuItemType
Definition:
vclenum.hxx:30
MenuItemBits
MenuItemBits
Definition:
vclenum.hxx:33
FloatWinPopupFlags
FloatWinPopupFlags
Definition:
vclenum.hxx:323
Generated on Sun Jul 30 2023 04:34:59 for LibreOffice Module vcl (master) by
1.9.3