VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMExpertPage.cpp@ 104158

Last change on this file since 104158 was 103957, checked in by vboxsync, 10 months ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in wizard page class hierarchy.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 41.5 KB
Line 
1/* $Id: UIWizardNewVMExpertPage.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIWizardNewVMExpertPage class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QButtonGroup>
30#include <QCheckBox>
31#include <QRadioButton>
32#include <QVBoxLayout>
33
34/* GUI includes: */
35#include "QIToolButton.h"
36#include "UICommon.h"
37#include "UIIconPool.h"
38#include "UIGlobalSession.h"
39#include "UIMediaComboBox.h"
40#include "UIMedium.h"
41#include "UINameAndSystemEditor.h"
42#include "UINotificationCenter.h"
43#include "UIToolBox.h"
44#include "UIWizardNewVM.h"
45#include "UIWizardDiskEditors.h"
46#include "UIWizardNewVMDiskPage.h"
47#include "UIWizardNewVMEditors.h"
48#include "UIWizardNewVMExpertPage.h"
49#include "UIWizardNewVMNameOSTypePage.h"
50
51/* COM includes: */
52#include "CSystemProperties.h"
53
54UIWizardNewVMExpertPage::UIWizardNewVMExpertPage(UIActionPool *pActionPool)
55 : m_pToolBox(0)
56 , m_pDiskFormatVariantGroupBox(0)
57 , m_pDiskVariantWidget(0)
58 , m_pFormatComboBox(0)
59 , m_pSizeAndLocationGroup(0)
60 , m_pNameAndSystemEditor(0)
61 , m_pSkipUnattendedCheckBox(0)
62 , m_pNameAndSystemLayout(0)
63 , m_pHardwareWidgetContainer(0)
64 , m_pAdditionalOptionsContainer(0)
65 , m_pGAInstallationISOContainer(0)
66 , m_pDiskSourceButtonGroup(0)
67 , m_pDiskEmpty(0)
68 , m_pDiskNew(0)
69 , m_pDiskExisting(0)
70 , m_pDiskSelector(0)
71 , m_pDiskSelectionButton(0)
72 , m_fRecommendedNoDisk(false)
73 , m_uMediumSizeMin(_4M)
74 , m_uMediumSizeMax(gpGlobalSession->virtualBox().GetSystemProperties().GetInfoVDSize())
75 , m_pActionPool(pActionPool)
76{
77 /* Create widgets: */
78 QVBoxLayout *pMainLayout = new QVBoxLayout(this);
79 {
80 m_pToolBox = new UIToolBox;
81 m_pToolBox->insertPage(ExpertToolboxItems_NameAndOSType, createNameOSTypeWidgets(), "");
82 m_pToolBox->insertPage(ExpertToolboxItems_Unattended, createUnattendedWidgets(), "");
83 m_pHardwareWidgetContainer = new UINewVMHardwareContainer;
84 m_pToolBox->insertPage(ExpertToolboxItems_Hardware, m_pHardwareWidgetContainer, "");
85 m_pToolBox->insertPage(ExpertToolboxItems_Disk, createDiskWidgets(), "");
86 m_pToolBox->setCurrentPage(ExpertToolboxItems_NameAndOSType);
87 pMainLayout->addWidget(m_pToolBox);
88 pMainLayout->addStretch();
89 }
90
91 createConnections();
92
93 /* Register classes: */
94 qRegisterMetaType<CMedium>();
95}
96
97void UIWizardNewVMExpertPage::setISOFilePath(const QString &strISOFilePath)
98{
99 QFileInfo isoFileInfo(strISOFilePath);
100 if (isoFileInfo.exists() && m_pNameAndSystemEditor)
101 m_pNameAndSystemEditor->setISOImagePath(strISOFilePath);
102}
103
104void UIWizardNewVMExpertPage::sltNameChanged(const QString &strNewName)
105{
106 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
107 /* Allow type guessing from name only if an OS type from ISO could not be detected: */
108 if (!m_userModifiedParameters.contains("GuestOSTypeFromISO") && m_pNameAndSystemEditor)
109 {
110 m_pNameAndSystemEditor->blockSignals(true);
111 if (UIWizardNewVMNameOSTypeCommon::guessOSTypeFromName(m_pNameAndSystemEditor, strNewName))
112 {
113 wizardWindow<UIWizardNewVM>()->setGuestOSTypeId(m_pNameAndSystemEditor->typeId());
114 /* Since the type `possibly` changed: */
115 setOSTypeDependedValues();
116 m_userModifiedParameters << "GuestOSTypeFromName";
117 }
118 m_pNameAndSystemEditor->blockSignals(false);
119 }
120 UIWizardNewVMNameOSTypeCommon::composeMachineFilePath(m_pNameAndSystemEditor, wizardWindow<UIWizardNewVM>());
121 if (!m_userModifiedParameters.contains("MediumPath"))
122 updateVirtualMediumPathFromMachinePathName();
123 if (!m_userModifiedParameters.contains("HostnameDomainName"))
124 updateHostnameDomainNameFromMachineName();
125 emit completeChanged();
126}
127
128void UIWizardNewVMExpertPage::sltPathChanged(const QString &strNewPath)
129{
130 Q_UNUSED(strNewPath);
131 UIWizardNewVMNameOSTypeCommon::composeMachineFilePath(m_pNameAndSystemEditor, wizardWindow<UIWizardNewVM>());
132 if (!m_userModifiedParameters.contains("MediumPath"))
133 updateVirtualMediumPathFromMachinePathName();
134}
135
136void UIWizardNewVMExpertPage::sltOsTypeChanged()
137{
138 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
139 /* Don't add GuestOSType to the set since we want to adjust os type when installation ISO changes. No matter if user
140 * has already set the os type explicitly or not: */
141 //m_userModifiedParameters << "GuestOSType";
142 if (m_pNameAndSystemEditor)
143 wizardWindow<UIWizardNewVM>()->setGuestOSTypeId(m_pNameAndSystemEditor->typeId());
144 setOSTypeDependedValues();
145}
146
147void UIWizardNewVMExpertPage::sltGetWithFileOpenDialog()
148{
149 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
150 AssertReturnVoid(pWizard);
151 QUuid uMediumId = UIWizardNewVMDiskCommon::getWithFileOpenDialog(pWizard->guestOSTypeId(),
152 pWizard->machineFolder(),
153 this, m_pActionPool);
154 if (!uMediumId.isNull())
155 {
156 m_pDiskSelector->setCurrentItem(uMediumId);
157 m_pDiskSelector->setFocus();
158 }
159}
160
161void UIWizardNewVMExpertPage::sltISOPathChanged(const QString &strISOPath)
162{
163 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
164 AssertReturnVoid(pWizard);
165
166 pWizard->setISOFilePath(strISOPath);
167
168 bool const fOsTypeFixed = UIWizardNewVMNameOSTypeCommon::guessOSTypeDetectedOSTypeString(m_pNameAndSystemEditor,
169 pWizard->detectedOSTypeId());
170 if (fOsTypeFixed)
171 m_userModifiedParameters << "GuestOSTypeFromISO";
172 else /* Remove GuestOSTypeFromISO from the set if it is there: */
173 m_userModifiedParameters.remove("GuestOSTypeFromISO");
174
175 /* Update the global recent ISO path: */
176 QFileInfo fileInfo(strISOPath);
177 if (fileInfo.exists() && fileInfo.isReadable())
178 uiCommon().updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType_DVD, strISOPath);
179
180 /* Populate the editions selector: */
181 if (m_pNameAndSystemEditor)
182 m_pNameAndSystemEditor->setEditionNameAndIndices(pWizard->detectedWindowsImageNames(),
183 pWizard->detectedWindowsImageIndices());
184 setSkipCheckBoxEnable();
185 disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
186
187 /* Redetect the OS type using the name if detection or the step above failed: */
188 if (!fOsTypeFixed && m_pNameAndSystemEditor)
189 sltNameChanged(m_pNameAndSystemEditor->name());
190
191 emit completeChanged();
192}
193
194void UIWizardNewVMExpertPage::sltGAISOPathChanged(const QString &strPath)
195{
196 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
197 m_userModifiedParameters << "GuestAdditionsISOPath";
198 wizardWindow<UIWizardNewVM>()->setGuestAdditionsISOPath(strPath);
199 emit completeChanged();
200}
201
202void UIWizardNewVMExpertPage::sltInstallGACheckBoxToggle(bool fEnabled)
203{
204 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
205 wizardWindow<UIWizardNewVM>()->setInstallGuestAdditions(fEnabled);
206 m_userModifiedParameters << "InstallGuestAdditions";
207 emit completeChanged();
208}
209
210void UIWizardNewVMExpertPage::sltOSFamilyTypeChanged(const QString &strGuestOSFamilyType)
211{
212 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
213 if (m_pAdditionalOptionsContainer)
214 m_pAdditionalOptionsContainer->disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
215 m_userModifiedParameters << "GuestOSFamilyId";
216 wizardWindow<UIWizardNewVM>()->setGuestOSFamilyId(strGuestOSFamilyType);
217}
218
219void UIWizardNewVMExpertPage::sltRetranslateUI()
220{
221 if (m_pSkipUnattendedCheckBox)
222 {
223 m_pSkipUnattendedCheckBox->setText(UIWizardNewVM::tr("&Skip Unattended Installation"));
224 m_pSkipUnattendedCheckBox->setToolTip(UIWizardNewVM::tr("When checked, the unattended install is disabled and the selected ISO "
225 "is mounted on the vm."));
226 }
227
228 if (m_pToolBox)
229 {
230 m_pToolBox->setPageTitle(ExpertToolboxItems_NameAndOSType, QString(UIWizardNewVM::tr("Name and &Operating System")));
231 m_pToolBox->setPageTitle(ExpertToolboxItems_Unattended, UIWizardNewVM::tr("&Unattended Install"));
232 m_pToolBox->setPageTitle(ExpertToolboxItems_Disk, UIWizardNewVM::tr("Hard Dis&k"));
233 m_pToolBox->setPageTitle(ExpertToolboxItems_Hardware, UIWizardNewVM::tr("H&ardware"));
234 }
235
236 if (m_pDiskEmpty)
237 m_pDiskEmpty->setText(UIWizardNewVM::tr("&Do Not Add a Virtual Hard Disk"));
238 if (m_pDiskNew)
239 m_pDiskNew->setText(UIWizardNewVM::tr("&Create a Virtual Hard Disk Now"));
240 if (m_pDiskExisting)
241 m_pDiskExisting->setText(UIWizardNewVM::tr("U&se an Existing Virtual Hard Disk File"));
242 if (m_pDiskSelectionButton)
243 m_pDiskSelectionButton->setToolTip(UIWizardNewVM::tr("Chooses a Virtual Hard Fisk File..."));
244
245 if (m_pNameAndSystemLayout && m_pNameAndSystemEditor)
246 m_pNameAndSystemLayout->setColumnMinimumWidth(0, m_pNameAndSystemEditor->firstColumnWidth());
247
248 if (m_pDiskFormatVariantGroupBox)
249 m_pDiskFormatVariantGroupBox->setTitle(UIWizardNewVM::tr("Hard Disk File &Type and Variant"));
250}
251
252void UIWizardNewVMExpertPage::createConnections()
253{
254 /* Connections for Name, OS Type, and unattended install stuff: */
255 if (m_pNameAndSystemEditor)
256 {
257 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged,
258 this, &UIWizardNewVMExpertPage::sltNameChanged);
259 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged,
260 this, &UIWizardNewVMExpertPage::sltPathChanged);
261 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
262 this, &UIWizardNewVMExpertPage::sltOsTypeChanged);
263 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOSFamilyChanged,
264 this, &UIWizardNewVMExpertPage::sltOSFamilyTypeChanged);
265 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged,
266 this, &UIWizardNewVMExpertPage::sltISOPathChanged);
267 connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigEditionChanged,
268 this, &UIWizardNewVMExpertPage::sltSelectedEditionChanged);
269 }
270
271 if (m_pHardwareWidgetContainer)
272 {
273 connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigMemorySizeChanged,
274 this, &UIWizardNewVMExpertPage::sltMemorySizeChanged);
275 connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigCPUCountChanged,
276 this, &UIWizardNewVMExpertPage::sltCPUCountChanged);
277 connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigEFIEnabledChanged,
278 this, &UIWizardNewVMExpertPage::sltEFIEnabledChanged);
279 }
280 /* Connections for username, password, and hostname, etc: */
281 if (m_pGAInstallationISOContainer)
282 {
283 connect(m_pGAInstallationISOContainer, &UIGAInstallationGroupBox::sigPathChanged,
284 this, &UIWizardNewVMExpertPage::sltGAISOPathChanged);
285 connect(m_pGAInstallationISOContainer, &UIGAInstallationGroupBox::toggled,
286 this, &UIWizardNewVMExpertPage::sltInstallGACheckBoxToggle);
287 }
288
289 if (m_pUserNamePasswordGroupBox)
290 {
291 connect(m_pUserNamePasswordGroupBox, &UIUserNamePasswordGroupBox::sigPasswordChanged,
292 this, &UIWizardNewVMExpertPage::sltPasswordChanged);
293 connect(m_pUserNamePasswordGroupBox, &UIUserNamePasswordGroupBox::sigUserNameChanged,
294 this, &UIWizardNewVMExpertPage::sltUserNameChanged);
295 }
296
297 if (m_pAdditionalOptionsContainer)
298 {
299 connect(m_pAdditionalOptionsContainer, &UIAdditionalUnattendedOptions::sigHostnameDomainNameChanged,
300 this, &UIWizardNewVMExpertPage::sltHostnameDomainNameChanged);
301 connect(m_pAdditionalOptionsContainer, &UIAdditionalUnattendedOptions::sigProductKeyChanged,
302 this, &UIWizardNewVMExpertPage::sltProductKeyChanged);
303 connect(m_pAdditionalOptionsContainer, &UIAdditionalUnattendedOptions::sigStartHeadlessChanged,
304 this, &UIWizardNewVMExpertPage::sltStartHeadlessChanged);
305 }
306
307 /* Virtual disk related connections: */
308 if (m_pDiskSourceButtonGroup)
309 connect(m_pDiskSourceButtonGroup, &QButtonGroup::buttonClicked,
310 this, &UIWizardNewVMExpertPage::sltSelectedDiskSourceChanged);
311
312 if (m_pSkipUnattendedCheckBox)
313 connect(m_pSkipUnattendedCheckBox, &QCheckBox::toggled,
314 this, &UIWizardNewVMExpertPage::sltSkipUnattendedCheckBoxChecked);
315
316 if (m_pSizeAndLocationGroup)
317 {
318 connect(m_pSizeAndLocationGroup, &UIMediumSizeAndPathGroupBox::sigMediumSizeChanged,
319 this, &UIWizardNewVMExpertPage::sltMediumSizeChanged);
320 connect(m_pSizeAndLocationGroup, &UIMediumSizeAndPathGroupBox::sigMediumPathChanged,
321 this, &UIWizardNewVMExpertPage::sltMediumPathChanged);
322 connect(m_pSizeAndLocationGroup, &UIMediumSizeAndPathGroupBox::sigMediumLocationButtonClicked,
323 this, &UIWizardNewVMExpertPage::sltMediumLocationButtonClicked);
324 }
325
326 if (m_pDiskSelectionButton)
327 connect(m_pDiskSelectionButton, &QIToolButton::clicked,
328 this, &UIWizardNewVMExpertPage::sltGetWithFileOpenDialog);
329
330 if (m_pDiskSelector)
331 connect(m_pDiskSelector, &UIMediaComboBox::currentIndexChanged,
332 this, &UIWizardNewVMExpertPage::sltMediaComboBoxIndexChanged);
333
334 if (m_pFormatComboBox)
335 connect(m_pFormatComboBox, &UIDiskFormatsComboBox::sigMediumFormatChanged,
336 this, &UIWizardNewVMExpertPage::sltMediumFormatChanged);
337
338 if (m_pDiskVariantWidget)
339 connect(m_pDiskVariantWidget, &UIDiskVariantWidget::sigMediumVariantChanged,
340 this, &UIWizardNewVMExpertPage::sltMediumVariantChanged);
341}
342
343void UIWizardNewVMExpertPage::setOSTypeDependedValues()
344{
345 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
346 AssertReturnVoid(pWizard);
347
348 QString strTypeId = pWizard->guestOSTypeId();
349 /* Get recommended 'ram' field value: */
350 ULONG recommendedRam = gpGlobalSession->guestOSTypeManager().getRecommendedRAM(strTypeId);
351
352 if (m_pHardwareWidgetContainer)
353 {
354 m_pHardwareWidgetContainer->blockSignals(true);
355
356 /* Set memory size of the widget and the wizard: */
357 if (!m_userModifiedParameters.contains("MemorySize"))
358 {
359 m_pHardwareWidgetContainer->setMemorySize(recommendedRam);
360 pWizard->setMemorySize(recommendedRam);
361 }
362
363 /* Set Firmware Type of the widget and the wizard: */
364 KFirmwareType fwType = gpGlobalSession->guestOSTypeManager().getRecommendedFirmware(strTypeId);
365 if (!m_userModifiedParameters.contains("EFIEnabled"))
366 {
367 m_pHardwareWidgetContainer->setEFIEnabled(fwType != KFirmwareType_BIOS);
368 pWizard->setEFIEnabled(fwType != KFirmwareType_BIOS);
369 }
370
371 /* Initialize CPU count:*/
372 int iCPUCount = gpGlobalSession->guestOSTypeManager().getRecommendedCPUCount(strTypeId);
373 if (!m_userModifiedParameters.contains("CPUCount"))
374 {
375 m_pHardwareWidgetContainer->setCPUCount(iCPUCount);
376 pWizard->setCPUCount(iCPUCount);
377 }
378 m_pHardwareWidgetContainer->blockSignals(false);
379 }
380
381 LONG64 iRecommendedDiskSize = gpGlobalSession->guestOSTypeManager().getRecommendedHDD(strTypeId);
382 /* Prepare initial disk choice: */
383 if (!m_userModifiedParameters.contains("SelectedDiskSource"))
384 {
385 if (iRecommendedDiskSize != 0)
386 {
387 if (m_pDiskNew)
388 m_pDiskNew->setChecked(true);
389 pWizard->setDiskSource(SelectedDiskSource_New);
390 setEnableDiskSelectionWidgets(false);
391 setEnableNewDiskWidgets(true);
392 m_fRecommendedNoDisk = false;
393 }
394 else
395 {
396 if (m_pDiskEmpty)
397 m_pDiskEmpty->setChecked(true);
398 pWizard->setDiskSource(SelectedDiskSource_Empty);
399 setEnableDiskSelectionWidgets(false);
400 setEnableNewDiskWidgets(false);
401 m_fRecommendedNoDisk = true;
402 }
403 if (m_pDiskSelector)
404 m_pDiskSelector->setCurrentIndex(0);
405 }
406 /* Initialize the medium size widgets and the member parameter of the wizard: */
407 if (m_pSizeAndLocationGroup && !m_userModifiedParameters.contains("MediumSize"))
408 {
409 m_pSizeAndLocationGroup->setMediumSize(iRecommendedDiskSize);
410 pWizard->setMediumSize(iRecommendedDiskSize);
411 }
412}
413
414void UIWizardNewVMExpertPage::initializePage()
415{
416 /* We need not to check existence of parameter within m_userModifiedParameters since initializePage() runs
417 once the page loads before user has a chance to modify parameters explicitly: */
418 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
419 AssertReturnVoid(pWizard);
420 /* Initialize wizard properties: */
421 {
422 if (m_pNameAndSystemEditor)
423 {
424 /* Guest OS type: */
425 pWizard->setGuestOSFamilyId(m_pNameAndSystemEditor->familyId());
426 pWizard->setGuestOSTypeId(m_pNameAndSystemEditor->typeId());
427 /* Vm name, folder, file path etc. will be initilized by composeMachineFilePath: */
428 }
429
430 /* Medium related properties: */
431 if (m_pFormatComboBox)
432 pWizard->setMediumFormat(m_pFormatComboBox->mediumFormat());
433 updateVirtualMediumPathFromMachinePathName();
434 }
435
436 /* Initialize user/password if they are not modified by the user: */
437 if (m_pUserNamePasswordGroupBox)
438 {
439 m_pUserNamePasswordGroupBox->blockSignals(true);
440 m_pUserNamePasswordGroupBox->setUserName(pWizard->userName());
441 m_pUserNamePasswordGroupBox->setPassword(pWizard->password());
442 m_pUserNamePasswordGroupBox->blockSignals(false);
443 }
444 updateHostnameDomainNameFromMachineName();
445
446 if (m_pGAInstallationISOContainer)
447 {
448 m_pGAInstallationISOContainer->blockSignals(true);
449 m_pGAInstallationISOContainer->setChecked(pWizard->installGuestAdditions());
450 m_pGAInstallationISOContainer->blockSignals(false);
451 }
452
453 setOSTypeDependedValues();
454 setSkipCheckBoxEnable();
455 disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
456 updateDiskWidgetsAfterMediumFormatChange();
457 sltRetranslateUI();
458
459 /* Focus on the name field (rather than the help button): */
460 if (m_pNameAndSystemEditor)
461 m_pNameAndSystemEditor->setFocus();
462}
463
464void UIWizardNewVMExpertPage::markWidgets() const
465{
466 if (m_pNameAndSystemEditor)
467 {
468 m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty());
469 m_pNameAndSystemEditor->markImageEditor(!UIWizardNewVMNameOSTypeCommon::checkISOFile(m_pNameAndSystemEditor),
470 UIWizardNewVM::tr("Invalid file path or unreadable file"));
471 }
472 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
473 if (pWizard && pWizard->installGuestAdditions() && m_pGAInstallationISOContainer)
474 m_pGAInstallationISOContainer->mark();
475 if (isUnattendedEnabled())
476 m_pAdditionalOptionsContainer->mark();
477}
478
479QWidget *UIWizardNewVMExpertPage::createUnattendedWidgets()
480{
481 QWidget *pContainerWidget = new QWidget;
482 QGridLayout *pLayout = new QGridLayout(pContainerWidget);
483 pLayout->setContentsMargins(0, 0, 0, 0);
484 int iRow = 0;
485 m_pUserNamePasswordGroupBox = new UIUserNamePasswordGroupBox;
486 AssertReturn(m_pUserNamePasswordGroupBox, 0);
487 pLayout->addWidget(m_pUserNamePasswordGroupBox, iRow, 0, 1, 2);
488
489 m_pAdditionalOptionsContainer = new UIAdditionalUnattendedOptions;
490 AssertReturn(m_pAdditionalOptionsContainer, 0);
491 pLayout->addWidget(m_pAdditionalOptionsContainer, iRow, 2, 1, 2);
492
493 ++iRow;
494
495 /* Guest additions installation: */
496 m_pGAInstallationISOContainer = new UIGAInstallationGroupBox;
497 AssertReturn(m_pGAInstallationISOContainer, 0);
498 pLayout->addWidget(m_pGAInstallationISOContainer, iRow, 0, 1, 4);
499
500 return pContainerWidget;
501}
502
503QWidget *UIWizardNewVMExpertPage::createNewDiskWidgets()
504{
505 QWidget *pNewDiskContainerWidget = new QWidget;
506 QGridLayout *pDiskContainerLayout = new QGridLayout(pNewDiskContainerWidget);
507
508 m_pSizeAndLocationGroup = new UIMediumSizeAndPathGroupBox(true, 0 /* parent */, _4M /* minimum size */);
509 pDiskContainerLayout->addWidget(m_pSizeAndLocationGroup, 0, 0, 2, 2);
510
511 m_pDiskFormatVariantGroupBox = new QGroupBox;
512 QHBoxLayout *pDiskFormatVariantLayout = new QHBoxLayout(m_pDiskFormatVariantGroupBox);
513
514 m_pFormatComboBox = new UIDiskFormatsComboBox(true, KDeviceType_HardDisk, 0);
515 pDiskFormatVariantLayout->addWidget(m_pFormatComboBox, 0 /* stretch */, Qt::AlignTop);
516
517 m_pDiskVariantWidget = new UIDiskVariantWidget(0);
518 pDiskFormatVariantLayout->addWidget(m_pDiskVariantWidget);
519
520 pDiskContainerLayout->addWidget(m_pDiskFormatVariantGroupBox, 2, 0, 2, 2);
521 return pNewDiskContainerWidget;
522}
523
524QWidget *UIWizardNewVMExpertPage::createDiskWidgets()
525{
526 QWidget *pDiskContainer = new QWidget;
527 QGridLayout *pDiskLayout = new QGridLayout(pDiskContainer);
528 pDiskLayout->setContentsMargins(0, 0, 0, 0);
529 m_pDiskSourceButtonGroup = new QButtonGroup(this);
530 m_pDiskEmpty = new QRadioButton;
531 m_pDiskNew = new QRadioButton;
532 m_pDiskExisting = new QRadioButton;
533 m_pDiskSourceButtonGroup->addButton(m_pDiskEmpty);
534 m_pDiskSourceButtonGroup->addButton(m_pDiskNew);
535 m_pDiskSourceButtonGroup->addButton(m_pDiskExisting);
536 QStyleOptionButton options;
537 options.initFrom(m_pDiskExisting);
538 int iWidth = m_pDiskExisting->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &options, m_pDiskExisting);
539 pDiskLayout->setColumnMinimumWidth(0, iWidth);
540 m_pDiskSelector = new UIMediaComboBox;
541 {
542 m_pDiskSelector->setType(UIMediumDeviceType_HardDisk);
543 m_pDiskSelector->repopulate();
544 }
545 m_pDiskSelectionButton = new QIToolButton;
546 {
547 m_pDiskSelectionButton->setAutoRaise(true);
548 m_pDiskSelectionButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png"));
549 }
550 pDiskLayout->addWidget(m_pDiskNew, 0, 0, 1, 6);
551 pDiskLayout->addWidget(createNewDiskWidgets(), 1, 2, 3, 4);
552 pDiskLayout->addWidget(m_pDiskExisting, 4, 0, 1, 6);
553 pDiskLayout->addWidget(m_pDiskSelector, 5, 2, 1, 3);
554 pDiskLayout->addWidget(m_pDiskSelectionButton, 5, 5, 1, 1);
555 pDiskLayout->addWidget(m_pDiskEmpty, 6, 0, 1, 6);
556 return pDiskContainer;
557}
558
559bool UIWizardNewVMExpertPage::isComplete() const
560{
561 markWidgets();
562 bool fIsComplete = true;
563 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType, QIcon());
564 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended, QIcon());
565 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk, QIcon());
566 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Hardware, QIcon());
567
568 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
569 AssertReturn(pWizard, false);
570
571 /* Check unattended install related stuff: */
572 if (isUnattendedEnabled())
573 {
574 /* Check the installation medium: */
575 if (!UIWizardNewVMNameOSTypeCommon::checkISOFile(m_pNameAndSystemEditor))
576 {
577 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType,
578 UIIconPool::iconSet(":/status_error_16px.png"),
579 UIWizardNewVM::tr("Invalid path or unreadable ISO file"));
580 fIsComplete = false;
581 }
582 /* Check the GA installation medium: */
583 if (m_pGAInstallationISOContainer && !m_pGAInstallationISOContainer->isComplete())
584 {
585 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended,
586 UIIconPool::iconSet(":/status_error_16px.png"),
587 UIWizardNewVM::tr("Invalid path or unreadable ISO file"));
588
589 fIsComplete = false;
590 }
591 if (m_pUserNamePasswordGroupBox)
592 {
593 if (!m_pUserNamePasswordGroupBox->isComplete())
594 {
595 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended,
596 UIIconPool::iconSet(":/status_error_16px.png"),
597 UIWizardNewVM::tr("Invalid username and/or password"));
598 fIsComplete = false;
599 }
600 }
601 if (m_pAdditionalOptionsContainer)
602 {
603 if (!m_pAdditionalOptionsContainer->isComplete())
604 {
605 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended,
606 UIIconPool::iconSet(":/status_error_16px.png"),
607 UIWizardNewVM::tr("Invalid hostname or domain name"));
608 fIsComplete = false;
609 }
610 }
611 }
612
613 if (m_pNameAndSystemEditor)
614 {
615 if (m_pNameAndSystemEditor->name().isEmpty())
616 {
617 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType,
618 UIIconPool::iconSet(":/status_error_16px.png"),
619 UIWizardNewVM::tr("Virtual machine name is invalid"));
620 fIsComplete = false;
621 }
622 if (!UIWizardNewVMNameOSTypeCommon::checkISOFile(m_pNameAndSystemEditor))
623 {
624 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType,
625 UIIconPool::iconSet(":/status_error_16px.png"),
626 UIWizardNewVM::tr("Invalid ISO file"));
627 fIsComplete = false;
628 }
629 }
630
631 if (pWizard->diskSource() == SelectedDiskSource_Existing && uiCommon().medium(m_pDiskSelector->id()).isNull())
632 {
633 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk,
634 UIIconPool::iconSet(":/status_error_16px.png"), UIWizardNewVM::tr("No valid disk is selected"));
635 fIsComplete = false;
636 }
637
638 if (pWizard->diskSource() == SelectedDiskSource_New)
639 {
640 qulonglong uSize = pWizard->mediumSize();
641 if( uSize < m_uMediumSizeMin || uSize > m_uMediumSizeMax)
642 {
643 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk,
644 UIIconPool::iconSet(":/status_error_16px.png"), UIWizardNewVM::tr("Invalid disk size"));
645 fIsComplete = false;
646 }
647 }
648 return fIsComplete;
649}
650
651bool UIWizardNewVMExpertPage::validatePage()
652{
653 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
654 AssertReturn(pWizard, false);
655 bool fResult = UIWizardNewVMNameOSTypeCommon::createMachineFolder(m_pNameAndSystemEditor, wizardWindow<UIWizardNewVM>());
656 if (!fResult)
657 return false;
658
659 if (pWizard->diskSource() == SelectedDiskSource_New)
660 {
661 /* Check if the path we will be using for hard drive creation exists: */
662 const QString &strMediumPath = pWizard->mediumPath();
663 fResult = !QFileInfo(strMediumPath).exists();
664 if (!fResult)
665 {
666 UINotificationMessage::cannotOverwriteMediumStorage(strMediumPath, wizard()->notificationCenter());
667 return fResult;
668 }
669 qulonglong uSize = pWizard->mediumSize();
670 qulonglong uVariant = pWizard->mediumVariant();
671 /* Check FAT size limitation of the host hard drive: */
672 fResult = UIWizardDiskEditors::checkFATSizeLimitation(uVariant, strMediumPath, uSize);
673 if (!fResult)
674 {
675 UINotificationMessage::cannotCreateMediumStorageInFAT(strMediumPath, wizard()->notificationCenter());
676 return fResult;
677 }
678 /* Try to create the hard drive:*/
679 fResult = pWizard->createVirtualDisk();
680 /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
681 if (!fResult)
682 return fResult;
683 }
684
685 return pWizard->createVM();
686}
687
688bool UIWizardNewVMExpertPage::isProductKeyWidgetEnabled() const
689{
690 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
691 if (!pWizard || !isUnattendedEnabled() || !pWizard->isGuestOSTypeWindows())
692 return false;
693 return true;
694}
695
696void UIWizardNewVMExpertPage::disableEnableUnattendedRelatedWidgets(bool fEnabled)
697{
698 if (m_pUserNamePasswordGroupBox)
699 m_pUserNamePasswordGroupBox->setEnabled(fEnabled);
700 if (m_pAdditionalOptionsContainer)
701 m_pAdditionalOptionsContainer->setEnabled(fEnabled);
702 if (m_pGAInstallationISOContainer)
703 m_pGAInstallationISOContainer->setEnabled(fEnabled);
704 if (m_pNameAndSystemEditor)
705 m_pNameAndSystemEditor->setEditionSelectorEnabled(fEnabled && !m_pNameAndSystemEditor->isEditionsSelectorEmpty());
706 m_pAdditionalOptionsContainer->disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
707}
708
709void UIWizardNewVMExpertPage::sltSkipUnattendedCheckBoxChecked(bool fSkip)
710{
711 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
712 m_userModifiedParameters << "SkipUnattendedInstall";
713 wizardWindow<UIWizardNewVM>()->setSkipUnattendedInstall(fSkip);
714 disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
715 emit completeChanged();
716}
717
718void UIWizardNewVMExpertPage::sltMediumFormatChanged()
719{
720 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
721 if (!m_pFormatComboBox)
722 return;
723
724 m_userModifiedParameters << "MediumFormat";
725 wizardWindow<UIWizardNewVM>()->setMediumFormat(m_pFormatComboBox->mediumFormat());
726 updateDiskWidgetsAfterMediumFormatChange();
727 emit completeChanged();
728}
729
730void UIWizardNewVMExpertPage::sltMediumSizeChanged(qulonglong uSize)
731{
732 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
733 m_userModifiedParameters << "MediumSize";
734 wizardWindow<UIWizardNewVM>()->setMediumSize(uSize);
735 emit completeChanged();
736}
737
738void UIWizardNewVMExpertPage::sltMediumPathChanged(const QString &strPath)
739{
740 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
741 AssertReturnVoid(pWizard);
742 AssertReturnVoid(!strPath.isEmpty());
743 m_userModifiedParameters << "MediumPath";
744 QString strMediumPath =
745 UIWizardDiskEditors::appendExtension(strPath,
746 UIWizardDiskEditors::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk));
747 pWizard->setMediumPath(strMediumPath);
748 emit completeChanged();
749}
750
751void UIWizardNewVMExpertPage::sltMediumLocationButtonClicked()
752{
753 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
754 AssertReturnVoid(pWizard);
755 CMediumFormat comMediumFormat(pWizard->mediumFormat());
756
757 QString strMediumPath =
758 UIWizardDiskEditors::appendExtension(m_pSizeAndLocationGroup->mediumFilePath(),
759 UIWizardDiskEditors::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk));
760 QString strSelectedPath =
761 UIWizardDiskEditors::openFileDialogForDiskFile(strMediumPath, comMediumFormat, KDeviceType_HardDisk, pWizard);
762 if (strSelectedPath.isEmpty())
763 return;
764 strMediumPath =
765 UIWizardDiskEditors::appendExtension(strSelectedPath,
766 UIWizardDiskEditors::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk));
767 QFileInfo mediumPath(strMediumPath);
768 m_pSizeAndLocationGroup->setMediumFilePath(QDir::toNativeSeparators(mediumPath.absoluteFilePath()));
769}
770
771void UIWizardNewVMExpertPage::sltMediumVariantChanged(qulonglong uVariant)
772{
773 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
774 m_userModifiedParameters << "MediumVariant";
775 wizardWindow<UIWizardNewVM>()->setMediumVariant(uVariant);
776}
777
778void UIWizardNewVMExpertPage::sltMediaComboBoxIndexChanged()
779{
780 AssertReturnVoid(m_pDiskSelector);
781 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
782 AssertReturnVoid(pWizard);
783
784 /* Make sure to set m_virtualDisk: */
785 pWizard->setVirtualDisk(m_pDiskSelector->id());
786 pWizard->setMediumPath(m_pDiskSelector->location());
787 emit completeChanged();
788}
789
790void UIWizardNewVMExpertPage::sltSelectedDiskSourceChanged()
791{
792 AssertReturnVoid(m_pDiskSelector && m_pDiskSourceButtonGroup);
793 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
794 AssertReturnVoid(pWizard);
795 m_userModifiedParameters << "SelectedDiskSource";
796
797 if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskEmpty)
798 {
799 pWizard->setDiskSource(SelectedDiskSource_Empty);
800 pWizard->setVirtualDisk(QUuid());
801 pWizard->setMediumPath(QString());
802 }
803 else if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskExisting)
804 {
805 pWizard->setDiskSource(SelectedDiskSource_Existing);
806 pWizard->setVirtualDisk(m_pDiskSelector->id());
807 pWizard->setMediumPath(m_pDiskSelector->location());
808 }
809 else
810 {
811 pWizard->setDiskSource(SelectedDiskSource_New);
812 pWizard->setVirtualDisk(QUuid());
813 pWizard->setMediumPath(QString());
814 }
815
816 setEnableDiskSelectionWidgets(pWizard->diskSource() == SelectedDiskSource_Existing);
817 setEnableNewDiskWidgets(pWizard->diskSource() == SelectedDiskSource_New);
818
819 emit completeChanged();
820}
821
822void UIWizardNewVMExpertPage::sltMemorySizeChanged(int iValue)
823{
824 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
825 wizardWindow<UIWizardNewVM>()->setMemorySize(iValue);
826 m_userModifiedParameters << "MemorySize";
827}
828
829void UIWizardNewVMExpertPage::sltCPUCountChanged(int iCount)
830{
831 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
832 wizardWindow<UIWizardNewVM>()->setCPUCount(iCount);
833 m_userModifiedParameters << "CPUCount";
834}
835
836void UIWizardNewVMExpertPage::sltEFIEnabledChanged(bool fEnabled)
837{
838 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
839 wizardWindow<UIWizardNewVM>()->setEFIEnabled(fEnabled);
840 m_userModifiedParameters << "EFIEnabled";
841}
842
843void UIWizardNewVMExpertPage::sltPasswordChanged(const QString &strPassword)
844{
845 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
846 wizardWindow<UIWizardNewVM>()->setPassword(strPassword);
847 m_userModifiedParameters << "Password";
848 emit completeChanged();
849}
850
851void UIWizardNewVMExpertPage::sltUserNameChanged(const QString &strUserName)
852{
853 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
854 wizardWindow<UIWizardNewVM>()->setUserName(strUserName);
855 m_userModifiedParameters << "UserName";
856 emit completeChanged();
857}
858
859void UIWizardNewVMExpertPage::sltHostnameDomainNameChanged(const QString &strHostnameDomainName, bool fIsComplete)
860{
861 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
862 emit completeChanged();
863
864 if (fIsComplete)
865 {
866 wizardWindow<UIWizardNewVM>()->setHostnameDomainName(strHostnameDomainName);
867 m_userModifiedParameters << "HostnameDomainName";
868 }
869}
870
871void UIWizardNewVMExpertPage::sltProductKeyChanged(const QString &strProductKey)
872{
873 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
874 m_userModifiedParameters << "ProductKey";
875 wizardWindow<UIWizardNewVM>()->setProductKey(strProductKey);
876}
877
878void UIWizardNewVMExpertPage::sltStartHeadlessChanged(bool fStartHeadless)
879{
880 AssertReturnVoid(wizardWindow<UIWizardNewVM>());
881 m_userModifiedParameters << "StartHeadless";
882 wizardWindow<UIWizardNewVM>()->setStartHeadless(fStartHeadless);
883}
884
885void UIWizardNewVMExpertPage::sltSelectedEditionChanged(ulong uEditionIndex)
886{
887 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
888 AssertReturnVoid(pWizard);
889 pWizard->setSelectedWindowImageIndex(uEditionIndex);
890 /* Update the OS type since IUnattended updates the detected OS type after edition (image index) changes: */
891 UIWizardNewVMNameOSTypeCommon::guessOSTypeDetectedOSTypeString(m_pNameAndSystemEditor, pWizard->detectedOSTypeId());
892}
893
894void UIWizardNewVMExpertPage::updateVirtualMediumPathFromMachinePathName()
895{
896 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
897 AssertReturnVoid(pWizard);
898 QString strDiskFileName = pWizard->machineFileName().isEmpty() ? QString("NewVirtualDisk1") : pWizard->machineFileName();
899 QString strMediumPath = pWizard->machineFolder();
900 if (strMediumPath.isEmpty())
901 {
902 if (m_pNameAndSystemEditor)
903 strMediumPath = m_pNameAndSystemEditor->path();
904 else
905 strMediumPath = gpGlobalSession->virtualBox().GetSystemProperties().GetDefaultMachineFolder();
906 }
907 QString strExtension = UIWizardDiskEditors::defaultExtension(pWizard->mediumFormat(), KDeviceType_HardDisk);
908 if (m_pSizeAndLocationGroup)
909 {
910 QString strMediumFilePath =
911 UIWizardDiskEditors::constructMediumFilePath(UIWizardDiskEditors::appendExtension(strDiskFileName,
912 strExtension), strMediumPath);
913 m_pSizeAndLocationGroup->blockSignals(true);
914 m_pSizeAndLocationGroup->setMediumFilePath(strMediumFilePath);
915 m_pSizeAndLocationGroup->blockSignals(false);
916 pWizard->setMediumPath(m_pSizeAndLocationGroup->mediumFilePath());
917 }
918}
919
920void UIWizardNewVMExpertPage::updateDiskWidgetsAfterMediumFormatChange()
921{
922 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
923 AssertReturnVoid(pWizard && m_pDiskVariantWidget && m_pSizeAndLocationGroup && m_pFormatComboBox);
924 const CMediumFormat &comMediumFormat = pWizard->mediumFormat();
925 AssertReturnVoid(!comMediumFormat.isNull());
926
927 /* Block signals of the updated widgets to avoid calling corresponding slots since they add the parameters to m_userModifiedParameters: */
928 m_pDiskVariantWidget->blockSignals(true);
929 m_pDiskVariantWidget->updateMediumVariantWidgetsAfterFormatChange(comMediumFormat);
930 m_pDiskVariantWidget->blockSignals(false);
931
932 m_pSizeAndLocationGroup->blockSignals(true);
933 m_pSizeAndLocationGroup->updateMediumPath(comMediumFormat, m_pFormatComboBox->formatExtensions(), KDeviceType_HardDisk);
934 m_pSizeAndLocationGroup->blockSignals(false);
935 /* Update the wizard parameters explicitly since we blocked th signals: */
936 pWizard->setMediumPath(m_pSizeAndLocationGroup->mediumFilePath());
937 pWizard->setMediumVariant(m_pDiskVariantWidget->mediumVariant());
938}
939
940void UIWizardNewVMExpertPage::setEnableNewDiskWidgets(bool fEnable)
941{
942 if (m_pSizeAndLocationGroup)
943 m_pSizeAndLocationGroup->setEnabled(fEnable);
944 if (m_pFormatComboBox)
945 m_pFormatComboBox->setEnabled(fEnable);
946 if (m_pDiskVariantWidget)
947 m_pDiskVariantWidget->setEnabled(fEnable);
948}
949
950QWidget *UIWizardNewVMExpertPage::createNameOSTypeWidgets()
951{
952 QWidget *pContainerWidget = new QWidget;
953 AssertReturn(pContainerWidget, 0);
954 m_pNameAndSystemLayout = new QGridLayout(pContainerWidget);
955 AssertReturn(m_pNameAndSystemLayout, 0);
956 m_pNameAndSystemLayout->setContentsMargins(0, 0, 0, 0);
957 m_pNameAndSystemEditor = new UINameAndSystemEditor(0,
958 true /* fChooseName? */,
959 true /* fChoosePath? */,
960 true /* fChooseImage? */,
961 true /* fChoseEdition? */,
962 true /* fChooseType? */);
963 if (m_pNameAndSystemEditor)
964 m_pNameAndSystemLayout->addWidget(m_pNameAndSystemEditor, 0, 0, 1, 2);
965 m_pSkipUnattendedCheckBox = new QCheckBox;
966 if (m_pSkipUnattendedCheckBox)
967 m_pNameAndSystemLayout->addWidget(m_pSkipUnattendedCheckBox, 1, 1);
968 return pContainerWidget;
969}
970
971void UIWizardNewVMExpertPage::setSkipCheckBoxEnable()
972{
973 AssertReturnVoid(m_pSkipUnattendedCheckBox && m_pNameAndSystemEditor);
974 const QString &strPath = m_pNameAndSystemEditor->ISOImagePath();
975 if (strPath.isEmpty())
976 {
977 m_pSkipUnattendedCheckBox->setEnabled(false);
978 return;
979 }
980 if (!isUnattendedInstallSupported())
981 {
982 m_pSkipUnattendedCheckBox->setEnabled(false);
983 return;
984 }
985
986 m_pSkipUnattendedCheckBox->setEnabled(UIWizardNewVMNameOSTypeCommon::checkISOFile(m_pNameAndSystemEditor));
987}
988
989void UIWizardNewVMExpertPage::updateHostnameDomainNameFromMachineName()
990{
991 if (!m_pAdditionalOptionsContainer)
992 return;
993 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
994 AssertReturnVoid(pWizard);
995
996 m_pAdditionalOptionsContainer->blockSignals(true);
997 m_pAdditionalOptionsContainer->setHostname(pWizard->machineBaseName());
998 m_pAdditionalOptionsContainer->setDomainName("myguest.virtualbox.org");
999 /* Initialize unattended hostname here since we cannot get the default value from CUnattended this early (unlike username etc): */
1000 if (m_pAdditionalOptionsContainer->isHostnameComplete())
1001 pWizard->setHostnameDomainName(m_pAdditionalOptionsContainer->hostnameDomainName());
1002
1003 m_pAdditionalOptionsContainer->blockSignals(false);
1004}
1005
1006bool UIWizardNewVMExpertPage::isUnattendedEnabled() const
1007{
1008 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
1009 AssertReturn(pWizard, false);
1010 return pWizard->isUnattendedEnabled();
1011}
1012
1013bool UIWizardNewVMExpertPage::isUnattendedInstallSupported() const
1014{
1015 UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
1016 AssertReturn(pWizard, false);
1017 return pWizard->isUnattendedInstallSupported();
1018}
1019
1020void UIWizardNewVMExpertPage::setEnableDiskSelectionWidgets(bool fEnabled)
1021{
1022 if (!m_pDiskSelector || !m_pDiskSelectionButton)
1023 return;
1024
1025 m_pDiskSelector->setEnabled(fEnabled);
1026 m_pDiskSelectionButton->setEnabled(fEnabled);
1027}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette