VirtualBox

Changeset 52583 in vbox


Ignore:
Timestamp:
Sep 3, 2014 1:15:23 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Action-pool: Move some code (menu-bar restriction stuff) to corresponding places.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r52459 r52583  
    7070template<> bool canConvert<SizeSuffix>();
    7171template<> bool canConvert<StorageSlot>();
    72 template<> bool canConvert<UIExtraDataMetaDefs::MenuHelpActionType>();
     72template<> bool canConvert<UIExtraDataMetaDefs::MenuType>();
    7373#ifdef Q_WS_MAC
    7474template<> bool canConvert<UIExtraDataMetaDefs::MenuApplicationActionType>();
    7575#endif /* Q_WS_MAC */
    76 template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuType>();
     76template<> bool canConvert<UIExtraDataMetaDefs::MenuHelpActionType>();
    7777template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>();
    7878template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuViewActionType>();
     
    123123template<> QString toString(const StorageSlot &storageSlot);
    124124template<> StorageSlot fromString<StorageSlot>(const QString &strStorageSlot);
    125 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuHelpActionType &menuHelpActionType);
    126 template<> UIExtraDataMetaDefs::MenuHelpActionType fromInternalString<UIExtraDataMetaDefs::MenuHelpActionType>(const QString &strMenuHelpActionType);
     125template<> QString toInternalString(const UIExtraDataMetaDefs::MenuType &menuType);
     126template<> UIExtraDataMetaDefs::MenuType fromInternalString<UIExtraDataMetaDefs::MenuType>(const QString &strMenuType);
    127127#ifdef Q_WS_MAC
    128128template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType &runtimeMenuApplicationActionType);
    129129template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &strRuntimeMenuApplicationActionType);
    130130#endif /* Q_WS_MAC */
    131 template<> QString toInternalString(const UIExtraDataMetaDefs::RuntimeMenuType &runtimeMenuType);
    132 template<> UIExtraDataMetaDefs::RuntimeMenuType fromInternalString<UIExtraDataMetaDefs::RuntimeMenuType>(const QString &strRuntimeMenuType);
     131template<> QString toInternalString(const UIExtraDataMetaDefs::MenuHelpActionType &menuHelpActionType);
     132template<> UIExtraDataMetaDefs::MenuHelpActionType fromInternalString<UIExtraDataMetaDefs::MenuHelpActionType>(const QString &strMenuHelpActionType);
    133133template<> QString toInternalString(const UIExtraDataMetaDefs::RuntimeMenuMachineActionType &runtimeMenuMachineActionType);
    134134template<> UIExtraDataMetaDefs::RuntimeMenuMachineActionType fromInternalString<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>(const QString &strRuntimeMenuMachineActionType);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r52557 r52583  
    3434template<> bool canConvert<SizeSuffix>() { return true; }
    3535template<> bool canConvert<StorageSlot>() { return true; }
    36 template<> bool canConvert<UIExtraDataMetaDefs::MenuHelpActionType>() { return true; }
     36template<> bool canConvert<UIExtraDataMetaDefs::MenuType>() { return true; }
    3737#ifdef Q_WS_MAC
    3838template<> bool canConvert<UIExtraDataMetaDefs::MenuApplicationActionType>() { return true; }
    3939#endif /* Q_WS_MAC */
    40 template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuType>() { return true; }
     40template<> bool canConvert<UIExtraDataMetaDefs::MenuHelpActionType>() { return true; }
    4141template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuMachineActionType>() { return true; }
    4242template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuViewActionType>() { return true; }
     
    357357}
    358358
     359/* QString <= UIExtraDataMetaDefs::MenuType: */
     360template<> QString toInternalString(const UIExtraDataMetaDefs::MenuType &menuType)
     361{
     362    QString strResult;
     363    switch (menuType)
     364    {
     365#ifdef RT_OS_DARWIN
     366        case UIExtraDataMetaDefs::MenuType_Application: strResult = "Application"; break;
     367#endif /* RT_OS_DARWIN */
     368        case UIExtraDataMetaDefs::MenuType_Machine:     strResult = "Machine"; break;
     369        case UIExtraDataMetaDefs::MenuType_View:        strResult = "View"; break;
     370        case UIExtraDataMetaDefs::MenuType_Devices:     strResult = "Devices"; break;
     371#ifdef VBOX_WITH_DEBUGGER_GUI
     372        case UIExtraDataMetaDefs::MenuType_Debug:       strResult = "Debug"; break;
     373#endif /* VBOX_WITH_DEBUGGER_GUI */
     374        case UIExtraDataMetaDefs::MenuType_Help:        strResult = "Help"; break;
     375        case UIExtraDataMetaDefs::MenuType_All:         strResult = "All"; break;
     376        default:
     377        {
     378            AssertMsgFailed(("No text for indicator type=%d", menuType));
     379            break;
     380        }
     381    }
     382    return strResult;
     383}
     384
     385/* UIExtraDataMetaDefs::MenuType <= QString: */
     386template<> UIExtraDataMetaDefs::MenuType fromInternalString<UIExtraDataMetaDefs::MenuType>(const QString &strMenuType)
     387{
     388    /* Here we have some fancy stuff allowing us
     389     * to search through the keys using 'case-insensitive' rule: */
     390    QStringList keys;      QList<UIExtraDataMetaDefs::MenuType> values;
     391#ifdef RT_OS_DARWIN
     392    keys << "Application"; values << UIExtraDataMetaDefs::MenuType_Application;
     393#endif /* RT_OS_DARWIN */
     394    keys << "Machine";     values << UIExtraDataMetaDefs::MenuType_Machine;
     395    keys << "View";        values << UIExtraDataMetaDefs::MenuType_View;
     396    keys << "Devices";     values << UIExtraDataMetaDefs::MenuType_Devices;
     397#ifdef VBOX_WITH_DEBUGGER_GUI
     398    keys << "Debug";       values << UIExtraDataMetaDefs::MenuType_Debug;
     399#endif /* VBOX_WITH_DEBUGGER_GUI */
     400    keys << "Help";        values << UIExtraDataMetaDefs::MenuType_Help;
     401    keys << "All";         values << UIExtraDataMetaDefs::MenuType_All;
     402    /* Invalid type for unknown words: */
     403    if (!keys.contains(strMenuType, Qt::CaseInsensitive))
     404        return UIExtraDataMetaDefs::MenuType_Invalid;
     405    /* Corresponding type for known words: */
     406    return values.at(keys.indexOf(QRegExp(strMenuType, Qt::CaseInsensitive)));
     407}
     408
     409#ifdef Q_WS_MAC
     410/* QString <= UIExtraDataMetaDefs::MenuApplicationActionType: */
     411template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType &runtimeMenuApplicationActionType)
     412{
     413    QString strResult;
     414    switch (runtimeMenuApplicationActionType)
     415    {
     416        case UIExtraDataMetaDefs::MenuApplicationActionType_About:       strResult = "About"; break;
     417        case UIExtraDataMetaDefs::MenuApplicationActionType_Preferences: strResult = "Preferences"; break;
     418        case UIExtraDataMetaDefs::MenuApplicationActionType_Close:       strResult = "Close"; break;
     419        case UIExtraDataMetaDefs::MenuApplicationActionType_All:         strResult = "All"; break;
     420        default:
     421        {
     422            AssertMsgFailed(("No text for action type=%d", runtimeMenuApplicationActionType));
     423            break;
     424        }
     425    }
     426    return strResult;
     427}
     428
     429/* UIExtraDataMetaDefs::MenuApplicationActionType <= QString: */
     430template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &strRuntimeMenuApplicationActionType)
     431{
     432    /* Here we have some fancy stuff allowing us
     433     * to search through the keys using 'case-insensitive' rule: */
     434    QStringList keys;      QList<UIExtraDataMetaDefs::MenuApplicationActionType> values;
     435    keys << "About";       values << UIExtraDataMetaDefs::MenuApplicationActionType_About;
     436    keys << "Preferences"; values << UIExtraDataMetaDefs::MenuApplicationActionType_Preferences;
     437    keys << "Close";       values << UIExtraDataMetaDefs::MenuApplicationActionType_Close;
     438    keys << "All";         values << UIExtraDataMetaDefs::MenuApplicationActionType_All;
     439    /* Invalid type for unknown words: */
     440    if (!keys.contains(strRuntimeMenuApplicationActionType, Qt::CaseInsensitive))
     441        return UIExtraDataMetaDefs::MenuApplicationActionType_Invalid;
     442    /* Corresponding type for known words: */
     443    return values.at(keys.indexOf(QRegExp(strRuntimeMenuApplicationActionType, Qt::CaseInsensitive)));
     444}
     445#endif /* Q_WS_MAC */
     446
    359447/* QString <= UIExtraDataMetaDefs::MenuHelpActionType: */
    360448template<> QString toInternalString(const UIExtraDataMetaDefs::MenuHelpActionType &menuHelpActionType)
     
    407495    /* Corresponding type for known words: */
    408496    return values.at(keys.indexOf(QRegExp(strMenuHelpActionType, Qt::CaseInsensitive)));
    409 }
    410 
    411 #ifdef Q_WS_MAC
    412 /* QString <= UIExtraDataMetaDefs::MenuApplicationActionType: */
    413 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType &runtimeMenuApplicationActionType)
    414 {
    415     QString strResult;
    416     switch (runtimeMenuApplicationActionType)
    417     {
    418         case UIExtraDataMetaDefs::MenuApplicationActionType_About:       strResult = "About"; break;
    419         case UIExtraDataMetaDefs::MenuApplicationActionType_Preferences: strResult = "Preferences"; break;
    420         case UIExtraDataMetaDefs::MenuApplicationActionType_Close:       strResult = "Close"; break;
    421         case UIExtraDataMetaDefs::MenuApplicationActionType_All:         strResult = "All"; break;
    422         default:
    423         {
    424             AssertMsgFailed(("No text for action type=%d", runtimeMenuApplicationActionType));
    425             break;
    426         }
    427     }
    428     return strResult;
    429 }
    430 
    431 /* UIExtraDataMetaDefs::MenuApplicationActionType <= QString: */
    432 template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &strRuntimeMenuApplicationActionType)
    433 {
    434     /* Here we have some fancy stuff allowing us
    435      * to search through the keys using 'case-insensitive' rule: */
    436     QStringList keys;      QList<UIExtraDataMetaDefs::MenuApplicationActionType> values;
    437     keys << "About";       values << UIExtraDataMetaDefs::MenuApplicationActionType_About;
    438     keys << "Preferences"; values << UIExtraDataMetaDefs::MenuApplicationActionType_Preferences;
    439     keys << "Close";       values << UIExtraDataMetaDefs::MenuApplicationActionType_Close;
    440     keys << "All";         values << UIExtraDataMetaDefs::MenuApplicationActionType_All;
    441     /* Invalid type for unknown words: */
    442     if (!keys.contains(strRuntimeMenuApplicationActionType, Qt::CaseInsensitive))
    443         return UIExtraDataMetaDefs::MenuApplicationActionType_Invalid;
    444     /* Corresponding type for known words: */
    445     return values.at(keys.indexOf(QRegExp(strRuntimeMenuApplicationActionType, Qt::CaseInsensitive)));
    446 }
    447 #endif /* Q_WS_MAC */
    448 
    449 /* QString <= UIExtraDataMetaDefs::RuntimeMenuType: */
    450 template<> QString toInternalString(const UIExtraDataMetaDefs::RuntimeMenuType &runtimeMenuType)
    451 {
    452     QString strResult;
    453     switch (runtimeMenuType)
    454     {
    455 #ifdef RT_OS_DARWIN
    456         case UIExtraDataMetaDefs::RuntimeMenuType_Application: strResult = "Application"; break;
    457 #endif /* RT_OS_DARWIN */
    458         case UIExtraDataMetaDefs::RuntimeMenuType_Machine:     strResult = "Machine"; break;
    459         case UIExtraDataMetaDefs::RuntimeMenuType_View:        strResult = "View"; break;
    460         case UIExtraDataMetaDefs::RuntimeMenuType_Devices:     strResult = "Devices"; break;
    461 #ifdef VBOX_WITH_DEBUGGER_GUI
    462         case UIExtraDataMetaDefs::RuntimeMenuType_Debug:       strResult = "Debug"; break;
    463 #endif /* VBOX_WITH_DEBUGGER_GUI */
    464         case UIExtraDataMetaDefs::RuntimeMenuType_Help:        strResult = "Help"; break;
    465         case UIExtraDataMetaDefs::RuntimeMenuType_All:         strResult = "All"; break;
    466         default:
    467         {
    468             AssertMsgFailed(("No text for indicator type=%d", runtimeMenuType));
    469             break;
    470         }
    471     }
    472     return strResult;
    473 }
    474 
    475 /* UIExtraDataMetaDefs::RuntimeMenuType <= QString: */
    476 template<> UIExtraDataMetaDefs::RuntimeMenuType fromInternalString<UIExtraDataMetaDefs::RuntimeMenuType>(const QString &strRuntimeMenuType)
    477 {
    478     /* Here we have some fancy stuff allowing us
    479      * to search through the keys using 'case-insensitive' rule: */
    480     QStringList keys;      QList<UIExtraDataMetaDefs::RuntimeMenuType> values;
    481 #ifdef RT_OS_DARWIN
    482     keys << "Application"; values << UIExtraDataMetaDefs::RuntimeMenuType_Application;
    483 #endif /* RT_OS_DARWIN */
    484     keys << "Machine";     values << UIExtraDataMetaDefs::RuntimeMenuType_Machine;
    485     keys << "View";        values << UIExtraDataMetaDefs::RuntimeMenuType_View;
    486     keys << "Devices";     values << UIExtraDataMetaDefs::RuntimeMenuType_Devices;
    487 #ifdef VBOX_WITH_DEBUGGER_GUI
    488     keys << "Debug";       values << UIExtraDataMetaDefs::RuntimeMenuType_Debug;
    489 #endif /* VBOX_WITH_DEBUGGER_GUI */
    490     keys << "Help";        values << UIExtraDataMetaDefs::RuntimeMenuType_Help;
    491     keys << "All";         values << UIExtraDataMetaDefs::RuntimeMenuType_All;
    492     /* Invalid type for unknown words: */
    493     if (!keys.contains(strRuntimeMenuType, Qt::CaseInsensitive))
    494         return UIExtraDataMetaDefs::RuntimeMenuType_Invalid;
    495     /* Corresponding type for known words: */
    496     return values.at(keys.indexOf(QRegExp(strRuntimeMenuType, Qt::CaseInsensitive)));
    497497}
    498498
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r52557 r52583  
    268268{
    269269    Q_OBJECT;
    270     Q_ENUMS(MenuHelpActionType);
     270    Q_ENUMS(MenuType);
    271271#ifdef RT_OS_DARWIN
    272272    Q_ENUMS(MenuApplicationActionType);
    273273#endif /* RT_OS_DARWIN */
    274     Q_ENUMS(RuntimeMenuType);
     274    Q_ENUMS(MenuHelpActionType);
    275275    Q_ENUMS(RuntimeMenuMachineActionType);
    276276    Q_ENUMS(RuntimeMenuViewActionType);
     
    281281
    282282public:
     283
     284    /** Common UI: Menu types. */
     285    enum MenuType
     286    {
     287        MenuType_Invalid     = 0,
     288#ifdef RT_OS_DARWIN
     289        MenuType_Application = RT_BIT(0),
     290#endif /* RT_OS_DARWIN */
     291        MenuType_Machine     = RT_BIT(1),
     292        MenuType_View        = RT_BIT(2),
     293        MenuType_Devices     = RT_BIT(3),
     294#ifdef VBOX_WITH_DEBUGGER_GUI
     295        MenuType_Debug       = RT_BIT(4),
     296#endif /* VBOX_WITH_DEBUGGER_GUI */
     297        MenuType_Help        = RT_BIT(5),
     298        MenuType_All         = 0xFF
     299    };
     300
     301#ifdef RT_OS_DARWIN
     302    /** Menu "Application": Action types. */
     303    enum MenuApplicationActionType
     304    {
     305        MenuApplicationActionType_Invalid     = 0,
     306        MenuApplicationActionType_About       = RT_BIT(0),
     307        MenuApplicationActionType_Preferences = RT_BIT(1),
     308        MenuApplicationActionType_Close       = RT_BIT(2),
     309        MenuApplicationActionType_All         = 0xFFFF
     310    };
     311#endif /* RT_OS_DARWIN */
    283312
    284313    /** Menu "Help": Action types. */
     
    298327#endif /* !RT_OS_DARWIN */
    299328        MenuHelpActionType_All                  = 0xFFFF
    300     };
    301 
    302 #ifdef RT_OS_DARWIN
    303     /** Menu "Application": Action types. */
    304     enum MenuApplicationActionType
    305     {
    306         MenuApplicationActionType_Invalid     = 0,
    307         MenuApplicationActionType_About       = RT_BIT(0),
    308         MenuApplicationActionType_Preferences = RT_BIT(1),
    309         MenuApplicationActionType_Close       = RT_BIT(2),
    310         MenuApplicationActionType_All         = 0xFFFF
    311     };
    312 #endif /* RT_OS_DARWIN */
    313 
    314     /** Runtime UI: Menu types. */
    315     enum RuntimeMenuType
    316     {
    317         RuntimeMenuType_Invalid     = 0,
    318 #ifdef RT_OS_DARWIN
    319         RuntimeMenuType_Application = RT_BIT(0),
    320 #endif /* RT_OS_DARWIN */
    321         RuntimeMenuType_Machine     = RT_BIT(1),
    322         RuntimeMenuType_View        = RT_BIT(2),
    323         RuntimeMenuType_Devices     = RT_BIT(3),
    324 #ifdef VBOX_WITH_DEBUGGER_GUI
    325         RuntimeMenuType_Debug       = RT_BIT(4),
    326 #endif /* VBOX_WITH_DEBUGGER_GUI */
    327         RuntimeMenuType_Help        = RT_BIT(5),
    328         RuntimeMenuType_All         = 0xFF
    329329    };
    330330
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r52556 r52583  
    24892489}
    24902490
    2491 UIExtraDataMetaDefs::RuntimeMenuType UIExtraDataManager::restrictedRuntimeMenuTypes(const QString &strID)
     2491UIExtraDataMetaDefs::MenuType UIExtraDataManager::restrictedRuntimeMenuTypes(const QString &strID)
    24922492{
    24932493    /* Prepare result: */
    2494     UIExtraDataMetaDefs::RuntimeMenuType result = UIExtraDataMetaDefs::RuntimeMenuType_Invalid;
     2494    UIExtraDataMetaDefs::MenuType result = UIExtraDataMetaDefs::MenuType_Invalid;
    24952495    /* Get restricted runtime-menu-types: */
    24962496    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeMenus, strID))
    24972497    {
    2498         UIExtraDataMetaDefs::RuntimeMenuType value = gpConverter->fromInternalString<UIExtraDataMetaDefs::RuntimeMenuType>(strValue);
    2499         if (value != UIExtraDataMetaDefs::RuntimeMenuType_Invalid)
    2500             result = static_cast<UIExtraDataMetaDefs::RuntimeMenuType>(result | value);
     2498        UIExtraDataMetaDefs::MenuType value = gpConverter->fromInternalString<UIExtraDataMetaDefs::MenuType>(strValue);
     2499        if (value != UIExtraDataMetaDefs::MenuType_Invalid)
     2500            result = static_cast<UIExtraDataMetaDefs::MenuType>(result | value);
    25012501    }
    25022502    /* Return result: */
     
    25042504}
    25052505
    2506 void UIExtraDataManager::setRestrictedRuntimeMenuTypes(UIExtraDataMetaDefs::RuntimeMenuType types, const QString &strID)
    2507 {
    2508     /* We have RuntimeMenuType enum registered, so we can enumerate it: */
     2506void UIExtraDataManager::setRestrictedRuntimeMenuTypes(UIExtraDataMetaDefs::MenuType types, const QString &strID)
     2507{
     2508    /* We have MenuType enum registered, so we can enumerate it: */
    25092509    const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
    2510     const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuType");
     2510    const int iEnumIndex = smo.indexOfEnumerator("MenuType");
    25112511    QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
    25122512
    25132513    /* Prepare result: */
    25142514    QStringList result;
    2515     /* Handle RuntimeMenuType_All enum-value: */
    2516     if (types == UIExtraDataMetaDefs::RuntimeMenuType_All)
     2515    /* Handle MenuType_All enum-value: */
     2516    if (types == UIExtraDataMetaDefs::MenuType_All)
    25172517        result << gpConverter->toInternalString(types);
    25182518    else
     
    25222522        {
    25232523            /* Get iterated enum-value: */
    2524             const UIExtraDataMetaDefs::RuntimeMenuType enumValue =
    2525                 static_cast<const UIExtraDataMetaDefs::RuntimeMenuType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
    2526             /* Skip RuntimeMenuType_Invalid & RuntimeMenuType_All enum-values: */
    2527             if (enumValue == UIExtraDataMetaDefs::RuntimeMenuType_Invalid ||
    2528                 enumValue == UIExtraDataMetaDefs::RuntimeMenuType_All)
     2524            const UIExtraDataMetaDefs::MenuType enumValue =
     2525                static_cast<const UIExtraDataMetaDefs::MenuType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
     2526            /* Skip MenuType_Invalid & MenuType_All enum-values: */
     2527            if (enumValue == UIExtraDataMetaDefs::MenuType_Invalid ||
     2528                enumValue == UIExtraDataMetaDefs::MenuType_All)
    25292529                continue;
    25302530            if (types & enumValue)
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r52556 r52583  
    287287
    288288        /** Returns restricted Runtime UI menu types. */
    289         UIExtraDataMetaDefs::RuntimeMenuType restrictedRuntimeMenuTypes(const QString &strID);
     289        UIExtraDataMetaDefs::MenuType restrictedRuntimeMenuTypes(const QString &strID);
    290290        /** Defines restricted Runtime UI menu types. */
    291         void setRestrictedRuntimeMenuTypes(UIExtraDataMetaDefs::RuntimeMenuType types, const QString &strID);
     291        void setRestrictedRuntimeMenuTypes(UIExtraDataMetaDefs::MenuType types, const QString &strID);
    292292
    293293#ifdef Q_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r52579 r52583  
    326326
    327327    /** Returns action extra-data ID. */
    328     virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuType_Application; }
     328    virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuType_Application; }
    329329    /** Returns action extra-data key. */
    330     virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuType_Application); }
     330    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Application); }
    331331
    332332    void retranslateUi()
     
    388388
    389389    /** Returns action extra-data ID. */
    390     virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuType_Help; }
     390    virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuType_Help; }
    391391    /** Returns action extra-data key. */
    392     virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuType_Help); }
     392    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Help); }
    393393
    394394    void retranslateUi()
     
    724724}
    725725
     726bool UIActionPool::isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType type) const
     727{
     728    foreach (const UIExtraDataMetaDefs::MenuType &restriction, m_restrictedMenus.values())
     729        if (restriction & type)
     730            return false;
     731    return true;
     732}
     733
     734void UIActionPool::setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType restriction)
     735{
     736    m_restrictedMenus[level] = restriction;
     737    updateMenus();
     738}
     739
     740#ifdef Q_WS_MAC
     741bool UIActionPool::isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType type) const
     742{
     743    foreach (const UIExtraDataMetaDefs::MenuApplicationActionType &restriction, m_restrictedActionsMenuApplication.values())
     744        if (restriction & type)
     745            return false;
     746    return true;
     747}
     748
     749void UIActionPool::setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType restriction)
     750{
     751    m_restrictedActionsMenuApplication[level] = restriction;
     752    m_invalidations << UIActionIndex_M_Application;
     753}
     754#endif /* Q_WS_MAC */
     755
    726756bool UIActionPool::isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType type) const
    727757{
     
    737767    m_invalidations << UIActionIndex_Menu_Help;
    738768}
    739 
    740 #ifdef Q_WS_MAC
    741 bool UIActionPool::isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType type) const
    742 {
    743     foreach (const UIExtraDataMetaDefs::MenuApplicationActionType &restriction, m_restrictedActionsMenuApplication.values())
    744         if (restriction & type)
    745             return false;
    746     return true;
    747 }
    748 
    749 void UIActionPool::setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType restriction)
    750 {
    751     m_restrictedActionsMenuApplication[level] = restriction;
    752     m_invalidations << UIActionIndex_M_Application;
    753 }
    754 #endif /* Q_WS_MAC */
    755769
    756770void UIActionPool::sltHandleMenuPrepare()
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r52579 r52583  
    355355    QList<UIAction*> actions() const { return m_pool.values(); }
    356356
    357     /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */
    358     bool isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType type) const;
    359     /** Defines 'Help' menu @a restriction for passed @a level. */
    360     void setRestrictionForMenuHelp(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuHelpActionType restriction);
     357    /** Returns whether the menu with passed @a type is allowed in menu-bar. */
     358    bool isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType type) const;
     359    /** Defines menu-bar @a restriction for passed @a level. */
     360    void setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuType restriction);
    361361
    362362#ifdef Q_WS_MAC
     
    366366    void setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType restriction);
    367367#endif /* Q_WS_MAC */
     368
     369    /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */
     370    bool isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType type) const;
     371    /** Defines 'Help' menu @a restriction for passed @a level. */
     372    void setRestrictionForMenuHelp(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuHelpActionType restriction);
    368373
    369374    /** Hot-key processing delegate. */
     
    437442    QSet<int> m_invalidations;
    438443
    439     /** Holds restricted action types of the Help menu. */
    440     QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuHelpActionType> m_restrictedActionsMenuHelp;
     444    /** Holds restricted menu types. */
     445    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuType> m_restrictedMenus;
    441446#ifdef Q_WS_MAC
    442447    /** Holds restricted action types of the Application menu. */
    443448    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuApplicationActionType> m_restrictedActionsMenuApplication;
    444449#endif /* Q_WS_MAC */
     450    /** Holds restricted action types of the Help menu. */
     451    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuHelpActionType> m_restrictedActionsMenuHelp;
    445452};
    446453
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r52579 r52583  
    4646
    4747    /** Returns action extra-data ID. */
    48     virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuType_Machine; }
    49     /** Returns action extra-data key. */
    50     virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuType_Machine); }
     48    virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuType_Machine; }
     49    /** Returns action extra-data key. */
     50    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Machine); }
    5151
    5252    void retranslateUi()
     
    574574
    575575    /** Returns action extra-data ID. */
    576     virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuType_View; }
    577     /** Returns action extra-data key. */
    578     virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuType_View); }
     576    virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuType_View; }
     577    /** Returns action extra-data key. */
     578    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_View); }
    579579
    580580    void retranslateUi()
     
    596596
    597597    /** Returns action extra-data ID. */
    598     virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuType_View; }
    599     /** Returns action extra-data key. */
    600     virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuType_View); }
     598    virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuType_View; }
     599    /** Returns action extra-data key. */
     600    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_View); }
    601601
    602602    void retranslateUi() {}
     
    917917
    918918    /** Returns action extra-data ID. */
    919     virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuType_Devices; }
    920     /** Returns action extra-data key. */
    921     virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuType_Devices); }
     919    virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuType_Devices; }
     920    /** Returns action extra-data key. */
     921    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Devices); }
    922922
    923923    void retranslateUi()
     
    14081408
    14091409    /** Returns action extra-data ID. */
    1410     virtual int extraDataID() const { return UIExtraDataMetaDefs::RuntimeMenuType_Debug; }
    1411     /** Returns action extra-data key. */
    1412     virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::RuntimeMenuType_Debug); }
     1410    virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuType_Debug; }
     1411    /** Returns action extra-data key. */
     1412    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Debug); }
    14131413
    14141414    void retranslateUi()
     
    16431643    /* Invalidate View menu: */
    16441644    m_invalidations << UIActionIndexRT_M_View;
    1645 }
    1646 
    1647 bool UIActionPoolRuntime::isAllowedInMenuBar(UIExtraDataMetaDefs::RuntimeMenuType type) const
    1648 {
    1649     foreach (const UIExtraDataMetaDefs::RuntimeMenuType &restriction, m_restrictedMenus.values())
    1650         if (restriction & type)
    1651             return false;
    1652     return true;
    1653 }
    1654 
    1655 void UIActionPoolRuntime::setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::RuntimeMenuType restriction)
    1656 {
    1657     m_restrictedMenus[level] = restriction;
    1658     updateMenus();
    16591645}
    16601646
     
    20091995
    20101996    /* 'Machine' menu: */
    2011     const bool fAllowToShowMenuMachine = isAllowedInMenuBar(UIExtraDataMetaDefs::RuntimeMenuType_Machine);
     1997    const bool fAllowToShowMenuMachine = isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Machine);
    20121998    action(UIActionIndexRT_M_Machine)->setVisible(fAllowToShowMenuMachine);
    20131999    if (fAllowToShowMenuMachine)
     
    20162002
    20172003    /* 'View' menu: */
    2018     const bool fAllowToShowMenuView = isAllowedInMenuBar(UIExtraDataMetaDefs::RuntimeMenuType_View);
     2004    const bool fAllowToShowMenuView = isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_View);
    20192005    action(UIActionIndexRT_M_View)->setVisible(fAllowToShowMenuView);
    20202006    action(UIActionIndexRT_M_ViewPopup)->setVisible(fAllowToShowMenuView);
     
    20252011
    20262012    /* 'Devices' menu: */
    2027     const bool fAllowToShowMenuDevices = isAllowedInMenuBar(UIExtraDataMetaDefs::RuntimeMenuType_Devices);
     2013    const bool fAllowToShowMenuDevices = isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Devices);
    20282014    action(UIActionIndexRT_M_Devices)->setVisible(fAllowToShowMenuDevices);
    20292015    if (fAllowToShowMenuDevices)
     
    20332019#ifdef VBOX_WITH_DEBUGGER_GUI
    20342020    /* 'Debug' menu: */
    2035     const bool fAllowToShowMenuDebug = isAllowedInMenuBar(UIExtraDataMetaDefs::RuntimeMenuType_Debug);
     2021    const bool fAllowToShowMenuDebug = isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Debug);
    20362022    action(UIActionIndexRT_M_Debug)->setVisible(fAllowToShowMenuDebug);
    20372023    if (fAllowToShowMenuDebug)
     
    20412027
    20422028    /* 'Help' menu: */
    2043     const bool fAllowToShowMenuHelp = isAllowedInMenuBar(UIExtraDataMetaDefs::RuntimeMenuType_Help);
     2029    const bool fAllowToShowMenuHelp = isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Help);
    20442030    action(UIActionIndex_Menu_Help)->setVisible(fAllowToShowMenuHelp);
    20452031    if (fAllowToShowMenuHelp)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h

    r52579 r52583  
    146146    /** Returns UI multi-screen layout object reference. */
    147147    UIMultiScreenLayout* multiScreenLayout() const { return m_pMultiScreenLayout; }
    148 
    149     /** Returns whether the menu with passed @a type is allowed in menu-bar. */
    150     bool isAllowedInMenuBar(UIExtraDataMetaDefs::RuntimeMenuType type) const;
    151     /** Defines menu-bar @a restriction for passed @a level. */
    152     void setRestrictionForMenuBar(UIActionRestrictionLevel level, UIExtraDataMetaDefs::RuntimeMenuType restriction);
    153148
    154149    /** Returns whether the action with passed @a type is allowed in the 'Machine' menu. */
     
    267262    QList<QMenu*> m_mainMenus;
    268263
    269     /** Holds restricted menu types. */
    270     QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::RuntimeMenuType> m_restrictedMenus;
    271264    /** Holds restricted action types of the Machine menu. */
    272265    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::RuntimeMenuMachineActionType> m_restrictedActionsMenuMachine;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.cpp

    r52579 r52583  
    172172    switch (pAction->property("class").toInt())
    173173    {
    174         case UIExtraDataMetaDefs::RuntimeMenuType_All:
     174        case UIExtraDataMetaDefs::MenuType_All:
    175175        {
    176176            /* Get sender type: */
    177             const UIExtraDataMetaDefs::RuntimeMenuType type =
    178                 static_cast<UIExtraDataMetaDefs::RuntimeMenuType>(pAction->property("type").toInt());
     177            const UIExtraDataMetaDefs::MenuType type =
     178                static_cast<UIExtraDataMetaDefs::MenuType>(pAction->property("type").toInt());
    179179            /* Load current menu-bar restrictions: */
    180             UIExtraDataMetaDefs::RuntimeMenuType restrictions = gEDataManager->restrictedRuntimeMenuTypes(vboxGlobal().managedVMUuid());
     180            UIExtraDataMetaDefs::MenuType restrictions = gEDataManager->restrictedRuntimeMenuTypes(vboxGlobal().managedVMUuid());
    181181            /* Invert restriction for sender type: */
    182             restrictions = (UIExtraDataMetaDefs::RuntimeMenuType)(restrictions ^ type);
     182            restrictions = (UIExtraDataMetaDefs::MenuType)(restrictions ^ type);
    183183            /* Save updated menu-bar restrictions: */
    184184            gEDataManager->setRestrictedRuntimeMenuTypes(restrictions, vboxGlobal().managedVMUuid());
     
    186186        }
    187187#ifdef Q_WS_MAC
    188         case UIExtraDataMetaDefs::RuntimeMenuType_Application:
     188        case UIExtraDataMetaDefs::MenuType_Application:
    189189        {
    190190            /* Get sender type: */
     
    200200        }
    201201#endif /* Q_WS_MAC */
    202         case UIExtraDataMetaDefs::RuntimeMenuType_Machine:
     202        case UIExtraDataMetaDefs::MenuType_Machine:
    203203        {
    204204            /* Get sender type: */
     
    213213            break;
    214214        }
    215         case UIExtraDataMetaDefs::RuntimeMenuType_View:
     215        case UIExtraDataMetaDefs::MenuType_View:
    216216        {
    217217            /* Get sender type: */
     
    226226            break;
    227227        }
    228         case UIExtraDataMetaDefs::RuntimeMenuType_Devices:
     228        case UIExtraDataMetaDefs::MenuType_Devices:
    229229        {
    230230            /* Get sender type: */
     
    240240        }
    241241#ifdef VBOX_WITH_DEBUGGER_GUI
    242         case UIExtraDataMetaDefs::RuntimeMenuType_Debug:
     242        case UIExtraDataMetaDefs::MenuType_Debug:
    243243        {
    244244            /* Get sender type: */
     
    254254        }
    255255#endif /* VBOX_WITH_DEBUGGER_GUI */
    256         case UIExtraDataMetaDefs::RuntimeMenuType_Help:
     256        case UIExtraDataMetaDefs::MenuType_Help:
    257257        {
    258258            /* Get sender type: */
     
    350350    {
    351351        /* Configure named menu: */
    352         pNamedMenu->setProperty("class", UIExtraDataMetaDefs::RuntimeMenuType_Application);
     352        pNamedMenu->setProperty("class", UIExtraDataMetaDefs::MenuType_Application);
    353353        /* Get named menu action: */
    354354        QAction *pNamedMenuAction = pNamedMenu->menuAction();
     
    395395            /* Configure copied menu action: */
    396396            pCopiedMenuAction->setCheckable(true);
    397             pCopiedMenuAction->setProperty("class", UIExtraDataMetaDefs::RuntimeMenuType_All);
     397            pCopiedMenuAction->setProperty("class", UIExtraDataMetaDefs::MenuType_All);
    398398            pCopiedMenuAction->setProperty("type", pAction->extraDataID());
    399399            connect(pCopiedMenuAction, SIGNAL(triggered(bool)), this, SLOT(sltHandleMenuBarMenuClick()));
     
    591591{
    592592    /* Recache menu-bar configuration: */
    593     const UIExtraDataMetaDefs::RuntimeMenuType restrictionsMenuBar = gEDataManager->restrictedRuntimeMenuTypes(vboxGlobal().managedVMUuid());
     593    const UIExtraDataMetaDefs::MenuType restrictionsMenuBar = gEDataManager->restrictedRuntimeMenuTypes(vboxGlobal().managedVMUuid());
    594594    /* Get static meta-object: */
    595595    const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
    596596
    597     /* We have UIExtraDataMetaDefs::RuntimeMenuType enum registered, so we can enumerate it: */
    598     const int iEnumIndex = smo.indexOfEnumerator("RuntimeMenuType");
     597    /* We have UIExtraDataMetaDefs::MenuType enum registered, so we can enumerate it: */
     598    const int iEnumIndex = smo.indexOfEnumerator("MenuType");
    599599    const QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
    600600    /* Handle other enum-values: */
     
    602602    {
    603603        /* Get iterated enum-value: */
    604         const UIExtraDataMetaDefs::RuntimeMenuType enumValue =
    605             static_cast<const UIExtraDataMetaDefs::RuntimeMenuType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
    606         /* Skip RuntimeMenuType_Invalid & RuntimeMenuType_All enum-value: */
    607         if (enumValue == UIExtraDataMetaDefs::RuntimeMenuType_Invalid ||
    608             enumValue == UIExtraDataMetaDefs::RuntimeMenuType_All)
     604        const UIExtraDataMetaDefs::MenuType enumValue =
     605            static_cast<const UIExtraDataMetaDefs::MenuType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
     606        /* Skip MenuType_Invalid & MenuType_All enum-value: */
     607        if (enumValue == UIExtraDataMetaDefs::MenuType_Invalid ||
     608            enumValue == UIExtraDataMetaDefs::MenuType_All)
    609609            continue;
    610610        /* Which key required action registered under? */
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