1 | /* $Id: UIMenuBarEditorWindow.h 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMenuBarEditorWindow class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2014-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ___UIMenuBarEditorWindow_h___
|
---|
19 | #define ___UIMenuBarEditorWindow_h___
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | /* Qt includes: */
|
---|
25 | #include <QMap>
|
---|
26 | #include <QUuid>
|
---|
27 |
|
---|
28 | /* GUI includes: */
|
---|
29 | #include "QIWithRetranslateUI.h"
|
---|
30 | #include "UIExtraDataDefs.h"
|
---|
31 | #include "UILibraryDefs.h"
|
---|
32 | #include "UISlidingToolBar.h"
|
---|
33 |
|
---|
34 | /* Forward declarations: */
|
---|
35 | class QAction;
|
---|
36 | class QHBoxLayout;
|
---|
37 | class QMenu;
|
---|
38 | #ifndef VBOX_WS_MAC
|
---|
39 | class QCheckBox;
|
---|
40 | #endif
|
---|
41 | class QString;
|
---|
42 | class QWidget;
|
---|
43 | class QIToolButton;
|
---|
44 | class UIAction;
|
---|
45 | class UIActionPool;
|
---|
46 | class UIToolBar;
|
---|
47 | class UIMachineWindow;
|
---|
48 |
|
---|
49 |
|
---|
50 | /** UISlidingToolBar subclass
|
---|
51 | * providing user with possibility to edit menu-bar layout. */
|
---|
52 | class SHARED_LIBRARY_STUFF UIMenuBarEditorWindow : public UISlidingToolBar
|
---|
53 | {
|
---|
54 | Q_OBJECT;
|
---|
55 |
|
---|
56 | public:
|
---|
57 |
|
---|
58 | /** Constructs sliding toolbar passing @a pParent to the base-class.
|
---|
59 | * @param pActionPool Brings the action-pool reference for internal use. */
|
---|
60 | UIMenuBarEditorWindow(UIMachineWindow *pParent, UIActionPool *pActionPool);
|
---|
61 | };
|
---|
62 |
|
---|
63 |
|
---|
64 | /** QWidget subclass
|
---|
65 | * used as menu-bar editor widget. */
|
---|
66 | class SHARED_LIBRARY_STUFF UIMenuBarEditorWidget : public QIWithRetranslateUI2<QWidget>
|
---|
67 | {
|
---|
68 | Q_OBJECT;
|
---|
69 |
|
---|
70 | signals:
|
---|
71 |
|
---|
72 | /** Notifies about Cancel button click. */
|
---|
73 | void sigCancelClicked();
|
---|
74 |
|
---|
75 | public:
|
---|
76 |
|
---|
77 | /** Constructs menu-bar editor widget passing @a pParent to the base-class.
|
---|
78 | * @param fStartedFromVMSettings Brings whether 'this' is a part of VM settings.
|
---|
79 | * @param uMachineID Brings the machine ID to be used by the editor.
|
---|
80 | * @param pActionPool Brings the action-pool to be used by the editor. */
|
---|
81 | UIMenuBarEditorWidget(QWidget *pParent,
|
---|
82 | bool fStartedFromVMSettings = true,
|
---|
83 | const QUuid &uMachineID = QUuid(),
|
---|
84 | UIActionPool *pActionPool = 0);
|
---|
85 |
|
---|
86 | /** Returns the machine ID instance. */
|
---|
87 | const QUuid &machineID() const { return m_uMachineID; }
|
---|
88 | /** Defines the @a uMachineID instance. */
|
---|
89 | void setMachineID(const QUuid &uMachineID);
|
---|
90 |
|
---|
91 | /** Returns the action-pool reference. */
|
---|
92 | const UIActionPool *actionPool() const { return m_pActionPool; }
|
---|
93 | /** Defines the @a pActionPool reference. */
|
---|
94 | void setActionPool(UIActionPool *pActionPool);
|
---|
95 |
|
---|
96 | #ifndef VBOX_WS_MAC
|
---|
97 | /** Returns whether the menu-bar enabled. */
|
---|
98 | bool isMenuBarEnabled() const;
|
---|
99 | /** Defines whether the menu-bar @a fEnabled. */
|
---|
100 | void setMenuBarEnabled(bool fEnabled);
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | /** Returns the cached restrictions of menu-bar. */
|
---|
104 | UIExtraDataMetaDefs::MenuType restrictionsOfMenuBar() const { return m_restrictionsOfMenuBar; }
|
---|
105 | /** Returns the cached restrictions of menu 'Application'. */
|
---|
106 | UIExtraDataMetaDefs::MenuApplicationActionType restrictionsOfMenuApplication() const { return m_restrictionsOfMenuApplication; }
|
---|
107 | /** Returns the cached restrictions of menu 'Machine'. */
|
---|
108 | UIExtraDataMetaDefs::RuntimeMenuMachineActionType restrictionsOfMenuMachine() const { return m_restrictionsOfMenuMachine; }
|
---|
109 | /** Returns the cached restrictions of menu 'View'. */
|
---|
110 | UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionsOfMenuView() const { return m_restrictionsOfMenuView; }
|
---|
111 | /** Returns the cached restrictions of menu 'Input'. */
|
---|
112 | UIExtraDataMetaDefs::RuntimeMenuInputActionType restrictionsOfMenuInput() const { return m_restrictionsOfMenuInput; }
|
---|
113 | /** Returns the cached restrictions of menu 'Devices'. */
|
---|
114 | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionsOfMenuDevices() const { return m_restrictionsOfMenuDevices; }
|
---|
115 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
116 | /** Returns the cached restrictions of menu 'Debug'. */
|
---|
117 | UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType restrictionsOfMenuDebug() const { return m_restrictionsOfMenuDebug; }
|
---|
118 | #endif
|
---|
119 | #ifdef VBOX_WS_MAC
|
---|
120 | /** Returns the cached restrictions of menu 'Window'. */
|
---|
121 | UIExtraDataMetaDefs::MenuWindowActionType restrictionsOfMenuWindow() const { return m_restrictionsOfMenuWindow; }
|
---|
122 | #endif
|
---|
123 | /** Returns the cached restrictions of menu 'Help'. */
|
---|
124 | UIExtraDataMetaDefs::MenuHelpActionType restrictionsOfMenuHelp() const { return m_restrictionsOfMenuHelp; }
|
---|
125 |
|
---|
126 | /** Defines the cached @a restrictions of menu-bar. */
|
---|
127 | void setRestrictionsOfMenuBar(UIExtraDataMetaDefs::MenuType restrictions);
|
---|
128 | /** Defines the cached @a restrictions of menu 'Application'. */
|
---|
129 | void setRestrictionsOfMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType restrictions);
|
---|
130 | /** Defines the cached @a restrictions of menu 'Machine'. */
|
---|
131 | void setRestrictionsOfMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType restrictions);
|
---|
132 | /** Defines the cached @a restrictions of menu 'View'. */
|
---|
133 | void setRestrictionsOfMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictions);
|
---|
134 | /** Defines the cached @a restrictions of menu 'Input'. */
|
---|
135 | void setRestrictionsOfMenuInput(UIExtraDataMetaDefs::RuntimeMenuInputActionType restrictions);
|
---|
136 | /** Defines the cached @a restrictions of menu 'Devices'. */
|
---|
137 | void setRestrictionsOfMenuDevices(UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictions);
|
---|
138 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
139 | /** Defines the cached @a restrictions of menu 'Debug'. */
|
---|
140 | void setRestrictionsOfMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType restrictions);
|
---|
141 | #endif
|
---|
142 | #ifdef VBOX_WS_MAC
|
---|
143 | /** Defines the cached @a restrictions of menu 'Window'. */
|
---|
144 | void setRestrictionsOfMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType restrictions);
|
---|
145 | #endif
|
---|
146 | /** Defines the cached @a restrictions of menu 'Help'. */
|
---|
147 | void setRestrictionsOfMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType restrictions);
|
---|
148 |
|
---|
149 | protected:
|
---|
150 |
|
---|
151 | /** Handles translation event. */
|
---|
152 | virtual void retranslateUi() /* override */;
|
---|
153 |
|
---|
154 | /** Handles paint @a pEvent. */
|
---|
155 | virtual void paintEvent(QPaintEvent *pEvent) /* override */;
|
---|
156 |
|
---|
157 | private slots:
|
---|
158 |
|
---|
159 | /** Handles configuration change. */
|
---|
160 | void sltHandleConfigurationChange(const QUuid &uMachineID);
|
---|
161 |
|
---|
162 | /** Handles menu-bar menu click. */
|
---|
163 | void sltHandleMenuBarMenuClick();
|
---|
164 |
|
---|
165 | private:
|
---|
166 |
|
---|
167 | /** Prepare routine. */
|
---|
168 | void prepare();
|
---|
169 |
|
---|
170 | #ifdef VBOX_WS_MAC
|
---|
171 | /** Prepare named menu routine. */
|
---|
172 | QMenu *prepareNamedMenu(const QString &strName);
|
---|
173 | #endif
|
---|
174 | /** Prepare copied menu routine. */
|
---|
175 | QMenu *prepareCopiedMenu(const UIAction *pAction);
|
---|
176 | #if 0
|
---|
177 | /** Prepare copied sub-menu routine. */
|
---|
178 | QMenu *prepareCopiedSubMenu(QMenu *pMenu, const UIAction *pAction);
|
---|
179 | #endif
|
---|
180 | /** Prepare named action routine. */
|
---|
181 | QAction *prepareNamedAction(QMenu *pMenu, const QString &strName,
|
---|
182 | int iExtraDataID, const QString &strExtraDataID);
|
---|
183 | /** Prepare copied action routine. */
|
---|
184 | QAction *prepareCopiedAction(QMenu *pMenu, const UIAction *pAction);
|
---|
185 |
|
---|
186 | /** Prepare menus routine. */
|
---|
187 | void prepareMenus();
|
---|
188 | /** Prepare 'Application' menu routine. */
|
---|
189 | void prepareMenuApplication();
|
---|
190 | /** Prepare 'Machine' menu routine. */
|
---|
191 | void prepareMenuMachine();
|
---|
192 | /** Prepare 'View' menu routine. */
|
---|
193 | void prepareMenuView();
|
---|
194 | /** Prepare 'Input' menu routine. */
|
---|
195 | void prepareMenuInput();
|
---|
196 | /** Prepare 'Devices' menu routine. */
|
---|
197 | void prepareMenuDevices();
|
---|
198 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
199 | /** Prepare 'Debug' menu routine. */
|
---|
200 | void prepareMenuDebug();
|
---|
201 | #endif
|
---|
202 | #ifdef VBOX_WS_MAC
|
---|
203 | /** Prepare 'Window' menu routine. */
|
---|
204 | void prepareMenuWindow();
|
---|
205 | #endif
|
---|
206 | /** Prepare 'Help' menu routine. */
|
---|
207 | void prepareMenuHelp();
|
---|
208 |
|
---|
209 | /** @name General
|
---|
210 | * @{ */
|
---|
211 | /** Holds whether 'this' is prepared. */
|
---|
212 | bool m_fPrepared;
|
---|
213 | /** Holds whether 'this' is a part of VM settings. */
|
---|
214 | bool m_fStartedFromVMSettings;
|
---|
215 | /** Holds the machine ID instance. */
|
---|
216 | QUuid m_uMachineID;
|
---|
217 | /** Holds the action-pool reference. */
|
---|
218 | const UIActionPool *m_pActionPool;
|
---|
219 | /** @} */
|
---|
220 |
|
---|
221 | /** @name Contents
|
---|
222 | * @{ */
|
---|
223 | /** Holds the main-layout instance. */
|
---|
224 | QHBoxLayout *m_pMainLayout;
|
---|
225 | /** Holds the tool-bar instance. */
|
---|
226 | UIToolBar *m_pToolBar;
|
---|
227 | /** Holds the close-button instance. */
|
---|
228 | QIToolButton *m_pButtonClose;
|
---|
229 | #ifndef VBOX_WS_MAC
|
---|
230 | /** Holds the enable-checkbox instance. */
|
---|
231 | QCheckBox *m_pCheckBoxEnable;
|
---|
232 | #endif
|
---|
233 | /** Holds tool-bar action references. */
|
---|
234 | QMap<QString, QAction*> m_actions;
|
---|
235 | /** @} */
|
---|
236 |
|
---|
237 | /** @name Contents: Restrictions
|
---|
238 | * @{ */
|
---|
239 | /** Holds the cached restrictions of menu-bar. */
|
---|
240 | UIExtraDataMetaDefs::MenuType m_restrictionsOfMenuBar;
|
---|
241 | /** Holds the cached restrictions of menu 'Application'. */
|
---|
242 | UIExtraDataMetaDefs::MenuApplicationActionType m_restrictionsOfMenuApplication;
|
---|
243 | /** Holds the cached restrictions of menu 'Machine'. */
|
---|
244 | UIExtraDataMetaDefs::RuntimeMenuMachineActionType m_restrictionsOfMenuMachine;
|
---|
245 | /** Holds the cached restrictions of menu 'View'. */
|
---|
246 | UIExtraDataMetaDefs::RuntimeMenuViewActionType m_restrictionsOfMenuView;
|
---|
247 | /** Holds the cached restrictions of menu 'Input'. */
|
---|
248 | UIExtraDataMetaDefs::RuntimeMenuInputActionType m_restrictionsOfMenuInput;
|
---|
249 | /** Holds the cached restrictions of menu 'Devices'. */
|
---|
250 | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType m_restrictionsOfMenuDevices;
|
---|
251 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
252 | /** Holds the cached restrictions of menu 'Debug'. */
|
---|
253 | UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType m_restrictionsOfMenuDebug;
|
---|
254 | #endif
|
---|
255 | #ifdef VBOX_WS_MAC
|
---|
256 | /** Holds the cached restrictions of menu 'Window'. */
|
---|
257 | UIExtraDataMetaDefs::MenuWindowActionType m_restrictionsOfMenuWindow;
|
---|
258 | #endif
|
---|
259 | /** Holds the cached restrictions of menu 'Help'. */
|
---|
260 | UIExtraDataMetaDefs::MenuHelpActionType m_restrictionsOfMenuHelp;
|
---|
261 | /** @} */
|
---|
262 | };
|
---|
263 |
|
---|
264 |
|
---|
265 | #endif /* !___UIMenuBarEditorWindow_h___ */
|
---|