VirtualBox

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


Ignore:
Timestamp:
Jul 7, 2021 3:40:54 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145574
Message:

FE/Qt: bugref:9996. More cleaning

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.cpp

    r90076 r90077  
    115115// }
    116116
    117     // registerField("mediumFormat", this, "mediumFormat");
    118     // registerField("mediumVariant" /* KMediumVariant */, this, "mediumVariant");
    119     // registerField("mediumPath", this, "mediumPath");
    120     // registerField("mediumSize", this, "mediumSize");
     117// registerField("mediumFormat", this, "mediumFormat");
     118// registerField("mediumVariant" /* KMediumVariant */, this, "mediumVariant");
     119// registerField("mediumPath", this, "mediumPath");
     120// registerField("mediumSize", this, "mediumSize");
    121121
    122122UIWizardNewVMDiskPageBasic::UIWizardNewVMDiskPageBasic()
     
    133133    , m_pDynamicLabel(0)
    134134    , m_pFixedLabel(0)
    135     , m_pSplitLabel(0)
    136135    , m_pFixedCheckBox(0)
    137     , m_pSplitBox(0)
    138136    , m_enmSelectedDiskSource(SelectedDiskSource_New)
    139137    , m_fRecommendedNoDisk(false)
     138    , m_fVDIFormatFound(false)
    140139{
    141140    prepare();
     
    143142    // qRegisterMetaType<SelectedDiskSource>();
    144143
    145     /* We do not have any UI elements for HDD format selection since we default to VDI in case of guided wizard mode: */
    146     bool fFoundVDI = false;
    147     CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties();
    148     const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
    149     foreach (const CMediumFormat &format, formats)
    150     {
    151         if (format.GetName() == "VDI")
    152         {
    153             m_mediumFormat = format;
    154             fFoundVDI = true;
    155         }
    156     }
    157     if (!fFoundVDI)
    158         AssertMsgFailed(("No medium format corresponding to VDI could be found!"));
    159 
    160     m_strDefaultExtension =  UIWizardNewVMDiskPage::defaultExtension(m_mediumFormat);
    161 
    162     /* Since the medium format is static we can decide widget visibility here: */
    163     setWidgetVisibility(m_mediumFormat);
    164 }
    165 
    166 CMediumFormat UIWizardNewVMDiskPageBasic::mediumFormat() const
    167 {
    168     return m_mediumFormat;
    169 }
     144}
     145
    170146
    171147void UIWizardNewVMDiskPageBasic::prepare()
     
    320296    }
    321297
    322     if (m_pSplitBox)
    323         m_pSplitBox->setText(UIWizardNewVD::tr("&Split Into Files of Less Than 2GB"));
    324 
    325 
    326298    /* Translate rich text labels: */
    327299    if (m_pDescriptionLabel)
     
    335307        m_pFixedLabel->setText(UIWizardNewVD::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some "
    336308                                                 "systems but is often faster to use.</p>"));
    337     if (m_pSplitLabel)
    338         m_pSplitLabel->setText(UIWizardNewVD::tr("<p>You can also choose to <b>split</b> the hard disk file into several files "
    339                                                  "of up to two gigabytes each. This is mainly useful if you wish to store the "
    340                                                  "virtual machine on removable USB devices or old systems, some of which cannot "
    341                                                  "handle very large files."));
    342 
    343309}
    344310
    345311void UIWizardNewVMDiskPageBasic::initializePage()
    346312{
    347      retranslateUi();
    348 
    349      UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
    350      AssertReturnVoid(pWizard);
    351 
    352      LONG64 iRecommendedSize = 0;
    353      CGuestOSType type = pWizard->guestOSType();
    354      if (!type.isNull())
    355      {
    356          iRecommendedSize = type.GetRecommendedHDD();
    357          if (iRecommendedSize != 0)
    358          {
    359              if (m_pDiskNew)
    360              {
    361                  m_pDiskNew->setFocus();
    362                  m_pDiskNew->setChecked(true);
    363              }
    364              m_enmSelectedDiskSource = SelectedDiskSource_New;
    365              m_fRecommendedNoDisk = false;
    366          }
    367          else
    368          {
    369              if (m_pDiskEmpty)
    370              {
    371                  m_pDiskEmpty->setFocus();
    372                  m_pDiskEmpty->setChecked(true);
    373              }
    374              m_enmSelectedDiskSource = SelectedDiskSource_Empty;
    375              m_fRecommendedNoDisk = true;
    376          }
    377      }
     313    retranslateUi();
     314
     315    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
     316    AssertReturnVoid(pWizard);
     317
     318    LONG64 iRecommendedSize = 0;
     319    CGuestOSType type = pWizard->guestOSType();
     320    if (!type.isNull())
     321    {
     322        iRecommendedSize = type.GetRecommendedHDD();
     323        if (iRecommendedSize != 0)
     324        {
     325            if (m_pDiskNew)
     326            {
     327                m_pDiskNew->setFocus();
     328                m_pDiskNew->setChecked(true);
     329            }
     330            m_enmSelectedDiskSource = SelectedDiskSource_New;
     331            m_fRecommendedNoDisk = false;
     332        }
     333        else
     334        {
     335            if (m_pDiskEmpty)
     336            {
     337                m_pDiskEmpty->setFocus();
     338                m_pDiskEmpty->setChecked(true);
     339            }
     340            m_enmSelectedDiskSource = SelectedDiskSource_Empty;
     341            m_fRecommendedNoDisk = true;
     342        }
     343    }
    378344
    379345    if (m_pDiskSelector)
     
    382348    setEnableNewDiskWidgets(m_enmSelectedDiskSource == SelectedDiskSource_New);
    383349
     350    if (!m_fVDIFormatFound)
     351    {
     352        /* We do not have any UI elements for HDD format selection since we default to VDI in case of guided wizard mode: */
     353        CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties();
     354        const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
     355        foreach (const CMediumFormat &format, formats)
     356        {
     357            if (format.GetName() == "VDI")
     358            {
     359                newVMWizardPropertySet(MediumFormat, format);
     360                m_fVDIFormatFound = true;
     361            }
     362        }
     363        if (!m_fVDIFormatFound)
     364            AssertMsgFailed(("No medium format corresponding to VDI could be found!"));
     365        setWidgetVisibility(pWizard->mediumFormat());
     366    }
     367    QString strDefaultExtension =  UIWizardNewVMDiskPage::defaultExtension(pWizard->mediumFormat());
     368
    384369    /* We set the medium name and path according to machine name/path and do not allow user change these in the guided mode: */
    385370    QString strDefaultName = pWizard->machineBaseName().isEmpty() ? QString("NewVirtualDisk1") : pWizard->machineBaseName();
    386371    const QString &strMachineFolder = pWizard->machineFolder();
    387     QString strMediumPath = UIWizardNewVMDiskPage::absoluteFilePath(UIWizardNewVMDiskPage::toFileName(strDefaultName,
    388                                                                                                       m_strDefaultExtension),
    389                                                                     strMachineFolder);
     372    QString strMediumPath =
     373        UIWizardNewVMDiskPage::absoluteFilePath(UIWizardNewVMDiskPage::toFileName(strDefaultName,
     374                                                                                  strDefaultExtension), strMachineFolder);
    390375    newVMWizardPropertySet(MediumPath, strMediumPath);
    391376
     
    464449    if (pWizard)
    465450    {
    466     //     if (selectedDiskSource() == SelectedDiskSource_New)
    467     //     {
    468     //         /* Try to create the hard drive:*/
    469     //         fResult = pWizard->createVirtualDisk();
    470     //         /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
    471     //         if (!fResult)
    472     //             return fResult;
    473     //     }
    474 
    475     //     fResult = pWizard->createVM();
    476     //     /* Try to delete the hard disk: */
    477     //     if (!fResult)
    478     //         pWizard->deleteVirtualDisk();
     451        //     if (selectedDiskSource() == SelectedDiskSource_New)
     452        //     {
     453        //         /* Try to create the hard drive:*/
     454        //         fResult = pWizard->createVirtualDisk();
     455        //         /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
     456        //         if (!fResult)
     457        //             return fResult;
     458        //     }
     459
     460        //     fResult = pWizard->createVM();
     461        //     /* Try to delete the hard disk: */
     462        //     if (!fResult)
     463        //         pWizard->deleteVirtualDisk();
    479464    }
    480465    // endProcessing();
     
    552537            m_pDynamicLabel = new QIRichTextLabel;
    553538            m_pFixedLabel = new QIRichTextLabel;
    554             m_pSplitLabel = new QIRichTextLabel;
    555539        }
    556540        QVBoxLayout *pVariantLayout = new QVBoxLayout;
     
    558542        {
    559543            m_pFixedCheckBox = new QCheckBox;
    560             m_pSplitBox = new QCheckBox;
    561544            pVariantLayout->addWidget(m_pFixedCheckBox);
    562             pVariantLayout->addWidget(m_pSplitBox);
    563545        }
    564546        if (fWithLabels)
     
    567549            pMainLayout->addWidget(m_pDynamicLabel);
    568550            pMainLayout->addWidget(m_pFixedLabel);
    569             pMainLayout->addWidget(m_pSplitLabel);
    570551        }
    571552        pMainLayout->addLayout(pVariantLayout);
     
    585566}
    586567
    587 void UIWizardNewVMDiskPageBasic::setWidgetVisibility(CMediumFormat &mediumFormat)
     568void UIWizardNewVMDiskPageBasic::setWidgetVisibility(const CMediumFormat &mediumFormat)
    588569{
    589570    ULONG uCapabilities = 0;
     
    595576    bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
    596577    bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
    597     bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
    598578    if (m_pFixedCheckBox)
    599579    {
     
    615595    if (m_pFixedCheckBox)
    616596        m_pFixedCheckBox->setHidden(!fIsCreateFixedPossible);
    617     if (m_pSplitLabel)
    618         m_pSplitLabel->setHidden(!fIsCreateSplitPossible);
    619     if (m_pSplitBox)
    620         m_pSplitBox->setHidden(!fIsCreateSplitPossible);
    621 }
     597}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.h

    r90076 r90077  
    7979
    8080    UIWizardNewVMDiskPageBasic();
    81     CMediumFormat mediumFormat() const;
    8281
    8382protected:
     
    108107
    109108    void setEnableDiskSelectionWidgets(bool fEnabled);
    110     void setWidgetVisibility(CMediumFormat &mediumFormat);
     109    void setWidgetVisibility(const CMediumFormat &mediumFormat);
    111110
    112111    /** @name Widgets
     
    124123       QIRichTextLabel *m_pDynamicLabel;
    125124       QIRichTextLabel *m_pFixedLabel;
    126        QIRichTextLabel *m_pSplitLabel;
    127125       QCheckBox *m_pFixedCheckBox;
    128        QCheckBox *m_pSplitBox;
    129126    /** @} */
    130127
    131     /** For guided new vm wizard VDI is the only format. Thus we have no UI item for it. */
    132     CMediumFormat m_mediumFormat;
    133128    SelectedDiskSource m_enmSelectedDiskSource;
    134129    bool m_fRecommendedNoDisk;
     
    136131    QString m_strDefaultExtension;
    137132    QSet<QString> m_userModifiedParameters;
     133    bool m_fVDIFormatFound;
    138134};
    139135
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