VirtualBox

Changeset 52132 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 22, 2014 4:23:57 PM (10 years ago)
Author:
vboxsync
Message:

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

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

Legend:

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

    r52130 r52132  
    10091009void UIMachineLogic::prepareMenu()
    10101010{
    1011     /* Update action-pool visibility: */
    1012     uisession()->updateActionPoolVisibility();
    1013 
    10141011    /* Update 'Machine' menu: */
    10151012    updateMenuMachine();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r52130 r52132  
    172172    , m_fIsHidingHostPointer(true)
    173173{
     174    /* Prepare actions: */
     175    prepareActions();
     176
    174177    /* Prepare connections: */
    175178    prepareConnections();
     
    967970    connect(gConsoleEvents, SIGNAL(sigGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)),
    968971            this, SLOT(sltGuestMonitorChange(KGuestMonitorChangedEventType, ulong, QRect)));
     972}
     973
     974void UISession::prepareActions()
     975{
     976    /* Get host/machine: */
     977    const CHost host = vboxGlobal().host();
     978    const CMachine machine = session().GetConsole().GetMachine();
     979
     980    /* Storage stuff: */
     981    {
     982        /* Initialize CD/FD menus: */
     983        int iDevicesCountCD = 0;
     984        int iDevicesCountFD = 0;
     985        foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments())
     986        {
     987            if (attachment.GetType() == KDeviceType_DVD)
     988                ++iDevicesCountCD;
     989            if (attachment.GetType() == KDeviceType_Floppy)
     990                ++iDevicesCountFD;
     991        }
     992        QAction *pOpticalDevicesMenu = gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices);
     993        QAction *pFloppyDevicesMenu = gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices);
     994        pOpticalDevicesMenu->setData(iDevicesCountCD);
     995        pOpticalDevicesMenu->setVisible(iDevicesCountCD);
     996        pFloppyDevicesMenu->setData(iDevicesCountFD);
     997        pFloppyDevicesMenu->setVisible(iDevicesCountFD);
     998    }
     999
     1000    /* Network stuff: */
     1001    {
     1002        /* Initialize Network menu: */
     1003        bool fAtLeastOneAdapterActive = false;
     1004        const KChipsetType chipsetType = machine.GetChipsetType();
     1005        ULONG uSlots = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(chipsetType);
     1006        for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
     1007        {
     1008            const CNetworkAdapter &adapter = machine.GetNetworkAdapter(uSlot);
     1009            if (adapter.GetEnabled())
     1010            {
     1011                fAtLeastOneAdapterActive = true;
     1012                break;
     1013            }
     1014        }
     1015        gActionPool->action(UIActionIndexRuntime_Menu_Network)->setVisible(fAtLeastOneAdapterActive);
     1016    }
     1017
     1018    /* USB stuff: */
     1019    {
     1020        /* Check whether there is at least one USB controller with an available proxy. */
     1021        const bool fUSBEnabled =    !machine.GetUSBDeviceFilters().isNull()
     1022                                 && !machine.GetUSBControllers().isEmpty()
     1023                                 && machine.GetUSBProxyAvailable();
     1024        gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->setVisible(fUSBEnabled);
     1025    }
     1026
     1027    /* WebCams stuff: */
     1028    {
     1029        /* Check whether there is an accessible video input devices pool: */
     1030        host.GetVideoInputDevices();
     1031        const bool fWebCamsEnabled = host.isOk() && !machine.GetUSBControllers().isEmpty();
     1032        gActionPool->action(UIActionIndexRuntime_Menu_WebCams)->setVisible(fWebCamsEnabled);
     1033    }
    9691034}
    9701035
     
    14431508}
    14441509
    1445 void UISession::updateActionPoolVisibility()
    1446 {
    1447     /* Get host: */
    1448     const CHost &host = vboxGlobal().host();
    1449 
    1450     /* Get uisession machine: */
    1451     const CMachine &machine = session().GetConsole().GetMachine();
    1452 
    1453     /* Storage stuff: */
    1454     {
    1455         /* Initialize CD/FD menus: */
    1456         int iDevicesCountCD = 0;
    1457         int iDevicesCountFD = 0;
    1458         const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();
    1459         for (int i = 0; i < attachments.size(); ++i)
    1460         {
    1461             const CMediumAttachment &attachment = attachments[i];
    1462             if (attachment.GetType() == KDeviceType_DVD)
    1463                 ++iDevicesCountCD;
    1464             if (attachment.GetType() == KDeviceType_Floppy)
    1465                 ++iDevicesCountFD;
    1466         }
    1467         QAction *pOpticalDevicesMenu = gActionPool->action(UIActionIndexRuntime_Menu_OpticalDevices);
    1468         QAction *pFloppyDevicesMenu = gActionPool->action(UIActionIndexRuntime_Menu_FloppyDevices);
    1469         pOpticalDevicesMenu->setData(iDevicesCountCD);
    1470         pOpticalDevicesMenu->setVisible(iDevicesCountCD);
    1471         pFloppyDevicesMenu->setData(iDevicesCountFD);
    1472         pFloppyDevicesMenu->setVisible(iDevicesCountFD);
    1473     }
    1474 
    1475     /* Network stuff: */
    1476     {
    1477         bool fAtLeastOneAdapterActive = false;
    1478         ULONG uSlots = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(KChipsetType_PIIX3);
    1479         for (ULONG uSlot = 0; uSlot < uSlots; ++uSlot)
    1480         {
    1481             const CNetworkAdapter &adapter = machine.GetNetworkAdapter(uSlot);
    1482             if (adapter.GetEnabled())
    1483             {
    1484                 fAtLeastOneAdapterActive = true;
    1485                 break;
    1486             }
    1487         }
    1488 
    1489         /* Show/Hide Network sub-menu depending on overall adapters activity status: */
    1490         gActionPool->action(UIActionIndexRuntime_Menu_Network)->setVisible(fAtLeastOneAdapterActive);
    1491     }
    1492 
    1493     /* USB stuff: */
    1494     {
    1495         /* Check whether there is at least one USB controllers with an available proxy. */
    1496         bool fUSBEnabled =    !machine.GetUSBDeviceFilters().isNull()
    1497                            && !machine.GetUSBControllers().isEmpty()
    1498                            && machine.GetUSBProxyAvailable();
    1499 
    1500         /* Show/Hide USB menu depending on controller availability, activity and USB-proxy presence: */
    1501         gActionPool->action(UIActionIndexRuntime_Menu_USBDevices)->setVisible(fUSBEnabled);
    1502     }
    1503 
    1504     /* WebCams stuff: */
    1505     {
    1506         /* Check whether there is an accessible video input devices pool: */
    1507         const CHostVideoInputDeviceVector &webcams = host.GetVideoInputDevices(); Q_UNUSED(webcams);
    1508         bool fWebCamsEnabled = host.isOk() && !machine.GetUSBControllers().isEmpty();
    1509 
    1510         /* Show/Hide WebCams menu depending on ExtPack availability: */
    1511         gActionPool->action(UIActionIndexRuntime_Menu_WebCams)->setVisible(fWebCamsEnabled);
    1512     }
    1513 }
    1514 
    15151510bool UISession::preparePowerUp()
    15161511{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r52129 r52132  
    9292    UIMachineLogic* machineLogic() const;
    9393    QWidget* mainMachineWindow() const;
    94     void updateActionPoolVisibility();
    9594    QCursor cursor() const { return m_cursor; }
    9695
     
    319318
    320319    /* Prepare helpers: */
     320    void prepareActions();
    321321    void prepareConnections();
    322322    void prepareConsoleEventHandlers();
     
    331331    void cleanupConsoleEventHandlers();
    332332    void cleanupConnections();
     333    //void cleanupActions() {}
    333334
    334335    /* Update helpers: */
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