VirtualBox

Ignore:
Timestamp:
Nov 16, 2010 11:32:27 AM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: New running VM ui: Cumulative patch for Device menu elements visibility.

File:
1 edited

Legend:

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

    r33844 r34105  
    620620    CMachine machine = session().GetConsole().GetMachine();
    621621
    622     /* Availability settings: */
    623     {
    624         /* VRDE Stuff: */
    625         CVRDEServer server = machine.GetVRDEServer();
    626         if (server.isNull())
    627         {
    628             /* Hide VRDE Action: */
    629             uimachine()->actionsPool()->action(UIActionIndex_Toggle_VRDEServer)->setVisible(false);
    630         }
    631         else
    632         {
    633             /* Check/Uncheck VRDE action depending on VRDE server status: */
    634             uimachine()->actionsPool()->action(UIActionIndex_Toggle_VRDEServer)->setChecked(server.GetEnabled());
    635         }
    636     }
    637 
    638622    /* Load extra-data settings: */
    639623    {
     
    941925    const CMachine &machine = session().GetConsole().GetMachine();
    942926
    943     /* Availability settings: */
    944     {
    945         /* USB Stuff: */
    946         const CUSBController &usbController = machine.GetUSBController();
    947         if (   usbController.isNull()
    948             || !usbController.GetEnabled()
    949             || !usbController.GetProxyAvailable())
    950         {
    951             /* Hide USB menu if controller is NULL or no USB proxy available: */
    952             uimachine()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->setVisible(false);
    953         }
    954         else
    955         {
    956             /* Enable/Disable USB menu depending on USB controller: */
    957             uimachine()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->setEnabled(usbController.GetEnabled());
    958         }
    959     }
    960 
    961     /* Prepare some initial settings: */
     927    /* Storage stuff: */
    962928    {
    963929        /* Initialize CD/FD menus: */
     
    965931        int iDevicesCountFD = 0;
    966932        const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();
    967         foreach (const CMediumAttachment &attachment, attachments)
    968         {
     933        for (int i = 0; i < attachments.size(); ++i)
     934        {
     935            const CMediumAttachment &attachment = attachments[i];
    969936            if (attachment.GetType() == KDeviceType_DVD)
    970                 ++ iDevicesCountCD;
     937                ++iDevicesCountCD;
    971938            if (attachment.GetType() == KDeviceType_Floppy)
    972                 ++ iDevicesCountFD;
     939                ++iDevicesCountFD;
    973940        }
    974941        QAction *pOpticalDevicesMenu = uimachine()->actionsPool()->action(UIActionIndex_Menu_OpticalDevices);
     
    978945        pFloppyDevicesMenu->setData(iDevicesCountFD);
    979946        pFloppyDevicesMenu->setVisible(iDevicesCountFD);
     947    }
     948
     949    /* VRDE stuff: */
     950    {
     951        /* Get VRDE server: */
     952        CVRDEServer server = machine.GetVRDEServer();
     953        bool fIsVRDEServerAvailable = !server.isNull();
     954        /* Show/Hide VRDE action depending on VRDE server availability status: */
     955        uimachine()->actionsPool()->action(UIActionIndex_Toggle_VRDEServer)->setVisible(fIsVRDEServerAvailable);
     956        /* Check/Uncheck VRDE action depending on VRDE server activity status: */
     957        if (fIsVRDEServerAvailable)
     958            uimachine()->actionsPool()->action(UIActionIndex_Toggle_VRDEServer)->setChecked(server.GetEnabled());
     959    }
     960
     961    /* Network stuff: */
     962    {
     963        bool fAtLeastOneAdapterActive = false;
     964        ULONG uSlots = vboxGlobal().virtualBox().GetSystemProperties().GetNetworkAdapterCount();
     965        for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
     966        {
     967            const CNetworkAdapter &adapter = machine.GetNetworkAdapter(uSlot);
     968            if (adapter.GetEnabled())
     969            {
     970                fAtLeastOneAdapterActive = true;
     971                break;
     972            }
     973        }
     974        /* Show/Hide Network Adapters action depending on overall adapters activity status: */
     975        uimachine()->actionsPool()->action(UIActionIndex_Simple_NetworkAdaptersDialog)->setVisible(fAtLeastOneAdapterActive);
     976    }
     977
     978    /* USB stuff: */
     979    {
     980        /* Get USB controller: */
     981        const CUSBController &usbController = machine.GetUSBController();
     982        bool fUSBControllerEnabled = !usbController.isNull() && usbController.GetEnabled() && usbController.GetProxyAvailable();
     983        /* Show/Hide USB menu depending on controller availability, activity and USB-proxy presence: */
     984        uimachine()->actionsPool()->action(UIActionIndex_Menu_USBDevices)->setVisible(fUSBControllerEnabled);
    980985    }
    981986}
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