- Timestamp:
- Oct 4, 2018 12:07:36 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceImportEditorWidget.cpp
r73137 r74610 22 22 /* Qt includes: */ 23 23 # include <QCheckBox> 24 # include <QGridLayout> 24 25 # include <QLabel> 25 26 # include <QTextEdit> … … 62 63 , m_pPathSelectorLabel(0) 63 64 , m_pPathSelector(0) 64 , m_pCheckBoxReinitMACs(0)65 65 , m_pImportHDsAsVDI(0) 66 66 , m_pMACComboBoxLabel(0) 67 , m_pMACComboBox(0) 68 , m_pOptionsLayout(0) 67 69 { 68 70 prepareWidgets(); … … 85 87 m_pLayout->addWidget(m_pPathSelector); 86 88 } 87 m_pCheckBoxReinitMACs = new QCheckBox; 88 { 89 m_pLayout->addWidget(m_pCheckBoxReinitMACs); 90 } 89 90 m_pOptionsLayout = new QGridLayout; 91 92 m_pMACComboBox = new QComboBox; 93 if (m_pMACComboBox) 94 { 95 m_pMACComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::QSizePolicy::Preferred); 96 /* Add into layout: */ 97 m_pOptionsLayout->addWidget(m_pMACComboBox, 0, 1); 98 } 99 100 /* Create format combo-box label: */ 101 m_pMACComboBoxLabel = new QLabel; 102 if (m_pMACComboBoxLabel) 103 { 104 m_pMACComboBoxLabel->setAlignment(Qt::AlignLeft | Qt::AlignTrailing | Qt::AlignVCenter); 105 /* Add into layout: */ 106 m_pOptionsLayout->addWidget(m_pMACComboBoxLabel, 0, 0); 107 } 108 109 if (m_pMACComboBoxLabel) 110 m_pMACComboBoxLabel->setBuddy(m_pMACComboBox); 91 111 92 112 m_pImportHDsAsVDI = new QCheckBox; 93 113 { 94 m_p Layout->addWidget(m_pImportHDsAsVDI);114 m_pOptionsLayout->addWidget(m_pImportHDsAsVDI, 2, 1); 95 115 m_pImportHDsAsVDI->setCheckState(Qt::Checked); 96 116 } 97 117 118 119 m_pLayout->addLayout(m_pOptionsLayout); 120 populateMACAddressImportPolicies(); 121 connect(m_pMACComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 122 this, &UIApplianceImportEditorWidget::sltHandleMACAddressImportPolicyComboChange); 98 123 retranslateUi(); 99 124 } … … 197 222 CProgress progress; 198 223 QVector<KImportOptions> options; 199 if (!m_pCheckBoxReinitMACs->isChecked()) 200 options.append(KImportOptions_KeepAllMACs); 224 if (m_pMACComboBox) 225 { 226 MACAddressImportPolicy macPolicy = static_cast<MACAddressImportPolicy>(m_pMACComboBox->currentIndex()); 227 switch (macPolicy) 228 { 229 case MACAddressImportPolicy_KeepAllMACs: 230 options.append(KImportOptions_KeepAllMACs); 231 break; 232 case MACAddressImportPolicy_KeepNATMACs: 233 options.append(KImportOptions_KeepNATMACs); 234 break; 235 default: 236 break; 237 } 238 } 239 201 240 if (m_pImportHDsAsVDI->isChecked()) 202 241 options.append(KImportOptions_ImportToVDI); … … 251 290 m_pPathSelectorLabel->setText(UIWizardImportApp::tr("You can modify the base folder which will host all the virtual machines.\n" 252 291 "Home folders can also be individually (per virtual machine) modified.")); 253 if (m_pCheckBoxReinitMACs)254 {255 m_pCheckBoxReinitMACs->setText(tr("&Reinitialize the MAC address of all network cards"));256 m_pCheckBoxReinitMACs->setToolTip(tr("When checked a new unique MAC address will assigned to all configured network cards."));257 }258 259 292 if (m_pImportHDsAsVDI) 260 293 { … … 262 295 m_pImportHDsAsVDI->setToolTip(tr("When checked a all the hard drives that belong to this appliance will be imported in VDI format")); 263 296 } 297 298 /* Translate MAC address policy combo-box: */ 299 m_pMACComboBoxLabel->setText(tr("MAC Address &Policy:")); 300 m_pMACComboBox->setItemText(MACAddressImportPolicy_KeepAllMACs, 301 tr("Include all network adapter MAC addresses")); 302 m_pMACComboBox->setItemText(MACAddressImportPolicy_KeepNATMACs, 303 tr("Include only NAT network adapter MAC addresses")); 304 m_pMACComboBox->setItemText(MACAddressImportPolicy_StripAllMACs, 305 tr("Generate new MAC addresses for all network adapters")); 306 m_pMACComboBox->setItemData(MACAddressImportPolicy_KeepAllMACs, 307 tr("Include all network adapter MAC addresses in exported " 308 "during cloning."), Qt::ToolTipRole); 309 m_pMACComboBox->setItemData(MACAddressImportPolicy_KeepNATMACs, 310 tr("Include only NAT network adapter MAC addresses " 311 "during cloning."), Qt::ToolTipRole); 312 m_pMACComboBox->setItemData(MACAddressImportPolicy_StripAllMACs, 313 tr("Generate new MAC addresses for all network adapters " 314 "during cloning."), Qt::ToolTipRole); 264 315 } 265 316 … … 268 319 setVirtualSystemBaseFolder(newPath); 269 320 } 321 322 void UIApplianceImportEditorWidget::populateMACAddressImportPolicies() 323 { 324 AssertReturnVoid(m_pMACComboBox->count() == 0); 325 326 /* Apply hardcoded policies list: */ 327 for (int i = 0; i < (int)MACAddressImportPolicy_MAX; ++i) 328 { 329 m_pMACComboBox->addItem(QString::number(i)); 330 m_pMACComboBox->setItemData(i, i); 331 } 332 333 /* Set default: */ 334 setMACAddressImportPolicy(MACAddressImportPolicy_KeepNATMACs); 335 } 336 337 void UIApplianceImportEditorWidget::setMACAddressImportPolicy(MACAddressImportPolicy enmMACAddressImportPolicy) 338 { 339 const int iIndex = m_pMACComboBox->findData((int)enmMACAddressImportPolicy); 340 AssertMsg(iIndex != -1, ("Data not found!")); 341 m_pMACComboBox->setCurrentIndex(iIndex); 342 } 343 344 void UIApplianceImportEditorWidget::sltHandleMACAddressImportPolicyComboChange() 345 { 346 /* Update tool-tip: */ 347 updateMACAddressImportPolicyComboToolTip(); 348 } 349 350 void UIApplianceImportEditorWidget::updateMACAddressImportPolicyComboToolTip() 351 { 352 const int iCurrentIndex = m_pMACComboBox->currentIndex(); 353 const QString strCurrentToolTip = m_pMACComboBox->itemData(iCurrentIndex, Qt::ToolTipRole).toString(); 354 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 355 m_pMACComboBox->setToolTip(strCurrentToolTip); 356 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIApplianceImportEditorWidget.h
r73137 r74610 25 25 class UIFilePathSelector; 26 26 class QIRichTextLabel; 27 class QComboBox; 28 class QGridLayout; 29 30 /** MAC address policies. */ 31 enum MACAddressImportPolicy 32 { 33 MACAddressImportPolicy_KeepAllMACs, 34 MACAddressImportPolicy_KeepNATMACs, 35 MACAddressImportPolicy_StripAllMACs, 36 MACAddressImportPolicy_MAX 37 }; 27 38 28 39 class UIApplianceImportEditorWidget: public UIApplianceEditorWidget … … 45 56 private slots: 46 57 47 void sltHandlePathChanged(const QString &newPath);58 void sltHandlePathChanged(const QString &newPath); 48 59 49 60 private: 50 61 51 void prepareWidgets(); 62 void prepareWidgets(); 63 /** Populates MAC address policies. */ 64 void populateMACAddressImportPolicies(); 65 void setMACAddressImportPolicy(MACAddressImportPolicy enmMACAddressImportPolicy); 66 void sltHandleMACAddressImportPolicyComboChange(); 67 void updateMACAddressImportPolicyComboToolTip(); 68 52 69 QIRichTextLabel *m_pPathSelectorLabel; 53 70 UIFilePathSelector *m_pPathSelector; 54 55 /** Holds the 'reinit MACs' check-box instance. */ 56 QCheckBox *m_pCheckBoxReinitMACs; 57 /** Holds the checkbox that controls 'imprt HDs as VDI' behaviour. */ 58 QCheckBox *m_pImportHDsAsVDI; 59 71 /** Holds the checkbox that controls 'import HDs as VDI' behaviour. */ 72 QCheckBox *m_pImportHDsAsVDI; 73 QLabel *m_pMACComboBoxLabel; 74 QComboBox *m_pMACComboBox; 75 QGridLayout *m_pOptionsLayout; 60 76 }; 61 77 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageExpert.cpp
r70805 r74610 136 136 return fResult; 137 137 } 138
Note:
See TracChangeset
for help on using the changeset viewer.