Changeset 72177 in vbox
- Timestamp:
- May 9, 2018 3:57:09 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 122600
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp
r72174 r72177 554 554 { 555 555 /* Configure widget: */ 556 m_pNameAndSystemEditor-> nameEditor()->setValidator(new QRegExpValidator(QRegExp(".+"), this));556 m_pNameAndSystemEditor->setNameFieldValidator(".+"); 557 557 } 558 558 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.cpp
r72174 r72177 31 31 # include "UIFilePathSelector.h" 32 32 # include "UINameAndSystemEditor.h" 33 # include "UIVMNamePathSelector.h" 33 34 34 35 /* COM includes: */ … … 50 51 , m_fSupportsHWVirtEx(false) 51 52 , m_fSupportsLongMode(false) 52 , m_pLabelName(0)53 53 , m_pLabelFamily(0) 54 54 , m_pLabelType(0) 55 55 , m_pIconType(0) 56 , m_p EditorName(0)57 , m_p EditorLocation(0)56 , m_pNamePathLabel(0) 57 , m_pNamePathSelector(0) 58 58 , m_pComboFamily(0) 59 59 , m_pComboType(0) … … 65 65 QString UINameAndSystemEditor::name() const 66 66 { 67 if (!m_fChooseLocation) 68 return m_pEditorName->text(); 69 else 70 return m_pEditorLocation->path(); 67 if (!m_pNamePathSelector) 68 return QString(); 69 return m_pNamePathSelector->name(); 70 } 71 72 QString UINameAndSystemEditor::path() const 73 { 74 if (!m_pNamePathSelector) 75 return vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 76 return m_pNamePathSelector->path(); 71 77 } 72 78 73 79 void UINameAndSystemEditor::setName(const QString &strName) 74 80 { 75 if (!m_fChooseLocation) 76 m_pEditorName->setText(strName); 77 else 78 m_pEditorLocation->setPath(strName); 81 if (!m_pNamePathSelector) 82 return; 83 m_pNamePathSelector->setName(strName); 79 84 } 80 85 … … 112 117 void UINameAndSystemEditor::retranslateUi() 113 118 { 114 m_pLabelName->setText(tr("N&ame:"));115 119 m_pLabelFamily->setText(tr("&Type:")); 116 120 m_pLabelType->setText(tr("&Version:")); 117 if (!m_fChooseLocation) 118 m_pEditorName->setWhatsThis(tr("Holds the name of the virtual machine.")); 119 else 120 m_pEditorLocation->setWhatsThis(tr("Holds the location of the virtual machine.")); 121 m_pNamePathLabel->setText(tr("Path/Name:")); 122 121 123 m_pComboFamily->setWhatsThis(tr("Selects the operating system family that " 122 124 "you plan to install into this virtual machine.")); … … 227 229 pMainLayout->setContentsMargins(0, 0, 0, 0); 228 230 229 /* Create VM name label: */ 230 m_pLabelName = new QLabel; 231 if (m_pLabelName) 232 { 233 /* Configure VM name label: */ 234 m_pLabelName->setAlignment(Qt::AlignRight); 235 m_pLabelName->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 236 /* Add VM name label into main-layout: */ 237 pMainLayout->addWidget(m_pLabelName, 0, 0); 238 } 239 240 if (!m_fChooseLocation) 241 { 242 /* Create VM name editor: */ 243 m_pEditorName = new QLineEdit; 244 if (m_pEditorName) 245 { 246 /* Configure VM name editor: */ 247 m_pEditorName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 248 m_pLabelName->setBuddy(m_pEditorName); 249 /* Add VM name editor into main-layout: */ 250 pMainLayout->addWidget(m_pEditorName, 0, 1, 1, 2); 251 } 252 } 253 else 254 { 255 /* Create VM location editor: */ 256 m_pEditorLocation = new UIFilePathSelector; 257 if (m_pEditorLocation) 258 { 259 /* Configure advanced VM name editor: */ 260 m_pEditorLocation->setResetEnabled(false); 261 m_pEditorLocation->setMode(UIFilePathSelector::Mode_File_Save); 262 m_pEditorLocation->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 263 m_pEditorLocation->setHomeDir(vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder()); 264 m_pLabelName->setBuddy(m_pEditorLocation); 265 /* Add advanced VM name editor into main-layout: */ 266 pMainLayout->addWidget(m_pEditorLocation, 0, 1, 1, 2); 267 } 231 m_pNamePathLabel = new QLabel; 232 if (m_pNamePathLabel) 233 { 234 m_pNamePathLabel->setAlignment(Qt::AlignRight); 235 m_pNamePathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 236 pMainLayout->addWidget(m_pNamePathLabel, 0, 0, 1, 1); 237 } 238 m_pNamePathSelector = new UIVMNamePathSelector; 239 if (m_pNamePathSelector) 240 { 241 m_pNamePathSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); 242 pMainLayout->addWidget(m_pNamePathSelector, 0, 1, 1, 2); 268 243 } 269 244 … … 325 300 pLayoutIcon->addWidget(m_pIconType); 326 301 } 327 328 302 /* Add stretch to sub-layout: */ 329 303 pLayoutIcon->addStretch(); … … 358 332 { 359 333 /* Prepare connections: */ 360 if (!m_fChooseLocation) 361 connect(m_pEditorName, &QLineEdit::textChanged, 362 this, &UINameAndSystemEditor::sigNameChanged); 363 else 364 connect(m_pEditorLocation, &UIFilePathSelector::pathChanged, 365 this, &UINameAndSystemEditor::sigNameChanged); 334 connect(m_pNamePathSelector, &UIVMNamePathSelector::sigNameChanged, 335 this, &UINameAndSystemEditor::sigNameChanged); 366 336 connect(m_pComboFamily, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 367 337 this, &UINameAndSystemEditor::sltFamilyChanged); … … 369 339 this, &UINameAndSystemEditor::sltTypeChanged); 370 340 } 341 342 void UINameAndSystemEditor::setNameFieldValidator(const QString &strValidatorString) 343 { 344 if (!m_pNamePathSelector) 345 return; 346 m_pNamePathSelector->setNameFieldValidator(strValidatorString); 347 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINameAndSystemEditor.h
r72174 r72177 36 36 class QString; 37 37 class UIFilePathSelector; 38 class UIVMNamePathSelector; 38 39 39 40 /** QWidget subclass providing complex editor for basic VM parameters. */ … … 58 59 UINameAndSystemEditor(QWidget *pParent, bool fChooseLocation = false); 59 60 60 /** Returns the VM name editor. */61 QLineEdit *nameEditor() const { return m_pEditorName; }62 /** Returns the VM location editor. */63 UIFilePathSelector *locationEditor() const { return m_pEditorLocation; }64 65 61 /** Returns the VM name. */ 66 62 QString name() const; 63 /** Returns path string selected by the user. */ 64 QString path() const; 65 67 66 /** Defines the VM @a strName. */ 68 67 void setName(const QString &strName); … … 72 71 /** Defines the VM OS @a enmType. */ 73 72 void setType(const CGuestOSType &enmType); 73 74 void setNameFieldValidator(const QString &strValidatorString); 74 75 75 76 protected: … … 113 114 bool m_fSupportsLongMode; 114 115 115 /** Holds the VM name label instance. */116 QLabel *m_pLabelName;117 116 /** Holds the VM OS family label instance. */ 118 117 QLabel *m_pLabelFamily; … … 121 120 /** Holds the VM OS type icon instance. */ 122 121 QLabel *m_pIconType; 123 /** Holds the VM name editor instance. */ 124 QLineEdit *m_pEditorName; 125 /** Holds the VM location editor instance. */ 126 UIFilePathSelector *m_pEditorLocation; 122 123 QLabel *m_pNamePathLabel; 124 UIVMNamePathSelector *m_pNamePathSelector; 127 125 /** Holds the VM OS family combo instance. */ 128 126 QComboBox *m_pComboFamily; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVMNamePathSelector.cpp
r72174 r72177 23 23 # include <QDir> 24 24 # include <QHBoxLayout> 25 # include <QRegExpValidator> 25 26 26 27 /* GUI includes: */ 28 # include "QIFileDialog.h" 27 29 # include "QILineEdit.h" 28 30 # include "QILabel.h" 31 # include "QIToolButton.h" 32 # include "UIIconPool.h" 29 33 # include "UIVMNamePathSelector.h" 30 34 # include "VBoxGlobal.h" … … 35 39 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 36 40 37 38 39 41 UIVMNamePathSelector::UIVMNamePathSelector(QWidget *pParent /* = 0 */) 40 42 : QIWithRetranslateUI<QWidget>(pParent) … … 43 45 , m_pName(0) 44 46 , m_pSeparator(0) 47 ,m_pFileDialogButton(0) 45 48 { 46 49 prepareWidgets(); 50 retranslateUi(); 47 51 } 48 52 … … 52 56 CVirtualBox vbox = vboxGlobal().virtualBox(); 53 57 /* Get default machine folder: */ 54 /*const QString strDefaultMachineFolder = */return vbox.GetSystemProperties().GetDefaultMachineFolder();58 return vbox.GetSystemProperties().GetDefaultMachineFolder(); 55 59 56 60 } … … 65 69 m_pMainLayout->setSpacing(0); 66 70 setLayout(m_pMainLayout); 71 72 m_pFileDialogButton = new QIToolButton(this); 73 if (m_pFileDialogButton) 74 { 75 m_pMainLayout->addWidget(m_pFileDialogButton); 76 m_pFileDialogButton->setIcon(UIIconPool::iconSet(QString(":/sf_add_16px.png"))); 77 connect(m_pFileDialogButton, &QIToolButton::clicked, this, &UIVMNamePathSelector::sltOpenPathSelector); 78 } 67 79 68 80 m_pPath = new QILineEdit; … … 84 96 { 85 97 m_pMainLayout->addWidget(m_pName); 98 connect(m_pName, &QILineEdit::textChanged, 99 this, &UIVMNamePathSelector::sigNameChanged); 100 86 101 } 87 102 … … 121 136 void UIVMNamePathSelector::retranslateUi() 122 137 { 138 setToolTip(tr("The Virtual Machine files will be saved under ...")); 123 139 } 140 141 void UIVMNamePathSelector::sltOpenPathSelector() 142 { 143 144 QString strSelectedPath = QIFileDialog::getExistingDirectory(m_pPath->text(), this, 145 QString("Select a parent folder for new Virtual Machine")); 146 if (!strSelectedPath.isEmpty()) 147 { 148 m_pPath->setText(strSelectedPath); 149 } 150 } 151 152 void UIVMNamePathSelector::setNameFieldValidator(const QString &strValidatorString) 153 { 154 if (!m_pName) 155 return; 156 m_pName->setValidator(new QRegExpValidator(QRegExp(strValidatorString), this)); 157 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIVMNamePathSelector.h
r72174 r72177 29 29 class QILabel; 30 30 class QILineEdit; 31 31 class QIToolButton; 32 32 33 33 class SHARED_LIBRARY_STUFF UIVMNamePathSelector : public QIWithRetranslateUI<QWidget> … … 36 36 37 37 signals: 38 39 void sigNameChanged(const QString &strName); 38 40 39 41 public: … … 48 50 QString name() const; 49 51 void setName(const QString &name); 52 void setNameFieldValidator(const QString &strValidatorString); 50 53 51 54 protected: … … 55 58 private slots: 56 59 60 void sltOpenPathSelector(); 57 61 58 62 private: … … 61 65 QString defaultMachineFolder() const; 62 66 63 QHBoxLayout *m_pMainLayout; 64 QILineEdit *m_pPath; 65 QILineEdit *m_pName; 66 QILabel *m_pSeparator; 67 QHBoxLayout *m_pMainLayout; 68 QILineEdit *m_pPath; 69 QILineEdit *m_pName; 70 QILabel *m_pSeparator; 71 QIToolButton *m_pFileDialogButton; 72 67 73 }; 68 74 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r71027 r72177 106 106 if (!m_strGroup.isEmpty()) 107 107 groups << m_strGroup; 108 m_machine = vbox.CreateMachine( QString() /* no file-path for now */,108 m_machine = vbox.CreateMachine(field("machineFilePath").toString(), 109 109 field("name").toString(), 110 110 groups, strTypeId, QString()); … … 397 397 return strControllerName; 398 398 } 399 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp
r72174 r72177 217 217 bool UIWizardNewVMPage1::createMachineFolder() 218 218 { 219 if (!m_pNameAndSystemEditor) 220 return false; 219 221 /* Cleanup previosly created folder if any: */ 220 222 if (machineFolderCreated() && !cleanupMachineFolder()) … … 227 229 CVirtualBox vbox = vboxGlobal().virtualBox(); 228 230 /* Get default machine folder: */ 229 const QString strDefaultMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder(); 231 //const QString strMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder(); 232 230 233 /* Compose machine filename: */ 231 const QStringstrMachineFilePath = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(),232 233 234 strDefaultMachineFolder);234 m_strMachineFilePath = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(), 235 m_strGroup, 236 QString(), 237 m_pNameAndSystemEditor->path()); 235 238 /* Compose machine folder/basename: */ 236 const QFileInfo fileInfo( strMachineFilePath);237 const QStringstrMachineFolder = fileInfo.absolutePath();238 const QStringstrMachineBaseName = fileInfo.completeBaseName();239 const QFileInfo fileInfo(m_strMachineFilePath); 240 m_strMachineFolder = fileInfo.absolutePath(); 241 m_strMachineBaseName = fileInfo.completeBaseName(); 239 242 240 243 /* Make sure that folder doesn't exists: */ 241 if (QDir( strMachineFolder).exists())244 if (QDir(m_strMachineFolder).exists()) 242 245 { 243 msgCenter().cannotRewriteMachineFolder( strMachineFolder, thisImp());246 msgCenter().cannotRewriteMachineFolder(m_strMachineFolder, thisImp()); 244 247 return false; 245 248 } 246 249 247 250 /* Try to create new folder (and it's predecessors): */ 248 bool fMachineFolderCreated = QDir().mkpath( strMachineFolder);251 bool fMachineFolderCreated = QDir().mkpath(m_strMachineFolder); 249 252 if (!fMachineFolderCreated) 250 253 { 251 msgCenter().cannotCreateMachineFolder( strMachineFolder, thisImp());254 msgCenter().cannotCreateMachineFolder(m_strMachineFolder, thisImp()); 252 255 return false; 253 256 } 254 255 /* Initialize fields: */256 m_strMachineFolder = strMachineFolder;257 m_strMachineBaseName = strMachineBaseName;258 257 return true; 259 258 } … … 293 292 registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &))); 294 293 registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged())); 294 registerField("machineFilePath", this, "machineFilePath"); 295 295 registerField("machineFolder", this, "machineFolder"); 296 296 registerField("machineBaseName", this, "machineBaseName"); … … 315 315 316 316 /* Translate widgets: */ 317 m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name for the new virtual machine "317 m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new virtual machine " 318 318 "and select the type of operating system you intend to install on it. " 319 319 "The name you choose will be used throughout VirtualBox " … … 340 340 return createMachineFolder(); 341 341 } 342 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h
r72174 r72177 43 43 bool cleanupMachineFolder(); 44 44 45 QString machineFilePath() const { return m_strMachineFilePath; } 46 void setMachineFilePath(const QString &strMachineFilePath) { m_strMachineFilePath = strMachineFilePath; } 47 45 48 /** Returns the machine folder value. */ 46 49 QString machineFolder() const { return m_strMachineFolder; } … … 53 56 void setMachineBaseName(const QString &strMachineBaseName) { m_strMachineBaseName = strMachineBaseName; } 54 57 55 /** Holds the machine folder value. */ 58 /** Full path (including the file name) of the machine's configuration file. */ 59 QString m_strMachineFilePath; 60 /** Path of the folder hosting the machine's configuration file. Generated from m_strMachineFilePath. */ 56 61 QString m_strMachineFolder; 57 /** Holds the machine base-name value. */62 /** Base name of the machine is generated from the m_strMachineFilePath. */ 58 63 QString m_strMachineBaseName; 59 64 60 /* Widgets:*/65 /** Provides a path selector and a line edit field for path and name entry. */ 61 66 UINameAndSystemEditor *m_pNameAndSystemEditor; 62 67 63 /* Variables: */68 /** Variables: */ 64 69 QString m_strGroup; 65 70 bool m_fSupportsHWVirtEx; … … 71 76 { 72 77 Q_OBJECT; 78 Q_PROPERTY(QString machineFilePath READ machineFilePath WRITE setMachineFilePath); 73 79 Q_PROPERTY(QString machineFolder READ machineFolder WRITE setMachineFolder); 74 80 Q_PROPERTY(QString machineBaseName READ machineBaseName WRITE setMachineBaseName); … … 107 113 108 114 #endif // __UIWizardNewVMPageBasic1_h__ 109 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp
r71948 r72177 160 160 registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &))); 161 161 registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged())); 162 registerField("machineFilePath", this, "machineFilePath"); 162 163 registerField("machineFolder", this, "machineFolder"); 163 164 registerField("machineBaseName", this, "machineBaseName"); … … 304 305 return fResult; 305 306 } 306 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h
r71027 r72177 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); 38 39 Q_PROPERTY(CMedium virtualDisk READ virtualDisk WRITE setVirtualDisk); 39 40 Q_PROPERTY(QString virtualDiskId READ virtualDiskId WRITE setVirtualDiskId); … … 84 85 85 86 #endif // __UIWizardNewVMPageExpert_h__ 86
Note:
See TracChangeset
for help on using the changeset viewer.