VirtualBox

Ignore:
Timestamp:
Dec 11, 2019 2:12:14 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9390: UIWizardCloneVMPageExpert: Get rid of hardcoded clone option types, instead acquire these types through CSystemProperties interface (clone options related to MAC addresses).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp

    r76606 r82549  
    1616 */
    1717
    18 /* Global includes: */
     18/* Qt includes: */
    1919#include <QButtonGroup>
    2020#include <QCheckBox>
     
    2424#include <QRadioButton>
    2525
    26 /* Local includes: */
     26/* GUI includes: */
    2727#include "QILineEdit.h"
     28#include "UICommon.h"
    2829#include "UIFilePathSelector.h"
    2930#include "UIWizardCloneVMPageExpert.h"
    3031#include "UIWizardCloneVM.h"
     32
     33/* COM includes: */
     34#include "CSystemProperties.h"
    3135
    3236
     
    134138                m_pCloneOptionsLayout->addWidget(m_pMACComboBoxLabel, 0, 0, 1, 1);
    135139            }
    136             m_pAdditionalOptionsLabel = new QLabel;
    137             if (m_pAdditionalOptionsLabel)
    138             {
    139                 m_pAdditionalOptionsLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    140                 m_pCloneOptionsLayout->addWidget(m_pAdditionalOptionsLabel, 3, 0, 1, 1);
    141             }
    142             m_pKeepDiskNamesCheckBox = new QCheckBox;
    143             if (m_pKeepDiskNamesCheckBox)
    144                 m_pCloneOptionsLayout->addWidget(m_pKeepDiskNamesCheckBox, 3, 1, 1, 1);
    145             m_pKeepHWUUIDsCheckBox = new QCheckBox;
    146             if (m_pKeepHWUUIDsCheckBox)
    147                 m_pCloneOptionsLayout->addWidget(m_pKeepHWUUIDsCheckBox, 4, 1, 1, 1);
    148 
     140
     141            /* Load currently supported clone options: */
     142            CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     143            const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
     144            /* Check whether we support additional clone options at all: */
     145            int iVerticalPosition = 3;
     146            const bool fSupportedKeepDiskNames = supportedOptions.contains(KCloneOptions_KeepDiskNames);
     147            const bool fSupportedKeepHWUUIDs = supportedOptions.contains(KCloneOptions_KeepHwUUIDs);
     148            if (fSupportedKeepDiskNames || fSupportedKeepHWUUIDs)
     149            {
     150                m_pAdditionalOptionsLabel = new QLabel;
     151                if (m_pAdditionalOptionsLabel)
     152                {
     153                    m_pAdditionalOptionsLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
     154                    m_pCloneOptionsLayout->addWidget(m_pAdditionalOptionsLabel, iVerticalPosition, 0, 1, 1);
     155                }
     156            }
     157            if (fSupportedKeepDiskNames)
     158            {
     159                m_pKeepDiskNamesCheckBox = new QCheckBox;
     160                if (m_pKeepDiskNamesCheckBox)
     161                    m_pCloneOptionsLayout->addWidget(m_pKeepDiskNamesCheckBox, iVerticalPosition++, 1, 1, 1);
     162            }
     163            if (fSupportedKeepHWUUIDs)
     164            {
     165                m_pKeepHWUUIDsCheckBox = new QCheckBox;
     166                if (m_pKeepHWUUIDsCheckBox)
     167                    m_pCloneOptionsLayout->addWidget(m_pKeepHWUUIDsCheckBox, iVerticalPosition++, 1, 1, 1);
     168            }
    149169        }
    150170
     
    216236    /* Translate MAC address policy combo-box: */
    217237    m_pMACComboBoxLabel->setText(UIWizardCloneVM::tr("MAC Address &Policy:"));
    218     m_pMACComboBox->setItemText(MACAddressClonePolicy_KeepAllMACs,
    219                                 UIWizardCloneVM::tr("Include all network adapter MAC addresses"));
    220     m_pMACComboBox->setItemText(MACAddressClonePolicy_KeepNATMACs,
    221                                 UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses"));
    222     m_pMACComboBox->setItemText(MACAddressClonePolicy_StripAllMACs,
    223                                 UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters"));
    224     m_pMACComboBox->setItemData(MACAddressClonePolicy_KeepAllMACs,
    225                                 UIWizardCloneVM::tr("Include all network adapter MAC addresses during cloning."), Qt::ToolTipRole);
    226     m_pMACComboBox->setItemData(MACAddressClonePolicy_KeepNATMACs,
    227                                 UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses during cloning."), Qt::ToolTipRole);
    228     m_pMACComboBox->setItemData(MACAddressClonePolicy_StripAllMACs,
    229                                 UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters during cloning."), Qt::ToolTipRole);
     238    for (int i = 0; i < m_pMACComboBox->count(); ++i)
     239    {
     240        const MACAddressClonePolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressClonePolicy>();
     241        switch (enmPolicy)
     242        {
     243            case MACAddressClonePolicy_KeepAllMACs:
     244            {
     245                m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses"));
     246                m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses during cloning."), Qt::ToolTipRole);
     247                break;
     248            }
     249            case MACAddressClonePolicy_KeepNATMACs:
     250            {
     251                m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses"));
     252                m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses during cloning."), Qt::ToolTipRole);
     253                break;
     254            }
     255            case MACAddressClonePolicy_StripAllMACs:
     256            {
     257                m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters"));
     258                m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters during cloning."), Qt::ToolTipRole);
     259                break;
     260            }
     261            default:
     262                break;
     263        }
     264    }
    230265
    231266    m_pAdditionalOptionsLabel->setText(UIWizardCloneVM::tr("Additional Options:"));
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