VirtualBox

Changeset 91736 in vbox


Ignore:
Timestamp:
Oct 14, 2021 5:35:29 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9974. Moving the boot medium mount location from the dialog back to UIMachineLogic

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

Legend:

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

    r91719 r91736  
    8181{
    8282    if (m_pCloseButton)
     83    {
    8384        m_pCloseButton->setText(tr("&Close"));
     85        m_pCloseButton->setToolTip(tr("Closes this dialog without resetting the guest or mounting a medium"));
     86    }
    8487    if (m_pResetButton)
    85         m_pResetButton->setText(tr("&Reset"));
     88    {
     89        m_pResetButton->setText(tr("&Reset VM"));
     90        m_pResetButton->setToolTip(tr("Mounts the selected ISO if any and restarts the vm"));
     91    }
    8692
    8793    if (m_pLabel)
    8894        m_pLabel->setText(tr("The virtual machine failed to boot. That might be caused by a missing operating system "
    8995                             "or misconfigured boot order. Mounting an operation install DVD might solve this problem. "
    90                              "Selecting an ISO file will attemt to mount it immediately to the guest machine."));
     96                             "Selecting an ISO file will attempt to mount it after the dialog is closed."));
     97
    9198    if (m_pBootImageLabel)
    9299        m_pBootImageLabel->setText(tr("Boot DVD:"));
     
    204211}
    205212
    206 bool UIBootFailureDialog::insertBootMedium(const QUuid &uMediumId)
    207 {
    208     AssertReturn(!uMediumId.isNull(), false);
    209 
    210     CVirtualBox comVBox = uiCommon().virtualBox();
    211     const CGuestOSType &comOsType = comVBox.GetGuestOSType(m_comMachine.GetOSTypeId());
    212     /* Get recommended controller bus & type: */
    213     const KStorageBus enmRecommendedDvdBus = comOsType.GetRecommendedDVDStorageBus();
    214     const KStorageControllerType enmRecommendedDvdType = comOsType.GetRecommendedDVDStorageController();
    215 
    216     CMediumAttachment comAttachment;
    217     /* Search for an attachment of required bus & type: */
    218     foreach (const CMediumAttachment &comCurrentAttachment, m_comMachine.GetMediumAttachments())
    219     {
    220         /* Determine current attachment's controller: */
    221         const CStorageController &comCurrentController = m_comMachine.GetStorageControllerByName(comCurrentAttachment.GetController());
    222 
    223         if (   comCurrentController.GetBus() == enmRecommendedDvdBus
    224             && comCurrentController.GetControllerType() == enmRecommendedDvdType
    225             && comCurrentAttachment.GetType() == KDeviceType_DVD)
    226         {
    227             comAttachment = comCurrentAttachment;
    228             break;
    229         }
    230     }
    231     AssertMsgReturn(!comAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false);
    232 
    233     const UIMedium guiMedium = uiCommon().medium(uMediumId);
    234     const CMedium comMedium = guiMedium.medium();
    235 
    236     /* Mount medium to the predefined port/device: */
    237     m_comMachine.MountMedium(comAttachment.GetController(), comAttachment.GetPort(), comAttachment.GetDevice(), comMedium, false /* force */);
    238     bool fSuccess = m_comMachine.isOk();
    239 
    240     QWidget *pParent = windowManager().realParentWindow(this);
    241 
    242     /* Show error message if necessary: */
    243     if (!fSuccess)
    244         msgCenter().cannotRemountMedium(m_comMachine, guiMedium, true /* mount? */, false /* retry? */, pParent);
    245     else
    246     {
    247         /* Save machine settings: */
    248         m_comMachine.SaveSettings();
    249         fSuccess = m_comMachine.isOk();
    250 
    251         /* Show error message if necessary: */
    252         if (!fSuccess)
    253             msgCenter().cannotSaveMachineSettings(m_comMachine, pParent);
    254     }
    255     return fSuccess;
    256 }
    257 
    258213void UIBootFailureDialog::sltFileSelectorPathChanged(const QString &strPath)
    259214{
    260     insertBootMedium(uiCommon().openMedium(UIMediumDeviceType_DVD, strPath));
     215    Q_UNUSED(strPath);
     216    bool fISOValid = checkISOImage();
     217    if (m_pBootImageSelector)
     218    {
     219        m_pBootImageSelector->mark(!fISOValid, tr("The selected path is invalid."));
     220    }
     221    if (m_pResetButton)
     222        m_pResetButton->setEnabled(fISOValid);
    261223}
    262224
     
    269231    return icon.pixmap(iSize, iSize);
    270232}
     233
     234bool UIBootFailureDialog::checkISOImage() const
     235{
     236    AssertReturn(m_pBootImageSelector, true);
     237    if (m_pBootImageSelector->path().isEmpty())
     238        return true;
     239    QFileInfo fileInfo(m_pBootImageSelector->path());
     240    if (!fileInfo.exists() || !fileInfo.isReadable())
     241        return false;
     242    return true;
     243}
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIBootFailureDialog.h

    r91717 r91736  
    7474private:
    7575
    76     bool insertBootMedium(const QUuid &uMediumId);
    7776    QPixmap iconPixmap();
     77    /* Checks if selected iso exists and readable. Returns false if not. Returns true if nothing is selected. */
     78    bool checkISOImage() const;
    7879
    7980    /** @name Event-handling stuff.
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r91719 r91736  
    32693269
    32703270    int iResult = pBootFailureDialog->exec(false);
     3271    QString strISOPath = pBootFailureDialog->bootMediumPath();
    32713272
    32723273    delete pBootFailureDialog;
     3274
     3275    QFileInfo bootMediumFileInfo(strISOPath);
     3276    if (bootMediumFileInfo.exists() && bootMediumFileInfo.isReadable())
     3277        mountBootMedium(uiCommon().openMedium(UIMediumDeviceType_DVD, strISOPath));
    32733278
    32743279    if (iResult == static_cast<int>(UIBootFailureDialog::ReturnCode_Reset))
    32753280        sltReset(false);
     3281}
     3282
     3283bool UIMachineLogic::mountBootMedium(const QUuid &uMediumId)
     3284{
     3285    AssertReturn(!uMediumId.isNull(), false);
     3286
     3287    CVirtualBox comVBox = uiCommon().virtualBox();
     3288    CMachine &comMachine = machine();
     3289    const CGuestOSType &comOsType = comVBox.GetGuestOSType(comMachine.GetOSTypeId());
     3290    /* Get recommended controller bus & type: */
     3291    const KStorageBus enmRecommendedDvdBus = comOsType.GetRecommendedDVDStorageBus();
     3292    const KStorageControllerType enmRecommendedDvdType = comOsType.GetRecommendedDVDStorageController();
     3293
     3294    CMediumAttachment comAttachment;
     3295    /* Search for an attachment of required bus & type: */
     3296    foreach (const CMediumAttachment &comCurrentAttachment, comMachine.GetMediumAttachments())
     3297    {
     3298        /* Determine current attachment's controller: */
     3299        const CStorageController &comCurrentController = comMachine.GetStorageControllerByName(comCurrentAttachment.GetController());
     3300
     3301        if (   comCurrentController.GetBus() == enmRecommendedDvdBus
     3302            && comCurrentController.GetControllerType() == enmRecommendedDvdType
     3303            && comCurrentAttachment.GetType() == KDeviceType_DVD)
     3304        {
     3305            comAttachment = comCurrentAttachment;
     3306            break;
     3307        }
     3308    }
     3309    AssertMsgReturn(!comAttachment.isNull(), ("Storage Controller is NOT properly configured!\n"), false);
     3310
     3311    const UIMedium guiMedium = uiCommon().medium(uMediumId);
     3312    const CMedium comMedium = guiMedium.medium();
     3313
     3314    /* Mount medium to the predefined port/device: */
     3315    comMachine.MountMedium(comAttachment.GetController(), comAttachment.GetPort(), comAttachment.GetDevice(), comMedium, false /* force */);
     3316    bool fSuccess = comMachine.isOk();
     3317
     3318    QWidget *pParent = windowManager().realParentWindow(activeMachineWindow());
     3319
     3320    /* Show error message if necessary: */
     3321    if (!fSuccess)
     3322        msgCenter().cannotRemountMedium(comMachine, guiMedium, true /* mount? */, false /* retry? */, pParent);
     3323    else
     3324    {
     3325        /* Save machine settings: */
     3326        comMachine.SaveSettings();
     3327        fSuccess = comMachine.isOk();
     3328
     3329        /* Show error message if necessary: */
     3330        if (!fSuccess)
     3331            msgCenter().cannotSaveMachineSettings(comMachine, pParent);
     3332    }
     3333    return fSuccess;
    32763334}
    32773335
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r91656 r91736  
    388388    /* Shows the boot failure dialog through which user can mount a boot DVD and reset the vm. */
    389389    void showBootFailureDialog();
     390    bool mountBootMedium(const QUuid &uMediumId);
    390391
    391392    /* Private variables: */
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