VirtualBox

Changeset 52215 in vbox


Ignore:
Timestamp:
Jul 28, 2014 6:24:57 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95278
Message:

FE/Qt: 7462: Runtime UI: Menu-bar, menu cleanup/rework (part 10).

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

Legend:

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

    r52190 r52215  
    7070template<> bool canConvert<SizeSuffix>();
    7171template<> bool canConvert<StorageSlot>();
     72template<> bool canConvert<MenuHelpActionType>();
    7273template<> bool canConvert<RuntimeMenuType>();
    7374#ifdef Q_WS_MAC
     
    8081template<> bool canConvert<RuntimeMenuDebuggerActionType>();
    8182#endif /* VBOX_WITH_DEBUGGER_GUI */
    82 template<> bool canConvert<RuntimeMenuHelpActionType>();
    8383template<> bool canConvert<UIVisualStateType>();
    8484template<> bool canConvert<DetailsElementType>();
     
    123123template<> QString toString(const StorageSlot &storageSlot);
    124124template<> StorageSlot fromString<StorageSlot>(const QString &strStorageSlot);
     125template<> QString toInternalString(const MenuHelpActionType &menuHelpActionType);
     126template<> MenuHelpActionType fromInternalString<MenuHelpActionType>(const QString &strMenuHelpActionType);
    125127template<> QString toInternalString(const RuntimeMenuType &runtimeMenuType);
    126128template<> RuntimeMenuType fromInternalString<RuntimeMenuType>(const QString &strRuntimeMenuType);
     
    139141template<> RuntimeMenuDebuggerActionType fromInternalString<RuntimeMenuDebuggerActionType>(const QString &strRuntimeMenuDebuggerActionType);
    140142#endif /* VBOX_WITH_DEBUGGER_GUI */
    141 template<> QString toInternalString(const RuntimeMenuHelpActionType &runtimeMenuHelpActionType);
    142 template<> RuntimeMenuHelpActionType fromInternalString<RuntimeMenuHelpActionType>(const QString &strRuntimeMenuHelpActionType);
    143143template<> QString toInternalString(const UIVisualStateType &visualStateType);
    144144template<> UIVisualStateType fromInternalString<UIVisualStateType>(const QString &strVisualStateType);
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r52203 r52215  
    3434template<> bool canConvert<SizeSuffix>() { return true; }
    3535template<> bool canConvert<StorageSlot>() { return true; }
     36template<> bool canConvert<MenuHelpActionType>() { return true; }
    3637template<> bool canConvert<RuntimeMenuType>() { return true; }
    3738#ifdef Q_WS_MAC
     
    4445template<> bool canConvert<RuntimeMenuDebuggerActionType>() { return true; }
    4546#endif /* VBOX_WITH_DEBUGGER_GUI */
    46 template<> bool canConvert<RuntimeMenuHelpActionType>() { return true; }
    4747template<> bool canConvert<UIVisualStateType>() { return true; }
    4848template<> bool canConvert<DetailsElementType>() { return true; }
     
    355355    }
    356356    return result;
     357}
     358
     359/* QString <= MenuHelpActionType: */
     360template<> QString toInternalString(const MenuHelpActionType &menuHelpActionType)
     361{
     362    QString strResult;
     363    switch (menuHelpActionType)
     364    {
     365        case MenuHelpActionType_Contents:             strResult = "Contents"; break;
     366        case MenuHelpActionType_WebSite:              strResult = "WebSite"; break;
     367        case MenuHelpActionType_ResetWarnings:        strResult = "ResetWarnings"; break;
     368#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     369        case MenuHelpActionType_NetworkAccessManager: strResult = "NetworkAccessManager"; break;
     370        case MenuHelpActionType_CheckForUpdates:      strResult = "CheckForUpdates"; break;
     371#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     372#ifndef Q_WS_MAC
     373        case MenuHelpActionType_About:                strResult = "About"; break;
     374        case MenuHelpActionType_Preferences:          strResult = "Preferences"; break;
     375#endif /* !Q_WS_MAC */
     376        case MenuHelpActionType_All:                  strResult = "All"; break;
     377        default:
     378        {
     379            AssertMsgFailed(("No text for action type=%d", menuHelpActionType));
     380            break;
     381        }
     382    }
     383    return strResult;
     384}
     385
     386/* MenuHelpActionType <= QString: */
     387template<> MenuHelpActionType fromInternalString<MenuHelpActionType>(const QString &strMenuHelpActionType)
     388{
     389    /* Here we have some fancy stuff allowing us
     390     * to search through the keys using 'case-insensitive' rule: */
     391    QStringList keys;               QList<MenuHelpActionType> values;
     392    keys << "Contents";             values << MenuHelpActionType_Contents;
     393    keys << "WebSite";              values << MenuHelpActionType_WebSite;
     394    keys << "ResetWarnings";        values << MenuHelpActionType_ResetWarnings;
     395#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     396    keys << "NetworkAccessManager"; values << MenuHelpActionType_NetworkAccessManager;
     397    keys << "CheckForUpdates";      values << MenuHelpActionType_CheckForUpdates;
     398#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     399#ifndef Q_WS_MAC
     400    keys << "About";                values << MenuHelpActionType_About;
     401    keys << "Preferences";          values << MenuHelpActionType_Preferences;
     402#endif /* !Q_WS_MAC */
     403    keys << "All";                  values << MenuHelpActionType_All;
     404    /* Invalid type for unknown words: */
     405    if (!keys.contains(strMenuHelpActionType, Qt::CaseInsensitive))
     406        return MenuHelpActionType_Invalid;
     407    /* Corresponding type for known words: */
     408    return values.at(keys.indexOf(QRegExp(strMenuHelpActionType, Qt::CaseInsensitive)));
    357409}
    358410
     
    663715#endif /* VBOX_WITH_DEBUGGER_GUI */
    664716
    665 /* QString <= RuntimeMenuHelpActionType: */
    666 template<> QString toInternalString(const RuntimeMenuHelpActionType &runtimeMenuHelpActionType)
    667 {
    668     QString strResult;
    669     switch (runtimeMenuHelpActionType)
    670     {
    671         case RuntimeMenuHelpActionType_Contents:             strResult = "Contents"; break;
    672         case RuntimeMenuHelpActionType_WebSite:              strResult = "WebSite"; break;
    673         case RuntimeMenuHelpActionType_ResetWarnings:        strResult = "ResetWarnings"; break;
    674 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    675         case RuntimeMenuHelpActionType_NetworkAccessManager: strResult = "NetworkAccessManager"; break;
    676 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    677 #ifndef Q_WS_MAC
    678         case RuntimeMenuHelpActionType_About:                strResult = "About"; break;
    679         case RuntimeMenuHelpActionType_Preferences:          strResult = "Preferences"; break;
    680 #endif /* !Q_WS_MAC */
    681         case RuntimeMenuHelpActionType_All:                  strResult = "All"; break;
    682         default:
    683         {
    684             AssertMsgFailed(("No text for action type=%d", runtimeMenuHelpActionType));
    685             break;
    686         }
    687     }
    688     return strResult;
    689 }
    690 
    691 /* RuntimeMenuHelpActionType <= QString: */
    692 template<> RuntimeMenuHelpActionType fromInternalString<RuntimeMenuHelpActionType>(const QString &strRuntimeMenuHelpActionType)
    693 {
    694     /* Here we have some fancy stuff allowing us
    695      * to search through the keys using 'case-insensitive' rule: */
    696     QStringList keys;               QList<RuntimeMenuHelpActionType> values;
    697     keys << "Contents";             values << RuntimeMenuHelpActionType_Contents;
    698     keys << "WebSite";              values << RuntimeMenuHelpActionType_WebSite;
    699     keys << "ResetWarnings";        values << RuntimeMenuHelpActionType_ResetWarnings;
    700 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    701     keys << "NetworkAccessManager"; values << RuntimeMenuHelpActionType_NetworkAccessManager;
    702 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    703 #ifndef Q_WS_MAC
    704     keys << "About";                values << RuntimeMenuHelpActionType_About;
    705     keys << "Preferences";          values << RuntimeMenuHelpActionType_Preferences;
    706 #endif /* !Q_WS_MAC */
    707     keys << "All";                  values << RuntimeMenuHelpActionType_All;
    708     /* Invalid type for unknown words: */
    709     if (!keys.contains(strRuntimeMenuHelpActionType, Qt::CaseInsensitive))
    710         return RuntimeMenuHelpActionType_Invalid;
    711     /* Corresponding type for known words: */
    712     return values.at(keys.indexOf(QRegExp(strRuntimeMenuHelpActionType, Qt::CaseInsensitive)));
    713 }
    714 
    715717/* QString <= UIVisualStateType: */
    716718template<> QString toInternalString(const UIVisualStateType &visualStateType)
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h

    r52203 r52215  
    360360
    361361
     362/** Menu "Help": Action types. */
     363enum MenuHelpActionType
     364{
     365    MenuHelpActionType_Invalid              = 0,
     366    MenuHelpActionType_Contents             = RT_BIT(0),
     367    MenuHelpActionType_WebSite              = RT_BIT(1),
     368    MenuHelpActionType_ResetWarnings        = RT_BIT(2),
     369#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     370    MenuHelpActionType_NetworkAccessManager = RT_BIT(3),
     371    MenuHelpActionType_CheckForUpdates      = RT_BIT(4),
     372#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     373#ifndef Q_WS_MAC
     374    MenuHelpActionType_About                = RT_BIT(5),
     375    MenuHelpActionType_Preferences          = RT_BIT(6),
     376#endif /* !Q_WS_MAC */
     377    MenuHelpActionType_All                  = 0xFFFF
     378};
     379
    362380/** Runtime UI: Menu types. */
    363381enum RuntimeMenuType
     
    467485#endif /* VBOX_WITH_DEBUGGER_GUI */
    468486
    469 /** Runtime UI: Menu "Help": Action types. */
    470 enum RuntimeMenuHelpActionType
    471 {
    472     RuntimeMenuHelpActionType_Invalid              = 0,
    473     RuntimeMenuHelpActionType_Contents             = RT_BIT(0),
    474     RuntimeMenuHelpActionType_WebSite              = RT_BIT(1),
    475     RuntimeMenuHelpActionType_ResetWarnings        = RT_BIT(2),
    476 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    477     RuntimeMenuHelpActionType_NetworkAccessManager = RT_BIT(3),
    478 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    479 #ifndef Q_WS_MAC
    480     RuntimeMenuHelpActionType_About                = RT_BIT(4),
    481     RuntimeMenuHelpActionType_Preferences          = RT_BIT(5),
    482 #endif /* !Q_WS_MAC */
    483     RuntimeMenuHelpActionType_All                  = 0xFFFF
    484 };
    485 
    486487/** Runtime UI: Visual-state types. */
    487488enum UIVisualStateType
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp

    r52202 r52215  
    25822582#endif /* VBOX_WITH_DEBUGGER_GUI */
    25832583
    2584 RuntimeMenuHelpActionType UIExtraDataManager::restrictedRuntimeMenuHelpActionTypes(const QString &strID)
     2584MenuHelpActionType UIExtraDataManager::restrictedRuntimeMenuHelpActionTypes(const QString &strID)
    25852585{
    25862586    /* Prepare result: */
    2587     RuntimeMenuHelpActionType result = RuntimeMenuHelpActionType_Invalid;
     2587    MenuHelpActionType result = MenuHelpActionType_Invalid;
    25882588    /* Get restricted runtime-help-menu action-types: */
    25892589    foreach (const QString &strValue, extraDataStringList(GUI_RestrictedRuntimeHelpMenuActions, strID))
    25902590    {
    2591         RuntimeMenuHelpActionType value = gpConverter->fromInternalString<RuntimeMenuHelpActionType>(strValue);
    2592         if (value != RuntimeMenuHelpActionType_Invalid)
    2593             result = static_cast<RuntimeMenuHelpActionType>(result | value);
     2591        MenuHelpActionType value = gpConverter->fromInternalString<MenuHelpActionType>(strValue);
     2592        if (value != MenuHelpActionType_Invalid)
     2593            result = static_cast<MenuHelpActionType>(result | value);
    25942594    }
    25952595    /* Return result: */
  • trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h

    r52190 r52215  
    301301    #endif /* VBOX_WITH_DEBUGGER_GUI */
    302302        /** Returns restricted Runtime UI action types for Help menu. */
    303         RuntimeMenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID);
     303        MenuHelpActionType restrictedRuntimeMenuHelpActionTypes(const QString &strID);
    304304
    305305        /** Returns restricted Runtime UI visual-states. */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp

    r52203 r52215  
    2727#include "UIIconPool.h"
    2828#include "VBoxGlobal.h"
     29#include "UIMessageCenter.h"
     30#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     31# include "UIExtraDataManager.h"
     32# include "UINetworkManager.h"
     33# include "UIUpdateManager.h"
     34#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    2935
    3036
     
    602608}
    603609
     610bool UIActionPool::isAllowedInMenuHelp(MenuHelpActionType type) const
     611{
     612    foreach (const MenuHelpActionType &restriction, m_restrictedActionsMenuHelp.values())
     613        if (restriction & type)
     614            return false;
     615    return true;
     616}
     617
     618void UIActionPool::setRestrictionForMenuHelp(UIActionRestrictionLevel level, MenuHelpActionType restriction)
     619{
     620    m_restrictedActionsMenuHelp[level] = restriction;
     621    updateMenuHelp();
     622}
     623
    604624void UIActionPool::prepare()
    605625{
     
    630650#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    631651    m_pool[UIActionIndex_Simple_About] = new UIActionSimpleAbout(this);
     652
     653    /* Retranslate finally: */
     654    retranslateUi();
    632655}
    633656
     
    680703}
    681704
     705void UIActionPool::updateConfiguration()
     706{
     707    /* Recache common action restrictions: */
     708    // Nothing here for now..
     709
     710#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     711    /* Recache update action restrictions: */
     712    bool fUpdateAllowed = gEDataManager->applicationUpdateEnabled();
     713    if (!fUpdateAllowed)
     714    {
     715        m_restrictedActionsMenuHelp[UIActionRestrictionLevel_Base] = (MenuHelpActionType)
     716            (m_restrictedActionsMenuHelp[UIActionRestrictionLevel_Base] | MenuHelpActionType_CheckForUpdates);
     717    }
     718#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     719
     720    /* Update menus: */
     721    updateMenus();
     722}
     723
     724void UIActionPool::updateMenuHelp()
     725{
     726    /* Get corresponding menu: */
     727    QMenu *pMenu = action(UIActionIndex_Menu_Help)->menu();
     728    AssertPtrReturnVoid(pMenu);
     729    /* Clear contents: */
     730    pMenu->clear();
     731
     732
     733    /* Separator #1? */
     734    bool fSeparator1 = false;
     735
     736    /* 'Contents' action: */
     737    const bool fAllowToShowActionContents = isAllowedInMenuHelp(MenuHelpActionType_Contents);
     738    action(UIActionIndex_Simple_Contents)->setEnabled(fAllowToShowActionContents);
     739    if (fAllowToShowActionContents)
     740    {
     741        pMenu->addAction(action(UIActionIndex_Simple_Contents));
     742        connect(action(UIActionIndex_Simple_Contents), SIGNAL(triggered()),
     743                &msgCenter(), SLOT(sltShowHelpHelpDialog()), Qt::UniqueConnection);
     744        fSeparator1 = true;
     745    }
     746
     747    /* 'Web Site' action: */
     748    const bool fAllowToShowActionWebSite = isAllowedInMenuHelp(MenuHelpActionType_WebSite);
     749    action(MenuHelpActionType_WebSite)->setEnabled(fAllowToShowActionWebSite);
     750    if (fAllowToShowActionWebSite)
     751    {
     752        pMenu->addAction(action(UIActionIndex_Simple_WebSite));
     753        connect(action(UIActionIndex_Simple_WebSite), SIGNAL(triggered()),
     754                &msgCenter(), SLOT(sltShowHelpWebDialog()), Qt::UniqueConnection);
     755        fSeparator1 = true;
     756    }
     757
     758    /* Separator #1: */
     759    if (fSeparator1)
     760        pMenu->addSeparator();
     761
     762
     763    /* Separator #2? */
     764    bool fSeparator2 = false;
     765
     766    /* 'Reset Warnings' action: */
     767    const bool fAllowToShowActionResetWarnings = isAllowedInMenuHelp(MenuHelpActionType_ResetWarnings);
     768    action(UIActionIndex_Simple_ResetWarnings)->setEnabled(fAllowToShowActionResetWarnings);
     769    if (fAllowToShowActionResetWarnings)
     770    {
     771        pMenu->addAction(action(UIActionIndex_Simple_ResetWarnings));
     772        connect(action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()),
     773                &msgCenter(), SLOT(sltResetSuppressedMessages()), Qt::UniqueConnection);
     774        fSeparator2 = true;
     775    }
     776
     777    /* Separator #2: */
     778    if (fSeparator2)
     779        pMenu->addSeparator();
     780
     781
     782#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
     783# ifndef Q_WS_MAC
     784    /* Separator #3? */
     785    bool fSeparator3 = false;
     786# endif /* !Q_WS_MAC */
     787
     788    /* 'Network Manager' action: */
     789    const bool fAllowToShowActionNetworkManager = isAllowedInMenuHelp(MenuHelpActionType_NetworkAccessManager);
     790    action(UIActionIndex_Simple_NetworkAccessManager)->setEnabled(fAllowToShowActionNetworkManager);
     791    if (fAllowToShowActionNetworkManager)
     792    {
     793        pMenu->addAction(action(UIActionIndex_Simple_NetworkAccessManager));
     794        connect(action(UIActionIndex_Simple_NetworkAccessManager), SIGNAL(triggered()),
     795                gNetworkManager, SLOT(show()), Qt::UniqueConnection);
     796# ifndef Q_WS_MAC
     797        fSeparator3 = true;
     798# endif /* !Q_WS_MAC */
     799    }
     800
     801    /* Only for Selector pool: */
     802    if (type() == UIActionPoolType_Selector)
     803    {
     804        /* 'Check for Updates' action: */
     805        const bool fAllowToShowActionCheckForUpdates = isAllowedInMenuHelp(MenuHelpActionType_CheckForUpdates);
     806        action(UIActionIndex_Simple_NetworkAccessManager)->setEnabled(fAllowToShowActionCheckForUpdates);
     807        if (fAllowToShowActionCheckForUpdates)
     808        {
     809            pMenu->addAction(action(UIActionIndex_Simple_CheckForUpdates));
     810            connect(action(UIActionIndex_Simple_CheckForUpdates), SIGNAL(triggered()),
     811                    gUpdateManager, SLOT(sltForceCheck()), Qt::UniqueConnection);
     812# ifndef Q_WS_MAC
     813            fSeparator3 = true;
     814# endif /* !Q_WS_MAC */
     815        }
     816    }
     817
     818# ifndef Q_WS_MAC
     819    /* Separator #3: */
     820    if (fSeparator3)
     821        pMenu->addSeparator();
     822# endif /* !Q_WS_MAC */
     823#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
     824
     825
     826    /* 'About' action: */
     827    const bool fAllowToShowActionAbout =
     828#ifdef Q_WS_MAC
     829        isAllowedInMenuApplication(RuntimeMenuApplicationActionType_About);
     830#else /* !Q_WS_MAC */
     831        isAllowedInMenuHelp(MenuHelpActionType_About);
     832#endif /* Q_WS_MAC */
     833    action(UIActionIndex_Simple_About)->setEnabled(fAllowToShowActionAbout);
     834    if (fAllowToShowActionAbout)
     835    {
     836        pMenu->addAction(action(UIActionIndex_Simple_About));
     837        connect(action(UIActionIndex_Simple_About), SIGNAL(triggered()),
     838                &msgCenter(), SLOT(sltShowHelpAboutDialog()), Qt::UniqueConnection);
     839    }
     840
     841    /* Only for Runtime pool: */
     842    if (type() == UIActionPoolType_Runtime)
     843    {
     844        /* 'Preferences' action: */
     845        const bool fAllowToShowActionPreferences =
     846#ifdef Q_WS_MAC
     847            isAllowedInMenuApplication(RuntimeMenuApplicationActionType_Preferences);
     848#else /* !Q_WS_MAC */
     849            isAllowedInMenuHelp(MenuHelpActionType_Preferences);
     850#endif /* Q_WS_MAC */
     851        action(UIActionIndex_Simple_Preferences)->setEnabled(fAllowToShowActionPreferences);
     852        if (fAllowToShowActionPreferences)
     853            pMenu->addAction(action(UIActionIndex_Simple_Preferences));
     854    }
     855}
     856
     857void UIActionPool::retranslateUi()
     858{
     859    /* Translate all the actions: */
     860    foreach (const int iActionPoolKey, m_pool.keys())
     861        m_pool[iActionPoolKey]->retranslateUi();
     862    /* Update shortcuts: */
     863    updateShortcuts();
     864}
     865
    682866bool UIActionPool::event(QEvent *pEvent)
    683867{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.h

    r52202 r52215  
    2424/* GUI includes: */
    2525#include "QIWithRetranslateUI.h"
     26#include "UIExtraDataDefs.h"
    2627
    2728/* Forward declarations: */
     
    301302    /** Returns all the actions action-pool contains. */
    302303    QList<UIAction*> actions() const { return m_pool.values(); }
     304
     305    /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */
     306    bool isAllowedInMenuHelp(MenuHelpActionType type) const;
     307    /** Defines 'Help' menu @a restriction for passed @a level. */
     308    void setRestrictionForMenuHelp(UIActionRestrictionLevel level, MenuHelpActionType restriction);
    303309
    304310    /** Hot-key processing delegate. */
     
    335341
    336342    /** Update configuration routine. */
    337     virtual void updateConfiguration() = 0;
     343    virtual void updateConfiguration();
     344
     345    /** Update menus routine. */
     346    virtual void updateMenus() = 0;
     347    /** Update 'Help' menu routine. */
     348    virtual void updateMenuHelp();
     349
    338350    /** Update shortcuts. */
    339351    virtual void updateShortcuts();
     352
     353    /** Translation handler. */
     354    virtual void retranslateUi();
    340355
    341356    /** General event handler. */
     
    348363    /** Holds all the actions action-pool contains. */
    349364    QMap<int, UIAction*> m_pool;
     365
     366    /** Holds restricted action types of the Help menu. */
     367    QMap<UIActionRestrictionLevel, MenuHelpActionType> m_restrictedActionsMenuHelp;
    350368};
    351369
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.cpp

    r52203 r52215  
    1919#include "UIActionPoolRuntime.h"
    2020#include "UIExtraDataManager.h"
    21 #include "UIMessageCenter.h"
    2221#include "UIShortcutPool.h"
    2322#include "VBoxGlobal.h"
    24 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    25 # include "UINetworkManager.h"
    26 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    2723
    2824/* COM includes: */
     
    13561352#endif /* VBOX_WITH_DEBUGGER_GUI */
    13571353
    1358 bool UIActionPoolRuntime::isAllowedInMenuHelp(RuntimeMenuHelpActionType type) const
    1359 {
    1360     foreach (const RuntimeMenuHelpActionType &restriction, m_restrictedActionsMenuHelp.values())
    1361         if (restriction & type)
    1362             return false;
    1363     return true;
    1364 }
    1365 
    1366 void UIActionPoolRuntime::setRestrictionForMenuHelp(UIActionRestrictionLevel level, RuntimeMenuHelpActionType restriction)
    1367 {
    1368     m_restrictedActionsMenuHelp[level] = restriction;
    1369     updateMenuHelp();
    1370 }
    1371 
    13721354void UIActionPoolRuntime::setCurrentFrameBufferSizes(const QList<QSize> &sizes, bool fUpdateMenu /* = false */)
    13731355{
     
    14031385void UIActionPoolRuntime::preparePool()
    14041386{
    1405     /* Call to base-class: */
    1406     UIActionPool::preparePool();
    1407 
    14081387    /* 'Machine' actions: */
    14091388    m_pool[UIActionIndexRT_M_Machine] = new UIActionMenuMachineRuntime(this);
     
    14761455#endif /* Q_WS_MAC */
    14771456
    1478     /* Retranslate finally: */
    1479     retranslateUi();
     1457    /* Call to base-class: */
     1458    UIActionPool::preparePool();
    14801459}
    14811460
     
    15751554    }
    15761555
    1577     /* Update menus: */
    1578     updateMenus();
     1556    /* Call to base-class: */
     1557    UIActionPool::updateConfiguration();
    15791558}
    15801559
     
    23002279#endif /* VBOX_WITH_DEBUGGER_GUI */
    23012280
    2302 void UIActionPoolRuntime::updateMenuHelp()
    2303 {
    2304     /* Get corresponding menu: */
    2305     QMenu *pMenu = action(UIActionIndex_Menu_Help)->menu();
    2306     AssertPtrReturnVoid(pMenu);
    2307     /* Clear contents: */
    2308     pMenu->clear();
    2309 
    2310 
    2311     /* Separator #1? */
    2312     bool fSeparator1 = false;
    2313 
    2314     /* 'Contents' action: */
    2315     const bool fAllowToShowActionContents = isAllowedInMenuHelp(RuntimeMenuHelpActionType_Contents);
    2316     action(UIActionIndex_Simple_Contents)->setEnabled(fAllowToShowActionContents);
    2317     if (fAllowToShowActionContents)
    2318     {
    2319         pMenu->addAction(action(UIActionIndex_Simple_Contents));
    2320         VBoxGlobal::connect(action(UIActionIndex_Simple_Contents), SIGNAL(triggered()),
    2321                             &msgCenter(), SLOT(sltShowHelpHelpDialog()), Qt::UniqueConnection);
    2322         fSeparator1 = true;
    2323     }
    2324 
    2325     /* 'Web Site' action: */
    2326     const bool fAllowToShowActionWebSite = isAllowedInMenuHelp(RuntimeMenuHelpActionType_WebSite);
    2327     action(RuntimeMenuHelpActionType_WebSite)->setEnabled(fAllowToShowActionWebSite);
    2328     if (fAllowToShowActionWebSite)
    2329     {
    2330         pMenu->addAction(action(UIActionIndex_Simple_WebSite));
    2331         VBoxGlobal::connect(action(UIActionIndex_Simple_WebSite), SIGNAL(triggered()),
    2332                             &msgCenter(), SLOT(sltShowHelpWebDialog()), Qt::UniqueConnection);
    2333         fSeparator1 = true;
    2334     }
    2335 
    2336     /* Separator #1: */
    2337     if (fSeparator1)
    2338         pMenu->addSeparator();
    2339 
    2340 
    2341     /* Separator #2? */
    2342     bool fSeparator2 = false;
    2343 
    2344     /* 'Reset Warnings' action: */
    2345     const bool fAllowToShowActionResetWarnings = isAllowedInMenuHelp(RuntimeMenuHelpActionType_ResetWarnings);
    2346     action(UIActionIndex_Simple_ResetWarnings)->setEnabled(fAllowToShowActionResetWarnings);
    2347     if (fAllowToShowActionResetWarnings)
    2348     {
    2349         pMenu->addAction(action(UIActionIndex_Simple_ResetWarnings));
    2350         VBoxGlobal::connect(action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()),
    2351                             &msgCenter(), SLOT(sltResetSuppressedMessages()), Qt::UniqueConnection);
    2352         fSeparator2 = true;
    2353     }
    2354 
    2355     /* Separator #2: */
    2356     if (fSeparator2)
    2357         pMenu->addSeparator();
    2358 
    2359 
    2360 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    2361 # ifndef Q_WS_MAC
    2362     /* Separator #3? */
    2363     bool fSeparator3 = false;
    2364 # endif /* !Q_WS_MAC */
    2365 
    2366     /* 'Network Manager' action: */
    2367     const bool fAllowToShowActionNetworkManager = isAllowedInMenuHelp(RuntimeMenuHelpActionType_NetworkAccessManager);
    2368     action(UIActionIndex_Simple_NetworkAccessManager)->setEnabled(fAllowToShowActionNetworkManager);
    2369     if (fAllowToShowActionNetworkManager)
    2370     {
    2371         pMenu->addAction(action(UIActionIndex_Simple_NetworkAccessManager));
    2372         VBoxGlobal::connect(action(UIActionIndex_Simple_NetworkAccessManager), SIGNAL(triggered()),
    2373                             gNetworkManager, SLOT(show()), Qt::UniqueConnection);
    2374 # ifndef Q_WS_MAC
    2375         fSeparator3 = true;
    2376 # endif /* !Q_WS_MAC */
    2377     }
    2378 
    2379 # ifndef Q_WS_MAC
    2380     /* Separator #3: */
    2381     if (fSeparator3)
    2382         pMenu->addSeparator();
    2383 # endif /* !Q_WS_MAC */
    2384 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    2385 
    2386 
    2387     /* 'About' action: */
    2388     const bool fAllowToShowActionAbout =
    2389 #ifdef Q_WS_MAC
    2390         isAllowedInMenuApplication(RuntimeMenuApplicationActionType_About);
    2391 #else /* !Q_WS_MAC */
    2392         isAllowedInMenuHelp(RuntimeMenuHelpActionType_About);
    2393 #endif /* Q_WS_MAC */
    2394     action(UIActionIndex_Simple_About)->setEnabled(fAllowToShowActionAbout);
    2395     if (fAllowToShowActionAbout)
    2396     {
    2397         pMenu->addAction(action(UIActionIndex_Simple_About));
    2398         VBoxGlobal::connect(action(UIActionIndex_Simple_About), SIGNAL(triggered()),
    2399                             &msgCenter(), SLOT(sltShowHelpAboutDialog()), Qt::UniqueConnection);
    2400     }
    2401 
    2402     /* 'Preferences' action: */
    2403     const bool fAllowToShowActionPreferences =
    2404 #ifdef Q_WS_MAC
    2405         isAllowedInMenuApplication(RuntimeMenuApplicationActionType_Preferences);
    2406 #else /* !Q_WS_MAC */
    2407         isAllowedInMenuHelp(RuntimeMenuHelpActionType_Preferences);
    2408 #endif /* Q_WS_MAC */
    2409     action(UIActionIndex_Simple_Preferences)->setEnabled(fAllowToShowActionPreferences);
    2410     if (fAllowToShowActionPreferences)
    2411         pMenu->addAction(action(UIActionIndex_Simple_Preferences));
    2412 }
    2413 
    24142281void UIActionPoolRuntime::retranslateUi()
    24152282{
    2416     /* Translate all the actions: */
    2417     foreach (const int iActionPoolKey, m_pool.keys())
    2418         m_pool[iActionPoolKey]->retranslateUi();
    2419     /* Update Runtime UI shortcuts: */
    2420     updateShortcuts();
     2283    /* Call to base-class: */
     2284    UIActionPool::retranslateUi();
    24212285    /* Create temporary Selector UI pool to do the same: */
    24222286    if (!m_fTemporary)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionPoolRuntime.h

    r52203 r52215  
    156156#endif /* VBOX_WITH_DEBUGGER_GUI */
    157157
    158     /** Returns whether the action with passed @a type is allowed in the 'Help' menu. */
    159     bool isAllowedInMenuHelp(RuntimeMenuHelpActionType type) const;
    160     /** Defines 'Help' menu @a restriction for passed @a level. */
    161     void setRestrictionForMenuHelp(UIActionRestrictionLevel level, RuntimeMenuHelpActionType restriction);
    162 
    163158    /** Defines current frame-buffer sizes
    164159      * for menus which uses such arguments to build content. */
     
    219214    void updateMenuDebug();
    220215#endif /* VBOX_WITH_DEBUGGER_GUI */
    221     /** Update 'Help' menu routine. */
    222     void updateMenuHelp();
    223216
    224217    /** Translation handler. */
     
    236229    QList<QMenu*> m_mainMenus;
    237230
    238     /** Holds restricted menus. */
     231    /** Holds restricted menu types. */
    239232    QMap<UIActionRestrictionLevel, RuntimeMenuType> m_restrictedMenus;
    240233#ifdef Q_WS_MAC
    241     /** Holds restricted actions of the Application menu. */
     234    /** Holds restricted action types of the Application menu. */
    242235    QMap<UIActionRestrictionLevel, RuntimeMenuApplicationActionType> m_restrictedActionsMenuApplication;
    243236#endif /* Q_WS_MAC */
    244     /** Holds restricted actions of the Machine menu. */
     237    /** Holds restricted action types of the Machine menu. */
    245238    QMap<UIActionRestrictionLevel, RuntimeMenuMachineActionType> m_restrictedActionsMenuMachine;
    246     /** Holds restricted actions of the View menu. */
     239    /** Holds restricted action types of the View menu. */
    247240    QMap<UIActionRestrictionLevel, RuntimeMenuViewActionType> m_restrictedActionsMenuView;
    248     /** Holds restricted actions of the Devices menu. */
     241    /** Holds restricted action types of the Devices menu. */
    249242    QMap<UIActionRestrictionLevel, RuntimeMenuDevicesActionType> m_restrictedActionsMenuDevices;
    250243#ifdef VBOX_WITH_DEBUGGER_GUI
    251     /** Holds restricted actions of the Debugger menu. */
     244    /** Holds restricted action types of the Debugger menu. */
    252245    QMap<UIActionRestrictionLevel, RuntimeMenuDebuggerActionType> m_restrictedActionsMenuDebug;
    253246#endif /* VBOX_WITH_DEBUGGER_GUI */
    254     /** Holds restricted actions of the Help menu. */
    255     QMap<UIActionRestrictionLevel, RuntimeMenuHelpActionType> m_restrictedActionsMenuHelp;
    256247
    257248    /** Defines current frame-buffer sizes
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.cpp

    r52202 r52215  
    894894void UIActionPoolSelector::preparePool()
    895895{
    896     /* Call to base-class: */
    897     UIActionPool::preparePool();
    898 
    899896    /* 'File' actions: */
    900897    m_pool[UIActionIndexST_M_File] = new UIActionMenuFile(this);
     
    947944    m_pool[UIActionIndexST_M_Machine_S_SortParent] = new UIActionSimpleMachineSortParent(this);
    948945
    949     /* Retranslate finally: */
    950     retranslateUi();
     946    /* Call to base-class: */
     947    UIActionPool::preparePool();
    951948}
    952949
     
    957954}
    958955
    959 void UIActionPoolSelector::updateConfiguration()
    960 {
    961     // TODO: Make it proper way..
     956void UIActionPoolSelector::updateMenus()
     957{
     958    /* 'Help' menu: */
     959    updateMenuHelp();
    962960}
    963961
    964962void UIActionPoolSelector::retranslateUi()
    965963{
    966     /* Translate all the actions: */
    967     foreach (const int iActionPoolKey, m_pool.keys())
    968         m_pool[iActionPoolKey]->retranslateUi();
    969     /* Update Selector UI shortcuts: */
    970     updateShortcuts();
     964    /* Call to base-class: */
     965    UIActionPool::retranslateUi();
    971966    /* Create temporary Runtime UI pool to do the same: */
    972967    if (!m_fTemporary)
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIActionPoolSelector.h

    r52202 r52215  
    102102    virtual void prepareConnections();
    103103
    104     /** Update configuration routine. */
    105     virtual void updateConfiguration();
     104    /** Update menus routine. */
     105    virtual void updateMenus();
    106106
    107107    /** Translation handler. */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r52202 r52215  
    11241124
    11251125    /* Prepare Help-menu: */
    1126     prepareMenuHelp(actionPool()->action(UIActionIndex_Menu_Help)->menu());
    11271126    menuBar()->addMenu(actionPool()->action(UIActionIndex_Menu_Help)->menu());
    11281127
     
    12751274}
    12761275
    1277 void UISelectorWindow::prepareMenuHelp(QMenu *pMenu)
    1278 {
    1279     /* Do not touch if filled already: */
    1280     if (!pMenu->isEmpty())
    1281         return;
    1282 
    1283     /* Populate Help-menu: */
    1284     pMenu->addAction(actionPool()->action(UIActionIndex_Simple_Contents));
    1285     pMenu->addAction(actionPool()->action(UIActionIndex_Simple_WebSite));
    1286     pMenu->addSeparator();
    1287     pMenu->addAction(actionPool()->action(UIActionIndex_Simple_ResetWarnings));
    1288 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    1289     pMenu->addSeparator();
    1290     pMenu->addAction(actionPool()->action(UIActionIndex_Simple_NetworkAccessManager));
    1291     if (gEDataManager->applicationUpdateEnabled())
    1292         pMenu->addAction(actionPool()->action(UIActionIndex_Simple_CheckForUpdates));
    1293     else
    1294         actionPool()->action(UIActionIndex_Simple_CheckForUpdates)->setEnabled(false);
    1295 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    1296 #ifndef Q_WS_MAC
    1297     pMenu->addSeparator();
    1298 #endif /* !Q_WS_MAC */
    1299     pMenu->addAction(actionPool()->action(UIActionIndex_Simple_About));
    1300 }
    1301 
    13021276void UISelectorWindow::prepareStatusBar()
    13031277{
     
    14291403    connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff), SIGNAL(triggered()), this, SLOT(sltPerformPowerOffAction()));
    14301404
    1431     /* 'Help' menu connections: */
    1432     connect(actionPool()->action(UIActionIndex_Simple_Contents), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));
    1433     connect(actionPool()->action(UIActionIndex_Simple_WebSite), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpWebDialog()));
    1434     connect(actionPool()->action(UIActionIndex_Simple_ResetWarnings), SIGNAL(triggered()), &msgCenter(), SLOT(sltResetSuppressedMessages()));
    1435 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    1436     connect(actionPool()->action(UIActionIndex_Simple_NetworkAccessManager), SIGNAL(triggered()), gNetworkManager, SLOT(show()));
    1437     connect(actionPool()->action(UIActionIndex_Simple_CheckForUpdates), SIGNAL(triggered()), gUpdateManager, SLOT(sltForceCheck()));
    1438 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    1439     connect(actionPool()->action(UIActionIndex_Simple_About), SIGNAL(triggered()), &msgCenter(), SLOT(sltShowHelpAboutDialog()));
    1440 
    14411405    /* Status-bar connections: */
    14421406    connect(statusBar(), SIGNAL(customContextMenuRequested(const QPoint&)),
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r52202 r52215  
    129129    void prepareMenuGroupClose(QMenu *pMenu);
    130130    void prepareMenuMachineClose(QMenu *pMenu);
    131     void prepareMenuHelp(QMenu *pMenu);
    132131    void prepareStatusBar();
    133132    void prepareWidgets();
Note: See TracChangeset for help on using the changeset viewer.

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