1 | /* $Id: UIActionPoolRuntime.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIActionPoolRuntime class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_globals_UIActionPoolRuntime_h
|
---|
29 | #define FEQT_INCLUDED_SRC_globals_UIActionPoolRuntime_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QMap>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "UIActionPool.h"
|
---|
39 | #include "UIExtraDataDefs.h"
|
---|
40 | #include "UILibraryDefs.h"
|
---|
41 |
|
---|
42 |
|
---|
43 | /** VirtualBox Runtime action-pool index enum.
|
---|
44 | * Naming convention is following:
|
---|
45 | * 1. Every menu index prepended with 'M',
|
---|
46 | * 2. Every simple-action index prepended with 'S',
|
---|
47 | * 3. Every toggle-action index presended with 'T',
|
---|
48 | * 5. Every sub-index contains full parent-index name. */
|
---|
49 | enum UIActionIndexRT
|
---|
50 | {
|
---|
51 | /* 'Machine' menu actions: */
|
---|
52 | UIActionIndexRT_M_Machine = UIActionIndex_Max + 1,
|
---|
53 | UIActionIndexRT_M_Machine_S_Settings,
|
---|
54 | UIActionIndexRT_M_Machine_S_TakeSnapshot,
|
---|
55 | UIActionIndexRT_M_Machine_S_ShowInformation,
|
---|
56 | UIActionIndexRT_M_Machine_S_ShowFileManager,
|
---|
57 | UIActionIndexRT_M_Machine_T_Pause,
|
---|
58 | UIActionIndexRT_M_Machine_S_Reset,
|
---|
59 | UIActionIndexRT_M_Machine_S_Detach,
|
---|
60 | UIActionIndexRT_M_Machine_S_SaveState,
|
---|
61 | UIActionIndexRT_M_Machine_S_Shutdown,
|
---|
62 | UIActionIndexRT_M_Machine_S_PowerOff,
|
---|
63 | UIActionIndexRT_M_Machine_S_ShowLogDialog,
|
---|
64 |
|
---|
65 | /* 'View' menu actions: */
|
---|
66 | UIActionIndexRT_M_View,
|
---|
67 | UIActionIndexRT_M_ViewPopup,
|
---|
68 | UIActionIndexRT_M_View_T_Fullscreen,
|
---|
69 | UIActionIndexRT_M_View_T_Seamless,
|
---|
70 | UIActionIndexRT_M_View_T_Scale,
|
---|
71 | #ifndef VBOX_WS_MAC
|
---|
72 | UIActionIndexRT_M_View_S_MinimizeWindow,
|
---|
73 | #endif
|
---|
74 | UIActionIndexRT_M_View_S_AdjustWindow,
|
---|
75 | UIActionIndexRT_M_View_T_GuestAutoresize,
|
---|
76 | UIActionIndexRT_M_View_S_TakeScreenshot,
|
---|
77 | UIActionIndexRT_M_View_M_Recording,
|
---|
78 | UIActionIndexRT_M_View_M_Recording_S_Settings,
|
---|
79 | UIActionIndexRT_M_View_M_Recording_T_Start,
|
---|
80 | UIActionIndexRT_M_View_T_VRDEServer,
|
---|
81 | UIActionIndexRT_M_View_M_MenuBar,
|
---|
82 | UIActionIndexRT_M_View_M_MenuBar_S_Settings,
|
---|
83 | #ifndef VBOX_WS_MAC
|
---|
84 | UIActionIndexRT_M_View_M_MenuBar_T_Visibility,
|
---|
85 | #endif
|
---|
86 | UIActionIndexRT_M_View_M_StatusBar,
|
---|
87 | UIActionIndexRT_M_View_M_StatusBar_S_Settings,
|
---|
88 | UIActionIndexRT_M_View_M_StatusBar_T_Visibility,
|
---|
89 |
|
---|
90 | /* 'Input' menu actions: */
|
---|
91 | UIActionIndexRT_M_Input,
|
---|
92 | UIActionIndexRT_M_Input_M_Keyboard,
|
---|
93 | UIActionIndexRT_M_Input_M_Keyboard_S_Settings,
|
---|
94 | UIActionIndexRT_M_Input_M_Keyboard_S_SoftKeyboard,
|
---|
95 | UIActionIndexRT_M_Input_M_Keyboard_S_TypeCAD,
|
---|
96 | #ifdef VBOX_WS_NIX
|
---|
97 | UIActionIndexRT_M_Input_M_Keyboard_S_TypeCABS,
|
---|
98 | #endif
|
---|
99 | UIActionIndexRT_M_Input_M_Keyboard_S_TypeCtrlBreak,
|
---|
100 | UIActionIndexRT_M_Input_M_Keyboard_S_TypeInsert,
|
---|
101 | UIActionIndexRT_M_Input_M_Keyboard_S_TypePrintScreen,
|
---|
102 | UIActionIndexRT_M_Input_M_Keyboard_S_TypeAltPrintScreen,
|
---|
103 | UIActionIndexRT_M_Input_M_Keyboard_T_TypeHostKeyCombo,
|
---|
104 | UIActionIndexRT_M_Input_M_Mouse,
|
---|
105 | UIActionIndexRT_M_Input_M_Mouse_T_Integration,
|
---|
106 |
|
---|
107 | /* 'Devices' menu actions: */
|
---|
108 | UIActionIndexRT_M_Devices,
|
---|
109 | UIActionIndexRT_M_Devices_M_HardDrives,
|
---|
110 | UIActionIndexRT_M_Devices_M_HardDrives_S_Settings,
|
---|
111 | UIActionIndexRT_M_Devices_M_OpticalDevices,
|
---|
112 | UIActionIndexRT_M_Devices_M_FloppyDevices,
|
---|
113 | UIActionIndexRT_M_Devices_M_Audio,
|
---|
114 | UIActionIndexRT_M_Devices_M_Audio_T_Output,
|
---|
115 | UIActionIndexRT_M_Devices_M_Audio_T_Input,
|
---|
116 | UIActionIndexRT_M_Devices_M_Network,
|
---|
117 | UIActionIndexRT_M_Devices_M_Network_S_Settings,
|
---|
118 | UIActionIndexRT_M_Devices_M_USBDevices,
|
---|
119 | UIActionIndexRT_M_Devices_M_USBDevices_S_Settings,
|
---|
120 | UIActionIndexRT_M_Devices_M_WebCams,
|
---|
121 | UIActionIndexRT_M_Devices_M_SharedClipboard,
|
---|
122 | UIActionIndexRT_M_Devices_M_DragAndDrop,
|
---|
123 | UIActionIndexRT_M_Devices_M_SharedFolders,
|
---|
124 | UIActionIndexRT_M_Devices_M_SharedFolders_S_Settings,
|
---|
125 | UIActionIndexRT_M_Devices_S_InsertGuestAdditionsDisk,
|
---|
126 | UIActionIndexRT_M_Devices_S_UpgradeGuestAdditions,
|
---|
127 |
|
---|
128 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
129 | /* 'Debugger' menu actions: */
|
---|
130 | UIActionIndexRT_M_Debug,
|
---|
131 | UIActionIndexRT_M_Debug_S_ShowStatistics,
|
---|
132 | UIActionIndexRT_M_Debug_S_ShowCommandLine,
|
---|
133 | UIActionIndexRT_M_Debug_T_Logging,
|
---|
134 | UIActionIndexRT_M_Debug_S_GuestControlConsole,
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | #ifdef VBOX_WS_MAC
|
---|
138 | /* 'Dock' menu actions: */
|
---|
139 | UIActionIndexRT_M_Dock,
|
---|
140 | UIActionIndexRT_M_Dock_M_DockSettings,
|
---|
141 | UIActionIndexRT_M_Dock_M_DockSettings_T_PreviewMonitor,
|
---|
142 | UIActionIndexRT_M_Dock_M_DockSettings_T_DisableMonitor,
|
---|
143 | UIActionIndexRT_M_Dock_M_DockSettings_T_DisableOverlay,
|
---|
144 | #endif
|
---|
145 |
|
---|
146 | /* Maximum index: */
|
---|
147 | UIActionIndexRT_Max
|
---|
148 | };
|
---|
149 |
|
---|
150 |
|
---|
151 | /** UIActionPool extension
|
---|
152 | * representing action-pool singleton for Runtime UI. */
|
---|
153 | class SHARED_LIBRARY_STUFF UIActionPoolRuntime : public UIActionPool
|
---|
154 | {
|
---|
155 | Q_OBJECT;
|
---|
156 |
|
---|
157 | signals:
|
---|
158 |
|
---|
159 | /** Notifies about 'View' : 'Virtual Screen #' menu : 'Toggle' action trigger. */
|
---|
160 | void sigNotifyAboutTriggeringViewScreenToggle(int iGuestScreenIndex, bool fEnabled);
|
---|
161 | /** Notifies about 'View' : 'Virtual Screen #' menu : 'Resize' action trigger. */
|
---|
162 | void sigNotifyAboutTriggeringViewScreenResize(int iGuestScreenIndex, const QSize &size);
|
---|
163 | /** Notifies about 'View' : 'Virtual Screen #' menu : 'Remap' action trigger. */
|
---|
164 | void sigNotifyAboutTriggeringViewScreenRemap(int iGuestScreenIndex, int iHostScreenIndex);
|
---|
165 |
|
---|
166 | public:
|
---|
167 |
|
---|
168 | /** Defines host-screen @a cCount. */
|
---|
169 | void setHostScreenCount(int cCount);
|
---|
170 | /** Defines guest-screen @a cCount. */
|
---|
171 | void setGuestScreenCount(int cCount);
|
---|
172 |
|
---|
173 | /** Defines @a iGuestScreen @a size. */
|
---|
174 | void setGuestScreenSize(int iGuestScreen, const QSize &size);
|
---|
175 | /** Defines whether @a iGuestScreen is @a fVisible. */
|
---|
176 | void setGuestScreenVisible(int iGuestScreen, bool fVisible);
|
---|
177 |
|
---|
178 | /** Defines whether guest supports graphics. */
|
---|
179 | void setGuestSupportsGraphics(bool fSupports);
|
---|
180 |
|
---|
181 | /** Defines host-to-guest mapping @a scheme. */
|
---|
182 | void setHostScreenForGuestScreenMap(const QMap<int, int> &scheme);
|
---|
183 | /** Returns host-to-guest mapping scheme. */
|
---|
184 | QMap<int, int> hostScreenForGuestScreenMap() const;
|
---|
185 |
|
---|
186 | /** Returns whether the action with passed @a type is allowed in the 'Machine' menu. */
|
---|
187 | bool isAllowedInMenuMachine(UIExtraDataMetaDefs::RuntimeMenuMachineActionType type) const;
|
---|
188 | /** Defines 'Machine' menu @a restriction for passed @a level. */
|
---|
189 | void setRestrictionForMenuMachine(UIActionRestrictionLevel level,
|
---|
190 | UIExtraDataMetaDefs::RuntimeMenuMachineActionType restriction);
|
---|
191 |
|
---|
192 | /** Returns whether the action with passed @a type is allowed in the 'View' menu. */
|
---|
193 | bool isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType type) const;
|
---|
194 | /** Defines 'View' menu @a restriction for passed @a level. */
|
---|
195 | void setRestrictionForMenuView(UIActionRestrictionLevel level,
|
---|
196 | UIExtraDataMetaDefs::RuntimeMenuViewActionType restriction);
|
---|
197 |
|
---|
198 | /** Returns whether the action with passed @a type is allowed in the 'Input' menu. */
|
---|
199 | bool isAllowedInMenuInput(UIExtraDataMetaDefs::RuntimeMenuInputActionType type) const;
|
---|
200 | /** Defines 'Input' menu @a restriction for passed @a level. */
|
---|
201 | void setRestrictionForMenuInput(UIActionRestrictionLevel level,
|
---|
202 | UIExtraDataMetaDefs::RuntimeMenuInputActionType restriction);
|
---|
203 |
|
---|
204 | /** Returns whether the action with passed @a type is allowed in the 'Devices' menu. */
|
---|
205 | bool isAllowedInMenuDevices(UIExtraDataMetaDefs::RuntimeMenuDevicesActionType type) const;
|
---|
206 | /** Defines 'Devices' menu @a restriction for passed @a level. */
|
---|
207 | void setRestrictionForMenuDevices(UIActionRestrictionLevel level,
|
---|
208 | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restriction);
|
---|
209 |
|
---|
210 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
211 | /** Returns whether the action with passed @a type is allowed in the 'Debug' menu. */
|
---|
212 | bool isAllowedInMenuDebug(UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType type) const;
|
---|
213 | /** Defines 'Debug' menu @a restriction for passed @a level. */
|
---|
214 | void setRestrictionForMenuDebugger(UIActionRestrictionLevel level,
|
---|
215 | UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType restriction);
|
---|
216 | #endif
|
---|
217 |
|
---|
218 | protected:
|
---|
219 |
|
---|
220 | /** Constructs action-pool.
|
---|
221 | * @param fTemporary Brings whether this action-pool is temporary,
|
---|
222 | * used to (re-)initialize shortcuts-pool. */
|
---|
223 | UIActionPoolRuntime(bool fTemporary = false);
|
---|
224 |
|
---|
225 | /** Prepares pool. */
|
---|
226 | virtual void preparePool() RT_OVERRIDE;
|
---|
227 | /** Prepares connections. */
|
---|
228 | virtual void prepareConnections() RT_OVERRIDE;
|
---|
229 |
|
---|
230 | /** Updates configuration. */
|
---|
231 | virtual void updateConfiguration() RT_OVERRIDE;
|
---|
232 |
|
---|
233 | /** Updates menu. */
|
---|
234 | virtual void updateMenu(int iIndex) RT_OVERRIDE;
|
---|
235 | /** Updates menus. */
|
---|
236 | virtual void updateMenus() RT_OVERRIDE;
|
---|
237 |
|
---|
238 | /** Returns extra-data ID to save keyboard shortcuts under. */
|
---|
239 | virtual QString shortcutsExtraDataID() const RT_OVERRIDE;
|
---|
240 | /** Updates shortcuts. */
|
---|
241 | virtual void updateShortcuts() RT_OVERRIDE;
|
---|
242 |
|
---|
243 | private slots:
|
---|
244 |
|
---|
245 | /** Handles configuration-change. */
|
---|
246 | void sltHandleConfigurationChange(const QUuid &uMachineID);
|
---|
247 |
|
---|
248 | /** Prepares 'View' : 'Virtual Screen #' menu (Normal, Scale). */
|
---|
249 | void sltPrepareMenuViewScreen();
|
---|
250 |
|
---|
251 | /** Handles 'View' : 'Virtual Screen #' menu : 'Toggle' action trigger. */
|
---|
252 | void sltHandleActionTriggerViewScreenToggle();
|
---|
253 | /** Handles 'View' : 'Virtual Screen #' menu : 'Resize' @a pAction trigger. */
|
---|
254 | void sltHandleActionTriggerViewScreenResize(QAction *pAction);
|
---|
255 | /** Handles 'View' : 'Virtual Screen #' menu : 'Remap' @a pAction trigger. */
|
---|
256 | void sltHandleActionTriggerViewScreenRemap(QAction *pAction);
|
---|
257 | /** Handles 'View' : 'Virtual Screen #' menu : 'Rescale' @a pAction trigger. */
|
---|
258 | void sltHandleActionTriggerViewScreenRescale(QAction *pAction);
|
---|
259 |
|
---|
260 | private:
|
---|
261 |
|
---|
262 | /** Updates 'Machine' menu. */
|
---|
263 | void updateMenuMachine();
|
---|
264 | /** Updates 'View' menu. */
|
---|
265 | void updateMenuView();
|
---|
266 | /** Updates 'View' : 'Popup' menu. */
|
---|
267 | void updateMenuViewPopup();
|
---|
268 | /** Updates 'View' : 'Recording' menu. */
|
---|
269 | void updateMenuViewRecording();
|
---|
270 | /** Updates 'View' : 'Menu Bar' menu. */
|
---|
271 | void updateMenuViewMenuBar();
|
---|
272 | /** Updates 'View' : 'Status Bar' menu. */
|
---|
273 | void updateMenuViewStatusBar();
|
---|
274 | /** Updates 'View' : 'Virtual Screen #' @a pMenu with "Resize to <Width> x <Height>" actions. */
|
---|
275 | void updateMenuViewResize(QMenu *pMenu);
|
---|
276 | /** Updates 'View' : 'Virtual Screen #' @a pMenu with "Use Host Screen <Number>" actions. */
|
---|
277 | void updateMenuViewRemap(QMenu *pMenu);
|
---|
278 | /** Updates 'View' : 'Virtual Screen #' @a pMenu with "Scale to <Scale>" actions. */
|
---|
279 | void updateMenuViewRescale(QMenu *pMenu);
|
---|
280 | /** Updates 'Input' menu. */
|
---|
281 | void updateMenuInput();
|
---|
282 | /** Updates 'Input' : 'Keyboard' menu. */
|
---|
283 | void updateMenuInputKeyboard();
|
---|
284 | /** Updates 'Input' : 'Mouse' menu. */
|
---|
285 | void updateMenuInputMouse();
|
---|
286 | /** Updates 'Devices' menu. */
|
---|
287 | void updateMenuDevices();
|
---|
288 | /** Updates 'Devices' : 'Hard Drives' menu. */
|
---|
289 | void updateMenuDevicesHardDrives();
|
---|
290 | /** Updates 'Devices' : 'Audio' menu. */
|
---|
291 | void updateMenuDevicesAudio();
|
---|
292 | /** Updates 'Devices' : 'Network' menu. */
|
---|
293 | void updateMenuDevicesNetwork();
|
---|
294 | /** Updates 'Devices' : 'USB' menu. */
|
---|
295 | void updateMenuDevicesUSBDevices();
|
---|
296 | /** Updates 'Devices' : 'Shared Folders' menu. */
|
---|
297 | void updateMenuDevicesSharedFolders();
|
---|
298 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
299 | /** Updates 'Debug' menu. */
|
---|
300 | void updateMenuDebug();
|
---|
301 | #endif
|
---|
302 |
|
---|
303 | /** Holds the host-screen count. */
|
---|
304 | int m_cHostScreens;
|
---|
305 | /** Holds the guest-screen count. */
|
---|
306 | int m_cGuestScreens;
|
---|
307 |
|
---|
308 | /** Holds the map of guest-screen sizes. */
|
---|
309 | QMap<int, QSize> m_mapGuestScreenSize;
|
---|
310 | /** Holds the map of guest-screen visibility states. */
|
---|
311 | QMap<int, bool> m_mapGuestScreenIsVisible;
|
---|
312 |
|
---|
313 | /** Holds whether guest supports graphics. */
|
---|
314 | bool m_fGuestSupportsGraphics;
|
---|
315 |
|
---|
316 | /** Holds the host-to-guest mapping scheme. */
|
---|
317 | QMap<int, int> m_mapHostScreenForGuestScreen;
|
---|
318 |
|
---|
319 | /** Holds restricted action types of the Machine menu. */
|
---|
320 | QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::RuntimeMenuMachineActionType> m_restrictedActionsMenuMachine;
|
---|
321 | /** Holds restricted action types of the View menu. */
|
---|
322 | QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::RuntimeMenuViewActionType> m_restrictedActionsMenuView;
|
---|
323 | /** Holds restricted action types of the Input menu. */
|
---|
324 | QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::RuntimeMenuInputActionType> m_restrictedActionsMenuInput;
|
---|
325 | /** Holds restricted action types of the Devices menu. */
|
---|
326 | QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::RuntimeMenuDevicesActionType> m_restrictedActionsMenuDevices;
|
---|
327 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
328 | /** Holds restricted action types of the Debugger menu. */
|
---|
329 | QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType> m_restrictedActionsMenuDebug;
|
---|
330 | #endif
|
---|
331 |
|
---|
332 | /** Enables factory in base-class. */
|
---|
333 | friend class UIActionPool;
|
---|
334 | };
|
---|
335 |
|
---|
336 |
|
---|
337 | #endif /* !FEQT_INCLUDED_SRC_globals_UIActionPoolRuntime_h */
|
---|