- Timestamp:
- Oct 1, 2018 12:57:05 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp
r72696 r74550 59 59 QString strSettingsFile = field("cloneFilePath").toString(); 60 60 61 /* Should we reinit mac status? */62 bool fReinitMACs = field("reinitMACs").toBool();63 61 /* Should we create linked clone? */ 64 62 bool fLinked = field("linkedClone").toBool(); … … 131 129 } 132 130 133 /* Add the keep all MACs option to the import settings when requested.*/131 /* Set the selected MAC address policy: */ 134 132 QVector<KCloneOptions> options; 135 if (!fReinitMACs) 136 options.append(KCloneOptions_KeepAllMACs); 133 switch (field("macAddressClonePolicy").value<MACAddressClonePolicy>()) 134 { 135 case MACAddressClonePolicy_KeepAllMACs: 136 options.append(KCloneOptions_KeepAllMACs); 137 break; 138 case MACAddressClonePolicy_KeepNATMACs: 139 options.append(KCloneOptions_KeepNATMACs); 140 break; 141 default: 142 break; 143 } 144 137 145 /* Linked clones requested? */ 138 146 if (fLinked) -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp
r74519 r74550 22 22 /* Qt includes: */ 23 23 # include <QCheckBox> 24 # include <QComboBox> 25 # include <QGridLayout> 24 26 # include <QLabel> 25 27 # include <QVBoxLayout> … … 43 45 , m_strDefaultPath(strDefaultPath) 44 46 , m_strGroup(strGroup) 45 , m_pReinitMACsCheckBox(0)46 47 , m_pNameLineEdit(0) 47 48 , m_pPathSelector(0) 48 49 , m_pNameLabel(0) 49 50 , m_pPathLabel(0) 51 , m_pMACComboBoxLabel(0) 52 , m_pMACComboBox(0) 50 53 { 51 54 } … … 88 91 return; 89 92 m_strCloneFilePath = path; 90 }91 92 93 bool UIWizardCloneVMPage1::isReinitMACsChecked() const94 {95 if (!m_pReinitMACsCheckBox)96 return false;97 return m_pReinitMACsCheckBox->isChecked();98 93 } 99 94 … … 109 104 } 110 105 106 void UIWizardCloneVMPage1::updateMACAddressClonePolicyComboToolTip() 107 { 108 const int iCurrentIndex = m_pMACComboBox->currentIndex(); 109 const QString strCurrentToolTip = m_pMACComboBox->itemData(iCurrentIndex, Qt::ToolTipRole).toString(); 110 AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!")); 111 m_pMACComboBox->setToolTip(strCurrentToolTip); 112 } 113 114 MACAddressClonePolicy UIWizardCloneVMPage1::macAddressClonePolicy() const 115 { 116 const int iIndex = m_pMACComboBox->currentIndex(); 117 return (MACAddressClonePolicy)m_pMACComboBox->itemData(iIndex).toInt(); 118 } 119 120 void UIWizardCloneVMPage1::setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy) 121 { 122 const int iIndex = m_pMACComboBox->findData((int)enmMACAddressClonePolicy); 123 AssertMsg(iIndex != -1, ("Data not found!")); 124 m_pMACComboBox->setCurrentIndex(iIndex); 125 } 126 127 void UIWizardCloneVMPage1::populateMACAddressClonePolicies() 128 { 129 AssertReturnVoid(m_pMACComboBox->count() == 0); 130 131 /* Apply hardcoded policies list: */ 132 for (int i = 0; i < (int)MACAddressClonePolicy_MAX; ++i) 133 { 134 m_pMACComboBox->addItem(QString::number(i)); 135 m_pMACComboBox->setItemData(i, i); 136 } 137 138 /* Set default: */ 139 setMACAddressClonePolicy(MACAddressClonePolicy_KeepNATMACs); 140 } 141 111 142 UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup) 112 143 : UIWizardCloneVMPage1(strOriginalName, strDefaultPath, strGroup) 113 144 , m_pMainLabel(0) 145 , m_pContainerLayout(0) 114 146 { 115 147 /* Create widgets: */ … … 128 160 { 129 161 pMainLayout->addWidget(pContainerWidget); 130 QGridLayout *pContainerLayout = new QGridLayout(pContainerWidget);131 pContainerLayout->setContentsMargins(0, 0, 0, 0);162 m_pContainerLayout = new QGridLayout(pContainerWidget); 163 m_pContainerLayout->setContentsMargins(0, 0, 0, 0); 132 164 133 165 m_pNameLabel = new QLabel; … … 136 168 m_pNameLabel->setAlignment(Qt::AlignRight); 137 169 m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 138 pContainerLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);170 m_pContainerLayout->addWidget(m_pNameLabel, 0, 0, 1, 1); 139 171 } 140 172 … … 142 174 if (m_pNameLineEdit) 143 175 { 144 pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);176 m_pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1); 145 177 m_pNameLineEdit->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName)); 146 178 } … … 151 183 m_pPathLabel->setAlignment(Qt::AlignRight); 152 184 m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 153 pContainerLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);185 m_pContainerLayout->addWidget(m_pPathLabel, 1, 0, 1, 1); 154 186 } 155 187 … … 157 189 if (m_pPathSelector) 158 190 { 159 pContainerLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);191 m_pContainerLayout->addWidget(m_pPathSelector, 1, 1, 1, 1); 160 192 m_pPathSelector->setPath(m_strDefaultPath); 161 162 } 163 164 m_pReinitMACsCheckBox = new QCheckBox(this); 165 if (m_pReinitMACsCheckBox) 166 { 167 pContainerLayout->addWidget(m_pReinitMACsCheckBox, 2, 0, 1, 2); 168 m_pReinitMACsCheckBox->setChecked(true); 169 } 193 } 194 195 /* Create MAC policy combo-box: */ 196 m_pMACComboBox = new QComboBox; 197 if (m_pMACComboBox) 198 { 199 /* Add into layout: */ 200 m_pContainerLayout->addWidget(m_pMACComboBox, 2, 1, 1, 1); 201 } 202 203 /* Create format combo-box label: */ 204 m_pMACComboBoxLabel = new QLabel; 205 if (m_pMACComboBoxLabel) 206 { 207 m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 208 m_pMACComboBoxLabel->setBuddy(m_pMACComboBox); 209 /* Add into layout: */ 210 m_pContainerLayout->addWidget(m_pMACComboBoxLabel, 2, 0, 1, 1); 211 } 170 212 } 171 213 pMainLayout->addStretch(); 214 215 /* Populate MAC address policies: */ 216 populateMACAddressClonePolicies(); 217 218 /* Register fields: */ 219 registerField("cloneName", this, "cloneName"); 220 registerField("cloneFilePath", this, "cloneFilePath"); 221 registerField("macAddressClonePolicy", this, "macAddressClonePolicy"); 222 223 composeCloneFilePath(); 172 224 173 225 /* Setup connections: */ … … 177 229 connect(m_pNameLineEdit, &QILineEdit::textChanged, this, &UIWizardCloneVMPageBasic1::sltNameChanged); 178 230 connect(m_pPathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardCloneVMPageBasic1::sltPathChanged); 179 180 /* Register fields: */ 181 registerField("cloneName", this, "cloneName"); 182 registerField("cloneFilePath", this, "cloneFilePath"); 183 registerField("reinitMACs", this, "reinitMACs"); 184 composeCloneFilePath(); 231 connect(m_pMACComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 232 this, &UIWizardCloneVMPageBasic1::sltHandleMACAddressClonePolicyComboChange); 185 233 } 186 234 … … 201 249 if (m_pPathLabel) 202 250 m_pPathLabel->setText(UIWizardCloneVM::tr("Path:")); 203 if (m_pReinitMACsCheckBox) 204 { 205 m_pReinitMACsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked a new unique MAC address will be assigned to all configured network cards.")); 206 m_pReinitMACsCheckBox->setText(UIWizardCloneVM::tr("&Reinitialize the MAC address of all network cards")); 207 } 251 252 /* Translate MAC address policy combo-box: */ 253 m_pMACComboBoxLabel->setText(UIWizardCloneVM::tr("MAC Address &Policy:")); 254 m_pMACComboBox->setItemText(MACAddressClonePolicy_KeepAllMACs, 255 UIWizardCloneVM::tr("Include all network adapter MAC addresses")); 256 m_pMACComboBox->setItemText(MACAddressClonePolicy_KeepNATMACs, 257 UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses")); 258 m_pMACComboBox->setItemText(MACAddressClonePolicy_StripAllMACs, 259 UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters")); 260 m_pMACComboBox->setItemData(MACAddressClonePolicy_KeepAllMACs, 261 UIWizardCloneVM::tr("Include all network adapter MAC addresses in exported " 262 "during cloning."), Qt::ToolTipRole); 263 m_pMACComboBox->setItemData(MACAddressClonePolicy_KeepNATMACs, 264 UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses " 265 "during cloning."), Qt::ToolTipRole); 266 m_pMACComboBox->setItemData(MACAddressClonePolicy_StripAllMACs, 267 UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters " 268 "during cloning."), Qt::ToolTipRole); 269 270 /* Adjust label widths: */ 271 QList<QWidget*> labels; 272 labels << m_pMACComboBoxLabel; 273 labels <<m_pNameLabel; 274 labels << m_pPathLabel; 275 276 int iMaxWidth = 0; 277 foreach (QWidget *pLabel, labels) 278 iMaxWidth = qMax(iMaxWidth, pLabel->minimumSizeHint().width()); 279 m_pContainerLayout->setColumnMinimumWidth(0, iMaxWidth); 208 280 } 209 281 … … 238 310 composeCloneFilePath(); 239 311 } 312 313 void UIWizardCloneVMPageBasic1::sltHandleMACAddressClonePolicyComboChange() 314 { 315 /* Update tool-tip: */ 316 updateMACAddressClonePolicyComboToolTip(); 317 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h
r72288 r74550 25 25 class QILineEdit; 26 26 class QCheckBox; 27 class QComboBox; 28 class QGridLayout; 27 29 class QLabel; 28 30 class QIRichTextLabel; 29 31 class UIFilePathSelector; 32 33 /** MAC address policies. */ 34 enum MACAddressClonePolicy 35 { 36 MACAddressClonePolicy_KeepAllMACs, 37 MACAddressClonePolicy_KeepNATMACs, 38 MACAddressClonePolicy_StripAllMACs, 39 MACAddressClonePolicy_MAX 40 }; 41 Q_DECLARE_METATYPE(MACAddressClonePolicy); 30 42 31 43 /* 1st page of the Clone Virtual Machine wizard (base part): */ … … 45 57 void setCloneFilePath(const QString &path); 46 58 47 bool isReinitMACsChecked() const;48 59 /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */ 49 60 void composeCloneFilePath(); 61 /** Populates MAC address policies. */ 62 void populateMACAddressClonePolicies(); 50 63 51 QString m_strOriginalName; 52 QString m_strDefaultPath; 53 QString m_strGroup; 64 /** Updates MAC address policy combo tool-tips. */ 65 void updateMACAddressClonePolicyComboToolTip(); 66 /** Returns MAC address clone policy. */ 67 MACAddressClonePolicy macAddressClonePolicy() const; 68 /** Defines @a enmMACAddressClonePolicy. */ 69 void setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy); 70 71 QString m_strOriginalName; 72 QString m_strDefaultPath; 73 QString m_strGroup; 54 74 /** Full, non-native path of the clone machines setting file. Generated by CVirtualBox::ComposeMachineFilename(...) */ 55 QString m_strCloneFilePath;75 QString m_strCloneFilePath; 56 76 /** The full path of the folder where clone machine's settings file is located. 57 77 * Generated from the m_strCloneFilePath by removing base file name */ 58 QString m_strCloneFolder; 59 QCheckBox *m_pReinitMACsCheckBox; 60 QILineEdit *m_pNameLineEdit; 78 QString m_strCloneFolder; 79 QILineEdit *m_pNameLineEdit; 61 80 UIFilePathSelector *m_pPathSelector; 62 QLabel *m_pNameLabel; 63 QLabel *m_pPathLabel; 64 81 QLabel *m_pNameLabel; 82 QLabel *m_pPathLabel; 83 QLabel *m_pMACComboBoxLabel; 84 QComboBox *m_pMACComboBox; 65 85 }; 66 86 … … 71 91 Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName); 72 92 Q_PROPERTY(QString cloneFilePath READ cloneFilePath WRITE setCloneFilePath); 73 Q_PROPERTY( bool reinitMACs READ isReinitMACsChecked);93 Q_PROPERTY(MACAddressClonePolicy macAddressClonePolicy READ macAddressClonePolicy WRITE setMACAddressClonePolicy); 74 94 75 95 public: … … 81 101 void sltNameChanged(); 82 102 void sltPathChanged(); 103 /** Handles change in MAC address policy combo-box. */ 104 void sltHandleMACAddressClonePolicyComboChange(); 83 105 84 106 private: … … 91 113 92 114 QIRichTextLabel *m_pMainLabel; 115 QGridLayout *m_pContainerLayout; 93 116 }; 94 117 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp
r74519 r74550 120 120 } 121 121 } 122 m_pReinitMACsCheckBox = new QCheckBox(this); 123 m_pReinitMACsCheckBox->setChecked(true); 122 m_pCloneOptionsCnt = new QGroupBox(this); 123 if (m_pCloneOptionsCnt) 124 { 125 m_pCloneOptionsLayout = new QGridLayout(m_pCloneOptionsCnt); 126 //m_pCloneOptionsLayout->setContentsMargins(0, 0, 0, 0); 127 /* Create MAC policy combo-box: */ 128 m_pMACComboBox = new QComboBox; 129 if (m_pMACComboBox) 130 { 131 /* Add into layout: */ 132 m_pCloneOptionsLayout->addWidget(m_pMACComboBox, 0, 1, 1, 1); 133 } 134 135 /* Create format combo-box label: */ 136 m_pMACComboBoxLabel = new QLabel; 137 if (m_pMACComboBoxLabel) 138 { 139 m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); 140 m_pMACComboBoxLabel->setBuddy(m_pMACComboBox); 141 /* Add into layout: */ 142 m_pCloneOptionsLayout->addWidget(m_pMACComboBoxLabel, 0, 0, 1, 1); 143 } 144 } 145 124 146 pMainLayout->addWidget(m_pNameCnt, 0, 0, 1, 2); 125 147 pMainLayout->addWidget(m_pCloneTypeCnt, 1, 0, Qt::AlignTop); 126 148 pMainLayout->addWidget(m_pCloneModeCnt, 1, 1, Qt::AlignTop); 127 pMainLayout->addWidget(m_p ReinitMACsCheckBox, 2, 0, 1, 2);149 pMainLayout->addWidget(m_pCloneOptionsCnt, 2, 0, 1, 2, Qt::AlignTop); 128 150 pMainLayout->setRowStretch(3, 1); 129 151 } … … 143 165 /* Register classes: */ 144 166 qRegisterMetaType<KCloneMode>(); 167 168 /* Populate MAC address policies: */ 169 populateMACAddressClonePolicies(); 170 145 171 /* Register fields: */ 146 172 registerField("cloneName", this, "cloneName"); 147 173 registerField("cloneFilePath", this, "cloneFilePath"); 148 registerField("reinitMACs", this, "reinitMACs");149 174 registerField("linkedClone", this, "linkedClone"); 150 175 registerField("cloneMode", this, "cloneMode"); 176 registerField("macAddressClonePolicy", this, "macAddressClonePolicy"); 151 177 composeCloneFilePath(); 152 178 } … … 176 202 m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current &snapshot tree branch")); 177 203 m_pAllRadio->setText(UIWizardCloneVM::tr("&Everything")); 178 m_pReinitMACsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked a new unique MAC address will be assigned to all configured network cards."));179 m_pReinitMACsCheckBox->setText(UIWizardCloneVM::tr("&Reinitialize the MAC address of all network cards"));180 204 m_pNameLabel->setText(UIWizardCloneVM::tr("Name:")); 181 205 m_pPathLabel->setText(UIWizardCloneVM::tr("Path:")); 206 207 m_pCloneOptionsCnt->setTitle(UIWizardCloneVM::tr("Additional &options")); 208 209 /* Translate MAC address policy combo-box: */ 210 m_pMACComboBoxLabel->setText(UIWizardCloneVM::tr("MAC Address &Policy:")); 211 m_pMACComboBox->setItemText(MACAddressClonePolicy_KeepAllMACs, 212 UIWizardCloneVM::tr("Include all network adapter MAC addresses")); 213 m_pMACComboBox->setItemText(MACAddressClonePolicy_KeepNATMACs, 214 UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses")); 215 m_pMACComboBox->setItemText(MACAddressClonePolicy_StripAllMACs, 216 UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters")); 217 m_pMACComboBox->setItemData(MACAddressClonePolicy_KeepAllMACs, 218 UIWizardCloneVM::tr("Include all network adapter MAC addresses in exported " 219 "during cloning."), Qt::ToolTipRole); 220 m_pMACComboBox->setItemData(MACAddressClonePolicy_KeepNATMACs, 221 UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses " 222 "during cloning."), Qt::ToolTipRole); 223 m_pMACComboBox->setItemData(MACAddressClonePolicy_StripAllMACs, 224 UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters " 225 "during cloning."), Qt::ToolTipRole); 226 227 /* Adjust label widths: */ 228 QList<QWidget*> labels; 229 labels << m_pMACComboBoxLabel; 230 231 int iMaxWidth = 0; 232 foreach (QWidget *pLabel, labels) 233 iMaxWidth = qMax(iMaxWidth, pLabel->minimumSizeHint().width()); 234 m_pCloneOptionsLayout->setColumnMinimumWidth(0, iMaxWidth); 182 235 } 183 236 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.h
r72554 r74550 36 36 Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName); 37 37 Q_PROPERTY(QString cloneFilePath READ cloneFilePath WRITE setCloneFilePath); 38 Q_PROPERTY(bool reinitMACs READ isReinitMACsChecked);39 38 Q_PROPERTY(bool linkedClone READ isLinkedClone); 40 39 Q_PROPERTY(KCloneMode cloneMode READ cloneMode WRITE setCloneMode); 40 Q_PROPERTY(MACAddressClonePolicy macAddressClonePolicy READ macAddressClonePolicy WRITE setMACAddressClonePolicy); 41 41 42 42 public: … … 66 66 67 67 /* Widgets: */ 68 QGroupBox *m_pNameCnt; 69 QGroupBox *m_pCloneTypeCnt; 70 QGroupBox *m_pCloneModeCnt; 68 QGroupBox *m_pNameCnt; 69 QGroupBox *m_pCloneTypeCnt; 70 QGroupBox *m_pCloneModeCnt; 71 QGroupBox *m_pCloneOptionsCnt; 72 QGridLayout *m_pCloneOptionsLayout; 71 73 }; 72 74
Note:
See TracChangeset
for help on using the changeset viewer.