VirtualBox

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


Ignore:
Timestamp:
Mar 27, 2014 3:34:51 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: VBoxGlobal: Cleanup medium-mounting functionality, prepare it for hard-drive reattach stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r50910 r50911  
    19421942
    19431943    /* Determine device & medium types: */
    1944     const KDeviceType deviceType = currentAttachment.GetType();
    1945     const UIMediumType mediumType = deviceType == KDeviceType_DVD    ? UIMediumType_DVD :
    1946                                     deviceType == KDeviceType_Floppy ? UIMediumType_Floppy :
    1947                                                                        UIMediumType_Invalid;
    1948     AssertMsgReturnVoid(deviceType != KDeviceType_Null, ("Incorrect storage device type!\n"));
     1944    const UIMediumType mediumType = mediumTypeToLocal(currentAttachment.GetType());
    19491945    AssertMsgReturnVoid(mediumType != UIMediumType_Invalid, ("Incorrect storage medium type!\n"));
    19501946
     
    19541950    pActionOpenExistingMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice(),
    19551951                                                                          mediumType)));
     1952    switch (mediumType)
     1953    {
     1954        case UIMediumType_DVD:
     1955            pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual CD/DVD disk file..."));
     1956            break;
     1957        case UIMediumType_Floppy:
     1958            pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual floppy disk file..."));
     1959            break;
     1960        default:
     1961            break;
     1962    }
    19561963
    19571964
     
    19641971    switch (mediumType)
    19651972    {
    1966         case UIMediumType_DVD: mediums = vboxGlobal().host().GetDVDDrives(); break;
     1973        case UIMediumType_DVD:    mediums = vboxGlobal().host().GetDVDDrives(); break;
    19671974        case UIMediumType_Floppy: mediums = vboxGlobal().host().GetFloppyDrives(); break;
    19681975        default: break;
     
    20012008    switch (mediumType)
    20022009    {
    2003         case UIMediumType_DVD: strRecentMediumAddress = GUI_RecentListCD; break;
     2010        case UIMediumType_DVD:    strRecentMediumAddress = GUI_RecentListCD; break;
    20042011        case UIMediumType_Floppy: strRecentMediumAddress = GUI_RecentListFD; break;
    20052012        default: break;
     
    20492056    pActionUnmountMedium->setEnabled(!currentMedium.isNull());
    20502057    pActionUnmountMedium->setData(QVariant::fromValue(UIMediumTarget(strControllerName, currentAttachment.GetPort(), currentAttachment.GetDevice())));
    2051 
    2052 
    2053     /* Switch CD/FD names/icons: */
    2054     switch (mediumType)
    2055     {
    2056         case UIMediumType_DVD:
    2057             pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual CD/DVD disk file..."));
    2058             pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
    2059             pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/cd_unmount_16px.png", ":/cd_unmount_disabled_16px.png"));
    2060             break;
    2061         case UIMediumType_Floppy:
    2062             pActionOpenExistingMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Choose a virtual floppy disk file..."));
    2063             pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
    2064             pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/fd_unmount_16px.png", ":/fd_unmount_disabled_16px.png"));
    2065             break;
    2066         default:
    2067             break;
    2068     }
     2058    pActionUnmountMedium->setText(QApplication::translate("UIMachineSettingsStorage", "Remove disk from virtual drive"));
     2059    if (mediumType == UIMediumType_DVD)
     2060        pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/cd_unmount_16px.png", ":/cd_unmount_disabled_16px.png"));
     2061    else if (mediumType == UIMediumType_Floppy)
     2062        pActionUnmountMedium->setIcon(UIIconPool::iconSet(":/fd_unmount_16px.png", ":/fd_unmount_disabled_16px.png"));
    20692063}
    20702064
     
    20912085            /* New mount-target attributes: */
    20922086            QString strNewID;
    2093             const bool fSelectWithMediaManager = target.mediumType != UIMediumType_Invalid && target.data.isNull();
    20942087
    20952088            /* Invoke file-open dialog to choose medium ID: */
    2096             if (fSelectWithMediaManager)
     2089            if (target.mediumType != UIMediumType_Invalid && target.data.isNull())
    20972090            {
    20982091                /* Keyboard can be captured by machine-view.
     
    21762169    /* Remount medium to the predefined port/device: */
    21772170    bool fWasMounted = false;
     2171    /* Remounting: */
    21782172    machine.MountMedium(target.name, target.port, target.device, cmedium, false /* force? */);
    2179     if (machine.isOk())
    2180         fWasMounted = true;
    2181     else
     2173    fWasMounted = machine.isOk();
     2174    if (!fWasMounted)
    21822175    {
    21832176        /* Ask for force remounting: */
    21842177        if (msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(strActualID),
    2185                                             fMount, true /* retry? */, activeMachineWindow()))
    2186         {
    2187             /* Force remount medium to the predefined port/device: */
     2178                                            fMount, true /* retry? */))
     2179        {
     2180            /* Force remounting: */
    21882181            machine.MountMedium(target.name, target.port, target.device, cmedium, true /* force? */);
    2189             if (machine.isOk())
    2190                 fWasMounted = true;
    2191             else
     2182            fWasMounted = machine.isOk();
     2183            if (!fWasMounted)
    21922184                msgCenter().cannotRemountMedium(machine, vboxGlobal().medium(strActualID),
    2193                                                 fMount, false /* retry? */, activeMachineWindow());
     2185                                                fMount, false /* retry? */);
    21942186        }
    21952187    }
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