VirtualBox

Ignore:
Timestamp:
Feb 1, 2023 2:48:38 PM (2 years ago)
Author:
vboxsync
Message:

Merging r155316 from gui4 branch: FE/Qt: Runtime UI: Moving action-pool stuff from UISession to UIMachine; Dangerous as well.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3:79645-79692
        21 /branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311
         21/branches/dsen/gui4:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316
        2222/trunk/src:92342,154921
  • trunk/src/VBox

    • Property svn:mergeinfo
      •  

        old new  
        1919/branches/dsen/gui2/src/VBox:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        2020/branches/dsen/gui3/src/VBox:79645-79692
        21 /branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311
         21/branches/dsen/gui4/src/VBox:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316
  • trunk/src/VBox/Frontends

    • Property svn:mergeinfo
      •  

        old new  
        1616/branches/dsen/gui2/src/VBox/Frontends:79224,79228,79233,79235,79258,79262-79263,79273,79341,79345,79354,79357,79387-79388,79559-79569,79572-79573,79578,79581-79582,79590-79591,79598-79599,79602-79603,79605-79606,79632,79635,79637,79644
        1717/branches/dsen/gui3/src/VBox/Frontends:79645-79692
        18 /branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311
         18/branches/dsen/gui4/src/VBox/Frontends:155183-155185,155187,155198,155200-155201,155205,155228,155235,155243,155248,155282,155285,155287-155288,155311,155316
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBuffer.cpp

    r98379 r98399  
    19101910
    19111911    /* Make sure action-pool knows frame-buffer size: */
    1912     m_pMachineView->uisession()->actionPool()->toRuntime()->setGuestScreenSize(m_pMachineView->screenId(),
     1912    m_pMachineView->uimachine()->actionPool()->toRuntime()->setGuestScreenSize(m_pMachineView->screenId(),
    19131913                                                                               QSize(m_iWidth, m_iHeight));
    19141914}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98398 r98399  
    3131#endif
    3232#ifdef VBOX_WS_MAC
     33# include <QMenuBar>
    3334# include <QTimer>
    3435#endif
     
    5152
    5253/* COM includes: */
     54#include "CAudioAdapter.h"
     55#include "CAudioSettings.h"
    5356#include "CConsole.h"
    5457#include "CGraphicsAdapter.h"
     58#include "CHostVideoInputDevice.h"
    5559#include "CMachine.h"
     60#include "CNetworkAdapter.h"
    5661#include "CProgress.h"
     62#include "CRecordingSettings.h"
    5763#include "CSession.h"
    5864#include "CSnapshot.h"
     65#include "CSystemProperties.h"
     66#include "CUSBController.h"
     67#include "CUSBDeviceFilters.h"
     68#include "CVRDEServer.h"
    5969
    6070
     
    216226}
    217227
     228void UIMachine::updateStateAdditionsActions()
     229{
     230    /* Make sure action-pool knows whether GA supports graphics: */
     231    actionPool()->toRuntime()->setGuestSupportsGraphics(uisession()->isGuestSupportsGraphics());
     232    /* Enable/Disable Upgrade Additions action depending on feature status: */
     233    actionPool()->action(UIActionIndexRT_M_Devices_S_UpgradeGuestAdditions)->setEnabled(uisession()->guestAdditionsUpgradable());
     234}
     235
     236void UIMachine::updateStateAudioActions()
     237{
     238    /* Make sure Audio adapter is present: */
     239    const CAudioSettings comAudioSettings = uisession()->machine().GetAudioSettings();
     240    AssertMsgReturnVoid(uisession()->machine().isOk() && comAudioSettings.isNotNull(),
     241                        ("Audio audio settings should NOT be null!\n"));
     242    const CAudioAdapter comAdapter = comAudioSettings.GetAdapter();
     243    AssertMsgReturnVoid(comAudioSettings.isOk() && comAdapter.isNotNull(),
     244                        ("Audio audio adapter should NOT be null!\n"));
     245
     246    /* Check/Uncheck Audio adapter output/input actions depending on features status: */
     247    actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(true);
     248    actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->setChecked(comAdapter.GetEnabledOut());
     249    actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(false);
     250    actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(true);
     251    actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->setChecked(comAdapter.GetEnabledIn());
     252    actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(false);
     253}
     254
     255void UIMachine::updateStateRecordingAction()
     256{
     257    /* Make sure recording settingss present: */
     258    const CRecordingSettings comRecordingSettings = uisession()->machine().GetRecordingSettings();
     259    AssertMsgReturnVoid(uisession()->machine().isOk() && comRecordingSettings.isNotNull(),
     260                        ("Recording settings can't be null!\n"));
     261
     262    /* Check/Uncheck Capture action depending on feature status: */
     263    actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start)->blockSignals(true);
     264    actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start)->setChecked(comRecordingSettings.GetEnabled());
     265    actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start)->blockSignals(false);
     266}
     267
     268void UIMachine::updateStateVRDEServerAction()
     269{
     270    /* Make sure VRDE server present: */
     271    const CVRDEServer comServer = uisession()->machine().GetVRDEServer();
     272    AssertMsgReturnVoid(uisession()->machine().isOk() && comServer.isNotNull(),
     273                        ("VRDE server can't be null!\n"));
     274
     275    /* Check/Uncheck VRDE Server action depending on feature status: */
     276    actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(true);
     277    actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->setChecked(comServer.GetEnabled());
     278    actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(false);
     279}
     280
    218281bool UIMachine::isScreenVisibleHostDesires(ulong uScreenId) const
    219282{
     
    260323
    261324    /* Make sure action-pool knows guest-screen visibility status: */
    262     uisession()->actionPool()->toRuntime()->setGuestScreenVisible(uScreenId, fIsMonitorVisible);
     325    actionPool()->toRuntime()->setGuestScreenVisible(uScreenId, fIsMonitorVisible);
    263326}
    264327
     
    348411    }
    349412}
     413
     414void UIMachine::sltHandleAdditionsActualChange()
     415{
     416    updateStateAdditionsActions();
     417    emit sigAdditionsStateChange();
     418}
     419
     420void UIMachine::sltHandleAudioAdapterChange()
     421{
     422    updateStateAudioActions();
     423    emit sigAudioAdapterChange();
     424}
     425
     426void UIMachine::sltHandleRecordingChange()
     427{
     428    updateStateRecordingAction();
     429    emit sigRecordingChange();
     430}
     431
     432void UIMachine::sltHandleStorageDeviceChange(const CMediumAttachment &comAttachment, bool fRemoved, bool fSilent)
     433{
     434    updateActionRestrictions();
     435    emit sigStorageDeviceChange(comAttachment, fRemoved, fSilent);
     436}
     437
     438void UIMachine::sltHandleVRDEChange()
     439{
     440    updateStateVRDEServerAction();
     441    emit sigVRDEChange();
     442}
     443
     444#ifdef VBOX_WS_MAC
     445void UIMachine::sltHandleMenuBarConfigurationChange(const QUuid &uMachineID)
     446{
     447    /* Skip unrelated machine IDs: */
     448    if (uiCommon().managedVMUuid() != uMachineID)
     449        return;
     450
     451    /* Update Mac OS X menu-bar: */
     452    updateMenu();
     453}
     454#endif /* VBOX_WS_MAC */
    350455
    351456void UIMachine::sltHandleHostScreenCountChange()
     
    581686    , m_pMachineLogic(0)
    582687    , m_pMachineWindowIcon(0)
     688    , m_pActionPool(0)
     689#ifdef VBOX_WS_MAC
     690    , m_pMenuBar(0)
     691#endif
    583692#ifdef VBOX_WS_MAC
    584693    , m_pWatchdogDisplayChange(0)
     
    623732    /* Prepare stuff: */
    624733    prepareSessionConnections();
     734    prepareActions();
    625735    prepareScreens();
    626736    prepareBranding();
     
    631741        return false;
    632742
    633     /* Update stuff: */
     743    /* Update stuff which doesn't send events on init: */
     744    updateStateAudioActions();
    634745    updateMouseState();
    635746
     
    642753    /* Console events stuff: */
    643754    connect(uisession(), &UISession::sigAudioAdapterChange,
    644             this, &UIMachine::sigAudioAdapterChange);
     755            this, &UIMachine::sltHandleAudioAdapterChange);
    645756    connect(uisession(), &UISession::sigAdditionsStateChange,
    646757            this, &UIMachine::sigAdditionsStateChange);
    647758    connect(uisession(), &UISession::sigAdditionsStateActualChange,
    648             this, &UIMachine::sigAdditionsStateActualChange);
     759            this, &UIMachine::sltHandleAdditionsActualChange);
    649760    connect(uisession(), &UISession::sigClipboardModeChange,
    650761            this, &UIMachine::sigClipboardModeChange);
     
    662773            this, &UIMachine::sigNetworkAdapterChange);
    663774    connect(uisession(), &UISession::sigRecordingChange,
    664             this, &UIMachine::sigRecordingChange);
     775            this, &UIMachine::sltHandleRecordingChange);
    665776    connect(uisession(), &UISession::sigSharedFolderChange,
    666777            this, &UIMachine::sigSharedFolderChange);
    667778    connect(uisession(), &UISession::sigStorageDeviceChange,
    668             this, &UIMachine::sigStorageDeviceChange);
     779            this, &UIMachine::sltHandleStorageDeviceChange);
    669780    connect(uisession(), &UISession::sigUSBControllerChange,
    670781            this, &UIMachine::sigUSBControllerChange);
     
    672783            this, &UIMachine::sigUSBDeviceStateChange);
    673784    connect(uisession(), &UISession::sigVRDEChange,
    674             this, &UIMachine::sigVRDEChange);
     785            this, &UIMachine::sltHandleVRDEChange);
    675786    connect(uisession(), &UISession::sigRuntimeError,
    676787            this, &UIMachine::sigRuntimeError);
     
    779890    /* Make sure action-pool knows guest-screen visibility status: */
    780891    for (int iScreenIndex = 0; iScreenIndex < m_monitorVisibilityVector.size(); ++iScreenIndex)
    781         uisession()->actionPool()->toRuntime()->setGuestScreenVisible(iScreenIndex, m_monitorVisibilityVector.at(iScreenIndex));
     892        actionPool()->toRuntime()->setGuestScreenVisible(iScreenIndex, m_monitorVisibilityVector.at(iScreenIndex));
    782893}
    783894
     
    802913}
    803914
     915void UIMachine::prepareActions()
     916{
     917    /* Create action-pool: */
     918    m_pActionPool = UIActionPool::create(UIActionPoolType_Runtime);
     919    if (actionPool())
     920    {
     921        /* Make sure action-pool knows guest-screen count: */
     922        actionPool()->toRuntime()->setGuestScreenCount(uisession()->frameBuffers().size());
     923        /* Update action restrictions: */
     924        updateActionRestrictions();
     925
     926#ifdef VBOX_WS_MAC
     927        /* Create Mac OS X menu-bar: */
     928        m_pMenuBar = new QMenuBar;
     929        if (m_pMenuBar)
     930        {
     931            /* Configure Mac OS X menu-bar: */
     932            connect(gEDataManager, &UIExtraDataManager::sigMenuBarConfigurationChange,
     933                    this, &UIMachine::sltHandleMenuBarConfigurationChange);
     934            /* Update Mac OS X menu-bar: */
     935            updateMenu();
     936        }
     937#endif /* VBOX_WS_MAC */
     938
     939        /* Get machine ID: */
     940        const QUuid uMachineID = uiCommon().managedVMUuid();
     941        Q_UNUSED(uMachineID);
     942
     943#ifdef VBOX_WS_MAC
     944        /* User-element (Menu-bar and Dock) options: */
     945        {
     946            const bool fDisabled = gEDataManager->guiFeatureEnabled(GUIFeatureType_NoUserElements);
     947            if (fDisabled)
     948                UICocoaApplication::instance()->hideUserElements();
     949        }
     950#else /* !VBOX_WS_MAC */
     951        /* Menu-bar options: */
     952        {
     953            const bool fEnabledGlobally = !gEDataManager->guiFeatureEnabled(GUIFeatureType_NoMenuBar);
     954            const bool fEnabledForMachine = gEDataManager->menuBarEnabled(uMachineID);
     955            const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
     956            actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings)->setEnabled(fEnabled);
     957            actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->blockSignals(true);
     958            actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->setChecked(fEnabled);
     959            actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility)->blockSignals(false);
     960        }
     961#endif /* !VBOX_WS_MAC */
     962
     963        /* View options: */
     964        const bool fGuestScreenAutoresize = gEDataManager->guestScreenAutoResizeEnabled(uMachineID);
     965        actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->blockSignals(true);
     966        actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->setChecked(fGuestScreenAutoresize);
     967        actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize)->blockSignals(false);
     968
     969        /* Input options: */
     970        const bool fMouseIntegrated = isMouseIntegrated(); // no e-data for now ..
     971        actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration)->blockSignals(true);
     972        actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration)->setChecked(fMouseIntegrated);
     973        actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration)->blockSignals(false);
     974
     975        /* Device options: */
     976        actionPool()->action(UIActionIndexRT_M_Devices_S_UpgradeGuestAdditions)->setEnabled(false);
     977
     978        /* Status-bar options: */
     979        {
     980            const bool fEnabledGlobally = !gEDataManager->guiFeatureEnabled(GUIFeatureType_NoStatusBar);
     981            const bool fEnabledForMachine = gEDataManager->statusBarEnabled(uMachineID);
     982            const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
     983            actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings)->setEnabled(fEnabled);
     984            actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility)->blockSignals(true);
     985            actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility)->setChecked(fEnabled);
     986            actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility)->blockSignals(false);
     987        }
     988    }
     989}
     990
    804991void UIMachine::prepareMachineLogic()
    805992{
     
    8441031}
    8451032
     1033void UIMachine::cleanupActions()
     1034{
     1035#ifdef VBOX_WS_MAC
     1036    /* Destroy Mac OS X menu-bar: */
     1037    delete m_pMenuBar;
     1038    m_pMenuBar = 0;
     1039#endif /* VBOX_WS_MAC */
     1040
     1041    /* Destroy action-pool if necessary: */
     1042    if (actionPool())
     1043        UIActionPool::destroy(actionPool());
     1044}
     1045
    8461046void UIMachine::cleanupBranding()
    8471047{
     
    8751075    cleanupBranding();
    8761076    cleanupScreens();
     1077    cleanupActions();
    8771078
    8781079    /* Cleanup session UI: */
     
    8841085    sltChangeVisualState(m_initialVisualState);
    8851086}
     1087
     1088void UIMachine::updateActionRestrictions()
     1089{
     1090    /* Get host and prepare restrictions: */
     1091    const CHost comHost = uiCommon().host();
     1092    UIExtraDataMetaDefs::RuntimeMenuMachineActionType restrictionForMachine =
     1093        UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid;
     1094    UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionForView =
     1095        UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid;
     1096    UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionForDevices =
     1097        UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
     1098
     1099    /* Separate process stuff: */
     1100    {
     1101        /* Initialize 'Machine' menu: */
     1102        if (!uiCommon().isSeparateProcess())
     1103            restrictionForMachine = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)
     1104                                    (restrictionForMachine | UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Detach);
     1105    }
     1106
     1107    /* VRDE server stuff: */
     1108    {
     1109        /* Initialize 'View' menu: */
     1110        const CVRDEServer comServer = uisession()->machine().GetVRDEServer();
     1111        if (comServer.isNull())
     1112            restrictionForView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)
     1113                                 (restrictionForView | UIExtraDataMetaDefs::RuntimeMenuViewActionType_VRDEServer);
     1114    }
     1115
     1116    /* Storage stuff: */
     1117    {
     1118        /* Initialize CD/FD menus: */
     1119        int iDevicesCountCD = 0;
     1120        int iDevicesCountFD = 0;
     1121        foreach (const CMediumAttachment &comAttachment, uisession()->machine().GetMediumAttachments())
     1122        {
     1123            if (comAttachment.GetType() == KDeviceType_DVD)
     1124                ++iDevicesCountCD;
     1125            if (comAttachment.GetType() == KDeviceType_Floppy)
     1126                ++iDevicesCountFD;
     1127        }
     1128        QAction *pOpticalDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices);
     1129        QAction *pFloppyDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices);
     1130        pOpticalDevicesMenu->setData(iDevicesCountCD);
     1131        pFloppyDevicesMenu->setData(iDevicesCountFD);
     1132        if (!iDevicesCountCD)
     1133            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
     1134                                    (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
     1135        if (!iDevicesCountFD)
     1136            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
     1137                                    (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
     1138    }
     1139
     1140    /* Audio stuff: */
     1141    {
     1142        /* Check whether audio controller is enabled. */
     1143        const CAudioSettings comAudioSettings = uisession()->machine().GetAudioSettings();
     1144        const CAudioAdapter comAudioAdapter = comAudioSettings.GetAdapter();
     1145        if (comAudioAdapter.isNull() || !comAudioAdapter.GetEnabled())
     1146            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
     1147                                    (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Audio);
     1148    }
     1149
     1150    /* Network stuff: */
     1151    {
     1152        /* Initialize Network menu: */
     1153        bool fAtLeastOneAdapterActive = false;
     1154        const KChipsetType enmChipsetType = uisession()->machine().GetChipsetType();
     1155        ULONG uSlots = uiCommon().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(enmChipsetType);
     1156        for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
     1157        {
     1158            const CNetworkAdapter &comNetworkAdapter = uisession()->machine().GetNetworkAdapter(uSlot);
     1159            if (comNetworkAdapter.GetEnabled())
     1160            {
     1161                fAtLeastOneAdapterActive = true;
     1162                break;
     1163            }
     1164        }
     1165        if (!fAtLeastOneAdapterActive)
     1166            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
     1167                                    (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
     1168    }
     1169
     1170    /* USB stuff: */
     1171    {
     1172        /* Check whether there is at least one USB controller with an available proxy. */
     1173        const bool fUSBEnabled =    !uisession()->machine().GetUSBDeviceFilters().isNull()
     1174                                 && !uisession()->machine().GetUSBControllers().isEmpty()
     1175                                 && uisession()->machine().GetUSBProxyAvailable();
     1176        if (!fUSBEnabled)
     1177            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
     1178                                    (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
     1179    }
     1180
     1181    /* WebCams stuff: */
     1182    {
     1183        /* Check whether there is an accessible video input devices pool: */
     1184        comHost.GetVideoInputDevices();
     1185        const bool fWebCamsEnabled = comHost.isOk() && !uisession()->machine().GetUSBControllers().isEmpty();
     1186        if (!fWebCamsEnabled)
     1187            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
     1188                                    (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
     1189    }
     1190
     1191    /* Apply cumulative restriction for 'Machine' menu: */
     1192    actionPool()->toRuntime()->setRestrictionForMenuMachine(UIActionRestrictionLevel_Session, restrictionForMachine);
     1193    /* Apply cumulative restriction for 'View' menu: */
     1194    actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Session, restrictionForView);
     1195    /* Apply cumulative restriction for 'Devices' menu: */
     1196    actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restrictionForDevices);
     1197}
     1198
     1199#ifdef VBOX_WS_MAC
     1200void UIMachine::updateMenu()
     1201{
     1202    /* Rebuild Mac OS X menu-bar: */
     1203    m_pMenuBar->clear();
     1204    foreach (QMenu *pMenu, actionPool()->menus())
     1205    {
     1206        UIMenu *pMenuUI = qobject_cast<UIMenu*>(pMenu);
     1207        if (!pMenuUI->isConsumable() || !pMenuUI->isConsumed())
     1208            m_pMenuBar->addMenu(pMenuUI);
     1209        if (pMenuUI->isConsumable() && !pMenuUI->isConsumed())
     1210            pMenuUI->setConsumed(true);
     1211    }
     1212    /* Update the dock menu as well: */
     1213    if (machineLogic())
     1214        machineLogic()->updateDock();
     1215}
     1216#endif /* VBOX_WS_MAC */
    8861217
    8871218void UIMachine::updateHostScreenData()
     
    8931224
    8941225    /* Make sure action-pool knows host-screen count: */
    895     uisession()->actionPool()->toRuntime()->setHostScreenCount(m_hostScreens.size());
     1226    actionPool()->toRuntime()->setHostScreenCount(m_hostScreens.size());
    8961227}
    8971228
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98398 r98399  
    4747/* Forward declarations: */
    4848class QWidget;
     49class UIActionPool;
    4950class UISession;
    5051class UIMachineLogic;
    5152#ifdef VBOX_WS_MAC
     53 class QMenuBar;
    5254 class QTimer;
    5355#endif
     
    180182    /** @} */
    181183
     184    /** @name Actions stuff.
     185     ** @{ */
     186        /** Returns the action-pool instance. */
     187        UIActionPool *actionPool() const { return m_pActionPool; }
     188
     189        /** Updates additions actions state. */
     190        void updateStateAdditionsActions();
     191        /** Updates Audio action state. */
     192        void updateStateAudioActions();
     193        /** Updates Recording action state. */
     194        void updateStateRecordingAction();
     195        /** Updates VRDE server action state. */
     196        void updateStateVRDEServerAction();
     197    /** @} */
     198
    182199    /** @name Host-screen stuff.
    183200     ** @{ */
     
    297314    /** Visual state-change handler. */
    298315    void sltChangeVisualState(UIVisualStateType visualStateType);
     316
     317    /** @name COM events stuff.
     318     ** @{ */
     319        /** Handles additions state actual change signal. */
     320        void sltHandleAdditionsActualChange();
     321        /** Handles audio adapter change signal. */
     322        void sltHandleAudioAdapterChange();
     323        /** Handles recording change signal. */
     324        void sltHandleRecordingChange();
     325        /** Handles storage device change for @a attachment, which was @a fRemoved and it was @a fSilent for guest. */
     326        void sltHandleStorageDeviceChange(const CMediumAttachment &comAttachment, bool fRemoved, bool fSilent);
     327        /** Handles VRDE change signal. */
     328        void sltHandleVRDEChange();
     329    /** @} */
     330
     331    /** @name Actions stuff.
     332     ** @{ */
     333#ifdef VBOX_WS_MAC
     334        /** Mac OS X: Handles menu-bar configuration-change. */
     335        void sltHandleMenuBarConfigurationChange(const QUuid &uMachineID);
     336#endif
     337    /** @} */
    299338
    300339    /** @name Host-screen stuff.
     
    372411    /** Prepare routine: Branding. */
    373412    void prepareBranding();
     413    /** Prepare routine: Actions stuff. */
     414    void prepareActions();
    374415    /** Prepare routine: Machine-logic stuff. */
    375416    void prepareMachineLogic();
     
    377418    /** Cleanup routine: Machine-logic stuff. */
    378419    void cleanupMachineLogic();
     420    /** Cleanup routine: Actions stuff. */
     421    void cleanupActions();
    379422    /** Cleanup routine: Branding. */
    380423    void cleanupBranding();
     
    388431    /** Moves VM to initial state. */
    389432    void enterInitialVisualState();
     433
     434    /** @name Actions stuff.
     435     ** @{ */
     436        /** Updates action restrictions. */
     437        void updateActionRestrictions();
     438
     439#ifdef VBOX_WS_MAC
     440        /** Mac OS X: Updates menu-bar content. */
     441        void updateMenu();
     442#endif
     443    /** @} */
    390444
    391445    /** @name Host-screen stuff.
     
    454508    /** @} */
    455509
     510    /** @name Actions stuff.
     511     ** @{ */
     512        /** Holds the action-pool instance. */
     513        UIActionPool *m_pActionPool;
     514
     515#ifdef VBOX_WS_MAC
     516        /** Mac OS X: Holds the menu-bar instance. */
     517        QMenuBar *m_pMenuBar;
     518#endif
     519    /** @} */
     520
    456521    /** @name Host-screen stuff.
    457522     * @{ */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r98386 r98399  
    278278UIActionPool *UIMachineLogic::actionPool() const
    279279{
    280     return uisession()->actionPool();
     280    return uimachine()->actionPool();
    281281}
    282282
     
    20012001    {
    20022002        /* Make sure action is updated: */
    2003         uisession()->updateStatusRecording();
     2003        uimachine()->updateStateRecordingAction();
    20042004        /* Notify about the error: */
    20052005        return UINotificationMessage::cannotToggleRecording(comRecordingSettings, machine().GetName(), fEnabled);
     
    20112011    {
    20122012        /* Make sure action is updated: */
    2013         uisession()->updateStatusRecording();
     2013        uimachine()->updateStateRecordingAction();
    20142014        /* Notify about the error: */
    20152015        return UINotificationMessage::cannotSaveMachineSettings(machine());
     
    20372037    {
    20382038        /* Make sure action is updated: */
    2039         uisession()->updateStatusVRDE();
     2039        uimachine()->updateStateVRDEServerAction();
    20402040        /* Notify about the error: */
    20412041        return UINotificationMessage::cannotToggleVRDEServer(server, machineName(), fEnabled);
     
    20472047    {
    20482048        /* Make sure action is updated: */
    2049         uisession()->updateStatusVRDE();
     2049        uimachine()->updateStateVRDEServerAction();
    20502050        /* Notify about the error: */
    20512051        return UINotificationMessage::cannotSaveMachineSettings(machine());
     
    22462246    {
    22472247        /* Make sure action is updated: */
    2248         uisession()->updateAudioOutput();
     2248        uimachine()->updateStateAudioActions();
    22492249        /* Notify about the error: */
    22502250        return UINotificationMessage::cannotToggleAudioOutput(comAdapter, machineName(), fEnabled);
     
    22562256    {
    22572257        /* Make sure action is updated: */
    2258         uisession()->updateAudioOutput();
     2258        uimachine()->updateStateAudioActions();
    22592259        /* Notify about the error: */
    22602260        return UINotificationMessage::cannotSaveMachineSettings(machine());
     
    22832283    {
    22842284        /* Make sure action is updated: */
    2285         uisession()->updateAudioInput();
     2285        uimachine()->updateStateAudioActions();
    22862286        /* Notify about the error: */
    22872287        return UINotificationMessage::cannotToggleAudioInput(comAdapter, machineName(), fEnabled);
     
    22932293    {
    22942294        /* Make sure action is updated: */
    2295         uisession()->updateAudioInput();
     2295        uimachine()->updateStateAudioActions();
    22962296        /* Notify about the error: */
    22972297        return UINotificationMessage::cannotSaveMachineSettings(machine());
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98398 r98399  
    2828/* Qt includes: */
    2929#include <QApplication>
    30 #include <QMenuBar>
    3130#include <QWidget>
    3231#ifdef VBOX_WS_WIN
     
    5756
    5857/* COM includes: */
    59 #include "CAudioAdapter.h"
    60 #include "CAudioSettings.h"
    6158#include "CGraphicsAdapter.h"
    6259#include "CHostNetworkInterface.h"
    6360#include "CHostUSBDevice.h"
    64 #include "CHostVideoInputDevice.h"
    6561#include "CMedium.h"
    6662#include "CMediumAttachment.h"
    67 #include "CNetworkAdapter.h"
    6863#include "CSnapshot.h"
    69 #include "CRecordingSettings.h"
    7064#include "CStorageController.h"
    7165#include "CSystemProperties.h"
     
    7367#include "CUSBDeviceFilter.h"
    7468#include "CUSBDeviceFilters.h"
    75 #include "CVRDEServer.h"
     69#ifdef VBOX_WITH_NETFLT
     70# include "CNetworkAdapter.h"
     71#endif
    7672
    7773/* External includes: */
     
    462458}
    463459
    464 #ifdef RT_OS_DARWIN
    465 void UISession::sltHandleMenuBarConfigurationChange(const QUuid &uMachineID)
    466 {
    467     /* Skip unrelated machine IDs: */
    468     if (uiCommon().managedVMUuid() != uMachineID)
    469         return;
    470 
    471     /* Update Mac OS X menu-bar: */
    472     updateMenu();
    473 }
    474 #endif /* RT_OS_DARWIN */
    475 
    476460void UISession::sltStateChange(KMachineState state)
    477461{
     
    486470        emit sigMachineStateChange();
    487471    }
    488 }
    489 
    490 void UISession::sltVRDEChange()
    491 {
    492     /* Make sure VRDE server is present: */
    493     const CVRDEServer server = machine().GetVRDEServer();
    494     AssertMsgReturnVoid(machine().isOk() && !server.isNull(),
    495                         ("VRDE server should NOT be null!\n"));
    496 
    497     /* Check/Uncheck VRDE Server action depending on feature status: */
    498     actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(true);
    499     actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->setChecked(server.GetEnabled());
    500     actionPool()->action(UIActionIndexRT_M_View_T_VRDEServer)->blockSignals(false);
    501 
    502     /* Notify listeners about VRDE change: */
    503     emit sigVRDEChange();
    504 }
    505 
    506 void UISession::sltRecordingChange()
    507 {
    508     CRecordingSettings comRecordingSettings = machine().GetRecordingSettings();
    509 
    510     /* Check/Uncheck Capture action depending on feature status: */
    511     actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start)->blockSignals(true);
    512     actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start)->setChecked(comRecordingSettings.GetEnabled());
    513     actionPool()->action(UIActionIndexRT_M_View_M_Recording_T_Start)->blockSignals(false);
    514 
    515     /* Notify listeners about Recording change: */
    516     emit sigRecordingChange();
    517 }
    518 
    519 void UISession::sltHandleStorageDeviceChange(const CMediumAttachment &attachment, bool fRemoved, bool fSilent)
    520 {
    521     /* Update action restrictions: */
    522     updateActionRestrictions();
    523 
    524     /* Notify listeners about storage device change: */
    525     emit sigStorageDeviceChange(attachment, fRemoved, fSilent);
    526 }
    527 
    528 void UISession::sltAudioAdapterChange()
    529 {
    530     /* Make sure Audio adapter is present: */
    531     const CAudioSettings comAudioSettings = machine().GetAudioSettings();
    532     const CAudioAdapter  comAdapter  = comAudioSettings.GetAdapter();
    533     AssertMsgReturnVoid(machine().isOk() && comAdapter.isNotNull(),
    534                         ("Audio adapter should NOT be null!\n"));
    535 
    536     /* Check/Uncheck Audio adapter output/input actions depending on features status: */
    537     actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(true);
    538     actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->setChecked(comAdapter.GetEnabledOut());
    539     actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(false);
    540     actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(true);
    541     actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->setChecked(comAdapter.GetEnabledIn());
    542     actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(false);
    543 
    544     /* Notify listeners about Audio adapter change: */
    545     emit sigAudioAdapterChange();
    546 
    547472}
    548473
     
    605530        m_fIsGuestSupportsSeamless = fIsGuestSupportsSeamless;
    606531
    607         /* Make sure action-pool knows whether GA supports graphics: */
    608         actionPool()->toRuntime()->setGuestSupportsGraphics(m_fIsGuestSupportsGraphics);
    609 
    610         if (actionPool()->action(UIActionIndexRT_M_Devices_S_UpgradeGuestAdditions))
    611             actionPool()->action(UIActionIndexRT_M_Devices_S_UpgradeGuestAdditions)->setEnabled(guestAdditionsUpgradable());
    612 
    613532        /* Notify listeners about GA state really changed: */
    614533        LogRel(("GUI: UISession::sltAdditionsChange: GA state really changed, notifying listeners.\n"));
     
    627546    , m_pMachine(pMachine)
    628547    , m_pConsoleEventhandler(0)
    629     , m_pActionPool(0)
    630 #ifdef VBOX_WS_MAC
    631     , m_pMenuBar(0)
    632 #endif /* VBOX_WS_MAC */
    633548    /* Common variables: */
    634549    , m_machineStatePrevious(KMachineState_Null)
     
    669584
    670585    /* Prepare GUI stuff: */
    671     prepareActions();
    672586    prepareConnections();
    673587    prepareSignalHandling();
     
    749663            this, &UISession::sltAdditionsChange);
    750664    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigAudioAdapterChange,
    751             this, &UISession::sltAudioAdapterChange);
     665            this, &UISession::sigAudioAdapterChange);
    752666    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigClipboardModeChange,
    753667            this, &UISession::sigClipboardModeChange);
     
    763677            this, &UISession::sigNetworkAdapterChange);
    764678    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigRecordingChange,
    765             this, &UISession::sltRecordingChange);
     679            this, &UISession::sigRecordingChange);
    766680    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigSharedFolderChange,
    767681            this, &UISession::sigSharedFolderChange);
     
    769683            this, &UISession::sltStateChange);
    770684    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigStorageDeviceChange,
    771             this, &UISession::sltHandleStorageDeviceChange);
     685            this, &UISession::sigStorageDeviceChange);
    772686    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigUSBControllerChange,
    773687            this, &UISession::sigUSBControllerChange);
     
    775689            this, &UISession::sigUSBDeviceStateChange);
    776690    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigVRDEChange,
    777             this, &UISession::sltVRDEChange);
     691            this, &UISession::sigVRDEChange);
    778692    connect(m_pConsoleEventhandler, &UIConsoleEventHandler::sigRuntimeError,
    779693            this, &UISession::sigRuntimeError);
     
    803717}
    804718
    805 void UISession::prepareActions()
    806 {
    807     /* Create action-pool: */
    808     m_pActionPool = UIActionPool::create(UIActionPoolType_Runtime);
    809     if (actionPool())
    810     {
    811         /* Make sure action-pool knows guest-screen count: */
    812         actionPool()->toRuntime()->setGuestScreenCount(m_frameBufferVector.size());
    813         /* Update action restrictions: */
    814         updateActionRestrictions();
    815 
    816 #ifdef VBOX_WS_MAC
    817         /* Create Mac OS X menu-bar: */
    818         m_pMenuBar = new QMenuBar;
    819         if (m_pMenuBar)
    820         {
    821             /* Configure Mac OS X menu-bar: */
    822             connect(gEDataManager, &UIExtraDataManager::sigMenuBarConfigurationChange,
    823                     this, &UISession::sltHandleMenuBarConfigurationChange);
    824             /* Update Mac OS X menu-bar: */
    825             updateMenu();
    826         }
    827 #endif /* VBOX_WS_MAC */
    828         /* Postpone enabling the GA update action until GA's are loaded: */
    829         if (actionPool()->action(UIActionIndexRT_M_Devices_S_UpgradeGuestAdditions))
    830             actionPool()->action(UIActionIndexRT_M_Devices_S_UpgradeGuestAdditions)->setEnabled(false);
    831     }
    832 }
    833 
    834719void UISession::prepareConnections()
    835720{
     
    856741        const QUuid uMachineID = uiCommon().managedVMUuid();
    857742
    858         /* Should guest autoresize? */
    859         QAction *pGuestAutoresizeSwitch = actionPool()->action(UIActionIndexRT_M_View_T_GuestAutoresize);
    860         pGuestAutoresizeSwitch->setChecked(gEDataManager->guestScreenAutoResizeEnabled(uMachineID));
    861 
    862 #ifdef VBOX_WS_MAC
    863         /* User-element (Menu-bar and Dock) options: */
    864         {
    865             const bool fDisabled = gEDataManager->guiFeatureEnabled(GUIFeatureType_NoUserElements);
    866             if (fDisabled)
    867                 UICocoaApplication::instance()->hideUserElements();
    868         }
    869 #else /* !VBOX_WS_MAC */
    870         /* Menu-bar options: */
    871         {
    872             const bool fEnabledGlobally = !gEDataManager->guiFeatureEnabled(GUIFeatureType_NoMenuBar);
    873             const bool fEnabledForMachine = gEDataManager->menuBarEnabled(uMachineID);
    874             const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
    875             QAction *pActionMenuBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_S_Settings);
    876             pActionMenuBarSettings->setEnabled(fEnabled);
    877             QAction *pActionMenuBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_MenuBar_T_Visibility);
    878             pActionMenuBarSwitch->blockSignals(true);
    879             pActionMenuBarSwitch->setChecked(fEnabled);
    880             pActionMenuBarSwitch->blockSignals(false);
    881         }
    882 #endif /* !VBOX_WS_MAC */
    883 
    884         /* Status-bar options: */
    885         {
    886             const bool fEnabledGlobally = !gEDataManager->guiFeatureEnabled(GUIFeatureType_NoStatusBar);
    887             const bool fEnabledForMachine = gEDataManager->statusBarEnabled(uMachineID);
    888             const bool fEnabled = fEnabledGlobally && fEnabledForMachine;
    889             QAction *pActionStatusBarSettings = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_S_Settings);
    890             pActionStatusBarSettings->setEnabled(fEnabled);
    891             QAction *pActionStatusBarSwitch = actionPool()->action(UIActionIndexRT_M_View_M_StatusBar_T_Visibility);
    892             pActionStatusBarSwitch->blockSignals(true);
    893             pActionStatusBarSwitch->setChecked(fEnabled);
    894             pActionStatusBarSwitch->blockSignals(false);
    895         }
    896 
    897         /* Input options: */
    898         actionPool()->action(UIActionIndexRT_M_Input_M_Mouse_T_Integration)->setChecked(uimachine()->isMouseIntegrated());
    899 
    900         /* Devices options: */
    901         {
    902             const CAudioSettings comAudioSettings = m_machine.GetAudioSettings();
    903             const CAudioAdapter  comAdapter = comAudioSettings.GetAdapter();
    904             actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(true);
    905             actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->setChecked(comAdapter.GetEnabledOut());
    906             actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Output)->blockSignals(false);
    907             actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(true);
    908             actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->setChecked(comAdapter.GetEnabledIn());
    909             actionPool()->action(UIActionIndexRT_M_Devices_M_Audio_T_Input)->blockSignals(false);
    910         }
    911 
    912743        /* What is the default close action and the restricted are? */
    913744        m_defaultCloseAction = gEDataManager->defaultMachineCloseAction(uMachineID);
     
    918749                                     && (m_restrictedCloseActions & MachineCloseAction_PowerOff);
    919750    }
    920 }
    921 
    922 void UISession::cleanupActions()
    923 {
    924 #ifdef VBOX_WS_MAC
    925     /* Destroy Mac OS X menu-bar: */
    926     delete m_pMenuBar;
    927     m_pMenuBar = 0;
    928 #endif /* VBOX_WS_MAC */
    929 
    930     /* Destroy action-pool if necessary: */
    931     if (actionPool())
    932         UIActionPool::destroy(actionPool());
    933751}
    934752
     
    950768    }
    951769    m_frameBufferVector.clear();
    952 
    953     /* Make sure action-pool knows guest-screen count: */
    954     if (actionPool())
    955         actionPool()->toRuntime()->setGuestScreenCount(m_frameBufferVector.size());
    956770}
    957771
     
    1005819    }
    1006820}
    1007 
    1008 void UISession::cleanup()
    1009 {
    1010     /* Cleanup GUI stuff: */
    1011     //cleanupSignalHandling();
    1012     //cleanupScreens();
    1013     //cleanupConnections();
    1014     cleanupActions();
    1015 }
    1016 
    1017 #ifdef VBOX_WS_MAC
    1018 void UISession::updateMenu()
    1019 {
    1020     /* Rebuild Mac OS X menu-bar: */
    1021     m_pMenuBar->clear();
    1022     foreach (QMenu *pMenu, actionPool()->menus())
    1023     {
    1024         UIMenu *pMenuUI = qobject_cast<UIMenu*>(pMenu);
    1025         if (!pMenuUI->isConsumable() || !pMenuUI->isConsumed())
    1026             m_pMenuBar->addMenu(pMenuUI);
    1027         if (pMenuUI->isConsumable() && !pMenuUI->isConsumed())
    1028             pMenuUI->setConsumed(true);
    1029     }
    1030     /* Update the dock menu as well: */
    1031     if (machineLogic())
    1032         machineLogic()->updateDock();
    1033 }
    1034 #endif /* VBOX_WS_MAC */
    1035821
    1036822bool UISession::preprocessInitialization()
     
    12691055}
    12701056
    1271 void UISession::updateActionRestrictions()
    1272 {
    1273     /* Get host and prepare restrictions: */
    1274     const CHost host = uiCommon().host();
    1275     UIExtraDataMetaDefs::RuntimeMenuMachineActionType restrictionForMachine = UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Invalid;
    1276     UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionForView = UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid;
    1277     UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionForDevices = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
    1278 
    1279     /* Separate process stuff: */
    1280     {
    1281         /* Initialize 'Machine' menu: */
    1282         if (!uiCommon().isSeparateProcess())
    1283             restrictionForMachine = (UIExtraDataMetaDefs::RuntimeMenuMachineActionType)(restrictionForMachine | UIExtraDataMetaDefs::RuntimeMenuMachineActionType_Detach);
    1284     }
    1285 
    1286     /* VRDE server stuff: */
    1287     {
    1288         /* Initialize 'View' menu: */
    1289         const CVRDEServer server = machine().GetVRDEServer();
    1290         if (server.isNull())
    1291             restrictionForView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(restrictionForView | UIExtraDataMetaDefs::RuntimeMenuViewActionType_VRDEServer);
    1292     }
    1293 
    1294     /* Storage stuff: */
    1295     {
    1296         /* Initialize CD/FD menus: */
    1297         int iDevicesCountCD = 0;
    1298         int iDevicesCountFD = 0;
    1299         foreach (const CMediumAttachment &attachment, machine().GetMediumAttachments())
    1300         {
    1301             if (attachment.GetType() == KDeviceType_DVD)
    1302                 ++iDevicesCountCD;
    1303             if (attachment.GetType() == KDeviceType_Floppy)
    1304                 ++iDevicesCountFD;
    1305         }
    1306         QAction *pOpticalDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices);
    1307         QAction *pFloppyDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices);
    1308         pOpticalDevicesMenu->setData(iDevicesCountCD);
    1309         pFloppyDevicesMenu->setData(iDevicesCountFD);
    1310         if (!iDevicesCountCD)
    1311             restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
    1312         if (!iDevicesCountFD)
    1313             restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
    1314     }
    1315 
    1316     /* Audio stuff: */
    1317     {
    1318         /* Check whether audio controller is enabled. */
    1319         const CAudioSettings comAudioSettings = machine().GetAudioSettings();
    1320         const CAudioAdapter  comAdapter = comAudioSettings.GetAdapter();
    1321         if (comAdapter.isNull() || !comAdapter.GetEnabled())
    1322             restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Audio);
    1323     }
    1324 
    1325     /* Network stuff: */
    1326     {
    1327         /* Initialize Network menu: */
    1328         bool fAtLeastOneAdapterActive = false;
    1329         const KChipsetType chipsetType = machine().GetChipsetType();
    1330         ULONG uSlots = uiCommon().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(chipsetType);
    1331         for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
    1332         {
    1333             const CNetworkAdapter &adapter = machine().GetNetworkAdapter(uSlot);
    1334             if (adapter.GetEnabled())
    1335             {
    1336                 fAtLeastOneAdapterActive = true;
    1337                 break;
    1338             }
    1339         }
    1340         if (!fAtLeastOneAdapterActive)
    1341             restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
    1342     }
    1343 
    1344     /* USB stuff: */
    1345     {
    1346         /* Check whether there is at least one USB controller with an available proxy. */
    1347         const bool fUSBEnabled =    !machine().GetUSBDeviceFilters().isNull()
    1348                                  && !machine().GetUSBControllers().isEmpty()
    1349                                  && machine().GetUSBProxyAvailable();
    1350         if (!fUSBEnabled)
    1351             restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
    1352     }
    1353 
    1354     /* WebCams stuff: */
    1355     {
    1356         /* Check whether there is an accessible video input devices pool: */
    1357         host.GetVideoInputDevices();
    1358         const bool fWebCamsEnabled = host.isOk() && !machine().GetUSBControllers().isEmpty();
    1359         if (!fWebCamsEnabled)
    1360             restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
    1361     }
    1362 
    1363     /* Apply cumulative restriction for 'Machine' menu: */
    1364     actionPool()->toRuntime()->setRestrictionForMenuMachine(UIActionRestrictionLevel_Session, restrictionForMachine);
    1365     /* Apply cumulative restriction for 'View' menu: */
    1366     actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Session, restrictionForView);
    1367     /* Apply cumulative restriction for 'Devices' menu: */
    1368     actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restrictionForDevices);
    1369 }
    1370 
    13711057#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
    13721058/**
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98386 r98399  
    179179    KMachineState machineStatePrevious() const { return m_machineStatePrevious; }
    180180    KMachineState machineState() const { return m_machineState; }
    181     UIActionPool *actionPool() const { return m_pActionPool; }
    182181    UIMachineLogic* machineLogic() const;
    183182    QWidget* mainMachineWindow() const;
     
    263262    const QVector<UIFrameBuffer*>& frameBuffers() const { return m_frameBufferVector; }
    264263
    265     /** Updates VRDE Server action state. */
    266     void updateStatusVRDE() { sltVRDEChange(); }
    267     /** Updates Recording action state. */
    268     void updateStatusRecording() { sltRecordingChange(); }
    269     /** Updates Audio output action state. */
    270     void updateAudioOutput() { sltAudioAdapterChange(); }
    271     /** Updates Audio input action state. */
    272     void updateAudioInput() { sltAudioAdapterChange(); }
    273 
    274264    /** @name CPU hardware virtualization features for VM.
    275265     ** @{ */
     
    305295    void sltDetachCOM();
    306296
    307 #ifdef RT_OS_DARWIN
    308     /** Mac OS X: Handles menu-bar configuration-change. */
    309     void sltHandleMenuBarConfigurationChange(const QUuid &uMachineID);
    310 #endif /* RT_OS_DARWIN */
    311 
    312297    /* Console events slots */
    313298    void sltStateChange(KMachineState state);
    314299    void sltAdditionsChange();
    315     void sltVRDEChange();
    316     void sltRecordingChange();
    317     /** Handles storage device change for @a attachment, which was @a fRemoved and it was @a fSilent for guest. */
    318     void sltHandleStorageDeviceChange(const CMediumAttachment &attachment, bool fRemoved, bool fSilent);
    319     /** Handles audio adapter change. */
    320     void sltAudioAdapterChange();
    321300
    322301    /** Handles signal about machine state saved.
     
    347326    void prepareConsoleEventHandlers();
    348327    void prepareFramebuffers();
    349     void prepareActions();
    350328    void prepareConnections();
    351329    void prepareSignalHandling();
     
    355333
    356334    /* Cleanup helpers: */
    357     //void cleanupSignalHandling() {}
    358     //void cleanupScreens() {}
    359     //void cleanupConnections() {}
    360     void cleanupActions();
    361335    void cleanupFramebuffers();
    362336    void cleanupConsoleEventHandlers();
    363337    void cleanupNotificationCenter();
    364338    void cleanupSession();
    365     void cleanup();
    366 
    367 #ifdef VBOX_WS_MAC
    368     /** Mac OS X: Updates menu-bar content. */
    369     void updateMenu();
    370 #endif /* VBOX_WS_MAC */
    371339
    372340    /* Common helpers: */
     
    376344    /** Loads VM settings. */
    377345    void loadVMSettings();
    378 
    379     /** Updates action restrictions. */
    380     void updateActionRestrictions();
    381346
    382347    /* Private variables: */
     
    406371    QString m_strMachineName;
    407372
    408     /** Holds the action-pool instance. */
    409     UIActionPool *m_pActionPool;
    410 
    411 #ifdef VBOX_WS_MAC
    412     /** Holds the menu-bar instance. */
    413     QMenuBar *m_pMenuBar;
    414 #endif /* VBOX_WS_MAC */
    415 
    416373    /* Frame-buffers vector: */
    417374    QVector<UIFrameBuffer*> m_frameBufferVector;
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