Changeset 90628 in vbox
- Timestamp:
- Aug 11, 2021 1:21:17 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp
r90619 r90628 38 38 , m_strGroup(strGroup) 39 39 , m_iCloneModePageIndex(-1) 40 , m_strCloneName(!machine.isNull() ? machine.GetName() : QString()) 40 41 { 41 42 #ifndef VBOX_WS_MAC … … 60 61 return true; 61 62 return isPageVisible(m_iCloneModePageIndex); 63 } 64 65 void UIWizardCloneVM::setCloneName(const QString &strCloneName) 66 { 67 m_strCloneName = strCloneName; 68 } 69 70 const QString &UIWizardCloneVM::cloneName() const 71 { 72 return m_strCloneName; 73 } 74 75 void UIWizardCloneVM::setCloneFilePath(const QString &strCloneFilePath) 76 { 77 m_strCloneFilePath = strCloneFilePath; 78 } 79 80 const QString &UIWizardCloneVM::cloneFilePath() const 81 { 82 return m_strCloneFilePath; 62 83 } 63 84 … … 182 203 /* Translate wizard: */ 183 204 setWindowTitle(tr("Clone Virtual Machine")); 184 //setButtonText(QWizard::FinishButton, tr("Clone"));185 205 } 186 206 … … 194 214 case WizardMode_Expert: 195 215 { 196 addPage(new UIWizardCloneVMPageBasic1(m_ machine.GetName(), strDefaultMachineFolder, m_strGroup));216 addPage(new UIWizardCloneVMPageBasic1(m_strCloneName, strDefaultMachineFolder, m_strGroup)); 197 217 addPage(new UIWizardCloneVMPageBasic2(m_snapshot.isNull())); 198 218 if (m_machine.GetSnapshotCount() > 0) -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.h
r90621 r90628 30 30 #include "CSnapshot.h" 31 31 32 #define cloneVMWizardPropertySet(functionName, value) \ 33 do \ 34 { \ 35 UIWizardCloneVM *pWizard = qobject_cast<UIWizardCloneVM*>(wizard()); \ 36 if (pWizard) \ 37 pWizard->set##functionName(value); \ 38 } \ 39 while(0) 40 41 32 42 /* Clone VM wizard: */ 33 43 class UIWizardCloneVM : public UINativeWizard … … 44 54 bool cloneVM(); 45 55 56 void setCloneName(const QString &strCloneName); 57 const QString &cloneName() const; 58 59 void setCloneFilePath(const QString &strCloneFilePath); 60 const QString &cloneFilePath() const; 61 46 62 protected: 47 63 … … 57 73 QString m_strGroup; 58 74 int m_iCloneModePageIndex; 75 76 /** @name Parameters needed during machine cloning 77 * @{ */ 78 QString m_strCloneName; 79 QString m_strCloneFilePath; 80 /** @} */ 81 82 59 83 }; 60 84 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp
r90599 r90628 17 17 18 18 /* Qt includes: */ 19 // #include <QCheckBox> 20 // #include <QComboBox> 21 // #include <QGridLayout> 22 // #include <QLabel> 19 #include <QDir> 23 20 #include <QVBoxLayout> 24 21 … … 26 23 #include "UIWizardCloneVMEditors.h" 27 24 #include "QIRichTextLabel.h" 28 // #include "QILineEdit.h"29 // #include "UIFilePathSelector.h"30 25 #include "UIWizardCloneVM.h" 31 26 #include "UIWizardCloneVMPageBasic1.h" 32 //#include "UICommon.h"27 #include "UICommon.h" 33 28 34 29 /* COM includes: */ 35 // #include "CSystemProperties.h" 36 // #include "CVirtualBox.h" 30 #include "CVirtualBox.h" 37 31 38 32 39 // UIWizardCloneVMPage1::UIWizardCloneVMPage1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup)40 // : m_strOriginalName(strOriginalName)41 // , m_strDefaultPath(strDefaultPath)42 // , m_strGroup(strGroup)43 // , m_pNameLineEdit(0)44 // , m_pPathSelector(0)45 // , m_pNameLabel(0)46 // , m_pPathLabel(0)47 // , m_pMACComboBoxLabel(0)48 // , m_pMACComboBox(0)49 // , m_pKeepDiskNamesCheckBox(0)50 // , m_pKeepHWUUIDsCheckBox(0)51 // {52 // }53 33 54 // QString UIWizardCloneVMPage1::cloneName() const 55 // { 56 // if (!m_pNameLineEdit) 57 // return QString(); 58 // return m_pNameLineEdit->text(); 59 // } 60 61 // void UIWizardCloneVMPage1::setCloneName(const QString &strName) 62 // { 63 // if (!m_pNameLineEdit) 64 // return; 65 // m_pNameLineEdit->setText(strName); 66 // } 67 68 // QString UIWizardCloneVMPage1::clonePath() const 69 // { 70 // if (!m_pPathSelector) 71 // return QString(); 72 // return m_pPathSelector->path(); 73 // } 74 75 // void UIWizardCloneVMPage1::setClonePath(const QString &strPath) 76 // { 77 // if (!m_pPathSelector) 78 // m_pPathSelector->setPath(strPath); 79 // } 80 81 // QString UIWizardCloneVMPage1::cloneFilePath() const 82 // { 83 // return m_strCloneFilePath; 84 // } 85 86 // void UIWizardCloneVMPage1::setCloneFilePath(const QString &path) 87 // { 88 // if (m_strCloneFilePath == path) 89 // return; 90 // m_strCloneFilePath = path; 91 // } 92 93 // void UIWizardCloneVMPage1::composeCloneFilePath() 94 // { 95 // CVirtualBox vbox = uiCommon().virtualBox(); 96 // setCloneFilePath(vbox.ComposeMachineFilename(m_pNameLineEdit ? m_pNameLineEdit->text() : QString(), 97 // m_strGroup, 98 // QString(), 99 // m_pPathSelector ? m_pPathSelector->path() : QString())); 100 // const QFileInfo fileInfo(m_strCloneFilePath); 101 // m_strCloneFolder = fileInfo.absolutePath(); 102 // } 103 104 // void UIWizardCloneVMPage1::updateMACAddressClonePolicyComboToolTip() 105 // { 106 // const QString strCurrentToolTip = m_pMACComboBox->currentData(Qt::ToolTipRole).toString(); 107 // AssertMsg(!strCurrentToolTip.isEmpty(), ("Tool-tip data not found!")); 108 // m_pMACComboBox->setToolTip(strCurrentToolTip); 109 // } 110 111 // MACAddressClonePolicy UIWizardCloneVMPage1::macAddressClonePolicy() const 112 // { 113 // return m_pMACComboBox->currentData().value<MACAddressClonePolicy>(); 114 // } 115 116 // void UIWizardCloneVMPage1::setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy) 117 // { 118 // const int iIndex = m_pMACComboBox->findData(enmMACAddressClonePolicy); 119 // AssertMsg(iIndex != -1, ("Data not found!")); 120 // m_pMACComboBox->setCurrentIndex(iIndex); 121 // } 122 123 // void UIWizardCloneVMPage1::populateMACAddressClonePolicies() 124 // { 125 // AssertReturnVoid(m_pMACComboBox->count() == 0); 126 127 // /* Map known clone options to known MAC address export policies: */ 128 // QMap<KCloneOptions, MACAddressClonePolicy> knownOptions; 129 // knownOptions[KCloneOptions_KeepAllMACs] = MACAddressClonePolicy_KeepAllMACs; 130 // knownOptions[KCloneOptions_KeepNATMACs] = MACAddressClonePolicy_KeepNATMACs; 131 132 // /* Load currently supported clone options: */ 133 // CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 134 // const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions(); 135 136 // /* Check which of supported options/policies are known: */ 137 // QList<MACAddressClonePolicy> supportedPolicies; 138 // foreach (const KCloneOptions &enmOption, supportedOptions) 139 // if (knownOptions.contains(enmOption)) 140 // supportedPolicies << knownOptions.value(enmOption); 141 142 // /* Add supported policies first: */ 143 // foreach (const MACAddressClonePolicy &enmPolicy, supportedPolicies) 144 // m_pMACComboBox->addItem(QString(), QVariant::fromValue(enmPolicy)); 145 146 // /* Add hardcoded policy finally: */ 147 // m_pMACComboBox->addItem(QString(), QVariant::fromValue(MACAddressClonePolicy_StripAllMACs)); 148 149 // /* Set default: */ 150 // if (supportedPolicies.contains(MACAddressClonePolicy_KeepNATMACs)) 151 // setMACAddressClonePolicy(MACAddressClonePolicy_KeepNATMACs); 152 // else 153 // setMACAddressClonePolicy(MACAddressClonePolicy_StripAllMACs); 154 // } 155 156 // bool UIWizardCloneVMPage1::keepDiskNames() const 157 // { 158 // if (!m_pKeepDiskNamesCheckBox) 159 // return false; 160 // return m_pKeepDiskNamesCheckBox->isChecked(); 161 // } 162 163 // void UIWizardCloneVMPage1::setKeepDiskNames(bool fKeepDiskNames) 164 // { 165 // if (!m_pKeepDiskNamesCheckBox) 166 // return; 167 // if (m_pKeepDiskNamesCheckBox->isChecked() == fKeepDiskNames) 168 // return; 169 // m_pKeepDiskNamesCheckBox->setChecked(fKeepDiskNames); 170 // } 171 172 // bool UIWizardCloneVMPage1::keepHWUUIDs() const 173 // { 174 // if (!m_pKeepHWUUIDsCheckBox) 175 // return false; 176 // return m_pKeepHWUUIDsCheckBox->isChecked(); 177 // } 178 179 // void UIWizardCloneVMPage1::setKeepHWUUIDs(bool fKeepHWUUIDs) 180 // { 181 // if (!m_pKeepHWUUIDsCheckBox) 182 // return; 183 // if (m_pKeepHWUUIDsCheckBox->isChecked() == fKeepHWUUIDs) 184 // return; 185 // m_pKeepHWUUIDsCheckBox->setChecked(fKeepHWUUIDs); 186 // } 34 QString UIWizardCloneVMNamePage::composeCloneFilePath(const QString &strCloneName, const QString &strGroup, const QString &strFolderPath) 35 { 36 CVirtualBox vbox = uiCommon().virtualBox(); 37 QString strCloneFilePath = vbox.ComposeMachineFilename(strCloneName, strGroup, QString(), strFolderPath); 38 return QDir::toNativeSeparators(QFileInfo(strCloneFilePath).absolutePath()); 39 } 187 40 188 41 … … 191 44 , m_pAdditionalOptionsEditor(0) 192 45 , m_strOriginalName(strOriginalName) 193 , m_strDefaultPath(strDefaultPath)194 46 , m_strGroup(strGroup) 195 47 { 196 prepare( );48 prepare(strDefaultPath); 197 49 } 198 50 … … 226 78 } 227 79 228 void UIWizardCloneVMPageBasic1::prepare( )80 void UIWizardCloneVMPageBasic1::prepare(const QString &strDefaultClonePath) 229 81 { 230 82 QVBoxLayout *pMainLayout = new QVBoxLayout(this); … … 236 88 pMainLayout->addWidget(m_pMainLabel); 237 89 238 m_pNamePathEditor = new UICloneVMNamePathEditor(m_strOriginalName, m_strDefaultPath);90 m_pNamePathEditor = new UICloneVMNamePathEditor(m_strOriginalName, strDefaultClonePath); 239 91 if (m_pNamePathEditor) 240 92 { 241 93 m_pNamePathEditor->setFlat(true); 242 94 pMainLayout->addWidget(m_pNamePathEditor); 95 connect(m_pNamePathEditor, &UICloneVMNamePathEditor::sigCloneNameChanged, 96 this, &UIWizardCloneVMPageBasic1::sltCloneNameChanged); 97 connect(m_pNamePathEditor, &UICloneVMNamePathEditor::sigClonePathChanged, 98 this, &UIWizardCloneVMPageBasic1::sltClonePathChanged); 243 99 } 244 100 … … 269 125 } 270 126 271 void UIWizardCloneVMPageBasic1::slt NameChanged()127 void UIWizardCloneVMPageBasic1::sltCloneNameChanged(const QString &strCloneName) 272 128 { 273 //composeCloneFilePath(); 129 AssertReturnVoid(m_pNamePathEditor); 130 m_userModifiedParameters << "CloneName"; 131 m_userModifiedParameters << "CloneFilePath"; 132 cloneVMWizardPropertySet(CloneName, strCloneName); 133 cloneVMWizardPropertySet(CloneFilePath, 134 UIWizardCloneVMNamePage::composeCloneFilePath(strCloneName, m_strGroup, m_pNamePathEditor->clonePath())); 274 135 } 275 136 276 void UIWizardCloneVMPageBasic1::slt PathChanged()137 void UIWizardCloneVMPageBasic1::sltClonePathChanged(const QString &strClonePath) 277 138 { 278 //composeCloneFilePath(); 139 AssertReturnVoid(m_pNamePathEditor); 140 m_userModifiedParameters << "CloneFilePath"; 141 cloneVMWizardPropertySet(CloneFilePath, 142 UIWizardCloneVMNamePage::composeCloneFilePath(m_pNamePathEditor->cloneName(), m_strGroup, strClonePath)); 279 143 } 280 144 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h
r90599 r90628 22 22 #endif 23 23 24 /* Qt includes: */ 25 #include <QSet> 26 24 27 /* Local includes: */ 25 28 #include "UINativeWizardPage.h" … … 28 31 class UICloneVMAdditionalOptionsEditor; 29 32 class UICloneVMNamePathEditor; 30 // class QILineEdit;31 // class QCheckBox;32 // class QComboBox;33 // class QGridLayout;34 // class QLabel;35 33 class QIRichTextLabel; 36 // class UIFilePathSelector;37 34 38 //Q_DECLARE_METATYPE(MACAddressClonePolicy); 35 namespace UIWizardCloneVMNamePage 36 { 37 QString composeCloneFilePath(const QString &strCloneName, const QString &strGroup, const QString &strFolderPath); 39 38 40 // /* 1st page of the Clone Virtual Machine wizard (base part): */41 // class UIWizardCloneVMPage1 : public UIWizardPageBase42 // {43 // protected:44 39 45 // UIWizardCloneVMPage1(const QString &strOriginalName, const QString &strDefaultPath, const QString &strGroup); 40 } 46 41 47 // QString cloneName() const;48 // void setCloneName(const QString &strName);49 50 // QString clonePath() const;51 // void setClonePath(const QString &strName);52 53 // QString cloneFilePath() const;54 // void setCloneFilePath(const QString &path);55 56 // /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */57 // void composeCloneFilePath();58 // /** Populates MAC address policies. */59 // void populateMACAddressClonePolicies();60 61 // /** Updates MAC address policy combo tool-tips. */62 // void updateMACAddressClonePolicyComboToolTip();63 // /** Returns MAC address clone policy. */64 // MACAddressClonePolicy macAddressClonePolicy() const;65 // /** Defines @a enmMACAddressClonePolicy. */66 // void setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy);67 68 // bool keepDiskNames() const;69 // void setKeepDiskNames(bool fKeepDiskNames);70 71 // bool keepHWUUIDs() const;72 // void setKeepHWUUIDs(bool bKeepHWUUIDs);73 74 // /** Full, non-native path of the clone machines setting file. Generated by CVirtualBox::ComposeMachineFilename(...) */75 // QString m_strCloneFilePath;76 // /** The full path of the folder where clone machine's settings file is located.77 // * Generated from the m_strCloneFilePath by removing base file name */78 // QString m_strCloneFolder;79 // QLabel *m_pMACComboBoxLabel;80 // QComboBox *m_pMACComboBox;81 // };82 83 /* 1st page of the Clone Virtual Machine wizard (basic extension): */84 42 class UIWizardCloneVMPageBasic1 : public UINativeWizardPage 85 43 { 86 44 Q_OBJECT; 87 // Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName);88 // Q_PROPERTY(QString cloneFilePath READ cloneFilePath WRITE setCloneFilePath);89 // Q_PROPERTY(MACAddressClonePolicy macAddressClonePolicy READ macAddressClonePolicy WRITE setMACAddressClonePolicy);90 // Q_PROPERTY(bool keepDiskNames READ keepDiskNames WRITE setKeepDiskNames);91 // Q_PROPERTY(bool keepHWUUIDs READ keepHWUUIDs WRITE setKeepHWUUIDs);92 93 45 94 46 public: … … 98 50 private slots: 99 51 100 void slt NameChanged();101 void slt PathChanged();52 void sltCloneNameChanged(const QString &strCloneName); 53 void sltClonePathChanged(const QString &strClonePath); 102 54 /** Handles change in MAC address policy combo-box. */ 103 55 void sltHandleMACAddressClonePolicyComboChange(); … … 107 59 void retranslateUi(); 108 60 void initializePage(); 109 void prepare( );61 void prepare(const QString &strDefaultClonePath); 110 62 /* Validation stuff: */ 111 63 bool isComplete() const; … … 117 69 UICloneVMAdditionalOptionsEditor *m_pAdditionalOptionsEditor; 118 70 QString m_strOriginalName; 119 QString m_strDefaultPath;120 71 QString m_strGroup; 72 QSet<QString> m_userModifiedParameters; 121 73 }; 122 74 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.cpp
r90620 r90628 66 66 } 67 67 68 QString UICloneVMNamePathEditor::cloneName() const 69 { 70 if (m_pNameLineEdit) 71 return m_pNameLineEdit->text(); 72 return QString(); 73 } 74 75 void UICloneVMNamePathEditor::setCloneName(const QString &strName) 76 { 77 if (m_pNameLineEdit) 78 m_pNameLineEdit->setText(strName); 79 } 80 81 QString UICloneVMNamePathEditor::clonePath() const 82 { 83 if (m_pPathSelector) 84 return m_pPathSelector->path(); 85 return QString(); 86 } 87 88 void UICloneVMNamePathEditor::setClonePath(const QString &strPath) 89 { 90 if (m_pPathSelector) 91 m_pPathSelector->setPath(strPath); 92 } 93 68 94 void UICloneVMNamePathEditor::setFirstColumnWidth(int iWidth) 69 95 { … … 100 126 m_pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1); 101 127 m_pNameLineEdit->setText(tr("%1 Clone").arg(m_strOriginalName)); 128 connect(m_pNameLineEdit, &QILineEdit::textChanged, 129 this, &UICloneVMNamePathEditor::sigCloneNameChanged); 102 130 } 103 131 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.h
r90617 r90628 69 69 signals: 70 70 71 // void sigNameChanged(const QString &strUserName);72 // void sigPathChanged(const QString &strPassword);71 void sigCloneNameChanged(const QString &strCloneName); 72 void sigClonePathChanged(const QString &strClonePath); 73 73 74 74 public: … … 79 79 int firstColumnWidth() const; 80 80 81 QString name() const;82 void set Name(const QString &strName);81 QString cloneName() const; 82 void setCloneName(const QString &strName); 83 83 84 QString path() const; 85 void setPath(const QString &strPath); 84 QString clonePath() const; 85 void setClonePath(const QString &strPath); 86 86 87 bool isComplete(); 87 88
Note:
See TracChangeset
for help on using the changeset viewer.