VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

Last change on this file was 104445, checked in by vboxsync, 4 weeks ago

FE/Qt. bugref:9510. Adding a new pane container to activity monitor widget to host setting controls.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.7 KB
Line 
1/* $Id: UIActionPool.h 104445 2024-04-26 14:09:35Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIActionPool class declaration.
4 */
5
6/*
7 * Copyright (C) 2010-2023 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_UIActionPool_h
29#define FEQT_INCLUDED_SRC_globals_UIActionPool_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QAction>
36#include <QMenu>
37#include <QVector>
38
39/* GUI includes: */
40#include "UIDefs.h"
41#include "UIExtraDataDefs.h"
42#include "UILibraryDefs.h"
43
44/* Forward declarations: */
45class QKeySequence;
46class QString;
47class UIActionPool;
48class UIActionPoolRuntime;
49class UIActionPoolManager;
50
51
52/** Action types. */
53enum UIActionType
54{
55 UIActionType_Menu,
56 UIActionType_Simple,
57 UIActionType_Toggle
58};
59
60/** Action indexes. */
61enum UIActionIndex
62{
63 /* 'Application' menu actions: */
64 UIActionIndex_M_Application,
65#ifdef VBOX_WS_MAC
66 UIActionIndex_M_Application_S_About,
67#endif
68 UIActionIndex_M_Application_S_Preferences,
69#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
70 UIActionIndex_M_Application_S_CheckForUpdates,
71#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
72 UIActionIndex_M_Application_S_ResetWarnings,
73 UIActionIndex_M_Application_S_Close,
74
75#ifdef VBOX_WS_MAC
76 /* 'Window' menu actions: */
77 UIActionIndex_M_Window,
78 UIActionIndex_M_Window_S_Minimize,
79#endif
80
81 /* 'Help' menu actions: */
82 UIActionIndex_Menu_Help,
83 UIActionIndex_Simple_Contents,
84 UIActionIndex_Simple_OnlineDocumentation,
85 UIActionIndex_Simple_WebSite,
86 UIActionIndex_Simple_BugTracker,
87 UIActionIndex_Simple_Forums,
88 UIActionIndex_Simple_Oracle,
89#ifndef VBOX_WS_MAC
90 UIActionIndex_Simple_About,
91#endif
92
93 /* 'Log' menu actions: */
94 UIActionIndex_M_LogWindow,
95 UIActionIndex_M_Log,
96 UIActionIndex_M_Log_T_Find,
97 UIActionIndex_M_Log_T_Filter,
98 UIActionIndex_M_Log_T_Bookmark,
99 UIActionIndex_M_Log_T_Preferences,
100 UIActionIndex_M_Log_S_Refresh,
101 UIActionIndex_M_Log_S_Reload,
102 UIActionIndex_M_Log_S_Save,
103
104 /* 'Performance' menu actions: */
105 UIActionIndex_M_Activity,
106 UIActionIndex_M_Activity_S_Export,
107 UIActionIndex_M_Activity_S_ToVMActivityOverview,
108 UIActionIndex_M_Activity_T_Preferences,
109
110 /* File Manager actions: */
111 UIActionIndex_M_FileManager,
112 UIActionIndex_M_FileManager_M_HostSubmenu,
113 UIActionIndex_M_FileManager_M_GuestSubmenu,
114 UIActionIndex_M_FileManager_S_CopyToGuest,
115 UIActionIndex_M_FileManager_S_CopyToHost,
116 UIActionIndex_M_FileManager_T_Preferences,
117 UIActionIndex_M_FileManager_T_Log,
118 UIActionIndex_M_FileManager_T_Operations,
119 UIActionIndex_M_FileManager_T_GuestSession,
120 UIActionIndex_M_FileManager_S_Host_GoUp,
121 UIActionIndex_M_FileManager_S_Guest_GoUp,
122 UIActionIndex_M_FileManager_S_Host_GoHome,
123 UIActionIndex_M_FileManager_S_Guest_GoHome,
124 UIActionIndex_M_FileManager_S_Host_GoForward,
125 UIActionIndex_M_FileManager_S_Guest_GoForward,
126 UIActionIndex_M_FileManager_S_Host_GoBackward,
127 UIActionIndex_M_FileManager_S_Guest_GoBackward,
128 UIActionIndex_M_FileManager_S_Host_Refresh,
129 UIActionIndex_M_FileManager_S_Guest_Refresh,
130 UIActionIndex_M_FileManager_S_Host_Delete,
131 UIActionIndex_M_FileManager_S_Guest_Delete,
132 UIActionIndex_M_FileManager_S_Host_Rename,
133 UIActionIndex_M_FileManager_S_Guest_Rename,
134 UIActionIndex_M_FileManager_S_Host_CreateNewDirectory,
135 UIActionIndex_M_FileManager_S_Guest_CreateNewDirectory,
136 UIActionIndex_M_FileManager_S_Host_Copy,
137 UIActionIndex_M_FileManager_S_Guest_Copy,
138 UIActionIndex_M_FileManager_S_Host_Cut,
139 UIActionIndex_M_FileManager_S_Guest_Cut,
140 UIActionIndex_M_FileManager_S_Host_Paste,
141 UIActionIndex_M_FileManager_S_Guest_Paste,
142 UIActionIndex_M_FileManager_S_Host_SelectAll,
143 UIActionIndex_M_FileManager_S_Guest_SelectAll,
144 UIActionIndex_M_FileManager_S_Host_InvertSelection,
145 UIActionIndex_M_FileManager_S_Guest_InvertSelection,
146 UIActionIndex_M_FileManager_S_Host_ShowProperties,
147 UIActionIndex_M_FileManager_S_Guest_ShowProperties,
148
149 /* VISO Creator actions: */
150 UIActionIndex_M_VISOCreator,
151 UIActionIndex_M_VISOCreator_ToggleSettingsDialog,
152 UIActionIndex_M_VISOCreator_Add,
153 UIActionIndex_M_VISOCreator_Remove,
154 UIActionIndex_M_VISOCreator_Restore,
155 UIActionIndex_M_VISOCreator_CreateNewDirectory,
156 UIActionIndex_M_VISOCreator_Rename,
157 UIActionIndex_M_VISOCreator_Reset,
158 UIActionIndex_M_VISOCreator_Open,
159 UIActionIndex_M_VISOCreator_SaveAs,
160 UIActionIndex_M_VISOCreator_ImportISO,
161 UIActionIndex_M_VISOCreator_RemoveISO,
162 UIActionIndex_M_VISOCreator_VisoContent_GoHome,
163 UIActionIndex_M_VISOCreator_VisoContent_GoUp,
164 UIActionIndex_M_VISOCreator_VisoContent_GoForward,
165 UIActionIndex_M_VISOCreator_VisoContent_GoBackward,
166 UIActionIndex_M_VISOCreator_Host_GoHome,
167 UIActionIndex_M_VISOCreator_Host_GoUp,
168 UIActionIndex_M_VISOCreator_Host_GoForward,
169 UIActionIndex_M_VISOCreator_Host_GoBackward,
170
171 /* Medium selector actions : */
172 UIActionIndex_M_MediumSelector,
173 UIActionIndex_M_MediumSelector_AddHD,
174 UIActionIndex_M_MediumSelector_AddFD,
175 UIActionIndex_M_MediumSelector_AddCD,
176 UIActionIndex_M_MediumSelector_CreateHD,
177 UIActionIndex_M_MediumSelector_CreateCD,
178 UIActionIndex_M_MediumSelector_CreateFD,
179 UIActionIndex_M_MediumSelector_Refresh,
180
181 /* Maximum index: */
182 UIActionIndex_Max
183};
184
185/** Action restriction levels. */
186enum UIActionRestrictionLevel
187{
188 UIActionRestrictionLevel_Base,
189 UIActionRestrictionLevel_Session,
190 UIActionRestrictionLevel_Logic
191};
192
193
194/** QMenu extension. */
195class SHARED_LIBRARY_STUFF UIMenu : public QMenu
196{
197 Q_OBJECT;
198
199public:
200
201 /** Constructs menu. */
202 UIMenu();
203
204 /** Defines whether tool-tip should be shown. */
205 void setShowToolTip(bool fShowToolTips) { m_fShowToolTip = fShowToolTips; }
206
207#ifdef VBOX_WS_MAC
208 /** Mac OS X: Returns whether this menu is consumable by the menu-bar. */
209 bool isConsumable() const { return m_fConsumable; }
210 /** Mac OS X: Defines whether this menu is @a fConsumable by the menu-bar. */
211 void setConsumable(bool fConsumable) { m_fConsumable = fConsumable; }
212
213 /** Mac OS X: Returns whether this menu is consumed by the menu-bar. */
214 bool isConsumed() const { return m_fConsumed; }
215 /** Mac OS X: Defines whether this menu is @a fConsumed by the menu-bar. */
216 void setConsumed(bool fConsumed) { m_fConsumed = fConsumed; }
217#endif /* VBOX_WS_MAC */
218
219protected:
220
221 /** Handles any Qt @a pEvent. */
222 virtual bool event(QEvent *pEvent) RT_OVERRIDE RT_FINAL;
223
224private:
225
226 /** Holds whether tool-tip should be shown. */
227 bool m_fShowToolTip;
228
229#ifdef VBOX_WS_MAC
230 /** Mac OS X: Holds whether this menu can be consumed by the menu-bar. */
231 bool m_fConsumable;
232 /** Mac OS X: Holds whether this menu is consumed by the menu-bar. */
233 bool m_fConsumed;
234#endif /* VBOX_WS_MAC */
235};
236
237
238/** Abstract QAction extension. */
239class SHARED_LIBRARY_STUFF UIAction : public QAction
240{
241 Q_OBJECT;
242
243public:
244
245 /** Constructs action passing @a pParent to the base-class.
246 * @param enmType Brings the action type. */
247 UIAction(UIActionPool *pParent, UIActionType enmType, bool fMachineMenuAction = false);
248 /** Destructs action. */
249 virtual ~UIAction() RT_OVERRIDE { delete menu(); QAction::setShortcuts(QList<QKeySequence>() /*unregister*/); }
250
251 /** Returns action-pool this action belongs to. */
252 UIActionPool *actionPool() const { return m_pActionPool; }
253 /** Returns action type. */
254 UIActionType type() const { return m_enmType; }
255
256 /** Returns menu contained by this action. */
257 UIMenu *menu() const;
258
259 /** Returns current action state. */
260 int state() const { return m_iState; }
261 /** Defines current action @a iState. */
262 void setState(int iState);
263
264 /** Defines @a icon for certain @a iState. */
265 void setIcon(int iState, const QIcon &icon);
266 /** Defines @a icon. */
267 void setIcon(const QIcon &icon);
268
269 /** Returns current action name. */
270 QString name() const { return m_strName; }
271 /** Defines current action name. */
272 void setName(const QString &strName);
273
274 /** Returns action shortcut scope. */
275 QString shortcutScope() const { return m_strShortcutScope; }
276 /** Defines action @a strShortcutScope. */
277 void setShortcutScope(const QString &strShortcutScope) { m_strShortcutScope = strShortcutScope; }
278
279 /** Defines current keyboard shortcuts for this action. */
280 void setShortcuts(const QList<QKeySequence> &shortcuts);
281 /** Make action show keyboard shortcut. */
282 void showShortcut();
283 /** Make action hide keyboard shortcut. */
284 void hideShortcut();
285
286 /** Returns action extra-data ID. */
287 virtual int extraDataID() const { return 0; }
288 /** Returns action extra-data key. */
289 virtual QString extraDataKey() const { return QString(); }
290 /** Returns whether action is allowed. */
291 virtual bool isAllowed() const { return true; }
292
293 /** Returns extra-data ID to save keyboard shortcut under. */
294 virtual QString shortcutExtraDataID() const { return QString(); }
295 /** Returns default keyboard shortcut for this action. */
296 virtual QKeySequence defaultShortcut(UIType) const { return QKeySequence(); }
297 /** Returns standard keyboard shortcut for this action. */
298 virtual QKeySequence standardShortcut(UIType) const { return QKeySequence(); }
299
300 /** Retranslates action. */
301 virtual void retranslateUi() = 0;
302
303protected:
304
305 /** Handles state change. */
306 virtual void handleStateChange() {}
307
308 /** Returns current action name in menu. */
309 QString nameInMenu() const;
310
311 /** Updates action icon. */
312 void updateIcon();
313 /** Updates action text. */
314 void updateText();
315
316 /** Simplifies passed @a strText by removing dots and ampersands.
317 * @note Used to simplify action names for tool-tip needs. */
318 static QString simplifyText(QString strText);
319
320 /** Holds the reference to the action-pool this action belongs to. */
321 UIActionPool *m_pActionPool;
322 /** Holds the type of the action-pool this action belongs to. */
323 const UIType m_enmActionPoolType;
324
325 /** Holds the action type. */
326 const UIActionType m_enmType;
327 /** Holds whether this is machine-menu action. */
328 const bool m_fMachineMenuAction;
329
330 /** Holds current action state. */
331 int m_iState;
332 /** Holds action icons. */
333 QVector<QIcon> m_icons;
334
335 /** Holds the action name. */
336 QString m_strName;
337
338 /** Holds the action shortcut scope. */
339 QString m_strShortcutScope;
340 /** Holds the action shortcuts. */
341 QList<QKeySequence> m_shortcuts;
342 /** Holds whether action shortcut hidden. */
343 bool m_fShortcutHidden;
344};
345
346
347/** Abstract UIAction extension for 'Menu' action type. */
348class SHARED_LIBRARY_STUFF UIActionMenu : public UIAction
349{
350 Q_OBJECT;
351
352protected:
353
354 /** Constructs menu action passing @a pParent to the base-class.
355 * @param strIcon Brings the normal-icon name.
356 * @param strIconDisabled Brings the disabled-icon name. */
357 UIActionMenu(UIActionPool *pParent,
358 const QString &strIcon = QString(), const QString &strIconDisabled = QString());
359 /** Constructs menu action passing @a pParent to the base-class.
360 * @param strIconNormal Brings the normal-icon name.
361 * @param strIconSmall Brings the small-icon name.
362 * @param strIconNormalDisabled Brings the normal-disabled-icon name.
363 * @param strIconSmallDisabled Brings the small-disabled-icon name. */
364 UIActionMenu(UIActionPool *pParent,
365 const QString &strIconNormal, const QString &strIconSmall,
366 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled);
367 /** Constructs menu action passing @a pParent to the base-class.
368 * @param icon Brings the icon. */
369 UIActionMenu(UIActionPool *pParent,
370 const QIcon &icon);
371
372 /** Destructs menu action. */
373 virtual ~UIActionMenu() RT_OVERRIDE;
374
375 /** Defines whether tool-tip should be shown. */
376 void setShowToolTip(bool fShowToolTip);
377
378 /** Shows menu. */
379 void showMenu();
380 /** Hides menu. */
381 void hideMenu();
382
383private:
384
385 /** Prepares all. */
386 void prepare();
387
388 /** Holds the menu instance. */
389 UIMenu *m_pMenu;
390};
391
392
393/** Abstract UIAction extension for 'Simple' action type. */
394class SHARED_LIBRARY_STUFF UIActionSimple : public UIAction
395{
396 Q_OBJECT;
397
398protected:
399
400 /** Constructs simple action passing @a pParent to the base-class.
401 * @param fMachineMenuAction Brings whether this action is a part of machine menu. */
402 UIActionSimple(UIActionPool *pParent,
403 bool fMachineMenuAction = false);
404 /** Constructs simple action passing @a pParent to the base-class.
405 * @param strIcon Brings the normal-icon name.
406 * @param strIconDisabled Brings the disabled-icon name.
407 * @param fMachineMenuAction Brings whether this action is a part of machine menu. */
408 UIActionSimple(UIActionPool *pParent,
409 const QString &strIcon, const QString &strIconDisabled,
410 bool fMachineMenuAction = false);
411 /** Constructs simple action passing @a pParent to the base-class.
412 * @param strIconNormal Brings the normal-icon name.
413 * @param strIconSmall Brings the small-icon name.
414 * @param strIconNormalDisabled Brings the normal-disabled-icon name.
415 * @param strIconSmallDisabled Brings the small-disabled-icon name.
416 * @param fMachineMenuAction Brings whether this action is a part of machine menu. */
417 UIActionSimple(UIActionPool *pParent,
418 const QString &strIconNormal, const QString &strIconSmall,
419 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled,
420 bool fMachineMenuAction = false);
421 /** Constructs simple action passing @a pParent to the base-class.
422 * @param icon Brings the icon.
423 * @param fMachineMenuAction Brings whether this action is a part of machine menu. */
424 UIActionSimple(UIActionPool *pParent,
425 const QIcon &icon,
426 bool fMachineMenuAction = false);
427};
428
429
430/** Abstract UIAction extension for 'Toggle' action type. */
431class SHARED_LIBRARY_STUFF UIActionToggle : public UIAction
432{
433 Q_OBJECT;
434
435protected:
436
437 /** Constructs toggle action passing @a pParent to the base-class.
438 * @param fMachineMenuAction Brings whether this action is a part of machine menu. */
439 UIActionToggle(UIActionPool *pParent,
440 bool fMachineMenuAction = false);
441 /** Constructs toggle action passing @a pParent to the base-class.
442 * @param strIcon Brings the normal-icon name.
443 * @param strIconDisabled Brings the disabled-icon name.
444 * @param fMachineMenuAction Brings whether this action is a part of machine menu. */
445 UIActionToggle(UIActionPool *pParent,
446 const QString &strIcon, const QString &strIconDisabled,
447 bool fMachineMenuAction = false);
448 /** Constructs toggle action passing @a pParent to the base-class.
449 * @param strIconOn Brings the on-icon name.
450 * @param strIconOff Brings the off-icon name.
451 * @param strIconOnDisabled Brings the on-disabled-icon name.
452 * @param strIconOffDisabled Brings the off-disabled-icon name.
453 * @param fMachineMenuAction Brings whether this action is a part of machine menu. */
454 UIActionToggle(UIActionPool *pParent,
455 const QString &strIconOn, const QString &strIconOff,
456 const QString &strIconOnDisabled, const QString &strIconOffDisabled,
457 bool fMachineMenuAction = false);
458 /** Constructs toggle action passing @a pParent to the base-class.
459 * @param icon Brings the icon.
460 * @param fMachineMenuAction Brings whether this action is a part of machine menu. */
461 UIActionToggle(UIActionPool *pParent,
462 const QIcon &icon,
463 bool fMachineMenuAction = false);
464
465private:
466
467 /** Prepares all. */
468 void prepare();
469};
470
471
472/** Abstract QObject extension
473 * representing action-pool interface and factory. */
474class SHARED_LIBRARY_STUFF UIActionPool : public QObject
475{
476 Q_OBJECT;
477
478#if RT_MSC_PREREQ(RT_MSC_VER_VS2019_U11)
479# pragma warning(push)
480# pragma warning(disable: 5243) /* warning C5243: 'UIActionPool::PTFActionPoolManager': using incomplete class 'UIActionPoolManager' can cause potential one definition rule violation due to ABI limitation */
481#endif
482 /** Pointer to menu update-handler for this class. */
483 typedef void (UIActionPool::*PTFActionPool)();
484 /** Pointer to menu update-handler for Manager sub-class. */
485 typedef void (UIActionPoolManager::*PTFActionPoolManager)();
486 /** Pointer to menu update-handler for Runtime sub-class. */
487 typedef void (UIActionPoolRuntime::*PTFActionPoolRuntime)();
488 /** Union for three defines above. */
489 union PointerToFunction
490 {
491 PTFActionPool ptf;
492 PTFActionPoolManager ptfm;
493 PTFActionPoolRuntime ptfr;
494 };
495#if RT_MSC_PREREQ(RT_MSC_VER_VS2019_U11)
496# pragma warning(pop)
497#endif
498
499signals:
500
501 /** Notifies about menu prepare. */
502 void sigNotifyAboutMenuPrepare(int iIndex, QMenu *pMenu);
503
504#ifdef VBOX_WS_MAC
505 /** Notifies about @a pAction hovered. */
506 void sigActionHovered(UIAction *pAction);
507#endif
508
509public:
510
511 /** Creates singleton instance. */
512 static UIActionPool *create(UIType enmType);
513 /** Destroys singleton instance. */
514 static void destroy(UIActionPool *pActionPool);
515
516 /** Creates temporary singleton instance,
517 * used to initialize shortcuts-pool from action-pool of passed @a enmType. */
518 static void createTemporary(UIType enmType);
519
520 /** Cast action-pool to Manager one. */
521 UIActionPoolManager *toManager();
522 /** Cast action-pool to Runtime one. */
523 UIActionPoolRuntime *toRuntime();
524
525 /** Returns action-pool type. */
526 UIType type() const { return m_enmType; }
527 /** Returns whether this action-pool is temporary. */
528 bool isTemporary() const { return m_fTemporary; }
529
530 /** Returns the action for the passed @a iIndex. */
531 UIAction *action(int iIndex) const;
532 /** Returns all the actions action-pool contains. */
533 QList<UIAction*> actions() const;
534
535 /** Returns the action group for the passed @a iIndex.
536 * @note Only menu actions can have action groups. */
537 QActionGroup *actionGroup(int iIndex) const;
538
539 /** Returns the list of main menus. */
540 QList<QMenu*> menus() const { return m_mainMenus; }
541
542 /** Returns whether the menu with passed @a type is allowed in menu-bar. */
543 bool isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType type) const;
544 /** Defines menu-bar @a enmRestriction for passed @a level. */
545 void setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType enmRestriction);
546
547 /** Returns whether the action with passed @a type is allowed in the 'Application' menu. */
548 bool isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType type) const;
549 /** Defines 'Application' menu @a enmRestriction for passed @a level. */
550 void setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType enmRestriction);
551
552#ifdef VBOX_WS_MAC
553 /** Mac OS X: Returns whether the action with passed @a type is allowed in the 'Window' menu. */
554 bool isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const;
555 /** Mac OS X: Defines 'Window' menu @a enmRestriction for passed @a level. */
556 void setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType enmRestriction);
557#endif /* VBOX_WS_MAC */
558
559 /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */
560 bool isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType enmType) const;
561 /** Defines 'Help' menu @a enmRestriction for passed @a level. */
562 void setRestrictionForMenuHelp(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuHelpActionType enmRestriction);
563
564 /** Hot-key processing delegate. */
565 bool processHotKey(const QKeySequence &key);
566
567 /** Defines whether shortcuts of menu actions with specified @a iIndex should be visible. */
568 virtual void setShortcutsVisible(int iIndex, bool fVisible) { Q_UNUSED(iIndex); Q_UNUSED(fVisible); }
569 /** Returns extra-data ID to save keyboard shortcuts under. */
570 virtual QString shortcutsExtraDataID() const = 0;
571
572public slots:
573
574 /** Handles menu prepare. */
575 void sltHandleMenuPrepare();
576
577#ifdef VBOX_WS_MAC
578 /** Handles action hovered signal. */
579 void sltActionHovered();
580#endif
581
582protected slots:
583
584 /** Loads keyboard shortcuts of action-pool into shortcuts-pool. */
585 void sltApplyShortcuts() { updateShortcuts(); }
586
587protected:
588
589 /** Constructs probably @a fTemporary action-pool of passed @a enmType. */
590 UIActionPool(UIType enmType, bool fTemporary = false);
591
592 /** Prepares pool. */
593 virtual void preparePool();
594 /** Prepares connections. */
595 virtual void prepareConnections();
596 /** Cleanups connections. */
597 virtual void cleanupConnections();
598 /** Cleanups pool. */
599 virtual void cleanupPool();
600
601 /** Updates configuration. */
602 virtual void updateConfiguration();
603
604 /** Updates menu with certain @a iIndex. */
605 virtual void updateMenu(int iIndex);
606 /** Updates menus. */
607 virtual void updateMenus() = 0;
608
609 /** Updates shortcuts. */
610 virtual void updateShortcuts();
611
612 /** Handles any Qt @a pEvent */
613 virtual bool event(QEvent *pEvent) RT_OVERRIDE;
614
615 /** Adds action into corresponding menu. */
616 bool addAction(UIMenu *pMenu, UIAction *pAction, bool fReallyAdd = true);
617 /** Adds action's menu into corresponding menu list. */
618 bool addMenu(QList<QMenu*> &menuList, UIAction *pAction, bool fReallyAdd = true);
619
620 /** Updates 'Application' menu. */
621 void updateMenuApplication();
622#ifdef VBOX_WS_MAC
623 /** Mac OS X: Updates 'Window' menu. */
624 void updateMenuWindow();
625#endif
626 /** Updates 'Help' menu. */
627 void updateMenuHelp();
628 /** Updates 'Log Viewer Window' menu. */
629 void updateMenuLogViewerWindow();
630 /** Updates 'Log Viewer' menu. */
631 void updateMenuLogViewer();
632 /** Updates 'Log Viewer' @a pMenu. */
633 void updateMenuLogViewerWrapper(UIMenu *pMenu);
634 /** Updates 'Performance Monitor' menu. */
635 void updateMenuVMActivityMonitor();
636 /** Updates 'File Manager' menu. */
637 void updateMenuFileManager();
638 /** Updates 'File Manager' @a pMenu. */
639 void updateMenuFileManagerWrapper(UIMenu *pMenu);
640
641 /** Holds the map of actions. */
642 QMap<int, UIAction*> m_pool;
643 /** Holds the map of action groups.
644 * @note Only menu actions can have action groups. */
645 QMap<int, QActionGroup*> m_groupPool;
646 /** Holds the map of validation handlers. */
647 QMap<int, PointerToFunction> m_menuUpdateHandlers;
648 /** Holds the set of invalidated action indexes. */
649 QSet<int> m_invalidations;
650
651 /** Holds the list of main menus. */
652 QList<QMenu*> m_mainMenus;
653
654 /** Holds restricted menu types. */
655 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuType> m_restrictedMenus;
656 /** Holds restricted action types of the 'Application' menu. */
657 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuApplicationActionType> m_restrictedActionsMenuApplication;
658#ifdef VBOX_WS_MAC
659 /** Mac OS X: Holds restricted action types of the 'Window' menu. */
660 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuWindowActionType> m_restrictedActionsMenuWindow;
661#endif
662 /** Holds restricted action types of the Help menu. */
663 QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuHelpActionType> m_restrictedActionsMenuHelp;
664
665private slots:
666
667 /** Handles translation event. */
668 void sltRetranslateUI();
669
670private:
671
672 /** Prepares all. */
673 void prepare();
674 /** Cleanups all. */
675 void cleanup();
676
677 /** Holds the action-pool type. */
678 const UIType m_enmType;
679 /** Holds whether this action-pool is temporary. */
680 const bool m_fTemporary;
681};
682
683
684#endif /* !FEQT_INCLUDED_SRC_globals_UIActionPool_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use