- Timestamp:
- May 14, 2018 12:57:36 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 122638
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp
r72182 r72199 240 240 { 241 241 m_pNamePathSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 242 m_pNamePathSelector->setPath(vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder()); 242 243 pMainLayout->addWidget(m_pNamePathSelector, 0, 1, 1, 2); 243 244 } … … 349 350 } 350 351 351 void UINameAndSystemEditor::setMachineF ilePath(const QString &strPath)352 void UINameAndSystemEditor::setMachineFolder(const QString &strPath) 352 353 { 353 354 if (!m_pNamePathSelector) -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h
r72182 r72199 76 76 77 77 /** Forwards the machine name to UIVMNamePathSelector member instance. */ 78 void setMachineF ilePath(const QString &strPath);78 void setMachineFolder(const QString &strPath); 79 79 80 80 protected: -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVMNamePathSelector.cpp
r72191 r72199 111 111 QString UIVMNamePathSelector::path() const 112 112 { 113 if (!m_pPath) 114 return QString(); 115 return m_pPath->text(); 113 return m_strNonNativePath; 116 114 } 117 115 118 116 void UIVMNamePathSelector::setPath(const QString &path) 119 117 { 120 if ( !m_pPath || m_pPath->text()== path)118 if (m_strNonNativePath == path) 121 119 return; 122 QString nativePath(QDir::toNativeSeparators(path)); 123 m_pPath->setText(nativePath); 124 m_pPath->setFixedWidthByText(nativePath); 125 emit sigPathChanged(nativePath); 120 m_strNonNativePath = path; 121 if (m_pPath) 122 { 123 QString nativePath(QDir::toNativeSeparators(path)); 124 m_pPath->setText(nativePath); 125 m_pPath->setFixedWidthByText(nativePath); 126 } 127 emit sigPathChanged(m_strNonNativePath); 126 128 } 127 129 … … 131 133 return QString(); 132 134 return m_pName->text(); 133 134 135 } 135 136 … … 141 142 } 142 143 143 144 144 void UIVMNamePathSelector::retranslateUi() 145 145 { 146 146 if (m_strToolTipText.isEmpty()) 147 { 148 setToolTip(tr("You have to enter a name for the virtual machine")); 147 149 return; 150 } 148 151 QString strToolTip = "The Virtual Machine files will be saved under " + m_strToolTipText; 149 152 setToolTip(tr(qPrintable(strToolTip))); … … 152 155 void UIVMNamePathSelector::sltOpenPathSelector() 153 156 { 154 155 QString strSelectedPath = QIFileDialog::getExistingDirectory(m_pPath->text(), this, 157 QString strSelectedPath = QIFileDialog::getExistingDirectory(m_strNonNativePath, this, 156 158 QString("Select a parent folder for new Virtual Machine")); 157 159 if (!strSelectedPath.isEmpty()) -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVMNamePathSelector.h
r72182 r72199 76 76 /** Tooltip set is set by clients of this widget. */ 77 77 QString m_strToolTipText; 78 /** Path string whose separators are not converted to native ones. */ 79 QString m_strNonNativePath; 78 80 }; 79 81 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp
r69500 r72199 31 31 /* COM includes: */ 32 32 # include "CConsole.h" 33 # include "CSystemProperties.h" 33 34 34 35 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 51 52 bool UIWizardCloneVM::cloneVM() 52 53 { 53 /* Get clone name: */54 /* Get the clone name: */ 54 55 QString strName = field("cloneName").toString(); 56 /* Get the clone path: */ 57 QString strPath = field("clonePath").toString(); 58 QString strSettingsFile = field("cloneFilePath").toString(); 59 55 60 /* Should we reinit mac status? */ 56 61 bool fReinitMACs = field("reinitMACs").toBool(); … … 118 123 119 124 /* Create a new machine object. */ 120 const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null /**< @todo group support */, QString::null, QString::null);121 125 CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QVector<QString>(), QString::null, QString::null); 122 126 if (!vbox.isOk()) … … 175 179 void UIWizardCloneVM::prepare() 176 180 { 181 QString strDefaultMachineFolder = vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 177 182 /* Create corresponding pages: */ 178 183 switch (mode()) … … 180 185 case WizardMode_Basic: 181 186 { 182 setPage(Page1, new UIWizardCloneVMPageBasic1(m_machine.GetName() ));187 setPage(Page1, new UIWizardCloneVMPageBasic1(m_machine.GetName(), strDefaultMachineFolder)); 183 188 setPage(Page2, new UIWizardCloneVMPageBasic2(m_snapshot.isNull())); 184 189 if (m_machine.GetSnapshotCount() > 0) … … 189 194 { 190 195 setPage(PageExpert, new UIWizardCloneVMPageExpert(m_machine.GetName(), 196 strDefaultMachineFolder, 191 197 m_snapshot.isNull(), 192 198 m_snapshot.isNull() ? false : m_snapshot.GetChildrenCount() > 0)); … … 202 208 UIWizard::prepare(); 203 209 } 204 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp
r70805 r72199 26 26 27 27 /* GUI includes: */ 28 # include "QIRichTextLabel.h" 29 # include "UIVMNamePathSelector.h" 30 # include "UIWizardCloneVM.h" 28 31 # include "UIWizardCloneVMPageBasic1.h" 29 # include "UIWizardCloneVM.h" 30 # include "QIRichTextLabel.h" 32 # include "VBoxGlobal.h" 33 34 /* COM includes: */ 35 # include "CVirtualBox.h" 31 36 32 37 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 33 38 34 39 35 UIWizardCloneVMPage1::UIWizardCloneVMPage1(const QString &strOriginalName )40 UIWizardCloneVMPage1::UIWizardCloneVMPage1(const QString &strOriginalName, const QString &strDefaultPath) 36 41 : m_strOriginalName(strOriginalName) 42 , m_strDefaultPath(strDefaultPath) 37 43 { 38 44 } … … 40 46 QString UIWizardCloneVMPage1::cloneName() const 41 47 { 42 return m_pName Editor->text();48 return m_pNamePathSelector->name(); 43 49 } 44 50 45 51 void UIWizardCloneVMPage1::setCloneName(const QString &strName) 46 52 { 47 m_pName Editor->setText(strName);53 m_pNamePathSelector->setName(strName); 48 54 } 55 56 QString UIWizardCloneVMPage1::clonePath() const 57 { 58 if (!m_pNamePathSelector) 59 return QString(); 60 return m_pNamePathSelector->path(); 61 } 62 63 void UIWizardCloneVMPage1::setClonePath(const QString &strPath) 64 { 65 m_pNamePathSelector->setPath(strPath); 66 } 67 68 QString UIWizardCloneVMPage1::cloneFilePath() const 69 { 70 return m_strCloneFilePath; 71 } 72 73 void UIWizardCloneVMPage1::setCloneFilePath(const QString &path) 74 { 75 if (m_strCloneFilePath == path) 76 return; 77 m_strCloneFilePath = path; 78 } 79 49 80 50 81 bool UIWizardCloneVMPage1::isReinitMACsChecked() const … … 53 84 } 54 85 55 UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName) 56 : UIWizardCloneVMPage1(strOriginalName) 86 void UIWizardCloneVMPage1::composeCloneFilePath() 87 { 88 CVirtualBox vbox = vboxGlobal().virtualBox(); 89 setCloneFilePath(vbox.ComposeMachineFilename(m_pNamePathSelector->name(), 90 QString::null, 91 QString::null, 92 m_pNamePathSelector->path())); 93 const QFileInfo fileInfo(m_strCloneFilePath); 94 m_strCloneFolder = fileInfo.absolutePath(); 95 if (m_pNamePathSelector) 96 m_pNamePathSelector->setToolTipText(m_strCloneFolder); 97 } 98 99 UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName, const QString &strDefaultPath) 100 : UIWizardCloneVMPage1(strOriginalName, strDefaultPath) 57 101 { 58 102 /* Create widgets: */ … … 60 104 { 61 105 m_pLabel = new QIRichTextLabel(this); 62 m_pNameEditor = new QLineEdit(this);106 if (m_pLabel) 63 107 { 64 m_pNameEditor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));108 pMainLayout->addWidget(m_pLabel); 65 109 } 110 111 m_pNamePathSelector = new UIVMNamePathSelector(this); 112 if (m_pNamePathSelector) 113 { 114 pMainLayout->addWidget(m_pNamePathSelector); 115 m_pNamePathSelector->setName(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName)); 116 m_pNamePathSelector->setPath(m_strDefaultPath); 117 } 118 66 119 m_pReinitMACsCheckBox = new QCheckBox(this); 67 pMainLayout->addWidget(m_pLabel); 68 pMainLayout->addWidget(m_pNameEditor); 69 pMainLayout->addWidget(m_pReinitMACsCheckBox); 120 121 if (m_pReinitMACsCheckBox) 122 { 123 pMainLayout->addWidget(m_pReinitMACsCheckBox); 124 } 70 125 pMainLayout->addStretch(); 71 126 } 72 127 73 128 /* Setup connections: */ 74 connect(m_pNameEditor, &QLineEdit::textChanged, this, &UIWizardCloneVMPageBasic1::completeChanged); 129 connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged, this, &UIWizardCloneVMPageBasic1::completeChanged); 130 connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged, this, &UIWizardCloneVMPageBasic1::completeChanged); 131 132 connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged, this, &UIWizardCloneVMPageBasic1::sltNameChanged); 133 connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged, this, &UIWizardCloneVMPageBasic1::sltPathChanged); 75 134 76 135 /* Register fields: */ 77 136 registerField("cloneName", this, "cloneName"); 137 registerField("clonePath", this, "clonePath"); 78 138 registerField("reinitMACs", this, "reinitMACs"); 79 139 } … … 85 145 86 146 /* Translate widgets: */ 87 m_pLabel->setText(UIWizardCloneVM::tr("<p>Please choose a name for the new virtual machine. "147 m_pLabel->setText(UIWizardCloneVM::tr("<p>Please choose a folder and a name for the new virtual machine. " 88 148 "The new machine will be a clone of the machine <b>%1</b>.</p>") 89 149 .arg(m_strOriginalName)); … … 100 160 bool UIWizardCloneVMPageBasic1::isComplete() const 101 161 { 162 if (!m_pNamePathSelector) 163 return false; 164 165 QString path = m_pNamePathSelector->path(); 166 if (path.isEmpty()) 167 return false; 102 168 /* Make sure VM name feat the rules: */ 103 QString strName = m_pName Editor->text().trimmed();169 QString strName = m_pNamePathSelector->name().trimmed(); 104 170 return !strName.isEmpty() && strName != m_strOriginalName; 105 171 } 106 172 173 void UIWizardCloneVMPageBasic1::sltNameChanged() 174 { 175 composeCloneFilePath(); 176 } 177 178 void UIWizardCloneVMPageBasic1::sltPathChanged() 179 { 180 composeCloneFilePath(); 181 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h
r69500 r72199 26 26 class QCheckBox; 27 27 class QIRichTextLabel; 28 class UIVMNamePathSelector; 28 29 29 30 /* 1st page of the Clone Virtual Machine wizard (base part): */ … … 32 33 protected: 33 34 34 /* Constructor: */ 35 UIWizardCloneVMPage1(const QString &strOriginalName); 35 UIWizardCloneVMPage1(const QString &strOriginalName, const QString &strDefaultPath); 36 36 37 /* Stuff for 'cloneName' field: */38 37 QString cloneName() const; 39 void setCloneName(const QString &strName);38 void setCloneName(const QString &strName); 40 39 41 /* Stuff for 'reinitMACs' field: */ 40 QString clonePath() const; 41 void setClonePath(const QString &strName); 42 43 QString cloneFilePath() const; 44 void setCloneFilePath(const QString &path); 45 42 46 bool isReinitMACsChecked() const; 47 /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */ 48 void composeCloneFilePath(); 43 49 44 /* Variables: */ 45 QString m_strOriginalName; 50 QString m_strOriginalName; 51 QString m_strDefaultPath; 52 /** Full, non-native path of the clone machines setting file. Generated by CVirtualBox::ComposeMachineFilename(...) */ 53 QString m_strCloneFilePath; 54 /** The full path of the folder where clone machine's settings file is located. 55 * Generated from the m_strCloneFilePath by removing base file name */ 56 QString m_strCloneFolder; 57 QCheckBox *m_pReinitMACsCheckBox; 58 UIVMNamePathSelector *m_pNamePathSelector; 46 59 47 /* Widgets: */48 QLineEdit *m_pNameEditor;49 QCheckBox *m_pReinitMACsCheckBox;50 60 }; 51 61 … … 55 65 Q_OBJECT; 56 66 Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName); 67 Q_PROPERTY(QString clonePath READ clonePath WRITE setClonePath); 68 Q_PROPERTY(QString cloneFilePath READ cloneFilePath WRITE setCloneFilePath); 57 69 Q_PROPERTY(bool reinitMACs READ isReinitMACsChecked); 58 70 59 71 public: 60 72 61 /* Constructor: */ 62 UIWizardCloneVMPageBasic1(const QString &strOriginalName); 73 UIWizardCloneVMPageBasic1(const QString &strOriginalName, const QString &strDefaultPath); 74 75 private slots: 76 77 void sltNameChanged(); 78 void sltPathChanged(); 63 79 64 80 private: 65 81 66 /* Translation stuff: */67 82 void retranslateUi(); 68 69 /* Prepare stuff: */70 83 void initializePage(); 71 84 … … 73 86 bool isComplete() const; 74 87 75 /* Widgets: */76 88 QIRichTextLabel *m_pLabel; 77 89 }; 78 90 79 91 #endif // __UIWizardCloneVMPageBasic1_h__ 80 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp
r70805 r72199 29 29 30 30 /* Local includes: */ 31 # include "UIVMNamePathSelector.h" 31 32 # include "UIWizardCloneVMPageExpert.h" 32 33 # include "UIWizardCloneVM.h" … … 35 36 36 37 37 UIWizardCloneVMPageExpert::UIWizardCloneVMPageExpert(const QString &strOriginalName, bool fAdditionalInfo, bool fShowChildsOption)38 : UIWizardCloneVMPage1(strOriginalName )38 UIWizardCloneVMPageExpert::UIWizardCloneVMPageExpert(const QString &strOriginalName, const QString &strDefaultPath, bool fAdditionalInfo, bool fShowChildsOption) 39 : UIWizardCloneVMPage1(strOriginalName, strDefaultPath) 39 40 , UIWizardCloneVMPage2(fAdditionalInfo) 40 41 , UIWizardCloneVMPage3(fShowChildsOption) … … 47 48 QVBoxLayout *pNameCntLayout = new QVBoxLayout(m_pNameCnt); 48 49 { 49 m_pName Editor = new QLineEdit(m_pNameCnt);50 m_pNamePathSelector = new UIVMNamePathSelector(m_pNameCnt); 50 51 { 51 m_pName Editor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));52 m_pNamePathSelector->setName(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName)); 52 53 } 53 pNameCntLayout->addWidget(m_pName Editor);54 pNameCntLayout->addWidget(m_pNamePathSelector); 54 55 } 55 56 } … … 101 102 102 103 /* Setup connections: */ 103 connect(m_pName Editor, &QLineEdit::textChanged,104 connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged, 104 105 this, &UIWizardCloneVMPageExpert::completeChanged); 106 connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged, 107 this, &UIWizardCloneVMPageExpert::completeChanged); 108 connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged, 109 this, &UIWizardCloneVMPageExpert::sltNameChanged); 110 connect(m_pNamePathSelector, &UIVMNamePathSelector::sigPathChanged, 111 this, &UIWizardCloneVMPageExpert::sltPathChanged); 105 112 connect(m_pButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked), 106 113 this, &UIWizardCloneVMPageExpert::sltButtonClicked); … … 110 117 /* Register fields: */ 111 118 registerField("cloneName", this, "cloneName"); 119 registerField("clonePath", this, "clonePath"); 112 120 registerField("reinitMACs", this, "reinitMACs"); 113 121 registerField("linkedClone", this, "linkedClone"); 114 122 registerField("cloneMode", this, "cloneMode"); 123 composeCloneFilePath(); 115 124 } 116 125 … … 144 153 bool UIWizardCloneVMPageExpert::isComplete() const 145 154 { 155 if (!m_pNamePathSelector) 156 return false; 157 158 QString path = m_pNamePathSelector->path(); 159 if (path.isEmpty()) 160 return false; 146 161 /* Make sure VM name feat the rules: */ 147 QString strName = m_pName Editor->text().trimmed();162 QString strName = m_pNamePathSelector->name().trimmed(); 148 163 return !strName.isEmpty() && strName != m_strOriginalName; 149 164 } … … 168 183 } 169 184 185 void UIWizardCloneVMPageExpert::sltNameChanged() 186 { 187 composeCloneFilePath(); 188 } 189 190 void UIWizardCloneVMPageExpert::sltPathChanged() 191 { 192 composeCloneFilePath(); 193 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.h
r69500 r72199 35 35 Q_OBJECT; 36 36 Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName); 37 Q_PROPERTY(QString clonePath READ clonePath WRITE setClonePath); 37 38 Q_PROPERTY(bool reinitMACs READ isReinitMACsChecked); 38 39 Q_PROPERTY(bool linkedClone READ isLinkedClone); … … 42 43 43 44 /* Constructor: */ 44 UIWizardCloneVMPageExpert(const QString &strOriginalName, bool fAdditionalInfo, bool fShowChildsOption); 45 UIWizardCloneVMPageExpert(const QString &strOriginalName, const QString &strDefaultPath, 46 bool fAdditionalInfo, bool fShowChildsOption); 45 47 46 48 private slots: … … 48 50 /* Button click handler: */ 49 51 void sltButtonClicked(QAbstractButton *pButton); 52 void sltNameChanged(); 53 void sltPathChanged(); 50 54 51 55 private: … … 68 72 69 73 #endif // __UIWizardCloneVMPageExpert_h__ 70 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp
r72191 r72199 236 236 237 237 if (m_pNameAndSystemEditor) 238 m_pNameAndSystemEditor->setMachineF ilePath(m_strMachineFolder);238 m_pNameAndSystemEditor->setMachineFolder(m_strMachineFolder); 239 239 } 240 240
Note:
See TracChangeset
for help on using the changeset viewer.