Changeset 64965 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 19, 2016 3:16:10 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r63567 r64965 106 106 if (!m_strGroup.isEmpty()) 107 107 groups << m_strGroup; 108 m_machine = vbox.CreateMachine( field("machineFilePath").toString(),109 field(" machineBaseName").toString(),108 m_machine = vbox.CreateMachine(QString() /* no file-path for now */, 109 field("name").toString(), 110 110 groups, strTypeId, QString()); 111 111 if (!vbox.isOk()) -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp
r64656 r64965 31 31 # include "UIMessageCenter.h" 32 32 # include "UINameAndSystemEditor.h" 33 # include "UIFilePathSelector.h"34 33 # include "QIRichTextLabel.h" 35 34 … … 205 204 } 206 205 207 void UIWizardNewVMPage1::adjustToolTip(const QString &strNewName /* = QString() */)208 {209 /* Compose tool-tip: */210 QString strToolTip;211 /* If name is empty: */212 if (strNewName.isEmpty())213 {214 /* We are just reseting the tool-tip to default: */215 strToolTip = UIWizardNewVM::tr("<p><nobr>Holds the name or full path to the virtual "216 "machine folder you are about to create.</nobr></p>");217 }218 /* If name is NOT empty: */219 else220 {221 /* Compose the machine file-path, acquire the machine folder from it: */222 const QString strMachineFilePath = composeMachineFilePath(strNewName);223 const QString strMachineFolder = QDir::toNativeSeparators(QFileInfo(strMachineFilePath).absolutePath());224 /* And compose the location-editor tool-tip accordingly: */225 strToolTip = UIWizardNewVM::tr("<p><nobr>You are about to create the virtual machine in the "226 "following folder:</nobr><br><nobr><b>%1</b></nobr></p>")227 .arg(strMachineFolder);228 }229 /* Assign tool-tip: */230 m_pNameAndSystemEditor->locationEditor()->setToolTip(strToolTip);231 }232 233 206 bool UIWizardNewVMPage1::machineFolderCreated() 234 207 { … … 245 218 } 246 219 247 /* Compose machine file-path, parse it to folder and base-name: */ 248 const QString strMachineFilePath = composeMachineFilePath(m_pNameAndSystemEditor->name()); 249 const QString strMachineFolder = QDir::toNativeSeparators(QFileInfo(strMachineFilePath).absolutePath()); 250 const QString strMachineBaseName = QFileInfo(strMachineFilePath).completeBaseName(); 220 /* Get VBox: */ 221 CVirtualBox vbox = vboxGlobal().virtualBox(); 222 /* Get default machine folder: */ 223 const QString strDefaultMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder(); 224 /* Compose machine filename: */ 225 const QString strMachineFilePath = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(), 226 m_strGroup, 227 QString(), 228 strDefaultMachineFolder); 229 /* Compose machine folder/basename: */ 230 const QFileInfo fileInfo(strMachineFilePath); 231 const QString strMachineFolder = fileInfo.absolutePath(); 232 const QString strMachineBaseName = fileInfo.completeBaseName(); 251 233 252 234 /* Make sure that folder doesn't exists: */ … … 268 250 m_strMachineFolder = strMachineFolder; 269 251 m_strMachineBaseName = strMachineBaseName; 270 m_strMachineFilePath = strMachineFilePath;271 252 return true; 272 253 } … … 286 267 } 287 268 288 QString UIWizardNewVMPage1::composeMachineFilePath(const QString &strUserMachineLocation)289 {290 /* Get VBox: */291 CVirtualBox vbox = vboxGlobal().virtualBox();292 /* Get default machine folder: */293 const QString strDefaultMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();294 /* Fetch user's machine location: */295 const QString strUserMachineFolder = QFileInfo(strUserMachineLocation).absolutePath();296 const QString strUserMachineBaseName = QFileInfo(strUserMachineLocation).fileName();297 const bool fUseDefaultPath = strUserMachineLocation == strUserMachineBaseName;298 /* Compose machine filename: */299 return vbox.ComposeMachineFilename(strUserMachineBaseName,300 fUseDefaultPath ? m_strGroup : QString() /* no group in that case */,301 QString(),302 fUseDefaultPath ? strDefaultMachineFolder : strUserMachineFolder);303 }304 305 269 UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1(const QString &strGroup) 306 270 : UIWizardNewVMPage1(strGroup) … … 310 274 { 311 275 m_pLabel = new QIRichTextLabel(this); 312 m_pNameAndSystemEditor = new UINameAndSystemEditor(this , true);276 m_pNameAndSystemEditor = new UINameAndSystemEditor(this); 313 277 pMainLayout->addWidget(m_pLabel); 314 278 pMainLayout->addWidget(m_pNameAndSystemEditor); … … 318 282 /* Setup connections: */ 319 283 connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &))); 320 connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltAdjustToolTip(const QString &)));321 284 connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(sltOsTypeChanged())); 322 285 … … 326 289 registerField("machineFolder", this, "machineFolder"); 327 290 registerField("machineBaseName", this, "machineBaseName"); 328 registerField("machineFilePath", this, "machineFilePath");329 330 /* Initialize tool-tip: */331 adjustToolTip();332 291 } 333 292 … … 336 295 /* Call to base-class: */ 337 296 onNameChanged(strNewName); 338 }339 340 void UIWizardNewVMPageBasic1::sltAdjustToolTip(const QString &strNewName)341 {342 /* Call to base-class: */343 adjustToolTip(strNewName);344 297 } 345 298 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h
r62493 r64965 38 38 void onOsTypeChanged(); 39 39 40 /** Adjusts tool-tip according to @a strNewName. */41 void adjustToolTip(const QString &strNewName = QString());42 43 40 /* Helping stuff: */ 44 41 bool machineFolderCreated(); 45 42 bool createMachineFolder(); 46 43 bool cleanupMachineFolder(); 47 48 /** Composes and returns machine file-path on the basis of passed @a strUserMachineLocation. */49 QString composeMachineFilePath(const QString &strUserMachineLocation);50 44 51 45 /** Returns the machine folder value. */ … … 59 53 void setMachineBaseName(const QString &strMachineBaseName) { m_strMachineBaseName = strMachineBaseName; } 60 54 61 /** Returns the machine file-path value. */62 QString machineFilePath() const { return m_strMachineFilePath; }63 /** Defines the @a strMachineFilePath value. */64 void setMachineFilePath(const QString &strMachineFilePath) { m_strMachineFilePath = strMachineFilePath; }65 66 55 /** Holds the machine folder value. */ 67 56 QString m_strMachineFolder; 68 57 /** Holds the machine base-name value. */ 69 58 QString m_strMachineBaseName; 70 /** Holds the machine file-path value. */71 QString m_strMachineFilePath;72 59 73 60 /* Widgets: */ … … 86 73 Q_PROPERTY(QString machineFolder READ machineFolder WRITE setMachineFolder); 87 74 Q_PROPERTY(QString machineBaseName READ machineBaseName WRITE setMachineBaseName); 88 Q_PROPERTY(QString machineFilePath READ machineFilePath WRITE setMachineFilePath);89 75 90 76 public: … … 103 89 void sltNameChanged(const QString &strNewText); 104 90 void sltOsTypeChanged(); 105 106 /** Adjusts tool-tip according to @a strNewName. */107 void sltAdjustToolTip(const QString &strNewName);108 91 109 92 private: -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
r62493 r64965 57 57 QHBoxLayout *pNameAndSystemCntLayout = new QHBoxLayout(m_pNameAndSystemCnt); 58 58 { 59 m_pNameAndSystemEditor = new UINameAndSystemEditor(m_pNameAndSystemCnt , true);59 m_pNameAndSystemEditor = new UINameAndSystemEditor(m_pNameAndSystemCnt); 60 60 pNameAndSystemCntLayout->addWidget(m_pNameAndSystemEditor); 61 61 } … … 139 139 /* Setup connections: */ 140 140 connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &))); 141 connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltAdjustToolTip(const QString &)));142 141 connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(sltOsTypeChanged())); 143 142 connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged())); … … 156 155 registerField("machineFolder", this, "machineFolder"); 157 156 registerField("machineBaseName", this, "machineBaseName"); 158 registerField("machineFilePath", this, "machineFilePath");159 157 registerField("ram", m_pRamSlider, "value", SIGNAL(valueChanged(int))); 160 158 registerField("virtualDisk", this, "virtualDisk"); 161 159 registerField("virtualDiskId", this, "virtualDiskId"); 162 160 registerField("virtualDiskLocation", this, "virtualDiskLocation"); 163 164 /* Initialize tool-tip: */165 adjustToolTip();166 161 } 167 162 … … 178 173 /* Broadcast complete-change: */ 179 174 emit completeChanged(); 180 }181 182 void UIWizardNewVMPageExpert::sltAdjustToolTip(const QString &strNewName)183 {184 /* Call to base-class: */185 adjustToolTip(strNewName);186 175 } 187 176 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h
r62493 r64965 36 36 Q_PROPERTY(QString machineFolder READ machineFolder WRITE setMachineFolder); 37 37 Q_PROPERTY(QString machineBaseName READ machineBaseName WRITE setMachineBaseName); 38 Q_PROPERTY(QString machineFilePath READ machineFilePath WRITE setMachineFilePath);39 38 Q_PROPERTY(CMedium virtualDisk READ virtualDisk WRITE setVirtualDisk); 40 39 Q_PROPERTY(QString virtualDiskId READ virtualDiskId WRITE setVirtualDiskId); … … 65 64 void sltGetWithFileOpenDialog(); 66 65 67 /** Adjusts tool-tip according to @a strNewName. */68 void sltAdjustToolTip(const QString &strNewName);69 70 66 private: 71 67
Note:
See TracChangeset
for help on using the changeset viewer.