VirtualBox

Changeset 90225 in vbox


Ignore:
Timestamp:
Jul 16, 2021 10:56:46 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145762
Message:

FE/Qt: bugref:9996. Still banging on the initialization and connection stuff of the expert page.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.cpp

    r90223 r90225  
    3737#include "UIWizardDiskEditors.h"
    3838#include "UIWizardNewVM.h"
     39#include "UIWizardNewVMDiskPageBasic.h"
    3940
    4041/* Other VBox includes: */
     
    168169        m_formatNames << medFormat.GetName();
    169170        m_pFormatButtonGroup->addButton(pFormatButton, m_formatNames.size() - 1);
    170         m_formatExtensions << defaultExtension(medFormat);
    171     }
    172 }
    173 
    174 /* static */
    175 QString UIDiskFormatsGroupBox::defaultExtension(const CMediumFormat &mediumFormatRef)
    176 {
    177     if (!mediumFormatRef.isNull())
    178     {
    179         /* Load extension / device list: */
    180         QVector<QString> fileExtensions;
    181         QVector<KDeviceType> deviceTypes;
    182         CMediumFormat mediumFormat(mediumFormatRef);
    183         mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    184         for (int i = 0; i < fileExtensions.size(); ++i)
    185             if (deviceTypes[i] == KDeviceType_HardDisk)
    186                 return fileExtensions[i].toLower();
    187     }
    188     AssertMsgFailed(("Extension can't be NULL!\n"));
    189     return QString();
     171        m_formatExtensions << UIWizardNewVMDiskPage::defaultExtension(medFormat);
     172    }
    190173}
    191174
     
    327310
    328311/*********************************************************************************************************************************
    329 *   UIDiskSizeAndLocationGroupBox implementation.                                                                                *
     312*   UIMediumSizeAndPathGroupBox implementation.                                                                                  *
    330313*********************************************************************************************************************************/
    331314
    332 UIDiskSizeAndLocationGroupBox::UIDiskSizeAndLocationGroupBox(QWidget *pParent /* = 0 */)
     315UIMediumSizeAndPathGroupBox::UIMediumSizeAndPathGroupBox(QWidget *pParent /* = 0 */)
    333316    : QIWithRetranslateUI<QGroupBox>(pParent)
    334317    , m_pLocationLabel(0)
     
    341324}
    342325
    343 void UIDiskSizeAndLocationGroupBox::prepare()
     326void UIMediumSizeAndPathGroupBox::prepare()
    344327{
    345328    QGridLayout *pDiskContainerLayout = new QGridLayout(this);
     
    374357    retranslateUi();
    375358}
    376 void UIDiskSizeAndLocationGroupBox::retranslateUi()
     359void UIMediumSizeAndPathGroupBox::retranslateUi()
    377360{
    378361    setTitle(tr("Hard Disk File Location and Size"));
    379362}
    380363
    381 QString UIDiskSizeAndLocationGroupBox::location() const
     364QString UIMediumSizeAndPathGroupBox::mediumPath() const
    382365{
    383366    if (m_pLocationEditor)
     
    386369}
    387370
    388 void UIDiskSizeAndLocationGroupBox::setLocation(const QString &strLocation)
     371void UIMediumSizeAndPathGroupBox::setMediumPath(const QString &strMediumPath)
    389372{
    390373    if (m_pLocationEditor)
    391         m_pLocationEditor->setText(strLocation);
    392 }
    393 
    394 void UIDiskSizeAndLocationGroupBox::updateLocationEditorAfterFormatChange(const CMediumFormat &mediumFormat, const QStringList &formatExtensions)
     374        m_pLocationEditor->setText(strMediumPath);
     375}
     376
     377void UIMediumSizeAndPathGroupBox::updateMediumPath(const CMediumFormat &mediumFormat, const QStringList &formatExtensions)
    395378{
    396379    /* Compose virtual-disk extension: */
    397     QString strDefaultExtension = UIDiskFormatsGroupBox::defaultExtension(mediumFormat);
     380    QString strDefaultExtension = UIWizardNewVMDiskPage::defaultExtension(mediumFormat);
    398381    /* Update m_pLocationEditor's text if necessary: */
    399382    if (!m_pLocationEditor->text().isEmpty() && !strDefaultExtension.isEmpty())
     
    412395
    413396/* static */
    414 QString UIDiskSizeAndLocationGroupBox::stripFormatExtension(const QString &strFileName, const QStringList &formatExtensions)
     397QString UIMediumSizeAndPathGroupBox::stripFormatExtension(const QString &strFileName, const QStringList &formatExtensions)
    415398{
    416399    QString result(strFileName);
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.h

    r90223 r90225  
    6262    void setMediumFormat(const CMediumFormat &mediumFormat);
    6363    const CMediumFormat &VDIMeiumFormat() const;
    64     static QString defaultExtension(const CMediumFormat &mediumFormatRef);
    6564    const QStringList formatExtensions() const;
    6665
     
    106105
    107106
    108 class UIDiskSizeAndLocationGroupBox : public QIWithRetranslateUI<QGroupBox>
     107class UIMediumSizeAndPathGroupBox : public QIWithRetranslateUI<QGroupBox>
    109108{
    110109    Q_OBJECT;
     
    115114public:
    116115
    117     UIDiskSizeAndLocationGroupBox(QWidget *pParent = 0);
     116    UIMediumSizeAndPathGroupBox(QWidget *pParent = 0);
    118117
    119     QString location() const;
    120     void setLocation(const QString &strLocation);
    121     void updateLocationEditorAfterFormatChange(const CMediumFormat &mediumFormat, const QStringList &formatExtensions);
     118    QString mediumPath() const;
     119    void setMediumPath(const QString &strMediumPath);
     120    void updateMediumPath(const CMediumFormat &mediumFormat, const QStringList &formatExtensions);
    122121
    123122private:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.cpp

    r90223 r90225  
    447447{
    448448    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(this->wizard());
     449    AssertReturnVoid(pWizard);
    449450    UIWizardNewVMNameOSTypePage::determineOSType(strPath, pWizard);
    450     if (pWizard)
    451     {
    452         if (!pWizard->detectedOSTypeId().isEmpty() && !m_userModifiedParameters.contains("GuestOSType"))
     451
     452    if (!pWizard->detectedOSTypeId().isEmpty() && !m_userModifiedParameters.contains("GuestOSType"))
    453453            UIWizardNewVMNameOSTypePage::guessOSTypeFromName(m_pNameAndSystemEditor, pWizard->detectedOSTypeId());
    454         pWizard->setISOFilePath(strPath);
    455     }
     454    pWizard->setISOFilePath(strPath);
     455
    456456    /* Update the global recent ISO path: */
    457457    QFileInfo fileInfo(strPath);
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r90223 r90225  
    123123        UIWizardNewVMNameOSTypePage::guessOSTypeFromName(m_pNameAndSystemEditor, strNewName);
    124124    UIWizardNewVMNameOSTypePage::composeMachineFilePath(m_pNameAndSystemEditor, qobject_cast<UIWizardNewVM*>(wizard()));
    125     updateVirtualDiskPathFromMachinePathName();
     125    updateVirtualMediumPathFromMachinePathName();
    126126    emit completeChanged();
    127127}
     
    131131    Q_UNUSED(strNewPath);
    132132    UIWizardNewVMNameOSTypePage::composeMachineFilePath(m_pNameAndSystemEditor, qobject_cast<UIWizardNewVM*>(wizard()));
    133     updateVirtualDiskPathFromMachinePathName();
     133    updateVirtualMediumPathFromMachinePathName();
    134134}
    135135
     
    147147}
    148148
    149 void UIWizardNewVMPageExpert::sltISOPathChanged(const QString &strPath)
    150 {
    151     Q_UNUSED(strPath);
    152     // determineOSType(strPath);
    153     // setTypeByISODetectedOSType(m_strDetectedOSTypeId);
    154     // disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
    155 
    156     // /* Update the global recent ISO path: */
    157     // QFileInfo fileInfo(strPath);
    158     // if (fileInfo.exists() && fileInfo.isReadable())
    159     //     uiCommon().updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType_DVD, strPath);
    160     // setSkipCheckBoxEnable();
    161     // emit completeChanged();
     149void UIWizardNewVMPageExpert::sltISOPathChanged(const QString &strISOPath)
     150{
     151    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
     152    AssertReturnVoid(pWizard);
     153
     154    UIWizardNewVMNameOSTypePage::determineOSType(strISOPath, pWizard);
     155
     156    if (!pWizard->detectedOSTypeId().isEmpty() && !m_userModifiedParameters.contains("GuestOSType"))
     157            UIWizardNewVMNameOSTypePage::guessOSTypeFromName(m_pNameAndSystemEditor, pWizard->detectedOSTypeId());
     158    newVMWizardPropertySet(ISOFilePath, strISOPath);
     159
     160    /* Update the global recent ISO path: */
     161    QFileInfo fileInfo(strISOPath);
     162    if (fileInfo.exists() && fileInfo.isReadable())
     163        uiCommon().updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType_DVD, strISOPath);
     164    setSkipCheckBoxEnable();
     165    disableEnableUnattendedRelatedWidgets(pWizard->isUnattendedEnabled());
     166    emit completeChanged();
    162167}
    163168
     
    168173}
    169174
    170 void UIWizardNewVMPageExpert::sltOSFamilyTypeChanged()
    171 {
    172     //disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
     175void UIWizardNewVMPageExpert::sltOSFamilyTypeChanged(const QString &strGuestOSFamilyType)
     176{
     177    if (m_pAdditionalOptionsContainer)
     178        m_pAdditionalOptionsContainer->disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
     179    m_userModifiedParameters << "GuestOSFamilyId";
     180    newVMWizardPropertySet(GuestOSFamilyId, strGuestOSFamilyType);
    173181}
    174182
     
    222230        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
    223231                this, &UIWizardNewVMPageExpert::sltOsTypeChanged);
    224     //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOSFamilyChanged,
    225     //             this, &UIWizardNewVMPageExpert::sltOSFamilyTypeChanged);
    226     //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged,
    227     //             this, &UIWizardNewVMPageExpert::sltISOPathChanged);
    228     }
    229 
     232        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOSFamilyChanged,
     233                this, &UIWizardNewVMPageExpert::sltOSFamilyTypeChanged);
     234        connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged,
     235                this, &UIWizardNewVMPageExpert::sltISOPathChanged);
     236    }
     237
     238    if (m_pHardwareWidgetContainer)
     239    {
     240        connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigMemorySizeChanged,
     241                this, &UIWizardNewVMPageExpert::sltMemorySizeChanged);
     242        connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigCPUCountChanged,
     243                this, &UIWizardNewVMPageExpert::sltCPUCountChanged);
     244        connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigEFIEnabledChanged,
     245                this, &UIWizardNewVMPageExpert::sltEFIEnabledChanged);
     246    }
    230247    // /* Connections for username, password, and hostname: */
    231248    // if (m_pUserNamePasswordGroupBox)
     
    240257    //             this, &UIWizardNewVMPageExpert::sltInstallGACheckBoxToggle);
    241258
    242     // if (m_pBaseMemoryEditor)
    243     //     connect(m_pBaseMemoryEditor, &UIBaseMemoryEditor::sigValueChanged,
    244     //             this, &UIWizardNewVMPageExpert::sltValueModified);
    245     // if (m_pEFICheckBox)
    246     //     connect(m_pEFICheckBox, &QCheckBox::toggled,
    247     //             this, &UIWizardNewVMPageExpert::sltValueModified);
    248 
    249259    // if (m_pFormatButtonGroup)
    250260    //     connect(m_pFormatButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
     
    291301
    292302
    293     // KFirmwareType fwType = type.GetRecommendedFirmware();
    294     // if (m_pEFICheckBox && !m_userSetWidgets.contains(m_pEFICheckBox))
    295     // {
    296     //     m_pEFICheckBox->blockSignals(true);
    297     //     m_pEFICheckBox->setChecked(fwType != KFirmwareType_BIOS);
    298     //     m_pEFICheckBox->blockSignals(false);
    299     // }
     303    KFirmwareType fwType = type.GetRecommendedFirmware();
     304    if (m_pHardwareWidgetContainer && !m_userModifiedParameters.contains("EFIEnabled"))
     305    {
     306        m_pHardwareWidgetContainer->blockSignals(true);
     307        m_pHardwareWidgetContainer->setEFIEnabled(fwType != KFirmwareType_BIOS);
     308        m_pHardwareWidgetContainer->blockSignals(false);
     309    }
    300310    // LONG64 recommendedDiskSize = type.GetRecommendedHDD();
    301311    // /* Prepare initial disk choice: */
     
    350360    }
    351361
    352 
     362    /* Medium related properties: */
    353363    if (m_pFormatButtonGroup)
    354364        newVMWizardPropertySet(MediumFormat, m_pFormatButtonGroup->mediumFormat());
    355 
     365    updateVirtualMediumPathFromMachinePathName();
    356366
    357367    // disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
    358368    setOSTypeDependedValues();
    359369    // disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
    360     updateVirtualDiskPathFromMachinePathName();
     370
    361371
    362372    // updateWidgetAterMediumFormatChange();
     
    405415    QGridLayout *pDiskContainerLayout = new QGridLayout(pNewDiskContainerWidget);
    406416
    407     m_pSizeAndLocationGroup = new UIDiskSizeAndLocationGroupBox;
     417    m_pSizeAndLocationGroup = new UIMediumSizeAndPathGroupBox;
    408418    pDiskContainerLayout->addWidget(m_pSizeAndLocationGroup, 0, 0, 2, 2);
    409419    m_pFormatButtonGroup = new UIDiskFormatsGroupBox;
     
    574584bool UIWizardNewVMPageExpert::isProductKeyWidgetEnabled() const
    575585{
    576     // UIWizardNewVM *pWizard = wizardImp();
    577     // AssertReturn(pWizard, false);
    578     // if (!pWizard->isUnattendedEnabled() || !pWizard->isGuestOSTypeWindows())
    579     //     return false;
     586    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
     587    if (!pWizard || !pWizard->isUnattendedEnabled() || !pWizard->isGuestOSTypeWindows())
     588        return false;
    580589    return true;
    581590}
     
    595604}
    596605
    597 void UIWizardNewVMPageExpert::sltValueModified()
    598 {
    599     QWidget *pSenderWidget = qobject_cast<QWidget*>(sender());
    600     if (!pSenderWidget)
    601         return;
    602 
    603 }
    604 
    605606void UIWizardNewVMPageExpert::sltSkipUnattendedCheckBoxChecked()
    606607{
     
    652653}
    653654
    654 void UIWizardNewVMPageExpert::updateVirtualDiskPathFromMachinePathName()
     655void UIWizardNewVMPageExpert::sltMemorySizeChanged(int iValue)
     656{
     657    newVMWizardPropertySet(MemorySize, iValue);
     658    m_userModifiedParameters << "MemorySize";
     659}
     660
     661void UIWizardNewVMPageExpert::sltCPUCountChanged(int iCount)
     662{
     663    newVMWizardPropertySet(CPUCount, iCount);
     664}
     665
     666void UIWizardNewVMPageExpert::sltEFIEnabledChanged(bool fEnabled)
     667{
     668    newVMWizardPropertySet(EFIEnabled, fEnabled);
     669    m_userModifiedParameters << "EFIEnabled";
     670}
     671
     672void UIWizardNewVMPageExpert::updateVirtualMediumPathFromMachinePathName()
    655673{
    656674    UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
    657675    AssertReturnVoid(pWizard);
    658676    QString strDiskFileName = pWizard->machineBaseName().isEmpty() ? QString("NewVirtualDisk1") : pWizard->machineBaseName();
    659     QString strDiskPath = pWizard->machineFolder();
    660     if (strDiskPath.isEmpty())
     677    QString strMediumPath = pWizard->machineFolder();
     678    if (strMediumPath.isEmpty())
    661679    {
    662680        if (m_pNameAndSystemEditor)
    663             strDiskPath = m_pNameAndSystemEditor->path();
     681            strMediumPath = m_pNameAndSystemEditor->path();
    664682        else
    665             strDiskPath = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
     683            strMediumPath = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
    666684    }
    667685    QString strExtension = UIWizardNewVMDiskPage::defaultExtension(pWizard->mediumFormat());
     
    672690        QString strMediumPath =
    673691            UIWizardNewVMDiskPage::absoluteFilePath(UIWizardNewVMDiskPage::toFileName(strDiskFileName,
    674                                                                                       strExtension), strDiskPath);
    675         m_pSizeAndLocationGroup->setLocation(strMediumPath);
     692                                                                                      strExtension), strMediumPath);
     693        m_pSizeAndLocationGroup->setMediumPath(strMediumPath);
    676694    }
    677695}
     
    684702    AssertReturnVoid(!comMediumFormat.isNull());
    685703    m_pDiskVariantGroupBox->updateMediumVariantWidgetsAfterFormatChange(comMediumFormat);
    686     m_pSizeAndLocationGroup->updateLocationEditorAfterFormatChange(comMediumFormat, m_pFormatButtonGroup->formatExtensions());
     704    m_pSizeAndLocationGroup->updateMediumPath(comMediumFormat, m_pFormatButtonGroup->formatExtensions());
    687705}
    688706
     
    725743    return pContainerWidget;
    726744}
     745
     746void UIWizardNewVMPageExpert::setSkipCheckBoxEnable()
     747{
     748    if (!m_pSkipUnattendedCheckBox)
     749        return;
     750    if (m_pNameAndSystemEditor)
     751    {
     752        const QString &strPath = m_pNameAndSystemEditor->image();
     753        m_pSkipUnattendedCheckBox->setEnabled(!strPath.isNull() && !strPath.isEmpty());
     754    }
     755}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h

    r90217 r90225  
    4242class UIAdditionalUnattendedOptions;
    4343class UIDiskFormatsGroupBox;
    44 class UIDiskSizeAndLocationGroupBox;
     44class UIMediumSizeAndPathGroupBox;
    4545class UIDiskVariantGroupBox;
    4646class UIFilePathSelector;
     
    7777    void sltISOPathChanged(const QString &strPath);
    7878    void sltGAISOPathChanged(const QString &strPath);
    79     void sltOSFamilyTypeChanged();
     79    void sltOSFamilyTypeChanged(const QString &strGuestOSFamilyType);
    8080    void sltInstallGACheckBoxToggle(bool fEnabled);
    81     void sltValueModified();
    8281    void sltSkipUnattendedCheckBoxChecked();
    8382    void sltMediumFormatChanged();
     
    8584    void sltSelectedDiskSourceChanged();
    8685    void sltSelectLocationButtonClicked();
     86
     87    void sltMemorySizeChanged(int iValue);
     88    void sltCPUCountChanged(int iCount);
     89    void sltEFIEnabledChanged(bool fEnabled);
     90
    8791
    8892private:
     
    122126    QWidget *createNameOSTypeWidgets();
    123127
    124     void updateVirtualDiskPathFromMachinePathName();
     128    void updateVirtualMediumPathFromMachinePathName();
    125129    void updateWidgetAterMediumFormatChange();
    126130    void setEnableNewDiskWidgets(bool fEnable);
    127131    void setVirtualDiskFromDiskCombo();
     132    void setSkipCheckBoxEnable();
    128133
    129134    /** @name Variables
     
    132137        UIDiskVariantGroupBox *m_pDiskVariantGroupBox;
    133138        UIDiskFormatsGroupBox *m_pFormatButtonGroup;
    134         UIDiskSizeAndLocationGroupBox *m_pSizeAndLocationGroup;
     139        UIMediumSizeAndPathGroupBox *m_pSizeAndLocationGroup;
    135140        UINameAndSystemEditor *m_pNameAndSystemEditor;
    136141        QCheckBox *m_pSkipUnattendedCheckBox;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette