summaryrefslogtreecommitdiff
path: root/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h
blob: 9e5f2bab8e0205157b044ebb2bf5a11ea75c4218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
/* $Id$ */
/** @file
 * VBox Qt GUI - UIActionPool class declaration.
 */

/*
 * Copyright (C) 2010-2022 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#ifndef FEQT_INCLUDED_SRC_globals_UIActionPool_h
#define FEQT_INCLUDED_SRC_globals_UIActionPool_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

/* Qt includes: */
#include <QAction>
#include <QMenu>
#include <QVector>

/* GUI includes: */
#include "QIWithRetranslateUI.h"
#include "UIExtraDataDefs.h"
#include "UILibraryDefs.h"

/* Forward declarations: */
class QKeySequence;
class QString;
class UIActionPool;
class UIActionPoolRuntime;
class UIActionPoolManager;


/** Action-pool types. */
enum UIActionPoolType
{
    UIActionPoolType_Manager,
    UIActionPoolType_Runtime
};

/** Action types. */
enum UIActionType
{
    UIActionType_Menu,
    UIActionType_Simple,
    UIActionType_Toggle
};

/** Action indexes. */
enum UIActionIndex
{
    /* 'Application' menu actions: */
    UIActionIndex_M_Application,
#ifdef VBOX_WS_MAC
    UIActionIndex_M_Application_S_About,
#endif
    UIActionIndex_M_Application_S_Preferences,
#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    UIActionIndex_M_Application_S_CheckForUpdates,
#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    UIActionIndex_M_Application_S_ResetWarnings,
    UIActionIndex_M_Application_S_Close,

#ifdef VBOX_WS_MAC
    /* 'Window' menu actions: */
    UIActionIndex_M_Window,
    UIActionIndex_M_Window_S_Minimize,
#endif

    /* 'Help' menu actions: */
    UIActionIndex_Menu_Help,
    UIActionIndex_Simple_Contents,
    UIActionIndex_Simple_WebSite,
    UIActionIndex_Simple_BugTracker,
    UIActionIndex_Simple_Forums,
    UIActionIndex_Simple_Oracle,
    UIActionIndex_Simple_OnlineDocumentation,
#ifndef VBOX_WS_MAC
    UIActionIndex_Simple_About,
#endif

    /* 'Log' menu actions: */
    UIActionIndex_M_LogWindow,
    UIActionIndex_M_Log,
    UIActionIndex_M_Log_T_Find,
    UIActionIndex_M_Log_T_Filter,
    UIActionIndex_M_Log_T_Bookmark,
    UIActionIndex_M_Log_T_Options,
    UIActionIndex_M_Log_S_Refresh,
    UIActionIndex_M_Log_S_Reload,
    UIActionIndex_M_Log_S_Save,

    /* 'Performance' menu actions: */
    UIActionIndex_M_Activity,
    UIActionIndex_M_Activity_S_Export,
    UIActionIndex_M_Activity_S_ToVMActivityOverview,

    /* File Manager actions: */
    UIActionIndex_M_FileManager,
    UIActionIndex_M_FileManager_M_HostSubmenu,
    UIActionIndex_M_FileManager_M_GuestSubmenu,
    UIActionIndex_M_FileManager_S_CopyToGuest,
    UIActionIndex_M_FileManager_S_CopyToHost,
    UIActionIndex_M_FileManager_T_Options,
    UIActionIndex_M_FileManager_T_Log,
    UIActionIndex_M_FileManager_T_Operations,
    UIActionIndex_M_FileManager_T_GuestSession,
    UIActionIndex_M_FileManager_S_Host_GoUp,
    UIActionIndex_M_FileManager_S_Guest_GoUp,
    UIActionIndex_M_FileManager_S_Host_GoHome,
    UIActionIndex_M_FileManager_S_Guest_GoHome,
    UIActionIndex_M_FileManager_S_Host_Refresh,
    UIActionIndex_M_FileManager_S_Guest_Refresh,
    UIActionIndex_M_FileManager_S_Host_Delete,
    UIActionIndex_M_FileManager_S_Guest_Delete,
    UIActionIndex_M_FileManager_S_Host_Rename,
    UIActionIndex_M_FileManager_S_Guest_Rename,
    UIActionIndex_M_FileManager_S_Host_CreateNewDirectory,
    UIActionIndex_M_FileManager_S_Guest_CreateNewDirectory,
    UIActionIndex_M_FileManager_S_Host_Copy,
    UIActionIndex_M_FileManager_S_Guest_Copy,
    UIActionIndex_M_FileManager_S_Host_Cut,
    UIActionIndex_M_FileManager_S_Guest_Cut,
    UIActionIndex_M_FileManager_S_Host_Paste,
    UIActionIndex_M_FileManager_S_Guest_Paste,
    UIActionIndex_M_FileManager_S_Host_SelectAll,
    UIActionIndex_M_FileManager_S_Guest_SelectAll,
    UIActionIndex_M_FileManager_S_Host_InvertSelection,
    UIActionIndex_M_FileManager_S_Guest_InvertSelection,
    UIActionIndex_M_FileManager_S_Host_ShowProperties,
    UIActionIndex_M_FileManager_S_Guest_ShowProperties,

    /* VISO Creator actions: */
    UIActionIndex_M_VISOCreator,
    UIActionIndex_M_VISOCreator_ToggleConfigPanel,
    UIActionIndex_M_VISOCreator_ToggleOptionsPanel,
    UIActionIndex_M_VISOCreator_Add,
    UIActionIndex_M_VISOCreator_Remove,
    UIActionIndex_M_VISOCreator_CreateNewDirectory,
    UIActionIndex_M_VISOCreator_Rename,
    UIActionIndex_M_VISOCreator_Reset,

    /* Medium selector actions : */
    UIActionIndex_M_MediumSelector,
    UIActionIndex_M_MediumSelector_AddHD,
    UIActionIndex_M_MediumSelector_AddFD,
    UIActionIndex_M_MediumSelector_AddCD,
    UIActionIndex_M_MediumSelector_CreateHD,
    UIActionIndex_M_MediumSelector_CreateCD,
    UIActionIndex_M_MediumSelector_CreateFD,
    UIActionIndex_M_MediumSelector_Refresh,

    /* Maximum index: */
    UIActionIndex_Max
};

/** Action restriction levels. */
enum UIActionRestrictionLevel
{
    UIActionRestrictionLevel_Base,
    UIActionRestrictionLevel_Session,
    UIActionRestrictionLevel_Logic
};


/** QMenu extension. */
class SHARED_LIBRARY_STUFF UIMenu : public QMenu
{
    Q_OBJECT;

public:

    /** Constructs menu. */
    UIMenu();

    /** Defines whether tool-tip should be shown. */
    void setShowToolTip(bool fShowToolTips) { m_fShowToolTip = fShowToolTips; }

#ifdef VBOX_WS_MAC
    /** Mac OS X: Returns whether this menu is consumable by the menu-bar. */
    bool isConsumable() const { return m_fConsumable; }
    /** Mac OS X: Defines whether this menu is @a fConsumable by the menu-bar. */
    void setConsumable(bool fConsumable) { m_fConsumable = fConsumable; }

    /** Mac OS X: Returns whether this menu is consumed by the menu-bar. */
    bool isConsumed() const { return m_fConsumed; }
    /** Mac OS X: Defines whether this menu is @a fConsumed by the menu-bar. */
    void setConsumed(bool fConsumed) { m_fConsumed = fConsumed; }
#endif /* VBOX_WS_MAC */

protected:

    /** Handles any Qt @a pEvent. */
    virtual bool event(QEvent *pEvent);

private:

    /** Holds whether tool-tip should be shown. */
    bool m_fShowToolTip;

#ifdef VBOX_WS_MAC
    /** Mac OS X: Holds whether this menu can be consumed by the menu-bar. */
    bool m_fConsumable;
    /** Mac OS X: Holds whether this menu is consumed by the menu-bar. */
    bool m_fConsumed;
#endif /* VBOX_WS_MAC */
};


/** Abstract QAction extension. */
class SHARED_LIBRARY_STUFF UIAction : public QAction
{
    Q_OBJECT;

public:

    /** Constructs action passing @a pParent to the base-class.
      * @param  enmType  Brings the action type. */
    UIAction(UIActionPool *pParent, UIActionType enmType, bool fMachineMenuAction = false);
    /** Destructs action. */
    virtual ~UIAction() RT_OVERRIDE { delete menu(); }

    /** Returns action-pool this action belongs to. */
    UIActionPool *actionPool() const { return m_pActionPool; }
    /** Returns action type. */
    UIActionType type() const { return m_enmType; }

    /** Returns menu contained by this action. */
    UIMenu *menu() const;

    /** Returns current action state. */
    int state() const { return m_iState; }
    /** Defines current action @a iState. */
    void setState(int iState);

    /** Defines @a icon for certain @a iState. */
    void setIcon(int iState, const QIcon &icon);
    /** Defines @a icon. */
    void setIcon(const QIcon &icon);

    /** Returns current action name. */
    QString name() const { return m_strName; }
    /** Defines current action name. */
    void setName(const QString &strName);

    /** Returns action shortcut scope. */
    QString shortcutScope() const { return m_strShortcutScope; }
    /** Defines action @a strShortcutScope. */
    void setShortcutScope(const QString &strShortcutScope) { m_strShortcutScope = strShortcutScope; }

    /** Defines current keyboard shortcuts for this action. */
    void setShortcuts(const QList<QKeySequence> &shortcuts);
    /** Make action show keyboard shortcut. */
    void showShortcut();
    /** Make action hide keyboard shortcut. */
    void hideShortcut();

    /** Returns action extra-data ID. */
    virtual int extraDataID() const { return 0; }
    /** Returns action extra-data key. */
    virtual QString extraDataKey() const { return QString(); }
    /** Returns whether action is allowed. */
    virtual bool isAllowed() const { return true; }

    /** Returns extra-data ID to save keyboard shortcut under. */
    virtual QString shortcutExtraDataID() const { return QString(); }
    /** Returns default keyboard shortcut for this action. */
    virtual QKeySequence defaultShortcut(UIActionPoolType) const { return QKeySequence(); }
    /** Returns standard keyboard shortcut for this action. */
    virtual QKeySequence standardShortcut(UIActionPoolType) const { return QKeySequence(); }

    /** Retranslates action. */
    virtual void retranslateUi() = 0;

protected:

    /** Handles state change. */
    virtual void handleStateChange() {}

    /** Returns current action name in menu. */
    QString nameInMenu() const;

    /** Updates action icon. */
    void updateIcon();
    /** Updates action text. */
    void updateText();

    /** Simplifies passed @a strText by removing dots and ampersands.
      * @note Used to simplify action names for tool-tip needs. */
    static QString simplifyText(QString strText);

    /** Holds the reference to the action-pool this action belongs to. */
    UIActionPool           *m_pActionPool;
    /** Holds the type of the action-pool this action belongs to. */
    const UIActionPoolType  m_enmActionPoolType;

    /** Holds the action type. */
    const UIActionType  m_enmType;
    /** Holds whether this is machine-menu action. */
    const bool          m_fMachineMenuAction;

    /** Holds current action state. */
    int             m_iState;
    /** Holds action icons. */
    QVector<QIcon>  m_icons;

    /** Holds the action name. */
    QString  m_strName;

    /** Holds the action shortcut scope. */
    QString              m_strShortcutScope;
    /** Holds the action shortcuts. */
    QList<QKeySequence>  m_shortcuts;
    /** Holds whether action shortcut hidden. */
    bool                 m_fShortcutHidden;
};


/** Abstract UIAction extension for 'Menu' action type. */
class SHARED_LIBRARY_STUFF UIActionMenu : public UIAction
{
    Q_OBJECT;

protected:

    /** Constructs menu action passing @a pParent to the base-class.
      * @param  strIcon          Brings the normal-icon name.
      * @param  strIconDisabled  Brings the disabled-icon name. */
    UIActionMenu(UIActionPool *pParent,
                 const QString &strIcon = QString(), const QString &strIconDisabled = QString());
    /** Constructs menu action passing @a pParent to the base-class.
      * @param  strIconNormal          Brings the normal-icon name.
      * @param  strIconSmall           Brings the small-icon name.
      * @param  strIconNormalDisabled  Brings the normal-disabled-icon name.
      * @param  strIconSmallDisabled   Brings the small-disabled-icon name. */
    UIActionMenu(UIActionPool *pParent,
                 const QString &strIconNormal, const QString &strIconSmall,
                 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled);
    /** Constructs menu action passing @a pParent to the base-class.
      * @param  icon  Brings the icon. */
    UIActionMenu(UIActionPool *pParent,
                 const QIcon &icon);

    /** Destructs menu action. */
    virtual ~UIActionMenu() RT_OVERRIDE;

    /** Defines whether tool-tip should be shown. */
    void setShowToolTip(bool fShowToolTip);

    /** Shows menu. */
    void showMenu();
    /** Hides menu. */
    void hideMenu();

private:

    /** Prepares all. */
    void prepare();

    /** Holds the menu instance. */
    UIMenu *m_pMenu;
};


/** Abstract UIAction extension for 'Simple' action type. */
class SHARED_LIBRARY_STUFF UIActionSimple : public UIAction
{
    Q_OBJECT;

protected:

    /** Constructs simple action passing @a pParent to the base-class.
      * @param  fMachineMenuAction  Brings whether this action is a part of machine menu. */
    UIActionSimple(UIActionPool *pParent,
                   bool fMachineMenuAction = false);
    /** Constructs simple action passing @a pParent to the base-class.
      * @param  strIcon             Brings the normal-icon name.
      * @param  strIconDisabled     Brings the disabled-icon name.
      * @param  fMachineMenuAction  Brings whether this action is a part of machine menu. */
    UIActionSimple(UIActionPool *pParent,
                   const QString &strIcon, const QString &strIconDisabled,
                   bool fMachineMenuAction = false);
    /** Constructs simple action passing @a pParent to the base-class.
      * @param  strIconNormal          Brings the normal-icon name.
      * @param  strIconSmall           Brings the small-icon name.
      * @param  strIconNormalDisabled  Brings the normal-disabled-icon name.
      * @param  strIconSmallDisabled   Brings the small-disabled-icon name.
      * @param  fMachineMenuAction     Brings whether this action is a part of machine menu. */
    UIActionSimple(UIActionPool *pParent,
                   const QString &strIconNormal, const QString &strIconSmall,
                   const QString &strIconNormalDisabled, const QString &strIconSmallDisabled,
                   bool fMachineMenuAction = false);
    /** Constructs simple action passing @a pParent to the base-class.
      * @param  icon                Brings the icon.
      * @param  fMachineMenuAction  Brings whether this action is a part of machine menu. */
    UIActionSimple(UIActionPool *pParent,
                   const QIcon &icon,
                   bool fMachineMenuAction = false);
};


/** Abstract UIAction extension for 'Toggle' action type. */
class SHARED_LIBRARY_STUFF UIActionToggle : public UIAction
{
    Q_OBJECT;

protected:

    /** Constructs toggle action passing @a pParent to the base-class.
      * @param  fMachineMenuAction  Brings whether this action is a part of machine menu. */
    UIActionToggle(UIActionPool *pParent,
                   bool fMachineMenuAction = false);
    /** Constructs toggle action passing @a pParent to the base-class.
      * @param  strIcon             Brings the normal-icon name.
      * @param  strIconDisabled     Brings the disabled-icon name.
      * @param  fMachineMenuAction  Brings whether this action is a part of machine menu. */
    UIActionToggle(UIActionPool *pParent,
                   const QString &strIcon, const QString &strIconDisabled,
                   bool fMachineMenuAction = false);
    /** Constructs toggle action passing @a pParent to the base-class.
      * @param  strIconOn           Brings the on-icon name.
      * @param  strIconOff          Brings the off-icon name.
      * @param  strIconOnDisabled   Brings the on-disabled-icon name.
      * @param  strIconOffDisabled  Brings the off-disabled-icon name.
      * @param  fMachineMenuAction  Brings whether this action is a part of machine menu. */
    UIActionToggle(UIActionPool *pParent,
                   const QString &strIconOn, const QString &strIconOff,
                   const QString &strIconOnDisabled, const QString &strIconOffDisabled,
                   bool fMachineMenuAction = false);
    /** Constructs toggle action passing @a pParent to the base-class.
      * @param  icon                Brings the icon.
      * @param  fMachineMenuAction  Brings whether this action is a part of machine menu. */
    UIActionToggle(UIActionPool *pParent,
                   const QIcon &icon,
                   bool fMachineMenuAction = false);

private:

    /** Prepares all. */
    void prepare();
};


/** Abstract QObject extension
  * representing action-pool interface and factory. */
class SHARED_LIBRARY_STUFF UIActionPool : public QIWithRetranslateUI3<QObject>
{
    Q_OBJECT;

#if RT_MSC_PREREQ(RT_MSC_VER_VS2019_U11)
# pragma warning(push)
# pragma warning(disable: 5243) /* warning C5243: 'UIActionPool::PTFActionPoolManager': using incomplete class 'UIActionPoolManager' can cause potential one definition rule violation due to ABI limitation */
#endif
    /** Pointer to menu update-handler for this class. */
    typedef void (UIActionPool::*PTFActionPool)();
    /** Pointer to menu update-handler for Manager sub-class. */
    typedef void (UIActionPoolManager::*PTFActionPoolManager)();
    /** Pointer to menu update-handler for Runtime sub-class. */
    typedef void (UIActionPoolRuntime::*PTFActionPoolRuntime)();
    /** Union for three defines above. */
    union PointerToFunction
    {
        PTFActionPool ptf;
        PTFActionPoolManager ptfm;
        PTFActionPoolRuntime ptfr;
    };
#if RT_MSC_PREREQ(RT_MSC_VER_VS2019_U11)
# pragma warning(pop)
#endif

signals:

    /** Notifies about menu prepare. */
    void sigNotifyAboutMenuPrepare(int iIndex, QMenu *pMenu);

#ifdef VBOX_WS_MAC
    /** Notifies about @a pAction hovered. */
    void sigActionHovered(UIAction *pAction);
#endif

public:

    /** Creates singleton instance. */
    static UIActionPool *create(UIActionPoolType enmType);
    /** Destroys singleton instance. */
    static void destroy(UIActionPool *pActionPool);

    /** Creates temporary singleton instance,
      * used to initialize shortcuts-pool from action-pool of passed @a enmType. */
    static void createTemporary(UIActionPoolType enmType);

    /** Cast action-pool to Manager one. */
    UIActionPoolManager *toManager();
    /** Cast action-pool to Runtime one. */
    UIActionPoolRuntime *toRuntime();

    /** Returns action-pool type. */
    UIActionPoolType type() const { return m_enmType; }
    /** Returns whether this action-pool is temporary. */
    bool isTemporary() const { return m_fTemporary; }

    /** Returns the action for the passed @a iIndex. */
    UIAction *action(int iIndex) const;
    /** Returns all the actions action-pool contains. */
    QList<UIAction*> actions() const;

    /** Returns the action group for the passed @a iIndex.
      * @note Only menu actions can have action groups. */
    QActionGroup *actionGroup(int iIndex) const;

    /** Returns the list of main menus. */
    QList<QMenu*> menus() const { return m_mainMenus; }

    /** Returns whether the menu with passed @a type is allowed in menu-bar. */
    bool isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType type) const;
    /** Defines menu-bar @a enmRestriction for passed @a level. */
    void setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType enmRestriction);

    /** Returns whether the action with passed @a type is allowed in the 'Application' menu. */
    bool isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType type) const;
    /** Defines 'Application' menu @a enmRestriction for passed @a level. */
    void setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType enmRestriction);

#ifdef VBOX_WS_MAC
    /** Mac OS X: Returns whether the action with passed @a type is allowed in the 'Window' menu. */
    bool isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const;
    /** Mac OS X: Defines 'Window' menu @a enmRestriction for passed @a level. */
    void setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType enmRestriction);
#endif /* VBOX_WS_MAC */

    /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */
    bool isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType enmType) const;
    /** Defines 'Help' menu @a enmRestriction for passed @a level. */
    void setRestrictionForMenuHelp(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuHelpActionType enmRestriction);

    /** Hot-key processing delegate. */
    bool processHotKey(const QKeySequence &key);

    /** Defines whether shortcuts of menu actions with specified @a iIndex should be visible. */
    virtual void setShortcutsVisible(int iIndex, bool fVisible) { Q_UNUSED(iIndex); Q_UNUSED(fVisible); }
    /** Returns extra-data ID to save keyboard shortcuts under. */
    virtual QString shortcutsExtraDataID() const = 0;

public slots:

    /** Handles menu prepare. */
    void sltHandleMenuPrepare();

#ifdef VBOX_WS_MAC
    /** Handles action hovered signal. */
    void sltActionHovered();
#endif

protected slots:

    /** Loads keyboard shortcuts of action-pool into shortcuts-pool. */
    void sltApplyShortcuts() { updateShortcuts(); }

protected:

    /** Constructs probably @a fTemporary action-pool of passed @a enmType. */
    UIActionPool(UIActionPoolType enmType, bool fTemporary = false);

    /** Prepares pool. */
    virtual void preparePool();
    /** Prepares connections. */
    virtual void prepareConnections();
    /** Cleanups connections. */
    virtual void cleanupConnections();
    /** Cleanups pool. */
    virtual void cleanupPool();

    /** Updates configuration. */
    virtual void updateConfiguration();

    /** Updates menu with certain @a iIndex. */
    virtual void updateMenu(int iIndex);
    /** Updates menus. */
    virtual void updateMenus() = 0;

    /** Updates shortcuts. */
    virtual void updateShortcuts();

    /** Handles any Qt @a pEvent */
    virtual bool event(QEvent *pEvent) RT_OVERRIDE;

    /** Handles translation event. */
    virtual void retranslateUi() RT_OVERRIDE;

    /** Adds action into corresponding menu. */
    bool addAction(UIMenu *pMenu, UIAction *pAction, bool fReallyAdd = true);
    /** Adds action's menu into corresponding menu list. */
    bool addMenu(QList<QMenu*> &menuList, UIAction *pAction, bool fReallyAdd = true);

    /** Updates 'Application' menu. */
    void updateMenuApplication();
#ifdef VBOX_WS_MAC
    /** Mac OS X: Updates 'Window' menu. */
    void updateMenuWindow();
#endif
    /** Updates 'Help' menu. */
    void updateMenuHelp();
    /** Updates 'Log Viewer Window' menu. */
    void updateMenuLogViewerWindow();
    /** Updates 'Log Viewer' menu. */
    void updateMenuLogViewer();
    /** Updates 'Log Viewer' @a pMenu. */
    void updateMenuLogViewerWrapper(UIMenu *pMenu);
    /** Updates 'Performance Monitor' menu. */
    void updateMenuVMActivityMonitor();
    /** Updates 'File Manager' menu. */
    void updateMenuFileManager();
    /** Updates 'File Manager' @a pMenu. */
    void updateMenuFileManagerWrapper(UIMenu *pMenu);

    /** Holds the map of actions. */
    QMap<int, UIAction*>          m_pool;
    /** Holds the map of action groups.
      * @note Only menu actions can have action groups. */
    QMap<int, QActionGroup*>      m_groupPool;
    /** Holds the map of validation handlers. */
    QMap<int, PointerToFunction>  m_menuUpdateHandlers;
    /** Holds the set of invalidated action indexes. */
    QSet<int>                     m_invalidations;

    /** Holds the list of main menus. */
    QList<QMenu*>  m_mainMenus;

    /** Holds restricted menu types. */
    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuType>                   m_restrictedMenus;
    /** Holds restricted action types of the 'Application' menu. */
    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuApplicationActionType>  m_restrictedActionsMenuApplication;
#ifdef VBOX_WS_MAC
    /** Mac OS X: Holds restricted action types of the 'Window' menu. */
    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuWindowActionType>       m_restrictedActionsMenuWindow;
#endif
    /** Holds restricted action types of the Help menu. */
    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuHelpActionType>         m_restrictedActionsMenuHelp;

private:

    /** Prepares all. */
    void prepare();
    /** Cleanups all. */
    void cleanup();

    /** Holds the action-pool type. */
    const UIActionPoolType  m_enmType;
    /** Holds whether this action-pool is temporary. */
    const bool              m_fTemporary;
};


#endif /* !FEQT_INCLUDED_SRC_globals_UIActionPool_h */