VirtualBox

Changeset 54272 in vbox


Ignore:
Timestamp:
Feb 18, 2015 4:45:36 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Mac OS X: 6985: Window menu for Runtime UI.

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

Legend:

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

    r52937 r54272  
    8080template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>();
    8181#endif /* VBOX_WITH_DEBUGGER_GUI */
     82#ifdef Q_WS_MAC
     83template<> bool canConvert<UIExtraDataMetaDefs::MenuWindowActionType>();
     84#endif /* Q_WS_MAC */
    8285template<> bool canConvert<UIVisualStateType>();
    8386template<> bool canConvert<DetailsElementType>();
     
    125128template<> UIExtraDataMetaDefs::MenuType fromInternalString<UIExtraDataMetaDefs::MenuType>(const QString &strMenuType);
    126129#ifdef Q_WS_MAC
    127 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType &runtimeMenuApplicationActionType);
    128 template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &strRuntimeMenuApplicationActionType);
     130template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType &menuApplicationActionType);
     131template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &strMenuApplicationActionType);
    129132#endif /* Q_WS_MAC */
    130133template<> QString toInternalString(const UIExtraDataMetaDefs::MenuHelpActionType &menuHelpActionType);
     
    142145template<> UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType fromInternalString<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>(const QString &strRuntimeMenuDebuggerActionType);
    143146#endif /* VBOX_WITH_DEBUGGER_GUI */
     147#ifdef Q_WS_MAC
     148template<> QString toInternalString(const UIExtraDataMetaDefs::MenuWindowActionType &menuWindowActionType);
     149template<> UIExtraDataMetaDefs::MenuWindowActionType fromInternalString<UIExtraDataMetaDefs::MenuWindowActionType>(const QString &strMenuWindowActionType);
     150#endif /* Q_WS_MAC */
    144151template<> QString toInternalString(const UIVisualStateType &visualStateType);
    145152template<> UIVisualStateType fromInternalString<UIVisualStateType>(const QString &strVisualStateType);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r54228 r54272  
    5151template<> bool canConvert<UIExtraDataMetaDefs::RuntimeMenuDebuggerActionType>() { return true; }
    5252#endif /* VBOX_WITH_DEBUGGER_GUI */
     53#ifdef Q_WS_MAC
     54template<> bool canConvert<UIExtraDataMetaDefs::MenuWindowActionType>() { return true; }
     55#endif /* Q_WS_MAC */
    5356template<> bool canConvert<UIVisualStateType>() { return true; }
    5457template<> bool canConvert<DetailsElementType>() { return true; }
     
    379382        case UIExtraDataMetaDefs::MenuType_Debug:       strResult = "Debug"; break;
    380383#endif /* VBOX_WITH_DEBUGGER_GUI */
     384#ifdef RT_OS_DARWIN
     385        case UIExtraDataMetaDefs::MenuType_Window:      strResult = "Window"; break;
     386#endif /* RT_OS_DARWIN */
    381387        case UIExtraDataMetaDefs::MenuType_Help:        strResult = "Help"; break;
    382388        case UIExtraDataMetaDefs::MenuType_All:         strResult = "All"; break;
     
    406412    keys << "Debug";       values << UIExtraDataMetaDefs::MenuType_Debug;
    407413#endif /* VBOX_WITH_DEBUGGER_GUI */
     414#ifdef RT_OS_DARWIN
     415    keys << "Window";      values << UIExtraDataMetaDefs::MenuType_Window;
     416#endif /* RT_OS_DARWIN */
    408417    keys << "Help";        values << UIExtraDataMetaDefs::MenuType_Help;
    409418    keys << "All";         values << UIExtraDataMetaDefs::MenuType_All;
     
    417426#ifdef Q_WS_MAC
    418427/* QString <= UIExtraDataMetaDefs::MenuApplicationActionType: */
    419 template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType &runtimeMenuApplicationActionType)
    420 {
    421     QString strResult;
    422     switch (runtimeMenuApplicationActionType)
     428template<> QString toInternalString(const UIExtraDataMetaDefs::MenuApplicationActionType &menuApplicationActionType)
     429{
     430    QString strResult;
     431    switch (menuApplicationActionType)
    423432    {
    424433        case UIExtraDataMetaDefs::MenuApplicationActionType_About:       strResult = "About"; break;
     
    428437        default:
    429438        {
    430             AssertMsgFailed(("No text for action type=%d", runtimeMenuApplicationActionType));
     439            AssertMsgFailed(("No text for action type=%d", menuApplicationActionType));
    431440            break;
    432441        }
     
    436445
    437446/* UIExtraDataMetaDefs::MenuApplicationActionType <= QString: */
    438 template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &strRuntimeMenuApplicationActionType)
     447template<> UIExtraDataMetaDefs::MenuApplicationActionType fromInternalString<UIExtraDataMetaDefs::MenuApplicationActionType>(const QString &strMenuApplicationActionType)
    439448{
    440449    /* Here we have some fancy stuff allowing us
     
    446455    keys << "All";         values << UIExtraDataMetaDefs::MenuApplicationActionType_All;
    447456    /* Invalid type for unknown words: */
    448     if (!keys.contains(strRuntimeMenuApplicationActionType, Qt::CaseInsensitive))
     457    if (!keys.contains(strMenuApplicationActionType, Qt::CaseInsensitive))
    449458        return UIExtraDataMetaDefs::MenuApplicationActionType_Invalid;
    450459    /* Corresponding type for known words: */
    451     return values.at(keys.indexOf(QRegExp(strRuntimeMenuApplicationActionType, Qt::CaseInsensitive)));
     460    return values.at(keys.indexOf(QRegExp(strMenuApplicationActionType, Qt::CaseInsensitive)));
    452461}
    453462#endif /* Q_WS_MAC */
     
    773782#endif /* VBOX_WITH_DEBUGGER_GUI */
    774783
     784#ifdef Q_WS_MAC
     785/* QString <= UIExtraDataMetaDefs::MenuWindowActionType: */
     786template<> QString toInternalString(const UIExtraDataMetaDefs::MenuWindowActionType &menuWindowActionType)
     787{
     788    QString strResult;
     789    switch (menuWindowActionType)
     790    {
     791        case UIExtraDataMetaDefs::MenuWindowActionType_Minimize: strResult = "Minimize"; break;
     792        case UIExtraDataMetaDefs::MenuWindowActionType_Switch:   strResult = "Switch"; break;
     793        case UIExtraDataMetaDefs::MenuWindowActionType_All:      strResult = "All"; break;
     794        default:
     795        {
     796            AssertMsgFailed(("No text for action type=%d", menuWindowActionType));
     797            break;
     798        }
     799    }
     800    return strResult;
     801}
     802
     803/* UIExtraDataMetaDefs::MenuWindowActionType <= QString: */
     804template<> UIExtraDataMetaDefs::MenuWindowActionType fromInternalString<UIExtraDataMetaDefs::MenuWindowActionType>(const QString &strMenuWindowActionType)
     805{
     806    /* Here we have some fancy stuff allowing us
     807     * to search through the keys using 'case-insensitive' rule: */
     808    QStringList keys;   QList<UIExtraDataMetaDefs::MenuWindowActionType> values;
     809    keys << "Minimize"; values << UIExtraDataMetaDefs::MenuWindowActionType_Minimize;
     810    keys << "Switch";   values << UIExtraDataMetaDefs::MenuWindowActionType_Switch;
     811    keys << "All";      values << UIExtraDataMetaDefs::MenuWindowActionType_All;
     812    /* Invalid type for unknown words: */
     813    if (!keys.contains(strMenuWindowActionType, Qt::CaseInsensitive))
     814        return UIExtraDataMetaDefs::MenuWindowActionType_Invalid;
     815    /* Corresponding type for known words: */
     816    return values.at(keys.indexOf(QRegExp(strMenuWindowActionType, Qt::CaseInsensitive)));
     817}
     818#endif /* Q_WS_MAC */
     819
    775820/* QString <= UIVisualStateType: */
    776821template<> QString toInternalString(const UIVisualStateType &visualStateType)
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp

    r53447 r54272  
    100100const char* UIExtraDataDefs::GUI_RestrictedRuntimeDebuggerMenuActions = "GUI/RestrictedRuntimeDebuggerMenuActions";
    101101#endif /* VBOX_WITH_DEBUGGER_GUI */
     102#ifdef Q_WS_MAC
     103const char* UIExtraDataDefs::GUI_RestrictedRuntimeWindowMenuActions = "GUI/RestrictedRuntimeWindowMenuActions";
     104#endif /* Q_WS_MAC */
    102105const char* UIExtraDataDefs::GUI_RestrictedRuntimeHelpMenuActions = "GUI/RestrictedRuntimeHelpMenuActions";
    103106const char* UIExtraDataDefs::GUI_RestrictedVisualStates = "GUI/RestrictedVisualStates";
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r54228 r54272  
    153153        extern const char* GUI_RestrictedRuntimeMenus;
    154154#ifdef Q_WS_MAC
    155         /** Mac OS X: Holds restricted Runtime UI action types for Application menu. */
     155        /** Mac OS X: Holds restricted Runtime UI action types for 'Application' menu. */
    156156        extern const char* GUI_RestrictedRuntimeApplicationMenuActions;
    157157#endif /* Q_WS_MAC */
     
    168168        extern const char* GUI_RestrictedRuntimeDebuggerMenuActions;
    169169#endif /* VBOX_WITH_DEBUGGER_GUI */
     170#ifdef Q_WS_MAC
     171        /** Mac OS X: Holds restricted Runtime UI action types for 'Window' menu. */
     172        extern const char* GUI_RestrictedRuntimeWindowMenuActions;
     173#endif /* Q_WS_MAC */
    170174        /** Holds restricted Runtime UI action types for Help menu. */
    171175        extern const char* GUI_RestrictedRuntimeHelpMenuActions;
     
    298302    Q_ENUMS(RuntimeMenuDebuggerActionType);
    299303#endif /* VBOX_WITH_DEBUGGER_GUI */
     304#ifdef RT_OS_DARWIN
     305    Q_ENUMS(MenuWindowActionType);
     306#endif /* RT_OS_DARWIN */
    300307
    301308public:
     
    315322        MenuType_Debug       = RT_BIT(5),
    316323#endif /* VBOX_WITH_DEBUGGER_GUI */
    317         MenuType_Help        = RT_BIT(6),
     324#ifdef RT_OS_DARWIN
     325        MenuType_Window      = RT_BIT(6),
     326#endif /* RT_OS_DARWIN */
     327        MenuType_Help        = RT_BIT(7),
    318328        MenuType_All         = 0xFF
    319329    };
     
    443453    };
    444454#endif /* VBOX_WITH_DEBUGGER_GUI */
     455
     456#ifdef RT_OS_DARWIN
     457    /** Menu "Window": Action types. */
     458    enum MenuWindowActionType
     459    {
     460        MenuWindowActionType_Invalid  = 0,
     461        MenuWindowActionType_Minimize = RT_BIT(0),
     462        MenuWindowActionType_Switch   = RT_BIT(1),
     463        MenuWindowActionType_All      = 0xFFFF
     464    };
     465#endif /* RT_OS_DARWIN */
    445466};
    446467
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r54151 r54272  
    17661766           << GUI_RestrictedRuntimeDebuggerMenuActions
    17671767#endif /* VBOX_WITH_DEBUGGER_GUI */
     1768#ifdef Q_WS_MAC
     1769           << GUI_RestrictedRuntimeWindowMenuActions
     1770#endif /* Q_WS_MAC */
    17681771           << GUI_RestrictedRuntimeHelpMenuActions
    17691772           << GUI_RestrictedVisualStates
     
    28842887#endif /* VBOX_WITH_DEBUGGER_GUI */
    28852888
     2889#ifdef Q_WS_MAC
     2890UIExtraDataMetaDefs::MenuWindowActionType UIExtraDataManager::restrictedRuntimeMenuWindowActionTypes(const QString &strID)
     2891{
     2892    /* Prepare result: */
     2893    UIExtraDataMetaDefs::MenuWindowActionType result = UIExtraDataMetaDefs::MenuWindowActionType_Invalid;
     2894    /* Get restricted runtime-window-menu action-types: */
     2895    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeWindowMenuActions, strID))
     2896    {
     2897        UIExtraDataMetaDefs::MenuWindowActionType value = gpConverter->fromInternalString<UIExtraDataMetaDefs::MenuWindowActionType>(strValue);
     2898        if (value != UIExtraDataMetaDefs::MenuWindowActionType_Invalid)
     2899            result = static_cast<UIExtraDataMetaDefs::MenuWindowActionType>(result | value);
     2900    }
     2901    /* Return result: */
     2902    return result;
     2903}
     2904
     2905void UIExtraDataManager::setRestrictedRuntimeMenuWindowActionTypes(UIExtraDataMetaDefs::MenuWindowActionType types, const QString &strID)
     2906{
     2907    /* We have MenuWindowActionType enum registered, so we can enumerate it: */
     2908    const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
     2909    const int iEnumIndex = smo.indexOfEnumerator("MenuWindowActionType");
     2910    QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
     2911
     2912    /* Prepare result: */
     2913    QStringList result;
     2914    /* Handle MenuWindowActionType_All enum-value: */
     2915    if (types == UIExtraDataMetaDefs::MenuWindowActionType_All)
     2916        result << gpConverter->toInternalString(types);
     2917    else
     2918    {
     2919        /* Handle other enum-values: */
     2920        for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
     2921        {
     2922            /* Get iterated enum-value: */
     2923            const UIExtraDataMetaDefs::MenuWindowActionType enumValue =
     2924                static_cast<const UIExtraDataMetaDefs::MenuWindowActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
     2925            /* Skip MenuWindowActionType_Invalid & MenuWindowActionType_All enum-values: */
     2926            if (enumValue == UIExtraDataMetaDefs::MenuWindowActionType_Invalid ||
     2927                enumValue == UIExtraDataMetaDefs::MenuWindowActionType_All)
     2928                continue;
     2929            if (types & enumValue)
     2930                result << gpConverter->toInternalString(enumValue);
     2931        }
     2932    }
     2933    /* Save result: */
     2934    setExtraDataStringList(GUI_RestrictedRuntimeWindowMenuActions, result, strID);
     2935}
     2936#endif /* Q_WS_MAC */
     2937
    28862938UIExtraDataMetaDefs::MenuHelpActionType UIExtraDataManager::restrictedRuntimeMenuHelpActionTypes(const QString &strID)
    28872939{
     
    35863638            strKey == GUI_RestrictedRuntimeDebuggerMenuActions ||
    35873639#endif /* VBOX_WITH_DEBUGGER_GUI */
     3640#ifdef Q_WS_MAC
     3641            strKey == GUI_RestrictedRuntimeWindowMenuActions ||
     3642#endif /* Q_WS_MAC */
    35883643            strKey == GUI_RestrictedRuntimeHelpMenuActions)
    35893644            emit sigMenuBarConfigurationChange(strMachineID);
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r53861 r54272  
    344344#endif /* VBOX_WITH_DEBUGGER_GUI */
    345345
     346#ifdef Q_WS_MAC
     347        /** Mac OS X: Returns restricted Runtime UI action types for Window menu. */
     348        UIExtraDataMetaDefs::MenuWindowActionType restrictedRuntimeMenuWindowActionTypes(const QString &strID);
     349        /** Mac OS X: Defines restricted Runtime UI action types for Window menu. */
     350        void setRestrictedRuntimeMenuWindowActionTypes(UIExtraDataMetaDefs::MenuWindowActionType types, const QString &strID);
     351#endif /* Q_WS_MAC */
     352
    346353        /** Returns restricted Runtime UI action types for Help menu. */
    347354        UIExtraDataMetaDefs::MenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID);
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r53305 r54272  
    382382    }
    383383};
     384
     385class UIActionMenuWindow : public UIActionMenu
     386{
     387    Q_OBJECT;
     388
     389public:
     390
     391    UIActionMenuWindow(UIActionPool *pParent)
     392        : UIActionMenu(pParent) {}
     393
     394protected:
     395
     396    /** Returns action extra-data ID. */
     397    virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuType_Window; }
     398    /** Returns action extra-data key. */
     399    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Window); }
     400    /** Returns whether action is allowed. */
     401    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Window); }
     402
     403    void retranslateUi()
     404    {
     405        setName(QApplication::translate("UIActionPool", "&Window"));
     406    }
     407};
     408
     409class UIActionSimpleMinimize : public UIActionSimple
     410{
     411    Q_OBJECT;
     412
     413public:
     414
     415    UIActionSimpleMinimize(UIActionPool *pParent)
     416        : UIActionSimple(pParent) {}
     417
     418protected:
     419
     420    /** Returns action extra-data ID. */
     421    virtual int extraDataID() const { return UIExtraDataMetaDefs::MenuWindowActionType_Minimize; }
     422    /** Returns action extra-data key. */
     423    virtual QString extraDataKey() const { return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuWindowActionType_Minimize); }
     424    /** Returns whether action is allowed. */
     425    virtual bool isAllowed() const { return actionPool()->isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Minimize); }
     426
     427    QString shortcutExtraDataID() const
     428    {
     429        return QString("Minimize");
     430    }
     431
     432    void retranslateUi()
     433    {
     434        setName(QApplication::translate("UIActionPool", "&Minimize"));
     435        setStatusTip(QApplication::translate("UIActionPool", "Minimize active machine-window"));
     436    }
     437};
    384438#endif /* RT_OS_DARWIN */
    385439
     
    792846    m_restrictedActionsMenuApplication[level] = restriction;
    793847    m_invalidations << UIActionIndex_M_Application;
     848}
     849
     850bool UIActionPool::isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const
     851{
     852    foreach (const UIExtraDataMetaDefs::MenuWindowActionType &restriction, m_restrictedActionsMenuWindow.values())
     853        if (restriction & type)
     854            return false;
     855    return true;
     856}
     857
     858void UIActionPool::setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType restriction)
     859{
     860    m_restrictedActionsMenuWindow[level] = restriction;
     861    m_invalidations << UIActionIndex_M_Window;
    794862}
    795863#endif /* Q_WS_MAC */
     
    848916    m_pool[UIActionIndex_M_Application_S_Preferences] = new UIActionSimplePreferences(this);
    849917    m_pool[UIActionIndex_M_Application_S_Close] = new UIActionSimplePerformClose(this);
     918
     919    /* Create 'Window' actions: */
     920    m_pool[UIActionIndex_M_Window] = new UIActionMenuWindow(this);
     921    m_pool[UIActionIndex_M_Window_S_Minimize] = new UIActionSimpleMinimize(this);
    850922#endif /* RT_OS_DARWIN */
    851923
     
    867939#ifdef RT_OS_DARWIN
    868940    m_menuUpdateHandlers[UIActionIndex_M_Application].ptf = &UIActionPool::updateMenuApplication;
     941    m_menuUpdateHandlers[UIActionIndex_M_Window].ptf = &UIActionPool::updateMenuWindow;
    869942#endif /* RT_OS_DARWIN */
    870943    m_menuUpdateHandlers[UIActionIndex_Menu_Help].ptf = &UIActionPool::updateMenuHelp;
     
    9951068    m_invalidations.remove(UIActionIndex_M_Application);
    9961069}
     1070
     1071void UIActionPool::updateMenuWindow()
     1072{
     1073    /* Get corresponding menu: */
     1074    UIMenu *pMenu = action(UIActionIndex_M_Window)->menu();
     1075    AssertPtrReturnVoid(pMenu);
     1076    /* Clear contents: */
     1077    pMenu->clear();
     1078
     1079    /* Separator: */
     1080    bool fSeparator = false;
     1081
     1082    /* 'Minimize' action: */
     1083    fSeparator = addAction(pMenu, action(UIActionIndex_M_Window_S_Minimize)) || fSeparator;
     1084
     1085    /* Separator: */
     1086    if (fSeparator)
     1087    {
     1088        pMenu->addSeparator();
     1089        fSeparator = false;
     1090    }
     1091
     1092    /* This menu always remains invalid.. */
     1093}
    9971094#endif /* RT_OS_DARWIN */
    9981095
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r52589 r54272  
    5858    UIActionIndex_M_Application_S_Preferences,
    5959    UIActionIndex_M_Application_S_Close,
     60
     61    /* 'Window' menu actions: */
     62    UIActionIndex_M_Window,
     63    UIActionIndex_M_Window_S_Minimize,
    6064#endif /* RT_OS_DARWIN */
    6165
     
    367371    /** Defines 'Application' menu @a restriction for passed @a level. */
    368372    void setRestrictionForMenuApplication(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuApplicationActionType restriction);
     373
     374    /** Returns whether the action with passed @a type is allowed in the 'Window' menu. */
     375    bool isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType type) const;
     376    /** Defines 'Window' menu @a restriction for passed @a level. */
     377    void setRestrictionForMenuWindow(UIActionRestrictionLevel level, UIExtraDataMetaDefs::MenuWindowActionType restriction);
    369378#endif /* Q_WS_MAC */
    370379
     
    419428    /** Update 'Application' menu routine. */
    420429    virtual void updateMenuApplication();
     430    /** Update 'Window' menu routine. */
     431    virtual void updateMenuWindow();
    421432#endif /* RT_OS_DARWIN */
    422433    /** Update 'Help' menu routine. */
     
    452463    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuType> m_restrictedMenus;
    453464#ifdef Q_WS_MAC
    454     /** Holds restricted action types of the Application menu. */
     465    /** Holds restricted action types of the 'Application' menu. */
    455466    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuApplicationActionType> m_restrictedActionsMenuApplication;
     467    /** Holds restricted action types of the 'Window' menu. */
     468    QMap<UIActionRestrictionLevel, UIExtraDataMetaDefs::MenuWindowActionType> m_restrictedActionsMenuWindow;
    456469#endif /* Q_WS_MAC */
    457470    /** Holds restricted action types of the Help menu. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r53406 r54272  
    21252125    m_restrictedActionsMenuDebug[UIActionRestrictionLevel_Base] =       gEDataManager->restrictedRuntimeMenuDebuggerActionTypes(strMachineID);
    21262126#endif /* VBOX_WITH_DEBUGGER_GUI */
     2127#ifdef Q_WS_MAC
     2128    m_restrictedActionsMenuWindow[UIActionRestrictionLevel_Base] =      gEDataManager->restrictedRuntimeMenuWindowActionTypes(strMachineID);
     2129#endif /* Q_WS_MAC */
    21272130    m_restrictedActionsMenuHelp[UIActionRestrictionLevel_Base] =        gEDataManager->restrictedRuntimeMenuHelpActionTypes(strMachineID);
    21282131
     
    22482251#endif /* VBOX_WITH_DEBUGGER_GUI */
    22492252
     2253#ifdef RT_OS_DARWIN
     2254    /* 'Window' menu: */
     2255    addMenu(m_mainMenus, action(UIActionIndex_M_Window));
     2256    updateMenuWindow();
     2257#endif /* RT_OS_DARWIN */
     2258
    22502259    /* 'Help' menu: */
    22512260    addMenu(m_mainMenus, action(UIActionIndex_Menu_Help));
     
    23652374    const bool fAllowToShowActionResize = isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize);
    23662375    const bool fAllowToShowActionMultiscreen = isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Multiscreen);
    2367     if (fAllowToShowActionResize && session())
    2368     {
    2369         for (int iGuestScreenIndex = 0; iGuestScreenIndex < session()->frameBuffers().size(); ++iGuestScreenIndex)
     2376    if (fAllowToShowActionResize && uisession())
     2377    {
     2378        for (int iGuestScreenIndex = 0; iGuestScreenIndex < uisession()->frameBuffers().size(); ++iGuestScreenIndex)
    23702379        {
    23712380            /* Add 'Virtual Screen %1' menu: */
     
    23792388    {
    23802389        /* Only for multi-screen host case: */
    2381         if (session()->hostScreens().size() > 1)
     2390        if (uisession()->hostScreens().size() > 1)
    23822391        {
    2383             for (int iGuestScreenIndex = 0; iGuestScreenIndex < session()->frameBuffers().size(); ++iGuestScreenIndex)
     2392            for (int iGuestScreenIndex = 0; iGuestScreenIndex < uisession()->frameBuffers().size(); ++iGuestScreenIndex)
    23842393            {
    23852394                /* Add 'Virtual Screen %1' menu: */
     
    24252434    /* Do we have to show resize menu? */
    24262435    const bool fAllowToShowActionResize = isAllowedInMenuView(UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize);
    2427     if (fAllowToShowActionResize && session())
    2428     {
    2429         for (int iGuestScreenIndex = 0; iGuestScreenIndex < session()->frameBuffers().size(); ++iGuestScreenIndex)
     2436    if (fAllowToShowActionResize && uisession())
     2437    {
     2438        for (int iGuestScreenIndex = 0; iGuestScreenIndex < uisession()->frameBuffers().size(); ++iGuestScreenIndex)
    24302439        {
    24312440            /* Add 'Virtual Screen %1' menu: */
     
    25272536{
    25282537    /* Make sure UI session defined: */
    2529     AssertPtrReturnVoid(session());
     2538    AssertPtrReturnVoid(uisession());
    25302539
    25312540    /* Clear contents: */
     
    25482557    /* Get corresponding screen index and frame-buffer size: */
    25492558    const int iGuestScreenIndex = pMenu->property("Guest Screen Index").toInt();
    2550     const UIFrameBuffer* pFrameBuffer = session()->frameBuffer(iGuestScreenIndex);
     2559    const UIFrameBuffer* pFrameBuffer = uisession()->frameBuffer(iGuestScreenIndex);
    25512560    const QSize screenSize = QSize(pFrameBuffer->width(), pFrameBuffer->height());
    2552     const bool fScreenEnabled = session()->isScreenVisible(iGuestScreenIndex);
     2561    const bool fScreenEnabled = uisession()->isScreenVisible(iGuestScreenIndex);
    25532562
    25542563    /* For non-primary screens: */
     
    25612570        {
    25622571            /* Configure 'toggle' action: */
    2563             pToggleAction->setEnabled(session()->isGuestSupportsGraphics());
     2572            pToggleAction->setEnabled(uisession()->isGuestSupportsGraphics());
    25642573            pToggleAction->setProperty("Guest Screen Index", iGuestScreenIndex);
    25652574            pToggleAction->setCheckable(true);
     
    25852594            {
    25862595                /* Configure exclusive 'resize' action: */
    2587                 pAction->setEnabled(session()->isGuestSupportsGraphics() && fScreenEnabled);
     2596                pAction->setEnabled(uisession()->isGuestSupportsGraphics() && fScreenEnabled);
    25882597                pAction->setProperty("Guest Screen Index", iGuestScreenIndex);
    25892598                pAction->setProperty("Requested Size", size);
     
    26192628        /* Configure exclusive action-group: */
    26202629        pActionGroup->setExclusive(true);
    2621         for (int iHostScreenIndex = 0; iHostScreenIndex < session()->hostScreens().size(); ++iHostScreenIndex)
     2630        for (int iHostScreenIndex = 0; iHostScreenIndex < uisession()->hostScreens().size(); ++iHostScreenIndex)
    26222631        {
    26232632            QAction *pAction = pActionGroup->addAction(UIMultiScreenLayout::tr("Use Host Screen %1")
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h

    r53406 r54272  
    144144    void setSession(UISession *pSession);
    145145    /** Returns UI session object reference. */
    146     UISession* session() const { return m_pSession; }
     146    UISession* uisession() const { return m_pSession; }
    147147
    148148    /** Defines UI multi-screen layout object reference.
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r54223 r54272  
    956956    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_Devices_M_VideoCapture_S_Settings));
    957957    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndexRT_M_Devices_S_InstallGuestTools));
     958#ifdef Q_WS_MAC
     959    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndex_M_Window));
     960    m_pRunningOrPausedActions->addAction(actionPool()->action(UIActionIndex_M_Window_S_Minimize));
     961#endif /* Q_WS_MAC */
    958962
    959963    /* Move actions into running-n-paused-n-stucked actions group: */
     
    10391043#endif /* VBOX_WITH_DEBUGGER_GUI */
    10401044
     1045#ifdef Q_WS_MAC
     1046    /* 'Window' action connections: */
     1047    connect(actionPool()->action(UIActionIndex_M_Window_S_Minimize), SIGNAL(triggered()),
     1048            this, SLOT(sltMinimizeActiveMachineWindow()));
     1049#endif /* Q_WS_MAC */
     1050
    10411051    /* 'Help' actions connections: */
    10421052#ifdef RT_OS_DARWIN
     
    10621072    m_menuUpdateHandlers[UIActionIndexRT_M_Debug] =                     &UIMachineLogic::updateMenuDebug;
    10631073#endif /* VBOX_WITH_DEBUGGER_GUI */
     1074#ifdef Q_WS_MAC
     1075    m_menuUpdateHandlers[UIActionIndex_M_Window] =                      &UIMachineLogic::updateMenuWindow;
     1076#endif /* Q_WS_MAC */
    10641077
    10651078    /* Create keyboard/mouse handlers: */
     
    19211934
    19221935#ifdef Q_WS_MAC
     1936void UIMachineLogic::sltMinimizeActiveMachineWindow()
     1937{
     1938    /* Minimize active machine-window: */
     1939    AssertPtrReturnVoid(activeMachineWindow());
     1940    activeMachineWindow()->showMinimized();
     1941}
     1942
     1943void UIMachineLogic::sltSwitchToMachineWindow()
     1944{
     1945    /* Acquire appropriate sender action: */
     1946    const QAction *pSender = qobject_cast<QAction*>(sender());
     1947    AssertReturnVoid(pSender);
     1948    {
     1949        /* Determine sender action index: */
     1950        const int iIndex = pSender->data().toInt();
     1951        AssertReturnVoid(iIndex >= 0 && iIndex < machineWindows().size());
     1952        {
     1953            /* Raise appropriate machine-window: */
     1954            UIMachineWindow *pMachineWindow = machineWindows().at(iIndex);
     1955            AssertPtrReturnVoid(pMachineWindow);
     1956            {
     1957                pMachineWindow->show();
     1958                pMachineWindow->raise();
     1959                pMachineWindow->activateWindow();
     1960            }
     1961        }
     1962    }
     1963}
     1964
    19231965void UIMachineLogic::sltDockPreviewModeChanged(QAction *pAction)
    19241966{
     
    22712313#endif /* VBOX_WITH_DEBUGGER_GUI */
    22722314
     2315#ifdef Q_WS_MAC
     2316void UIMachineLogic::updateMenuWindow(QMenu *pMenu)
     2317{
     2318    /* Make sure 'Switch' action(s) are allowed: */
     2319    AssertPtrReturnVoid(actionPool());
     2320    if (actionPool()->isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Switch))
     2321    {
     2322        /* Append menu with actions to switch to machine-window(s): */
     2323        foreach (UIMachineWindow *pMachineWindow, machineWindows())
     2324        {
     2325            /* Create machine-window action: */
     2326            AssertPtrReturnVoid(pMachineWindow);
     2327            QAction *pMachineWindowAction = pMenu->addAction(pMachineWindow->windowTitle(),
     2328                                                             this, SLOT(sltSwitchToMachineWindow()));
     2329            AssertPtrReturnVoid(pMachineWindowAction);
     2330            {
     2331                pMachineWindowAction->setCheckable(true);
     2332                pMachineWindowAction->setChecked(activeMachineWindow() == pMachineWindow);
     2333                pMachineWindowAction->setData((int)pMachineWindow->screenId());
     2334            }
     2335        }
     2336    }
     2337}
     2338#endif /* Q_WS_MAC */
     2339
    22732340void UIMachineLogic::showGlobalPreferences(const QString &strCategory /* = QString() */, const QString &strControl /* = QString() */)
    22742341{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r54151 r54272  
    286286
    287287#ifdef RT_OS_DARWIN /* Something is *really* broken in regards of the moc here */
     288    /* "Window" menu functionality: */
     289    void sltMinimizeActiveMachineWindow();
     290    void sltSwitchToMachineWindow();
     291
     292    /* "Dock" menu functionality: */
    288293    void sltDockPreviewModeChanged(QAction *pAction);
    289294    void sltDockPreviewMonitorChanged(QAction *pAction);
     
    317322    void updateMenuDebug(QMenu *pMenu);
    318323#endif /* VBOX_WITH_DEBUGGER_GUI */
     324#ifdef Q_WS_MAC
     325    /** Update 'Window' menu routine. */
     326    void updateMenuWindow(QMenu *pMenu);
     327#endif /* Q_WS_MAC */
    319328
    320329    /** Show Global Preferences on the page defined by @a strCategory and tab defined by @a strControl. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.cpp

    r54079 r54272  
    189189        }
    190190#endif /* VBOX_WITH_DEBUGGER_GUI */
     191#ifdef Q_WS_MAC
     192        case UIExtraDataMetaDefs::MenuType_Window:
     193        {
     194            /* Get sender type: */
     195            const UIExtraDataMetaDefs::MenuWindowActionType type =
     196                static_cast<UIExtraDataMetaDefs::MenuWindowActionType>(pAction->property("type").toInt());
     197            /* Load current menu-bar restrictions: */
     198            UIExtraDataMetaDefs::MenuWindowActionType restrictions = gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID());
     199            /* Invert restriction for sender type: */
     200            restrictions = (UIExtraDataMetaDefs::MenuWindowActionType)(restrictions ^ type);
     201            /* Save updated menu-bar restrictions: */
     202            gEDataManager->setRestrictedRuntimeMenuWindowActionTypes(restrictions, machineID());
     203            break;
     204        }
     205#endif /* Q_WS_MAC */
    191206        case UIExtraDataMetaDefs::MenuType_Help:
    192207        {
     
    281296    prepareMenuDebug();
    282297#endif /* VBOX_WITH_DEBUGGER_GUI */
     298#ifdef Q_WS_MAC
     299    prepareMenuWindow();
     300#endif /* Q_WS_MAC */
    283301    prepareMenuHelp();
    284302
     
    541559#endif /* VBOX_WITH_DEBUGGER_GUI */
    542560
     561#ifdef Q_WS_MAC
     562void UIMenuBarEditorWidget::prepareMenuWindow()
     563{
     564    /* Copy menu: */
     565    QMenu *pMenu = prepareCopiedMenu(actionPool()->action(UIActionIndex_M_Window));
     566    AssertPtrReturnVoid(pMenu);
     567    {
     568        prepareCopiedAction(pMenu, actionPool()->action(UIActionIndex_M_Window_S_Minimize));
     569        prepareNamedAction(pMenu, tr("Switch"),
     570                           UIExtraDataMetaDefs::MenuWindowActionType_Switch,
     571                           gpConverter->toInternalString(UIExtraDataMetaDefs::MenuWindowActionType_Switch));
     572    }
     573}
     574#endif /* Q_WS_MAC */
     575
    543576void UIMenuBarEditorWidget::prepareMenuHelp()
    544577{
     
    602635    updateMenuDebug();
    603636#endif /* VBOX_WITH_DEBUGGER_GUI */
     637#ifdef Q_WS_MAC
     638    updateMenuWindow();
     639#endif /* Q_WS_MAC */
    604640    updateMenuHelp();
    605641}
     
    782818}
    783819#endif /* VBOX_WITH_DEBUGGER_GUI */
     820
     821#ifdef Q_WS_MAC
     822void UIMenuBarEditorWidget::updateMenuWindow()
     823{
     824    /* Recache menu-bar configuration: */
     825    const UIExtraDataMetaDefs::MenuWindowActionType restrictionsMenuWindow = gEDataManager->restrictedRuntimeMenuWindowActionTypes(machineID());
     826    /* Get static meta-object: */
     827    const QMetaObject &smo = UIExtraDataMetaDefs::staticMetaObject;
     828
     829    /* We have UIExtraDataMetaDefs::MenuWindowActionType enum registered, so we can enumerate it: */
     830    const int iEnumIndex = smo.indexOfEnumerator("MenuWindowActionType");
     831    QMetaEnum metaEnum = smo.enumerator(iEnumIndex);
     832    /* Handle other enum-values: */
     833    for (int iKeyIndex = 0; iKeyIndex < metaEnum.keyCount(); ++iKeyIndex)
     834    {
     835        /* Get iterated enum-value: */
     836        const UIExtraDataMetaDefs::MenuWindowActionType enumValue =
     837            static_cast<const UIExtraDataMetaDefs::MenuWindowActionType>(metaEnum.keyToValue(metaEnum.key(iKeyIndex)));
     838        /* Skip MenuWindowActionType_Invalid & MenuWindowActionType_All enum-value: */
     839        if (enumValue == UIExtraDataMetaDefs::MenuWindowActionType_Invalid ||
     840            enumValue == UIExtraDataMetaDefs::MenuWindowActionType_All)
     841            continue;
     842        /* Which key required action registered under? */
     843        const QString strKey = gpConverter->toInternalString(enumValue);
     844        if (!m_actions.contains(strKey))
     845            continue;
     846        /* Update action 'checked' state: */
     847        m_actions.value(strKey)->setChecked(!(restrictionsMenuWindow & enumValue));
     848    }
     849}
     850#endif /* Q_WS_MAC */
    784851
    785852void UIMenuBarEditorWidget::updateMenuHelp()
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMenuBarEditorWindow.h

    r53321 r54272  
    128128    void prepareMenuDebug();
    129129#endif /* VBOX_WITH_DEBUGGER_GUI */
     130#ifdef Q_WS_MAC
     131    /** Mac OS X: Prepare 'Window' menu routine. */
     132    void prepareMenuWindow();
     133#endif /* Q_WS_MAC */
    130134    /** Prepare 'Help' menu routine. */
    131135    void prepareMenuHelp();
     
    149153    void updateMenuDebug();
    150154#endif /* VBOX_WITH_DEBUGGER_GUI */
     155#ifdef Q_WS_MAC
     156    /** Mac OS X: Updates 'Window' menu routine. */
     157    void updateMenuWindow();
     158#endif /* Q_WS_MAC */
    151159    /** Updates 'Help' menu routine. */
    152160    void updateMenuHelp();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r54160 r54272  
    458458UIMachineLogic* UISession::machineLogic() const
    459459{
    460     return uimachine()->machineLogic();
     460    return uimachine() ? uimachine()->machineLogic() : 0;
    461461}
    462462
    463463QWidget* UISession::mainMachineWindow() const
    464464{
    465     return machineLogic()->mainMachineWindow();
     465    return machineLogic() ? machineLogic()->mainMachineWindow() : 0;
    466466}
    467467
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r54160 r54272  
    474474                                                          UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar |
    475475                                                          UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize));
     476#ifdef Q_WS_MAC
     477    /* Restrict 'Window' menu: */
     478    actionPool()->toRuntime()->setRestrictionForMenuBar(UIActionRestrictionLevel_Logic,
     479                                                        UIExtraDataMetaDefs::MenuType_Window);
     480#endif /* Q_WS_MAC */
    476481
    477482    /* Take care of view-action toggle state: */
     
    666671    actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Logic,
    667672                                                         UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid);
     673#ifdef Q_WS_MAC
     674    /* Allow 'Window' menu: */
     675    actionPool()->toRuntime()->setRestrictionForMenuBar(UIActionRestrictionLevel_Logic,
     676                                                        UIExtraDataMetaDefs::MenuType_Invalid);
     677#endif /* Q_WS_MAC */
    668678
    669679    /* Call to base-class: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r54160 r54272  
    220220                                                          UIExtraDataMetaDefs::RuntimeMenuViewActionType_StatusBar |
    221221                                                          UIExtraDataMetaDefs::RuntimeMenuViewActionType_Resize));
     222#ifdef Q_WS_MAC
     223    /* Restrict 'Window' menu: */
     224    actionPool()->toRuntime()->setRestrictionForMenuBar(UIActionRestrictionLevel_Logic,
     225                                                        UIExtraDataMetaDefs::MenuType_Window);
     226#endif /* Q_WS_MAC */
    222227
    223228    /* Take care of view-action toggle state: */
     
    346351    actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Logic,
    347352                                                         UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid);
     353#ifdef Q_WS_MAC
     354    /* Allow 'Window' menu: */
     355    actionPool()->toRuntime()->setRestrictionForMenuBar(UIActionRestrictionLevel_Logic,
     356                                                        UIExtraDataMetaDefs::MenuType_Invalid);
     357#endif /* Q_WS_MAC */
    348358
    349359    /* Call to base-class: */
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