VirtualBox

Changeset 71582 in vbox


Ignore:
Timestamp:
Mar 30, 2018 3:46:47 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Heavy cleanup for UIActionPool.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/globals
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r71027 r71582  
    55
    66/*
    7  * Copyright (C) 2010-2017 Oracle Corporation
     7 * Copyright (C) 2010-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2525
    2626/* GUI includes: */
     27# include "VBoxGlobal.h"
    2728# include "UIActionPool.h"
    2829# include "UIActionPoolSelector.h"
    2930# include "UIActionPoolRuntime.h"
    30 # include "UIShortcutPool.h"
    3131# include "UIConverter.h"
    3232# include "UIIconPool.h"
    33 # include "VBoxGlobal.h"
    3433# include "UIMessageCenter.h"
     34# include "UIShortcutPool.h"
    3535# ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    3636#  include "UIExtraDataManager.h"
     
    4242
    4343
    44 
    4544/** QEvent extension
    4645  * representing action-activation event. */
     
    4948public:
    5049
    51     /** Constructor. */
     50    /** Constructs @a pAction event. */
    5251    ActivateActionEvent(QAction *pAction)
    5352        : QEvent((QEvent::Type)ActivateActionEventType)
    54         , m_pAction(pAction) {}
    55 
    56     /** Returns the action this event corresponding to. */
    57     QAction* action() const { return m_pAction; }
     53        , m_pAction(pAction)
     54    {}
     55
     56    /** Returns the action this event corresponds to. */
     57    QAction *action() const { return m_pAction; }
    5858
    5959private:
    6060
    61     /** Ho0lds the action this event corresponding to. */
     61    /** Holds the action this event corresponds to. */
    6262    QAction *m_pAction;
    6363};
    6464
    6565
     66/*********************************************************************************************************************************
     67*   Class UIMenu implementation.                                                                                                 *
     68*********************************************************************************************************************************/
     69
    6670UIMenu::UIMenu()
    6771    : m_fShowToolTip(false)
     
    6973    , m_fConsumable(false)
    7074    , m_fConsumed(false)
    71 #endif /* VBOX_WS_MAC */
     75#endif
    7276{
    7377}
     
    98102
    99103
    100 UIAction::UIAction(UIActionPool *pParent, UIActionType type)
     104/*********************************************************************************************************************************
     105*   Class UIAction implementation.                                                                                               *
     106*********************************************************************************************************************************/
     107
     108UIAction::UIAction(UIActionPool *pParent, UIActionType enmType)
    101109    : QAction(pParent)
    102     , m_type(type)
     110    , m_enmType(enmType)
    103111    , m_pActionPool(pParent)
    104     , m_actionPoolType(pParent->type())
     112    , m_enmActionPoolType(pParent->type())
    105113    , m_fShortcutHidden(false)
    106114{
     
    116124}
    117125
    118 UIMenu* UIAction::menu() const
     126UIMenu *UIAction::menu() const
    119127{
    120128    return QAction::menu() ? qobject_cast<UIMenu*>(QAction::menu()) : 0;
    121129}
    122130
    123 UIActionPolymorphic* UIAction::toActionPolymorphic()
     131UIActionPolymorphic *UIAction::toActionPolymorphic()
    124132{
    125133    return qobject_cast<UIActionPolymorphic*>(this);
    126134}
    127135
    128 UIActionPolymorphicMenu* UIAction::toActionPolymorphicMenu()
     136UIActionPolymorphicMenu *UIAction::toActionPolymorphicMenu()
    129137{
    130138    return qobject_cast<UIActionPolymorphicMenu*>(this);
     
    142150{
    143151    /* Only for selector's action-pool: */
    144     if (m_actionPoolType == UIActionPoolType_Selector)
     152    if (m_enmActionPoolType == UIActionPoolType_Selector)
    145153    {
    146154        /* If shortcut is visible: */
     
    172180{
    173181    /* Action-name format depends on action-pool type: */
    174     switch (m_actionPoolType)
     182    switch (m_enmActionPoolType)
    175183    {
    176184        /* Unchanged name for Selector UI: */
     
    186194{
    187195    /* Action-text format depends on action-pool type: */
    188     switch (m_actionPoolType)
     196    switch (m_enmActionPoolType)
    189197    {
    190198        /* The same as menu name for Selector UI: */
     
    201209
    202210
     211/*********************************************************************************************************************************
     212*   Class UIActionMenu implementation.                                                                                           *
     213*********************************************************************************************************************************/
     214
    203215UIActionMenu::UIActionMenu(UIActionPool *pParent,
    204                            const QString &strIcon, const QString &strIconDis)
     216                           const QString &strIcon, const QString &strIconDisabled)
    205217    : UIAction(pParent, UIActionType_Menu)
    206218{
    207219    if (!strIcon.isNull())
    208         setIcon(UIIconPool::iconSet(strIcon, strIconDis));
     220        setIcon(UIIconPool::iconSet(strIcon, strIconDisabled));
    209221    prepare();
    210222}
     
    241253}
    242254
     255
     256/*********************************************************************************************************************************
     257*   Class UIActionSimple implementation.                                                                                         *
     258*********************************************************************************************************************************/
    243259
    244260UIActionSimple::UIActionSimple(UIActionPool *pParent,
     
    259275
    260276UIActionSimple::UIActionSimple(UIActionPool *pParent,
    261                                const QIcon& icon)
     277                               const QIcon &icon)
    262278    : UIAction(pParent, UIActionType_Simple)
    263279{
     
    265281}
    266282
     283
     284/*********************************************************************************************************************************
     285*   Class UIActionToggle implementation.                                                                                         *
     286*********************************************************************************************************************************/
    267287
    268288UIActionToggle::UIActionToggle(UIActionPool *pParent,
     
    298318}
    299319
     320
     321/*********************************************************************************************************************************
     322*   Class UIActionPolymorphic implementation.                                                                                    *
     323*********************************************************************************************************************************/
    300324
    301325UIActionPolymorphic::UIActionPolymorphic(UIActionPool *pParent,
     
    326350}
    327351
     352
     353/*********************************************************************************************************************************
     354*   Class UIActionPolymorphicMenu implementation.                                                                                *
     355*********************************************************************************************************************************/
    328356
    329357UIActionPolymorphicMenu::UIActionPolymorphicMenu(UIActionPool *pParent,
     
    409437
    410438
     439/** Menu action extension, used as 'Application' menu class. */
    411440class UIActionMenuApplication : public UIActionMenu
    412441{
     
    415444public:
    416445
     446    /** Constructs action passing @a pParent to the base-class. */
    417447    UIActionMenuApplication(UIActionPool *pParent)
    418448        : UIActionMenu(pParent)
    419449    {
    420 #ifdef RT_OS_DARWIN
     450#ifdef VBOX_WS_MAC
    421451        menu()->setConsumable(true);
    422 #endif /* RT_OS_DARWIN */
     452#endif
    423453        retranslateUi();
    424454    }
     
    433463    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Application); }
    434464
    435     void retranslateUi()
    436     {
    437 #ifdef RT_OS_DARWIN
     465    /** Handles translation event. */
     466    virtual void retranslateUi() /* override */
     467    {
     468#ifdef VBOX_WS_MAC
    438469        setName(QApplication::translate("UIActionPool", "&VirtualBox"));
    439 #else /* !RT_OS_DARWIN */
     470#else
    440471        setName(QApplication::translate("UIActionPool", "&File"));
    441 #endif /* !RT_OS_DARWIN */
     472#endif
    442473    }
    443474};
    444475
     476
     477/** Simple action extension, used as 'Close' action class. */
    445478class UIActionSimplePerformClose : public UIActionSimple
    446479{
     
    449482public:
    450483
     484    /** Constructs action passing @a pParent to the base-class. */
    451485    UIActionSimplePerformClose(UIActionPool *pParent)
    452486        : UIActionSimple(pParent, ":/exit_16px.png")
     
    464498    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Close); }
    465499
     500    /** Returns shortcut extra-data ID. */
    466501    QString shortcutExtraDataID() const
    467502    {
     
    469504    }
    470505
     506    /** Returns default shortcut. */
    471507    QKeySequence defaultShortcut(UIActionPoolType actionPoolType) const
    472508    {
     
    479515    }
    480516
    481     void retranslateUi()
     517    /** Handles translation event. */
     518    virtual void retranslateUi() /* override */
    482519    {
    483520        setName(QApplication::translate("UIActionPool", "&Close..."));
     
    486523};
    487524
    488 #ifdef RT_OS_DARWIN
     525#ifdef VBOX_WS_MAC
     526/** Menu action extension, used as 'Window' menu class. */
    489527class UIActionMenuWindow : public UIActionMenu
    490528{
     
    493531public:
    494532
     533    /** Constructs action passing @a pParent to the base-class. */
    495534    UIActionMenuWindow(UIActionPool *pParent)
    496         : UIActionMenu(pParent) {}
     535        : UIActionMenu(pParent)
     536    {}
    497537
    498538protected:
     
    505545    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Window); }
    506546
    507     void retranslateUi()
     547    /** Handles translation event. */
     548    virtual void retranslateUi() /* override */
    508549    {
    509550        setName(QApplication::translate("UIActionPool", "&Window"));
     
    511552};
    512553
     554
     555/** Simple action extension, used as 'Minimize' action class. */
    513556class UIActionSimpleMinimize : public UIActionSimple
    514557{
     
    517560public:
    518561
     562    /** Constructs action passing @a pParent to the base-class. */
    519563    UIActionSimpleMinimize(UIActionPool *pParent)
    520         : UIActionSimple(pParent) {}
     564        : UIActionSimple(pParent)
     565    {}
    521566
    522567protected:
     
    529574    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Minimize); }
    530575
     576    /** Returns shortcut extra-data ID. */
    531577    QString shortcutExtraDataID() const
    532578    {
     
    534580    }
    535581
    536     void retranslateUi()
     582    /** Handles translation event. */
     583    virtual void retranslateUi() /* override */
    537584    {
    538585        setName(QApplication::translate("UIActionPool", "&Minimize"));
     
    540587    }
    541588};
    542 #endif /* RT_OS_DARWIN */
    543 
     589#endif /* VBOX_WS_MAC */
     590
     591
     592/** Menu action extension, used as 'Help' menu class. */
    544593class UIActionMenuHelp : public UIActionMenu
    545594{
     
    548597public:
    549598
     599    /** Constructs action passing @a pParent to the base-class. */
    550600    UIActionMenuHelp(UIActionPool *pParent)
    551601        : UIActionMenu(pParent)
     
    563613    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Help); }
    564614
    565     void retranslateUi()
     615    /** Handles translation event. */
     616    virtual void retranslateUi() /* override */
    566617    {
    567618        setName(QApplication::translate("UIActionPool", "&Help"));
     
    569620};
    570621
     622
     623/** Simple action extension, used as 'Contents' action class. */
    571624class UIActionSimpleContents : public UIActionSimple
    572625{
     
    575628public:
    576629
     630    /** Constructs action passing @a pParent to the base-class. */
    577631    UIActionSimpleContents(UIActionPool *pParent)
    578632        : UIActionSimple(pParent, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_DialogHelp))
     
    590644    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Contents); }
    591645
     646    /** Returns shortcut extra-data ID. */
    592647    QString shortcutExtraDataID() const
    593648    {
     
    595650    }
    596651
     652    /** Returns default shortcut. */
    597653    QKeySequence defaultShortcut(UIActionPoolType actionPoolType) const
    598654    {
     
    605661    }
    606662
    607     void retranslateUi()
     663    /** Handles translation event. */
     664    virtual void retranslateUi() /* override */
    608665    {
    609666        setName(QApplication::translate("UIActionPool", "&Contents..."));
     
    612669};
    613670
     671
     672/** Simple action extension, used as 'Web Site' action class. */
    614673class UIActionSimpleWebSite : public UIActionSimple
    615674{
     
    618677public:
    619678
     679    /** Constructs action passing @a pParent to the base-class. */
    620680    UIActionSimpleWebSite(UIActionPool *pParent)
    621681        : UIActionSimple(pParent, ":/site_16px.png")
     
    633693    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_WebSite); }
    634694
     695    /** Returns shortcut extra-data ID. */
    635696    QString shortcutExtraDataID() const
    636697    {
     
    638699    }
    639700
    640     void retranslateUi()
     701    /** Handles translation event. */
     702    virtual void retranslateUi() /* override */
    641703    {
    642704        setName(QApplication::translate("UIActionPool", "&VirtualBox Web Site..."));
     
    645707};
    646708
     709
     710/** Simple action extension, used as 'Bug Tracker' action class. */
    647711class UIActionSimpleBugTracker : public UIActionSimple
    648712{
     
    651715public:
    652716
     717    /** Constructs action passing @a pParent to the base-class. */
    653718    UIActionSimpleBugTracker(UIActionPool *pParent)
    654719        : UIActionSimple(pParent, ":/site_bugtracker_16px.png")
     
    666731    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_BugTracker); }
    667732
     733    /** Returns shortcut extra-data ID. */
    668734    QString shortcutExtraDataID() const
    669735    {
     
    671737    }
    672738
    673     void retranslateUi()
     739    /** Handles translation event. */
     740    virtual void retranslateUi() /* override */
    674741    {
    675742        setName(QApplication::translate("UIActionPool", "&VirtualBox Bug Tracker..."));
     
    678745};
    679746
     747
     748/** Simple action extension, used as 'Forums' action class. */
    680749class UIActionSimpleForums : public UIActionSimple
    681750{
     
    684753public:
    685754
     755    /** Constructs action passing @a pParent to the base-class. */
    686756    UIActionSimpleForums(UIActionPool *pParent)
    687757        : UIActionSimple(pParent, ":/site_forum_16px.png")
     
    699769    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Forums); }
    700770
     771    /** Returns shortcut extra-data ID. */
    701772    QString shortcutExtraDataID() const
    702773    {
     
    704775    }
    705776
    706     void retranslateUi()
     777    /** Handles translation event. */
     778    virtual void retranslateUi() /* override */
    707779    {
    708780        setName(QApplication::translate("UIActionPool", "&VirtualBox Forums..."));
     
    711783};
    712784
     785
     786/** Simple action extension, used as 'Oracle' action class. */
    713787class UIActionSimpleOracle : public UIActionSimple
    714788{
     
    717791public:
    718792
     793    /** Constructs action passing @a pParent to the base-class. */
    719794    UIActionSimpleOracle(UIActionPool *pParent)
    720795        : UIActionSimple(pParent, ":/site_oracle_16px.png")
     
    732807    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Oracle); }
    733808
     809    /** Returns shortcut extra-data ID. */
    734810    QString shortcutExtraDataID() const
    735811    {
     
    737813    }
    738814
    739     void retranslateUi()
     815    /** Handles translation event. */
     816    virtual void retranslateUi() /* override */
    740817    {
    741818        setName(QApplication::translate("UIActionPool", "&Oracle Web Site..."));
     
    744821};
    745822
     823
     824/** Simple action extension, used as 'Reset Warnings' action class. */
    746825class UIActionSimpleResetWarnings : public UIActionSimple
    747826{
     
    750829public:
    751830
     831    /** Constructs action passing @a pParent to the base-class. */
    752832    UIActionSimpleResetWarnings(UIActionPool *pParent)
    753833        : UIActionSimple(pParent, ":/reset_warnings_16px.png")
     
    766846    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_ResetWarnings); }
    767847
     848    /** Returns shortcut extra-data ID. */
    768849    QString shortcutExtraDataID() const
    769850    {
     
    771852    }
    772853
    773     void retranslateUi()
     854    /** Handles translation event. */
     855    virtual void retranslateUi() /* override */
    774856    {
    775857        setName(QApplication::translate("UIActionPool", "&Reset All Warnings"));
     
    778860};
    779861
     862
    780863#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     864/** Simple action extension, used as 'Network Access Manager' action class. */
    781865class UIActionSimpleNetworkAccessManager : public UIActionSimple
    782866{
     
    785869public:
    786870
     871    /** Constructs action passing @a pParent to the base-class. */
    787872    UIActionSimpleNetworkAccessManager(UIActionPool *pParent)
    788873        : UIActionSimple(pParent, ":/download_manager_16px.png")
     
    801886    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_NetworkAccessManager); }
    802887
     888    /** Returns shortcut extra-data ID. */
    803889    QString shortcutExtraDataID() const
    804890    {
     
    806892    }
    807893
    808     void retranslateUi()
     894    /** Handles translation event. */
     895    virtual void retranslateUi() /* override */
    809896    {
    810897        setName(QApplication::translate("UIActionPool", "&Network Operations Manager..."));
     
    813900};
    814901
     902
     903/** Simple action extension, used as 'Check for Updates' action class. */
    815904class UIActionSimpleCheckForUpdates : public UIActionSimple
    816905{
     
    819908public:
    820909
     910    /** Constructs action passing @a pParent to the base-class. */
    821911    UIActionSimpleCheckForUpdates(UIActionPool *pParent)
    822912        : UIActionSimple(pParent, ":/refresh_16px.png", ":/refresh_disabled_16px.png")
     
    835925    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_CheckForUpdates); }
    836926
     927    /** Returns shortcut extra-data ID. */
    837928    QString shortcutExtraDataID() const
    838929    {
     
    840931    }
    841932
    842     void retranslateUi()
     933    /** Handles translation event. */
     934    virtual void retranslateUi() /* override */
    843935    {
    844936        setName(QApplication::translate("UIActionPool", "C&heck for Updates..."));
     
    848940#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    849941
     942
     943/** Simple action extension, used as 'About' action class. */
    850944class UIActionSimpleAbout : public UIActionSimple
    851945{
     
    854948public:
    855949
     950    /** Constructs action passing @a pParent to the base-class. */
    856951    UIActionSimpleAbout(UIActionPool *pParent)
    857952        : UIActionSimple(pParent, ":/about_16px.png")
     
    866961    virtual int extraDataID() const
    867962    {
    868 #ifdef RT_OS_DARWIN
     963#ifdef VBOX_WS_MAC
    869964        return UIExtraDataMetaDefs::MenuApplicationActionType_About;
    870 #else /* !RT_OS_DARWIN */
     965#else
    871966        return UIExtraDataMetaDefs::MenuHelpActionType_About;
    872 #endif /* !RT_OS_DARWIN */
     967#endif
    873968    }
    874969    /** Returns action extra-data key. */
    875970    virtual QString extraDataKey() const
    876971    {
    877 #ifdef RT_OS_DARWIN
     972#ifdef VBOX_WS_MAC
    878973        return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_About);
    879 #else /* !RT_OS_DARWIN */
     974#else
    880975        return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuHelpActionType_About);
    881 #endif /* !RT_OS_DARWIN */
     976#endif
    882977    }
    883978    /** Returns whether action is allowed. */
    884979    virtual bool isAllowed() const
    885980    {
    886 #ifdef RT_OS_DARWIN
     981#ifdef VBOX_WS_MAC
    887982        return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_About);
    888 #else /* !RT_OS_DARWIN */
     983#else
    889984        return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_About);
    890 #endif /* !RT_OS_DARWIN */
    891     }
    892 
     985#endif
     986    }
     987
     988    /** Returns shortcut extra-data ID. */
    893989    QString shortcutExtraDataID() const
    894990    {
     
    896992    }
    897993
    898     void retranslateUi()
     994    /** Handles translation event. */
     995    virtual void retranslateUi() /* override */
    899996    {
    900997        setName(QApplication::translate("UIActionPool", "&About VirtualBox..."));
     
    9031000};
    9041001
     1002
     1003/** Simple action extension, used as 'Preferences' action class. */
    9051004class UIActionSimplePreferences : public UIActionSimple
    9061005{
     
    9091008public:
    9101009
     1010    /** Constructs action passing @a pParent to the base-class. */
    9111011    UIActionSimplePreferences(UIActionPool *pParent)
    9121012        : UIActionSimple(pParent, ":/global_settings_16px.png")
     
    9251025    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Preferences); }
    9261026
     1027    /** Returns shortcut extra-data ID. */
    9271028    QString shortcutExtraDataID() const
    9281029    {
     
    9301031    }
    9311032
     1033    /** Returns default shortcut. */
    9321034    QKeySequence defaultShortcut(UIActionPoolType) const
    9331035    {
     
    9401042    }
    9411043
    942     void retranslateUi()
     1044    /** Handles translation event. */
     1045    virtual void retranslateUi() /* override */
    9431046    {
    9441047        setName(QApplication::translate("UIActionPool", "&Preferences...", "global preferences window"));
     
    9481051
    9491052
     1053/*********************************************************************************************************************************
     1054*   Class UIActionPool implementation.                                                                                           *
     1055*********************************************************************************************************************************/
     1056
    9501057/* static */
    951 UIActionPool* UIActionPool::create(UIActionPoolType type)
     1058UIActionPool *UIActionPool::create(UIActionPoolType enmType)
    9521059{
    9531060    UIActionPool *pActionPool = 0;
    954     switch (type)
     1061    switch (enmType)
    9551062    {
    9561063        case UIActionPoolType_Selector: pActionPool = new UIActionPoolSelector; break;
     
    9721079
    9731080/* static */
    974 void UIActionPool::createTemporary(UIActionPoolType type)
     1081void UIActionPool::createTemporary(UIActionPoolType enmType)
    9751082{
    9761083    UIActionPool *pActionPool = 0;
    977     switch (type)
     1084    switch (enmType)
    9781085    {
    9791086        case UIActionPoolType_Selector: pActionPool = new UIActionPoolSelector(true); break;
     
    9871094}
    9881095
    989 UIActionPool::UIActionPool(UIActionPoolType type, bool fTemporary /* = false */)
    990     : m_type(type)
     1096UIActionPool::UIActionPool(UIActionPoolType enmType, bool fTemporary /* = false */)
     1097    : m_enmType(enmType)
    9911098    , m_fTemporary(fTemporary)
    9921099{
    9931100}
    9941101
    995 UIActionPoolRuntime* UIActionPool::toRuntime()
     1102UIActionPoolRuntime *UIActionPool::toRuntime()
    9961103{
    9971104    return qobject_cast<UIActionPoolRuntime*>(this);
    9981105}
    9991106
    1000 UIActionPoolSelector* UIActionPool::toSelector()
     1107UIActionPoolSelector *UIActionPool::toSelector()
    10011108{
    10021109    return qobject_cast<UIActionPoolSelector*>(this);
    10031110}
    10041111
    1005 bool UIActionPool::isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType type) const
    1006 {
    1007     foreach (const UIExtraDataMetaDefs::MenuType &restriction, m_restrictedMenus.values())
    1008         if (restriction & type)
     1112bool UIActionPool::isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType enmType) const
     1113{
     1114    foreach (const UIExtraDataMetaDefs::MenuType &enmRestriction, m_restrictedMenus.values())
     1115        if (enmRestriction & enmType)
    10091116            return false;
    10101117    return true;
    10111118}
    10121119
    1013 void UIActionPool::setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType restriction)
    1014 {
    1015     m_restrictedMenus[level] = restriction;
     1120void UIActionPool::setRestrictionForMenuBar(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuType enmRestriction)
     1121{
     1122    m_restrictedMenus[enmLevel] = enmRestriction;
    10161123    updateMenus();
    10171124}
    10181125
    1019 bool UIActionPool::isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType type) const
    1020 {
    1021     foreach (const UIExtraDataMetaDefs::MenuApplicationActionType &restriction, m_restrictedActionsMenuApplication.values())
    1022         if (restriction & type)
     1126bool UIActionPool::isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType enmType) const
     1127{
     1128    foreach (const UIExtraDataMetaDefs::MenuApplicationActionType &enmRestriction, m_restrictedActionsMenuApplication.values())
     1129        if (enmRestriction & enmType)
    10231130            return false;
    10241131    return true;
    10251132}
    10261133
    1027 void UIActionPool::setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType restriction)
    1028 {
    1029     m_restrictedActionsMenuApplication[level] = restriction;
     1134void UIActionPool::setRestrictionForMenuApplication(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuApplicationActionType enmRestriction)
     1135{
     1136    m_restrictedActionsMenuApplication[enmLevel] = enmRestriction;
    10301137    m_invalidations << UIActionIndex_M_Application;
    10311138}
    10321139
    10331140#ifdef VBOX_WS_MAC
    1034 bool UIActionPool::isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const
    1035 {
    1036     foreach (const UIExtraDataMetaDefs::MenuWindowActionType &restriction, m_restrictedActionsMenuWindow.values())
    1037         if (restriction & type)
     1141bool UIActionPool::isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType enmType) const
     1142{
     1143    foreach (const UIExtraDataMetaDefs::MenuWindowActionType &enmRestriction, m_restrictedActionsMenuWindow.values())
     1144        if (enmRestriction & enmType)
    10381145            return false;
    10391146    return true;
    10401147}
    10411148
    1042 void UIActionPool::setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType restriction)
    1043 {
    1044     m_restrictedActionsMenuWindow[level] = restriction;
     1149void UIActionPool::setRestrictionForMenuWindow(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuWindowActionType enmRestriction)
     1150{
     1151    m_restrictedActionsMenuWindow[enmLevel] = enmRestriction;
    10451152    m_invalidations << UIActionIndex_M_Window;
    10461153}
    10471154#endif /* VBOX_WS_MAC */
    10481155
    1049 bool UIActionPool::isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType type) const
    1050 {
    1051     foreach (const UIExtraDataMetaDefs::MenuHelpActionType &restriction, m_restrictedActionsMenuHelp.values())
    1052         if (restriction & type)
     1156bool UIActionPool::isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType enmType) const
     1157{
     1158    foreach (const UIExtraDataMetaDefs::MenuHelpActionType &enmRestriction, m_restrictedActionsMenuHelp.values())
     1159        if (enmRestriction & enmType)
    10531160            return false;
    10541161    return true;
    10551162}
    10561163
    1057 void UIActionPool::setRestrictionForMenuHelp(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuHelpActionType restriction)
    1058 {
    1059     m_restrictedActionsMenuHelp[level] = restriction;
     1164void UIActionPool::setRestrictionForMenuHelp(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuHelpActionType enmRestriction)
     1165{
     1166    m_restrictedActionsMenuHelp[enmLevel] = enmRestriction;
    10601167    m_invalidations << UIActionIndex_Menu_Help;
    10611168}
     
    11111218    /* Create 'Application' actions: */
    11121219    m_pool[UIActionIndex_M_Application] = new UIActionMenuApplication(this);
    1113 #ifdef RT_OS_DARWIN
     1220#ifdef VBOX_WS_MAC
    11141221    m_pool[UIActionIndex_M_Application_S_About] = new UIActionSimpleAbout(this);
    1115 #endif /* RT_OS_DARWIN */
     1222#endif
    11161223    m_pool[UIActionIndex_M_Application_S_Preferences] = new UIActionSimplePreferences(this);
    11171224#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    11181225    m_pool[UIActionIndex_M_Application_S_NetworkAccessManager] = new UIActionSimpleNetworkAccessManager(this);
    11191226    m_pool[UIActionIndex_M_Application_S_CheckForUpdates] = new UIActionSimpleCheckForUpdates(this);
    1120 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     1227#endif
    11211228    m_pool[UIActionIndex_M_Application_S_ResetWarnings] = new UIActionSimpleResetWarnings(this);
    11221229    m_pool[UIActionIndex_M_Application_S_Close] = new UIActionSimplePerformClose(this);
    11231230
    1124 #ifdef RT_OS_DARWIN
     1231#ifdef VBOX_WS_MAC
    11251232    /* Create 'Window' actions: */
    11261233    m_pool[UIActionIndex_M_Window] = new UIActionMenuWindow(this);
    11271234    m_pool[UIActionIndex_M_Window_S_Minimize] = new UIActionSimpleMinimize(this);
    1128 #endif /* RT_OS_DARWIN */
     1235#endif
    11291236
    11301237    /* Create 'Help' actions: */
     
    11351242    m_pool[UIActionIndex_Simple_Forums] = new UIActionSimpleForums(this);
    11361243    m_pool[UIActionIndex_Simple_Oracle] = new UIActionSimpleOracle(this);
    1137 #ifndef RT_OS_DARWIN
     1244#ifndef VBOX_WS_MAC
    11381245    m_pool[UIActionIndex_Simple_About] = new UIActionSimpleAbout(this);
    1139 #endif /* !RT_OS_DARWIN */
     1246#endif
    11401247
    11411248    /* Prepare update-handlers for known menus: */
    1142 #ifdef RT_OS_DARWIN
     1249#ifdef VBOX_WS_MAC
    11431250    m_menuUpdateHandlers[UIActionIndex_M_Application].ptf = &UIActionPool::updateMenuApplication;
    11441251    m_menuUpdateHandlers[UIActionIndex_M_Window].ptf = &UIActionPool::updateMenuWindow;
    1145 #endif /* RT_OS_DARWIN */
     1252#endif
    11461253    m_menuUpdateHandlers[UIActionIndex_Menu_Help].ptf = &UIActionPool::updateMenuHelp;
    11471254
     
    11561263{
    11571264    /* 'Application' menu connections: */
    1158 #ifdef RT_OS_DARWIN
     1265#ifdef VBOX_WS_MAC
    11591266    connect(action(UIActionIndex_M_Application_S_About), &UIAction::triggered,
    11601267            &msgCenter(), &UIMessageCenter::sltShowHelpAboutDialog, Qt::UniqueConnection);
    1161 #endif /* RT_OS_DARWIN */
     1268#endif
    11621269#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    11631270    connect(action(UIActionIndex_M_Application_S_NetworkAccessManager), &UIAction::triggered,
     
    11651272    connect(action(UIActionIndex_M_Application_S_CheckForUpdates), &UIAction::triggered,
    11661273            gUpdateManager, &UIUpdateManager::sltForceCheck, Qt::UniqueConnection);
    1167 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     1274#endif
    11681275    connect(action(UIActionIndex_M_Application_S_ResetWarnings), &UIAction::triggered,
    11691276            &msgCenter(), &UIMessageCenter::sltResetSuppressedMessages, Qt::UniqueConnection);
     
    11801287    connect(action(UIActionIndex_Simple_Oracle), &UIAction::triggered,
    11811288            &msgCenter(), &UIMessageCenter::sltShowOracle, Qt::UniqueConnection);
    1182 #ifndef RT_OS_DARWIN
     1289#ifndef VBOX_WS_MAC
    11831290    connect(action(UIActionIndex_Simple_About), &UIAction::triggered,
    11841291            &msgCenter(), &UIMessageCenter::sltShowHelpAboutDialog, Qt::UniqueConnection);
    1185 #endif /* !RT_OS_DARWIN */
     1292#endif
    11861293}
    11871294
     
    12651372    UIMenu *pMenu = action(UIActionIndex_M_Application)->menu();
    12661373    AssertPtrReturnVoid(pMenu);
    1267 #ifdef RT_OS_DARWIN
     1374#ifdef VBOX_WS_MAC
    12681375    AssertReturnVoid(pMenu->isConsumable());
    1269 #endif /* RT_OS_DARWIN */
     1376#endif
    12701377    /* Clear contents: */
    1271 #ifdef RT_OS_DARWIN
     1378#ifdef VBOX_WS_MAC
    12721379    if (!pMenu->isConsumed())
    1273 #endif /* RT_OS_DARWIN */
     1380#endif
    12741381        pMenu->clear();
    12751382
     
    12771384    bool fSeparator = false;
    12781385
    1279 #ifdef RT_OS_DARWIN
     1386#ifdef VBOX_WS_MAC
    12801387    /* 'About' action: */
    12811388    fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_About)) || fSeparator;
    1282 #endif /* RT_OS_DARWIN */
     1389#endif
    12831390
    12841391    /* 'Preferences' action: */
    12851392    fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_Preferences)) || fSeparator;
    12861393
    1287 #ifndef RT_OS_DARWIN
     1394#ifndef VBOX_WS_MAC
    12881395    /* Separator: */
    12891396    if (fSeparator)
     
    12921399        fSeparator = false;
    12931400    }
    1294 #endif /* !RT_OS_DARWIN */
     1401#endif
    12951402
    12961403#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    12971404    /* 'Network Manager' action: */
    12981405    fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_NetworkAccessManager)) || fSeparator;
    1299 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     1406#endif
    13001407    /* 'Reset Warnings' action: */
    13011408    fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_ResetWarnings)) || fSeparator;
    13021409
    1303 #ifndef RT_OS_DARWIN
     1410#ifndef VBOX_WS_MAC
    13041411    /* Separator: */
    13051412    if (fSeparator)
     
    13081415        fSeparator = false;
    13091416    }
    1310 #endif /* !RT_OS_DARWIN */
     1417#endif
    13111418
    13121419    /* 'Close' action: */
     
    13171424}
    13181425
    1319 #ifdef RT_OS_DARWIN
     1426#ifdef VBOX_WS_MAC
    13201427void UIActionPool::updateMenuWindow()
    13211428{
     
    13411448    /* This menu always remains invalid.. */
    13421449}
    1343 #endif /* RT_OS_DARWIN */
     1450#endif /* VBOX_WS_MAC */
    13441451
    13451452void UIActionPool::updateMenuHelp()
     
    13721479    }
    13731480
    1374 #ifndef RT_OS_DARWIN
     1481#ifndef VBOX_WS_MAC
    13751482    /* 'About' action: */
    13761483    fSeparator = addAction(pMenu, action(UIActionIndex_Simple_About)) || fSeparator;;
    1377 #endif /* !RT_OS_DARWIN */
     1484#endif
    13781485
    13791486    /* Mark menu as valid: */
     
    14151522    const bool fIsActionAllowed = pAction->isAllowed();
    14161523
    1417 #ifdef RT_OS_DARWIN
     1524#ifdef VBOX_WS_MAC
    14181525    /* Check if menu is consumable: */
    14191526    const bool fIsMenuConsumable = pMenu->isConsumable();
    14201527    /* Check if menu is NOT yet consumed: */
    14211528    const bool fIsMenuConsumed = pMenu->isConsumed();
    1422 #endif /* RT_OS_DARWIN */
     1529#endif
    14231530
    14241531    /* Make this action visible
     
    14261533    pAction->setVisible(fIsActionAllowed);
    14271534
    1428 #ifdef RT_OS_DARWIN
     1535#ifdef VBOX_WS_MAC
    14291536    /* If menu is consumable: */
    14301537    if (fIsMenuConsumable)
     
    14361543    /* If menu is NOT consumable: */
    14371544    else
    1438 #endif /* RT_OS_DARWIN */
     1545#endif
    14391546    {
    14401547        /* Add action only if is allowed: */
     
    14551562    UIMenu *pMenu = pAction->menu();
    14561563
    1457 #ifdef RT_OS_DARWIN
     1564#ifdef VBOX_WS_MAC
    14581565    /* Check if menu is consumable: */
    14591566    const bool fIsMenuConsumable = pMenu->isConsumable();
    14601567    /* Check if menu is NOT yet consumed: */
    14611568    const bool fIsMenuConsumed = pMenu->isConsumed();
    1462 #endif /* RT_OS_DARWIN */
     1569#endif
    14631570
    14641571    /* Make this action visible
    14651572     * depending on clearance state. */
    14661573    pAction->setVisible(   fIsActionAllowed
    1467 #ifdef RT_OS_DARWIN
     1574#ifdef VBOX_WS_MAC
    14681575                        && !fIsMenuConsumable
    1469 #endif /* RT_OS_DARWIN */
     1576#endif
    14701577                        );
    14711578
    1472 #ifdef RT_OS_DARWIN
     1579#ifdef VBOX_WS_MAC
    14731580    /* If menu is consumable: */
    14741581    if (fIsMenuConsumable)
     
    14801587    /* If menu is NOT consumable: */
    14811588    else
    1482 #endif /* RT_OS_DARWIN */
     1589#endif
    14831590    {
    14841591        /* Add action only if is allowed: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r71027 r71582  
    55
    66/*
    7  * Copyright (C) 2010-2017 Oracle Corporation
     7 * Copyright (C) 2010-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828
    2929/* Forward declarations: */
     30class QKeySequence;
     31class QString;
    3032class UIActionPolymorphic;
    3133class UIActionPolymorphicMenu;
     
    5759    /* 'Application' menu actions: */
    5860    UIActionIndex_M_Application,
    59 #ifdef RT_OS_DARWIN
     61#ifdef VBOX_WS_MAC
    6062    UIActionIndex_M_Application_S_About,
    61 #endif /* RT_OS_DARWIN */
     63#endif
    6264    UIActionIndex_M_Application_S_Preferences,
    6365#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     
    6870    UIActionIndex_M_Application_S_Close,
    6971
    70 #ifdef RT_OS_DARWIN
     72#ifdef VBOX_WS_MAC
    7173    /* 'Window' menu actions: */
    7274    UIActionIndex_M_Window,
    7375    UIActionIndex_M_Window_S_Minimize,
    74 #endif /* RT_OS_DARWIN */
     76#endif
    7577
    7678    /* 'Help' menu actions: */
     
    8183    UIActionIndex_Simple_Forums,
    8284    UIActionIndex_Simple_Oracle,
    83 #ifndef RT_OS_DARWIN
     85#ifndef VBOX_WS_MAC
    8486    UIActionIndex_Simple_About,
    85 #endif /* !RT_OS_DARWIN */
     87#endif
    8688
    8789    /* Maximum index: */
     
    105107public:
    106108
    107     /** Constructor. */
     109    /** Constructs menu. */
    108110    UIMenu();
    109111
     
    125127protected:
    126128
    127     /** General event handler. */
     129    /** Handles any Qt @a pEvent. */
    128130    virtual bool event(QEvent *pEvent);
    129131
     
    150152
    151153    /** Returns action type. */
    152     UIActionType type() const { return m_type; }
     154    UIActionType type() const { return m_enmType; }
    153155
    154156    /** Returns menu contained by this action. */
    155     UIMenu* menu() const;
     157    UIMenu *menu() const;
    156158
    157159    /** Returns action-pool this action belongs to. */
    158     UIActionPool* actionPool() const { return m_pActionPool; }
     160    UIActionPool *actionPool() const { return m_pActionPool; }
    159161
    160162    /** Casts action to polymorphic-action. */
    161     UIActionPolymorphic* toActionPolymorphic();
     163    UIActionPolymorphic *toActionPolymorphic();
    162164    /** Casts action to polymorphic-menu-action. */
    163     UIActionPolymorphicMenu* toActionPolymorphicMenu();
     165    UIActionPolymorphicMenu *toActionPolymorphicMenu();
    164166
    165167    /** Returns current action name. */
    166     const QString& name() const { return m_strName; }
     168    const QString &name() const { return m_strName; }
    167169    /** Defines current action name. */
    168170    void setName(const QString &strName);
     
    189191    /** Retranslates action. */
    190192    virtual void retranslateUi() = 0;
    191     virtual ~UIAction() { delete menu(); }
    192 
    193 protected:
    194 
    195     /** Constructor. */
    196     UIAction(UIActionPool *pParent, UIActionType type);
     193    virtual ~UIAction() /* override */ { delete menu(); }
     194
     195protected:
     196
     197    /** Constructs action passing @a pParent to the base-class.
     198      * @param  enmType  Brings the action type. */
     199    UIAction(UIActionPool *pParent, UIActionType enmType);
    197200
    198201    /** Returns current action name in menu. */
     
    205208
    206209    /** Holds the action type. */
    207     UIActionType m_type;
     210    UIActionType  m_enmType;
    208211
    209212    /** Holds the reference to the action-pool this action belongs to. */
    210     UIActionPool *m_pActionPool;
     213    UIActionPool     *m_pActionPool;
    211214    /** Holds the type of the action-pool this action belongs to. */
    212     UIActionPoolType m_actionPoolType;
     215    UIActionPoolType  m_enmActionPoolType;
    213216
    214217    /** Holds the action name. */
    215     QString m_strName;
     218    QString       m_strName;
    216219    /** Holds the action shortcut. */
    217     QKeySequence m_shortcut;
     220    QKeySequence  m_shortcut;
    218221    /** Holds whether action shortcut hidden. */
    219     bool m_fShortcutHidden;
     222    bool          m_fShortcutHidden;
    220223};
    221224
     
    228231protected:
    229232
    230     /** Constructor, taking normal icon name and name for disabled analog. */
     233    /** Constructs menu action passing @a pParent to the base-class.
     234      * @param  strIcon          Brings the normal-icon name.
     235      * @param  strIconDisabled  Brings the disabled-icon name. */
    231236    UIActionMenu(UIActionPool *pParent,
    232                  const QString &strIcon = QString(), const QString &strIconDis = QString());
    233     /** Constructor, taking copy of existing icon. */
     237                 const QString &strIcon = QString(),
     238                 const QString &strIconDisabled = QString());
     239    /** Constructs menu action passing @a pParent to the base-class.
     240      * @param  icon  Brings the icon. */
    234241    UIActionMenu(UIActionPool *pParent,
    235242                 const QIcon &icon);
     
    255262protected:
    256263
    257     /** Constructor, taking normal icon name and name for disabled analog. */
     264    /** Constructs simple action passing @a pParent to the base-class.
     265      * @param  strIcon          Brings the normal-icon name.
     266      * @param  strIconDisabled  Brings the disabled-icon name. */
    258267    UIActionSimple(UIActionPool *pParent,
    259                    const QString &strIcon = QString(), const QString &strIconDisabled = QString());
    260     /** Constructor, taking normal, small icon names and names for disabled analogs. */
     268                   const QString &strIcon = QString(),
     269                   const QString &strIconDisabled = QString());
     270    /** Constructs simple action passing @a pParent to the base-class.
     271      * @param  strIconNormal          Brings the normal-icon name.
     272      * @param  strIconSmall           Brings the small-icon name.
     273      * @param  strIconNormalDisabled  Brings the normal-disabled-icon name.
     274      * @param  strIconSmallDisabled   Brings the small-disabled-icon name. */
    261275    UIActionSimple(UIActionPool *pParent,
    262276                   const QString &strIconNormal, const QString &strIconSmall,
    263277                   const QString &strIconNormalDisabled, const QString &strIconSmallDisabled);
    264     /** Constructor, taking copy of existing icon. */
     278    /** Constructs simple action passing @a pParent to the base-class.
     279      * @param  icon  Brings the icon. */
    265280    UIActionSimple(UIActionPool *pParent,
    266281                   const QIcon& icon);
     
    275290protected:
    276291
    277     /** Constructor, taking normal icon name and name for disabled analog. */
     292    /** Constructs toggle action passing @a pParent to the base-class.
     293      * @param  strIcon          Brings the normal-icon name.
     294      * @param  strIconDisabled  Brings the disabled-icon name. */
    278295    UIActionToggle(UIActionPool *pParent,
    279296                   const QString &strIcon = QString(), const QString &strIconDisabled = QString());
    280     /** Constructor, taking normal on/off icon names and names for disabled analogs. */
     297    /** Constructs toggle action passing @a pParent to the base-class.
     298      * @param  strIconOn           Brings the on-icon name.
     299      * @param  strIconOff          Brings the off-icon name.
     300      * @param  strIconOnDisabled   Brings the on-disabled-icon name.
     301      * @param  strIconOffDisabled  Brings the off-disabled-icon name. */
    281302    UIActionToggle(UIActionPool *pParent,
    282303                   const QString &strIconOn, const QString &strIconOff,
    283304                   const QString &strIconOnDisabled, const QString &strIconOffDisabled);
    284     /** Constructor, taking copy of existing icon. */
     305    /** Constructs toggle action passing @a pParent to the base-class.
     306      * @param  icon  Brings the icon. */
    285307    UIActionToggle(UIActionPool *pParent,
    286308                   const QIcon &icon);
     
    307329protected:
    308330
    309     /** Constructor, taking normal icon name and name for disabled analog. */
     331    /** Constructs polymorphic action passing @a pParent to the base-class.
     332      * @param  strIcon          Brings the normal-icon name.
     333      * @param  strIconDisabled  Brings the disabled-icon name. */
    310334    UIActionPolymorphic(UIActionPool *pParent,
    311                   const QString &strIcon = QString(), const QString &strIconDisabled = QString());
    312     /** Constructor, taking normal, small icon names and names for disabled analogs. */
     335                        const QString &strIcon = QString(), const QString &strIconDisabled = QString());
     336    /** Constructs polymorphic action passing @a pParent to the base-class.
     337      * @param  strIconNormal          Brings the normal-icon name.
     338      * @param  strIconSmall           Brings the small-icon name.
     339      * @param  strIconNormalDisabled  Brings the normal-disabled-icon name.
     340      * @param  strIconSmallDisabled   Brings the small-disabled-icon name. */
    313341    UIActionPolymorphic(UIActionPool *pParent,
    314                   const QString &strIconNormal, const QString &strIconSmall,
    315                   const QString &strIconNormalDisabled, const QString &strIconSmallDisabled);
    316     /** Constructor, taking copy of existing icon. */
     342                        const QString &strIconNormal, const QString &strIconSmall,
     343                        const QString &strIconNormalDisabled, const QString &strIconSmallDisabled);
     344    /** Constructs polymorphic action passing @a pParent to the base-class.
     345      * @param  icon  Brings the icon. */
    317346    UIActionPolymorphic(UIActionPool *pParent,
    318                   const QIcon& icon);
     347                        const QIcon& icon);
    319348
    320349private:
     
    339368protected:
    340369
    341     /** Constructor, taking normal icon name and name for disabled analog. */
     370    /** Constructs polymorphic menu action passing @a pParent to the base-class.
     371      * @param  strIcon          Brings the normal-icon name.
     372      * @param  strIconDisabled  Brings the disabled-icon name. */
    342373    UIActionPolymorphicMenu(UIActionPool *pParent,
    343                             const QString &strIcon = QString(), const QString &strIconDis = QString());
    344     /** Constructor, taking normal, small icon names and names for disabled analogs. */
     374                            const QString &strIcon = QString(), const QString &strIconDisabled = QString());
     375    /** Constructs polymorphic menu action passing @a pParent to the base-class.
     376      * @param  strIconNormal          Brings the normal-icon name.
     377      * @param  strIconSmall           Brings the small-icon name.
     378      * @param  strIconNormalDisabled  Brings the normal-disabled-icon name.
     379      * @param  strIconSmallDisabled   Brings the small-disabled-icon name. */
    345380    UIActionPolymorphicMenu(UIActionPool *pParent,
    346381                            const QString &strIconNormal, const QString &strIconSmall,
    347382                            const QString &strIconNormalDisabled, const QString &strIconSmallDisabled);
    348     /** Constructor, taking copy of existing icon. */
     383    /** Constructs polymorphic menu action passing @a pParent to the base-class.
     384      * @param  icon  Brings the icon. */
    349385    UIActionPolymorphicMenu(UIActionPool *pParent,
    350386                            const QIcon &icon);
    351387
    352     /** Destructor. */
     388    /** Destructs polymorphic menu action. */
    353389    ~UIActionPolymorphicMenu();
    354390
     
    374410    UIMenu *m_pMenu;
    375411    /** Holds current action state. */
    376     int m_iState;
     412    int     m_iState;
    377413};
    378414
     
    403439    /** Notifies about @a pAction hovered. */
    404440    void sigActionHovered(UIAction *pAction);
    405 #endif /* VBOX_WS_MAC */
     441#endif
    406442
    407443public:
    408444
    409     /** Static factory constructor. */
    410     static UIActionPool* create(UIActionPoolType type);
    411     /** Static factory destructor. */
     445    /** Creates singleton instance. */
     446    static UIActionPool *create(UIActionPoolType enmType);
     447    /** Destroys singleton instance. */
    412448    static void destroy(UIActionPool *pActionPool);
    413449
    414     /** Static factory constructor (temporary),
    415       * used to initialize shortcuts-pool from action-pool of passed @a type. */
    416     static void createTemporary(UIActionPoolType type);
     450    /** Creates temporary singleton instance,
     451      * used to initialize shortcuts-pool from action-pool of passed @a enmType. */
     452    static void createTemporary(UIActionPoolType enmType);
    417453
    418454    /** Cast action-pool to Runtime one. */
    419     UIActionPoolRuntime* toRuntime();
     455    UIActionPoolRuntime *toRuntime();
    420456    /** Cast action-pool to Selector one. */
    421     UIActionPoolSelector* toSelector();
     457    UIActionPoolSelector *toSelector();
    422458
    423459    /** Returns action-pool type. */
    424     UIActionPoolType type() const { return m_type; }
     460    UIActionPoolType type() const { return m_enmType; }
    425461
    426462    /** Returns the action for the passed @a iIndex. */
    427     UIAction* action(int iIndex) const { return m_pool.value(iIndex); }
     463    UIAction *action(int iIndex) const { return m_pool.value(iIndex); }
    428464    /** Returns all the actions action-pool contains. */
    429465    QList<UIAction*> actions() const { return m_pool.values(); }
     
    431467    /** Returns whether the menu with passed @a type is allowed in menu-bar. */
    432468    bool isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType type) const;
    433     /** Defines menu-bar @a restriction for passed @a level. */
    434     void setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType restriction);
     469    /** Defines menu-bar @a enmRestriction for passed @a level. */
     470    void setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType enmRestriction);
    435471
    436472    /** Returns whether the action with passed @a type is allowed in the 'Application' menu. */
    437473    bool isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType type) const;
    438     /** Defines 'Application' menu @a restriction for passed @a level. */
    439     void setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType restriction);
     474    /** Defines 'Application' menu @a enmRestriction for passed @a level. */
     475    void setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType enmRestriction);
    440476
    441477#ifdef VBOX_WS_MAC
    442478    /** Mac OS X: Returns whether the action with passed @a type is allowed in the 'Window' menu. */
    443479    bool isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const;
    444     /** Mac OS X: Defines 'Window' menu @a restriction for passed @a level. */
    445     void setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType restriction);
     480    /** Mac OS X: Defines 'Window' menu @a enmRestriction for passed @a level. */
     481    void setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType enmRestriction);
    446482#endif /* VBOX_WS_MAC */
    447483
    448484    /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */
    449     bool isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType type) const;
    450     /** Defines 'Help' menu @a restriction for passed @a level. */
    451     void setRestrictionForMenuHelp(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuHelpActionType restriction);
     485    bool isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType enmType) const;
     486    /** Defines 'Help' menu @a enmRestriction for passed @a level. */
     487    void setRestrictionForMenuHelp(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuHelpActionType enmRestriction);
    452488
    453489    /** Hot-key processing delegate. */
     
    477513protected:
    478514
    479     /** Constructor of the action-pool of passed @a type. */
    480     UIActionPool(UIActionPoolType type, bool fTemporary = false);
    481 
    482     /** Prepare routine. */
     515    /** Constructs probably @a fTemporary action-pool of passed @a enmType. */
     516    UIActionPool(UIActionPoolType enmType, bool fTemporary = false);
     517
     518    /** Prepares all. */
    483519    void prepare();
    484     /** Prepare pool routine. */
     520    /** Prepares pool. */
    485521    virtual void preparePool();
    486     /** Prepare connections routine. */
     522    /** Prepares connections. */
    487523    virtual void prepareConnections();
    488     /** Cleanup connections routine. */
     524    /** Cleanups connections. */
    489525    virtual void cleanupConnections() {}
    490     /** Cleanup pool routine. */
     526    /** Cleanups pool. */
    491527    virtual void cleanupPool();
    492     /** Cleanup routine. */
     528    /** Cleanups all. */
    493529    void cleanup();
    494530
    495     /** Update configuration routine. */
     531    /** Updates configuration. */
    496532    virtual void updateConfiguration();
    497533
    498     /** Update menu routine. */
     534    /** Updates menu with certain @a iIndex. */
    499535    virtual void updateMenu(int iIndex);
    500     /** Update menus routine. */
     536    /** Updates menus. */
    501537    virtual void updateMenus() = 0;
    502     /** Update 'Application' menu routine. */
     538    /** Updates 'Application' menu. */
    503539    virtual void updateMenuApplication();
    504 #ifdef RT_OS_DARWIN
    505     /** Mac OS X: Update 'Window' menu routine. */
     540#ifdef VBOX_WS_MAC
     541    /** Mac OS X: Updates 'Window' menu. */
    506542    virtual void updateMenuWindow();
    507 #endif /* RT_OS_DARWIN */
    508     /** Update 'Help' menu routine. */
     543#endif
     544    /** Updates 'Help' menu. */
    509545    virtual void updateMenuHelp();
    510546
    511     /** Update shortcuts. */
     547    /** Updates shortcuts. */
    512548    virtual void updateShortcuts();
    513549
    514     /** Translation handler. */
    515     virtual void retranslateUi();
    516 
    517     /** General event handler. */
    518     virtual bool event(QEvent *pEvent);
     550    /** Hadles translation event. */
     551    virtual void retranslateUi() /* override */;
     552
     553    /** Handles any Qt @a pEvent */
     554    virtual bool event(QEvent *pEvent) /* override */;
    519555
    520556    /** Adds action into corresponding menu. */
     
    524560
    525561    /** Holds the action-pool type. */
    526     const UIActionPoolType m_type;
     562    const UIActionPoolType  m_enmType;
    527563    /** Holds whether this action-pool is temporary. */
    528     const bool m_fTemporary;
     564    const bool              m_fTemporary;
    529565
    530566    /** Holds the map of actions. */
    531     QMap<int, UIAction*> m_pool;
     567    QMap<int, UIAction*>          m_pool;
    532568    /** Holds the map of validation handlers. */
    533     QMap<int, PointerToFunction> m_menuUpdateHandlers;
     569    QMap<int, PointerToFunction>  m_menuUpdateHandlers;
    534570    /** Holds the set of invalidated action indexes. */
    535     QSet<int> m_invalidations;
     571    QSet<int>                     m_invalidations;
    536572
    537573    /** Holds restricted menu types. */
    538     QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuType> m_restrictedMenus;
     574    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuType>                   m_restrictedMenus;
    539575    /** Holds restricted action types of the 'Application' menu. */
    540     QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuApplicationActionType> m_restrictedActionsMenuApplication;
     576    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuApplicationActionType>  m_restrictedActionsMenuApplication;
    541577#ifdef VBOX_WS_MAC
    542578    /** Mac OS X: Holds restricted action types of the 'Window' menu. */
    543     QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuWindowActionType> m_restrictedActionsMenuWindow;
    544 #endif /* VBOX_WS_MAC */
     579    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuWindowActionType>       m_restrictedActionsMenuWindow;
     580#endif
    545581    /** Holds restricted action types of the Help menu. */
    546     QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuHelpActionType> m_restrictedActionsMenuHelp;
    547 };
     582    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuHelpActionType>         m_restrictedActionsMenuHelp;
     583};
     584
    548585
    549586#endif /* !___UIActionPool_h___ */
     587
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette