VirtualBox

Ignore:
Timestamp:
Sep 23, 2015 4:13:09 PM (9 years ago)
Author:
vboxsync
Message:

FE/Qt: Runtime UI: Update session action restrictions on IStorageDeviceChangedEvent as well.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r57873 r57874  
    776776void UISession::sltHandleStorageDeviceChange(const CMediumAttachment &attachment, bool fRemoved, bool fSilent)
    777777{
     778    /* Update action restrictions: */
     779    updateActionRestrictions();
     780
    778781    /* Notify listeners about storage device change: */
    779782    emit sigStorageDeviceChange(attachment, fRemoved, fSilent);
     
    10571060        actionPool()->toRuntime()->setSession(this);
    10581061
    1059         /* Get host: */
    1060         const CHost host = vboxGlobal().host();
    1061         UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionForView = UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid;
    1062         UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionForDevices = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
    1063 
    1064         /* VRDE server stuff: */
    1065         {
    1066             /* Initialize 'View' menu: */
    1067             const CVRDEServer server = machine().GetVRDEServer();
    1068             if (server.isNull())
    1069                 restrictionForView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(restrictionForView | UIExtraDataMetaDefs::RuntimeMenuViewActionType_VRDEServer);
    1070         }
    1071 
    1072         /* Storage stuff: */
    1073         {
    1074             /* Initialize CD/FD menus: */
    1075             int iDevicesCountCD = 0;
    1076             int iDevicesCountFD = 0;
    1077             foreach (const CMediumAttachment &attachment, machine().GetMediumAttachments())
    1078             {
    1079                 if (attachment.GetType() == KDeviceType_DVD)
    1080                     ++iDevicesCountCD;
    1081                 if (attachment.GetType() == KDeviceType_Floppy)
    1082                     ++iDevicesCountFD;
    1083             }
    1084             QAction *pOpticalDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices);
    1085             QAction *pFloppyDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices);
    1086             pOpticalDevicesMenu->setData(iDevicesCountCD);
    1087             pFloppyDevicesMenu->setData(iDevicesCountFD);
    1088             if (!iDevicesCountCD)
    1089                 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
    1090             if (!iDevicesCountFD)
    1091                 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
    1092         }
    1093 
    1094         /* Network stuff: */
    1095         {
    1096             /* Initialize Network menu: */
    1097             bool fAtLeastOneAdapterActive = false;
    1098             const KChipsetType chipsetType = machine().GetChipsetType();
    1099             ULONG uSlots = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(chipsetType);
    1100             for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
    1101             {
    1102                 const CNetworkAdapter &adapter = machine().GetNetworkAdapter(uSlot);
    1103                 if (adapter.GetEnabled())
    1104                 {
    1105                     fAtLeastOneAdapterActive = true;
    1106                     break;
    1107                 }
    1108             }
    1109             if (!fAtLeastOneAdapterActive)
    1110                 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
    1111         }
    1112 
    1113         /* USB stuff: */
    1114         {
    1115             /* Check whether there is at least one USB controller with an available proxy. */
    1116             const bool fUSBEnabled =    !machine().GetUSBDeviceFilters().isNull()
    1117                                      && !machine().GetUSBControllers().isEmpty()
    1118                                      && machine().GetUSBProxyAvailable();
    1119             if (!fUSBEnabled)
    1120                 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
    1121         }
    1122 
    1123         /* WebCams stuff: */
    1124         {
    1125             /* Check whether there is an accessible video input devices pool: */
    1126             host.GetVideoInputDevices();
    1127             const bool fWebCamsEnabled = host.isOk() && !machine().GetUSBControllers().isEmpty();
    1128             if (!fWebCamsEnabled)
    1129                 restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
    1130         }
    1131 
    1132         /* Apply cumulative restriction for 'View' menu: */
    1133         actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Session, restrictionForView);
    1134         /* Apply cumulative restriction for 'Devices' menu: */
    1135         actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restrictionForDevices);
     1062        /* Update action restrictions: */
     1063        updateActionRestrictions();
    11361064
    11371065#ifdef Q_WS_MAC
     
    19821910}
    19831911
     1912void UISession::updateActionRestrictions()
     1913{
     1914    /* Get host and prepare restrictions: */
     1915    const CHost host = vboxGlobal().host();
     1916    UIExtraDataMetaDefs::RuntimeMenuViewActionType restrictionForView = UIExtraDataMetaDefs::RuntimeMenuViewActionType_Invalid;
     1917    UIExtraDataMetaDefs::RuntimeMenuDevicesActionType restrictionForDevices = UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Invalid;
     1918
     1919    /* VRDE server stuff: */
     1920    {
     1921        /* Initialize 'View' menu: */
     1922        const CVRDEServer server = machine().GetVRDEServer();
     1923        if (server.isNull())
     1924            restrictionForView = (UIExtraDataMetaDefs::RuntimeMenuViewActionType)(restrictionForView | UIExtraDataMetaDefs::RuntimeMenuViewActionType_VRDEServer);
     1925    }
     1926
     1927    /* Storage stuff: */
     1928    {
     1929        /* Initialize CD/FD menus: */
     1930        int iDevicesCountCD = 0;
     1931        int iDevicesCountFD = 0;
     1932        foreach (const CMediumAttachment &attachment, machine().GetMediumAttachments())
     1933        {
     1934            if (attachment.GetType() == KDeviceType_DVD)
     1935                ++iDevicesCountCD;
     1936            if (attachment.GetType() == KDeviceType_Floppy)
     1937                ++iDevicesCountFD;
     1938        }
     1939        QAction *pOpticalDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices);
     1940        QAction *pFloppyDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices);
     1941        pOpticalDevicesMenu->setData(iDevicesCountCD);
     1942        pFloppyDevicesMenu->setData(iDevicesCountFD);
     1943        if (!iDevicesCountCD)
     1944            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
     1945        if (!iDevicesCountFD)
     1946            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
     1947    }
     1948
     1949    /* Network stuff: */
     1950    {
     1951        /* Initialize Network menu: */
     1952        bool fAtLeastOneAdapterActive = false;
     1953        const KChipsetType chipsetType = machine().GetChipsetType();
     1954        ULONG uSlots = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(chipsetType);
     1955        for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
     1956        {
     1957            const CNetworkAdapter &adapter = machine().GetNetworkAdapter(uSlot);
     1958            if (adapter.GetEnabled())
     1959            {
     1960                fAtLeastOneAdapterActive = true;
     1961                break;
     1962            }
     1963        }
     1964        if (!fAtLeastOneAdapterActive)
     1965            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_Network);
     1966    }
     1967
     1968    /* USB stuff: */
     1969    {
     1970        /* Check whether there is at least one USB controller with an available proxy. */
     1971        const bool fUSBEnabled =    !machine().GetUSBDeviceFilters().isNull()
     1972                                 && !machine().GetUSBControllers().isEmpty()
     1973                                 && machine().GetUSBProxyAvailable();
     1974        if (!fUSBEnabled)
     1975            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_USBDevices);
     1976    }
     1977
     1978    /* WebCams stuff: */
     1979    {
     1980        /* Check whether there is an accessible video input devices pool: */
     1981        host.GetVideoInputDevices();
     1982        const bool fWebCamsEnabled = host.isOk() && !machine().GetUSBControllers().isEmpty();
     1983        if (!fWebCamsEnabled)
     1984            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)(restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_WebCams);
     1985    }
     1986
     1987    /* Apply cumulative restriction for 'View' menu: */
     1988    actionPool()->toRuntime()->setRestrictionForMenuView(UIActionRestrictionLevel_Session, restrictionForView);
     1989    /* Apply cumulative restriction for 'Devices' menu: */
     1990    actionPool()->toRuntime()->setRestrictionForMenuDevices(UIActionRestrictionLevel_Session, restrictionForDevices);
     1991}
     1992
    19841993#ifdef VBOX_GUI_WITH_KEYS_RESET_HANDLER
    19851994/**
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r57873 r57874  
    381381    void updateHostScreenData();
    382382
     383    /** Updates action restrictions. */
     384    void updateActionRestrictions();
     385
    383386    /* Private variables: */
    384387    UIMachine *m_pMachine;
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