VirtualBox

Changeset 52557 in vbox


Ignore:
Timestamp:
Sep 1, 2014 4:45:25 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Mac OS X: Runtime UI: Menu-bar editor: Properly edit 'Application' menu.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r52478 r52557  
    453453    switch (runtimeMenuType)
    454454    {
    455         case UIExtraDataMetaDefs::RuntimeMenuType_Machine: strResult = "Machine"; break;
    456         case UIExtraDataMetaDefs::RuntimeMenuType_View:    strResult = "View"; break;
    457         case UIExtraDataMetaDefs::RuntimeMenuType_Devices: strResult = "Devices"; break;
     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;
    458461#ifdef VBOX_WITH_DEBUGGER_GUI
    459         case UIExtraDataMetaDefs::RuntimeMenuType_Debug:   strResult = "Debug"; break;
     462        case UIExtraDataMetaDefs::RuntimeMenuType_Debug:       strResult = "Debug"; break;
    460463#endif /* VBOX_WITH_DEBUGGER_GUI */
    461         case UIExtraDataMetaDefs::RuntimeMenuType_Help:    strResult = "Help"; break;
    462         case UIExtraDataMetaDefs::RuntimeMenuType_All:     strResult = "All"; break;
     464        case UIExtraDataMetaDefs::RuntimeMenuType_Help:        strResult = "Help"; break;
     465        case UIExtraDataMetaDefs::RuntimeMenuType_All:         strResult = "All"; break;
    463466        default:
    464467        {
     
    475478    /* Here we have some fancy stuff allowing us
    476479     * to search through the keys using 'case-insensitive' rule: */
    477     QStringList keys;  QList<UIExtraDataMetaDefs::RuntimeMenuType> values;
    478     keys << "Machine"; values << UIExtraDataMetaDefs::RuntimeMenuType_Machine;
    479     keys << "View";    values << UIExtraDataMetaDefs::RuntimeMenuType_View;
    480     keys << "Devices"; values << UIExtraDataMetaDefs::RuntimeMenuType_Devices;
     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;
    481487#ifdef VBOX_WITH_DEBUGGER_GUI
    482     keys << "Debug";   values << UIExtraDataMetaDefs::RuntimeMenuType_Debug;
     488    keys << "Debug";       values << UIExtraDataMetaDefs::RuntimeMenuType_Debug;
    483489#endif /* VBOX_WITH_DEBUGGER_GUI */
    484     keys << "Help";    values << UIExtraDataMetaDefs::RuntimeMenuType_Help;
    485     keys << "All";     values << UIExtraDataMetaDefs::RuntimeMenuType_All;
     490    keys << "Help";        values << UIExtraDataMetaDefs::RuntimeMenuType_Help;
     491    keys << "All";         values << UIExtraDataMetaDefs::RuntimeMenuType_All;
    486492    /* Invalid type for unknown words: */
    487493    if (!keys.contains(strRuntimeMenuType, Qt::CaseInsensitive))
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r52478 r52557  
    315315    enum RuntimeMenuType
    316316    {
    317         RuntimeMenuType_Invalid = 0,
    318         RuntimeMenuType_Machine = RT_BIT(0),
    319         RuntimeMenuType_View    = RT_BIT(1),
    320         RuntimeMenuType_Devices = RT_BIT(2),
     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),
    321324#ifdef VBOX_WITH_DEBUGGER_GUI
    322         RuntimeMenuType_Debug   = RT_BIT(3),
     325        RuntimeMenuType_Debug       = RT_BIT(4),
    323326#endif /* VBOX_WITH_DEBUGGER_GUI */
    324         RuntimeMenuType_Help    = RT_BIT(4),
    325         RuntimeMenuType_All     = 0xFF
     327        RuntimeMenuType_Help        = RT_BIT(5),
     328        RuntimeMenuType_All         = 0xFF
    326329    };
    327330
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.cpp

    r52480 r52557  
    6969    /** Prepare routine. */
    7070    void prepare();
     71
    7172#ifdef Q_WS_MAC
    7273    /** Prepare named menu routine. */
     
    8182    /** Prepare copied action routine. */
    8283    QAction* prepareCopiedAction(QMenu *pMenu, const UIAction *pAction);
     84
    8385    /** Prepare menus routine. */
    8486    void prepareMenus();
     
    102104    /** Updates menus routine. */
    103105    void updateMenus();
     106#ifdef Q_WS_MAC
     107    /** Mac OS X: Updates 'Application' menu routine. */
     108    void updateMenuApplication();
     109#endif /* Q_WS_MAC */
    104110    /** Updates 'Machine' menu routine. */
    105111    void updateMenuMachine();
     
    179185            break;
    180186        }
     187#ifdef Q_WS_MAC
     188        case UIExtraDataMetaDefs::RuntimeMenuType_Application:
     189        {
     190            /* Get sender type: */
     191            const UIExtraDataMetaDefs::MenuApplicationActionType type =
     192                static_cast<UIExtraDataMetaDefs::MenuApplicationActionType>(pAction->property("type").toInt());
     193            /* Load current menu-bar restrictions: */
     194            UIExtraDataMetaDefs::MenuApplicationActionType restrictions = gEDataManager->restrictedRuntimeMenuApplicationActionTypes(vboxGlobal().managedVMUuid());
     195            /* Invert restriction for sender type: */
     196            restrictions = (UIExtraDataMetaDefs::MenuApplicationActionType)(restrictions ^ type);
     197            /* Save updated menu-bar restrictions: */
     198            gEDataManager->setRestrictedRuntimeMenuApplicationActionTypes(restrictions, vboxGlobal().managedVMUuid());
     199            break;
     200        }
     201#endif /* Q_WS_MAC */
    181202        case UIExtraDataMetaDefs::RuntimeMenuType_Machine:
    182203        {
     
    329350    {
    330351        /* Configure named menu: */
    331         pNamedMenu->setProperty("class", UIExtraDataMetaDefs::RuntimeMenuType_Help);
     352        pNamedMenu->setProperty("class", UIExtraDataMetaDefs::RuntimeMenuType_Application);
    332353        /* Get named menu action: */
    333354        QAction *pNamedMenuAction = pNamedMenu->menuAction();
     
    596617
    597618    /* Update known menu-bar menus: */
     619#ifdef Q_WS_MAC
     620    updateMenuApplication();
     621#endif /* Q_WS_MAC */
    598622    updateMenuMachine();
    599623    updateMenuView();
     
    604628    updateMenuHelp();
    605629}
     630
     631#ifdef Q_WS_MAC
     632void UIMenuBarEditorWidget::updateMenuApplication()
     633{
     634    /* Recache menu-bar configuration: */
     635    const UIExtraDataMetaDefs::MenuApplicationActionType restrictionsMenuApplication = gEDataManager->restrictedRuntimeMenuApplicationActionTypes(vboxGlobal().managedVMUuid());
     636    /* Get static meta-object: */
     637    const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
     638
     639    /* We have UIExtraDataMetaDefs::MenuApplicationActionType enum registered, so we can enumerate it: */
     640    const int iEnumIndex = smo.indexOfEnumerator("MenuApplicationActionType");
     641    QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
     642    /* Handle other enum-values: */
     643    for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
     644    {
     645        /* Get iterated enum-value: */
     646        const UIExtraDataMetaDefs::MenuApplicationActionType enumValue =
     647            static_cast<const UIExtraDataMetaDefs::MenuApplicationActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
     648        /* Skip MenuApplicationActionType_Invalid & MenuApplicationActionType_All enum-value: */
     649        if (enumValue == UIExtraDataMetaDefs::MenuApplicationActionType_Invalid ||
     650            enumValue == UIExtraDataMetaDefs::MenuApplicationActionType_All)
     651            continue;
     652        /* Which key required action registered under? */
     653        const QString strKey = gpConverter->toInternalString(enumValue);
     654        if (!m_actions.contains(strKey))
     655            continue;
     656        /* Update action 'checked' state: */
     657        m_actions.value(strKey)->setChecked(!(restrictionsMenuApplication & enumValue));
     658    }
     659}
     660#endif /* Q_WS_MAC */
    606661
    607662void UIMenuBarEditorWidget::updateMenuMachine()
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