VirtualBox

Changeset 98810 in vbox


Ignore:
Timestamp:
Mar 1, 2023 5:20:14 PM (21 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking CMachine wrapper usage step-by-step; Storage menu related stuff.

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

Legend:

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

    r98809 r98810  
    750750{
    751751    return uisession()->setDnDMode(enmMode);
     752}
     753
     754bool UIMachine::acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives)
     755{
     756    return uisession()->acquireAmountOfStorageDevices(cHardDisks, cOpticalDrives, cFloppyDrives);
    752757}
    753758
     
    18341839    {
    18351840        /* Initialize CD/FD menus: */
    1836         int iDevicesCountCD = 0;
    1837         int iDevicesCountFD = 0;
    1838         foreach (const CMediumAttachment &comAttachment, uisession()->machine().GetMediumAttachments())
    1839         {
    1840             if (comAttachment.GetType() == KDeviceType_DVD)
    1841                 ++iDevicesCountCD;
    1842             if (comAttachment.GetType() == KDeviceType_Floppy)
    1843                 ++iDevicesCountFD;
    1844         }
     1841        ulong cHardDisks = 0;
     1842        ulong iOpticalDevices = 0;
     1843        ulong cFloppyDevices = 0;
     1844        acquireAmountOfStorageDevices(cHardDisks, iOpticalDevices, cFloppyDevices);
    18451845        QAction *pOpticalDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_OpticalDevices);
    18461846        QAction *pFloppyDevicesMenu = actionPool()->action(UIActionIndexRT_M_Devices_M_FloppyDevices);
    1847         pOpticalDevicesMenu->setData(iDevicesCountCD);
    1848         pFloppyDevicesMenu->setData(iDevicesCountFD);
    1849         if (!iDevicesCountCD)
     1847        pOpticalDevicesMenu->setData((int)iOpticalDevices);
     1848        pFloppyDevicesMenu->setData((int)cFloppyDevices);
     1849        if (!iOpticalDevices)
    18501850            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
    18511851                                    (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_OpticalDevices);
    1852         if (!iDevicesCountFD)
     1852        if (!cFloppyDevices)
    18531853            restrictionForDevices = (UIExtraDataMetaDefs::RuntimeMenuDevicesActionType)
    18541854                                    (restrictionForDevices | UIExtraDataMetaDefs::RuntimeMenuDevicesActionType_FloppyDevices);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98809 r98810  
    516516    /** @name Storage stuff.
    517517     ** @{ */
     518        /** Enumerates amount of storage devices. */
     519        bool acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives);
     520
    518521        /** Returns a list of storage devices. */
    519522        bool storageDevices(KDeviceType enmDeviceType, QList<StorageDeviceInfo> &guiStorageDevices);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98809 r98810  
    555555    if (!fSuccess)
    556556        UINotificationMessage::cannotAcquireMachineParameter(comMachine);
     557    return fSuccess;
     558}
     559
     560bool UISession::acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives)
     561{
     562    const CMachine comMachine = machine();
     563    ulong cActualHardDisks = 0, cActualOpticalDrives = 0, cActualFloppyDrives = 0;
     564    const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments();
     565    bool fSuccess = comMachine.isOk();
     566    if (!fSuccess)
     567        UINotificationMessage::cannotAcquireMachineParameter(comMachine);
     568    else
     569    {
     570        foreach (const CMediumAttachment &comAttachment, comAttachments)
     571        {
     572            /* Get device type: */
     573            const KDeviceType enmDeviceType = comAttachment.GetType();
     574            fSuccess = comAttachment.isOk();
     575            if (!fSuccess)
     576            {
     577                UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
     578                break;
     579            }
     580
     581            /* And advance corresponding amount: */
     582            switch (enmDeviceType)
     583            {
     584                case KDeviceType_HardDisk: ++cActualHardDisks; break;
     585                case KDeviceType_DVD: ++cActualOpticalDrives; break;
     586                case KDeviceType_Floppy: ++cActualFloppyDrives; break;
     587                default: break;
     588            }
     589        }
     590    }
     591    if (fSuccess)
     592    {
     593        cHardDisks = cActualHardDisks;
     594        cOpticalDrives = cActualOpticalDrives;
     595        cFloppyDrives = cActualFloppyDrives;
     596    }
    557597    return fSuccess;
    558598}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98809 r98810  
    326326    /** @name Storage stuff.
    327327     ** @{ */
     328        /** Enumerates amount of storage devices. */
     329        bool acquireAmountOfStorageDevices(ulong &cHardDisks, ulong &cOpticalDrives, ulong &cFloppyDrives);
     330
    328331        /** Returns a list of storage devices. */
    329332        bool storageDevices(KDeviceType enmDeviceType, QList<StorageDeviceInfo> &guiStorageDevices);
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