VirtualBox

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


Ignore:
Timestamp:
Dec 3, 2019 7:33:45 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9611: UIMachineSettingsSystem: Get rid of hardcoded chipset types, instead acquire these types through CSystemProperties interface; Besides that, using more modern Qt approach to cache enum data directly without casting it to int.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.cpp

    r82351 r82355  
    195195KChipsetType UIMachineSettingsSystem::chipsetType() const
    196196{
    197     return (KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt();
     197    return m_pComboChipsetType->currentData().value<KChipsetType>();
    198198}
    199199
     
    267267    /* We are doing that *now* because these combos have
    268268     * dynamical content which depends on cashed value: */
     269    repopulateComboChipsetType();
    269270    repopulateComboPointingHIDType();
    270271    repopulateComboParavirtProviderType();
     
    314315    newSystemData.m_iMemorySize = m_pBaseMemoryEditor->value();
    315316    newSystemData.m_bootItems = m_pBootOrderEditor->value();
    316     newSystemData.m_chipsetType = (KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt();
     317    newSystemData.m_chipsetType = m_pComboChipsetType->currentData().value<KChipsetType>();
    317318    newSystemData.m_pointingHIDType = m_pComboPointingHIDType->currentData().value<KPointingHIDType>();
    318     newSystemData.m_fEnabledIoApic = m_pCheckBoxApic->isChecked() || m_pSliderCPUCount->value() > 1 ||
    319                                   (KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt() == KChipsetType_ICH9;
     319    newSystemData.m_fEnabledIoApic =    m_pCheckBoxApic->isChecked()
     320                                     || m_pSliderCPUCount->value() > 1
     321                                     || m_pComboChipsetType->currentData().value<KChipsetType>() == KChipsetType_ICH9;
    320322    newSystemData.m_fEnabledEFI = m_pCheckBoxEFI->isChecked();
    321323    newSystemData.m_fEnabledUTC = m_pCheckBoxUseUTC->isChecked();
     
    390392
    391393        /* Chipset type vs IO-APIC test: */
    392         if ((KChipsetType)m_pComboChipsetType->itemData(m_pComboChipsetType->currentIndex()).toInt() == KChipsetType_ICH9 && !m_pCheckBoxApic->isChecked())
     394        if (m_pComboChipsetType->currentData().value<KChipsetType>() == KChipsetType_ICH9 && !m_pCheckBoxApic->isChecked())
    393395        {
    394396            message.second << tr(
     
    740742        {
    741743            /* Configure combo-box: */
    742             m_pComboChipsetType->addItem(gpConverter->toString(KChipsetType_PIIX3), QVariant(KChipsetType_PIIX3));
    743             m_pComboChipsetType->addItem(gpConverter->toString(KChipsetType_ICH9), QVariant(KChipsetType_ICH9));
     744            m_pComboChipsetType->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    744745        }
    745746
     
    835836    /* Configure 'Motherboard' connections: */
    836837    connect(m_pComboChipsetType, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    837         this, &UIMachineSettingsSystem::revalidate);
     838            this, &UIMachineSettingsSystem::revalidate);
    838839    connect(m_pComboPointingHIDType, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
    839840            this, &UIMachineSettingsSystem::revalidate);
     
    864865}
    865866
     867void UIMachineSettingsSystem::repopulateComboChipsetType()
     868{
     869    /* Chipset Type combo-box created in the .ui file. */
     870    AssertPtrReturnVoid(m_pComboChipsetType);
     871    {
     872        /* Clear combo first of all: */
     873        m_pComboChipsetType->clear();
     874
     875        /* Load currently supported chipset types: */
     876        CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     877        QVector<KChipsetType> chipsetTypes = comProperties.GetSupportedChipsetTypes();
     878        /* Take into account currently cached value: */
     879        const KChipsetType enmCachedValue = m_pCache->base().m_chipsetType;
     880        if (!chipsetTypes.contains(enmCachedValue))
     881            chipsetTypes.prepend(enmCachedValue);
     882
     883        /* Populate combo finally: */
     884        foreach (const KChipsetType &enmType, chipsetTypes)
     885            m_pComboChipsetType->addItem(gpConverter->toString(enmType), QVariant::fromValue(enmType));
     886    }
     887}
     888
    866889void UIMachineSettingsSystem::repopulateComboPointingHIDType()
    867890{
     
    910933void UIMachineSettingsSystem::retranslateComboChipsetType()
    911934{
    912     /* For each the element in KChipsetType enum: */
    913     for (int iIndex = (int)KChipsetType_Null; iIndex < (int)KChipsetType_Max; ++iIndex)
    914     {
    915         /* Cast to the corresponding type: */
    916         const KChipsetType enmType = (KChipsetType)iIndex;
    917         /* Look for the corresponding item: */
    918         const int iCorrespondingIndex = m_pComboChipsetType->findData((int)enmType);
    919         /* Re-translate if corresponding item was found: */
    920         if (iCorrespondingIndex != -1)
    921             m_pComboChipsetType->setItemText(iCorrespondingIndex, gpConverter->toString(enmType));
     935    /* For each the element in m_pComboChipsetType: */
     936    for (int iIndex = 0; iIndex < m_pComboChipsetType->count(); ++iIndex)
     937    {
     938        /* Apply retranslated text: */
     939        const KChipsetType enmType = m_pComboChipsetType->currentData().value<KChipsetType>();
     940        m_pComboChipsetType->setItemText(iIndex, gpConverter->toString(enmType));
    922941    }
    923942}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSystem.h

    r82289 r82355  
    128128    void cleanup();
    129129
     130    /** Repopulates Chipset type combo-box. */
     131    void repopulateComboChipsetType();
    130132    /** Repopulates Pointing HID type combo-box. */
    131133    void repopulateComboPointingHIDType();
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