VirtualBox

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

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

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.6 KB
Line 
1/* $Id: UIWizardNewVM.cpp 103961 2024-03-20 14:34:36Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIWizardNewVM 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 <QAbstractButton>
30#include <QLayout>
31
32/* GUI includes: */
33#include "UICommon.h"
34#include "UIGlobalSession.h"
35#include "UIGuestOSType.h"
36#include "UIMedium.h"
37#include "UINotificationCenter.h"
38#include "UIWizardNewVM.h"
39#include "UIWizardNewVMNameOSTypePage.h"
40#include "UIWizardNewVMUnattendedPage.h"
41#include "UIWizardNewVMHardwarePage.h"
42#include "UIWizardNewVMDiskPage.h"
43#include "UIWizardNewVMExpertPage.h"
44#include "UIWizardNewVMSummaryPage.h"
45
46/* COM includes: */
47#include "CAudioAdapter.h"
48#include "CAudioSettings.h"
49#include "CFirmwareSettings.h"
50#include "CGraphicsAdapter.h"
51#include "CExtPackManager.h"
52#include "CMediumFormat.h"
53#include "CPlatform.h"
54#include "CPlatformX86.h"
55#include "CStorageController.h"
56#include "CUSBController.h"
57#include "CUSBDeviceFilters.h"
58
59/* Namespaces: */
60using namespace UIExtraDataDefs;
61
62
63UIWizardNewVM::UIWizardNewVM(QWidget *pParent,
64 UIActionPool *pActionPool,
65 const QString &strMachineGroup,
66 const QString &strISOFilePath /* = QString() */)
67 : UINativeWizard(pParent, WizardType_NewVM, WizardMode_Auto, "create-vm-wizard" /* help keyword */)
68 , m_strMachineGroup(strMachineGroup)
69 , m_iIDECount(0)
70 , m_iSATACount(0)
71 , m_iSCSICount(0)
72 , m_iFloppyCount(0)
73 , m_iSASCount(0)
74 , m_iUSBCount(0)
75 , m_fInstallGuestAdditions(false)
76 , m_fSkipUnattendedInstall(false)
77 , m_fEFIEnabled(false)
78 , m_iCPUCount(1)
79 , m_iMemorySize(0)
80 , m_iUnattendedInstallPageIndex(-1)
81 , m_uMediumVariant(0)
82 , m_uMediumSize(0)
83 , m_enmDiskSource(SelectedDiskSource_New)
84 , m_fEmptyDiskRecommended(false)
85 , m_pActionPool(pActionPool)
86 , m_fStartHeadless(false)
87 , m_strInitialISOFilePath(strISOFilePath)
88{
89#ifndef VBOX_WS_MAC
90 /* Assign watermark: */
91 setPixmapName(":/wizard_new_welcome.png");
92#else /* VBOX_WS_MAC */
93 /* Assign background image: */
94 setPixmapName(":/wizard_new_welcome_bg.png");
95#endif /* VBOX_WS_MAC */
96 connect(this, &UIWizardNewVM::rejected, this, &UIWizardNewVM::sltHandleWizardCancel);
97
98 /* Create installer: */
99 m_comUnattended = gpGlobalSession->virtualBox().CreateUnattendedInstaller();
100 AssertMsg(!m_comUnattended.isNull(), ("Could not create unattended installer!\n"));
101}
102
103void UIWizardNewVM::populatePages()
104{
105 switch (mode())
106 {
107 case WizardMode_Basic:
108 {
109 UIWizardNewVMNameOSTypePage *pNamePage = new UIWizardNewVMNameOSTypePage;
110 addPage(pNamePage);
111 if (!m_strInitialISOFilePath.isEmpty())
112 pNamePage->setISOFilePath(m_strInitialISOFilePath);
113 m_iUnattendedInstallPageIndex = addPage(new UIWizardNewVMUnattendedPage);
114 setUnattendedPageVisible(false);
115 addPage(new UIWizardNewVMHardwarePage);
116 addPage(new UIWizardNewVMDiskPage(m_pActionPool));
117 addPage(new UIWizardNewVMSummaryPage);
118 break;
119 }
120 case WizardMode_Expert:
121 {
122 UIWizardNewVMExpertPage *pExpertPage = new UIWizardNewVMExpertPage(m_pActionPool);
123 addPage(pExpertPage);
124 if (!m_strInitialISOFilePath.isEmpty())
125 pExpertPage->setISOFilePath(m_strInitialISOFilePath);
126 break;
127 }
128 default:
129 {
130 AssertMsgFailed(("Invalid mode: %d", mode()));
131 break;
132 }
133 }
134}
135
136void UIWizardNewVM::cleanWizard()
137{
138 /* Try to delete the hard disk in case we have created one: */
139 deleteVirtualDisk();
140 /* Cleanup the machine folder: */
141 UIWizardNewVMNameOSTypeCommon::cleanupMachineFolder(this, true);
142
143 if (!m_machine.isNull())
144 m_machine.detach();
145}
146
147bool UIWizardNewVM::createVM()
148{
149 CVirtualBox vbox = gpGlobalSession->virtualBox();
150
151 /* Create virtual machine: */
152 if (m_machine.isNull())
153 {
154 QVector<QString> groups;
155 if (!m_strMachineGroup.isEmpty())
156 groups << m_strMachineGroup;
157 m_machine = vbox.CreateMachine(m_strMachineFilePath,
158 m_strMachineBaseName,
159 KPlatformArchitecture_x86,
160 groups, m_guestOSTypeId, QString(),
161 QString(), QString(), QString());
162 if (!vbox.isOk())
163 {
164 UINotificationMessage::cannotCreateMachine(vbox, notificationCenter());
165 cleanWizard();
166 return false;
167 }
168 }
169
170 CFirmwareSettings comFirmwareSettings = m_machine.GetFirmwareSettings();
171
172 /* The newer and less tested way of configuring vms: */
173 m_machine.ApplyDefaults(QString());
174 /* Apply user preferences again. IMachine::applyDefaults may have overwritten the user setting: */
175 m_machine.SetMemorySize(m_iMemorySize);
176 int iVPUCount = qMax(1, m_iCPUCount);
177 m_machine.SetCPUCount(iVPUCount);
178 /* Correct the VRAM size since API does not take fullscreen memory requirements into account: */
179 CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter();
180 comGraphics.SetVRAMSize(qMax(comGraphics.GetVRAMSize(), (ULONG)(UICommon::requiredVideoMemory(m_guestOSTypeId) / _1M)));
181 /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */
182 if (iVPUCount > 1)
183 comFirmwareSettings.SetIOAPICEnabled(true);
184
185 /* Set recommended firmware type: */
186 comFirmwareSettings.SetFirmwareType(m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS);
187
188 /* Register the VM prior to attaching hard disks: */
189 vbox.RegisterMachine(m_machine);
190 if (!vbox.isOk())
191 {
192 UINotificationMessage::cannotRegisterMachine(vbox, m_machine.GetName(), notificationCenter());
193 cleanWizard();
194 return false;
195 }
196
197 if (!attachDefaultDevices())
198 {
199 cleanWizard();
200 return false;
201 }
202
203 if (isUnattendedEnabled())
204 {
205 m_comUnattended.SetMachine(m_machine);
206 if (!checkUnattendedInstallError(m_comUnattended))
207 {
208 cleanWizard();
209 return false;
210 }
211 }
212 return true;
213}
214
215bool UIWizardNewVM::createVirtualDisk()
216{
217 /* Prepare result: */
218 bool fResult = false;
219
220 /* Check attributes: */
221 AssertReturn(!m_strMediumPath.isNull(), false);
222 AssertReturn(m_uMediumSize > 0, false);
223
224 /* Acquire VBox: */
225 CVirtualBox comVBox = gpGlobalSession->virtualBox();
226
227 /* Create new virtual hard-disk: */
228 CMedium newVirtualDisk = comVBox.CreateMedium(m_comMediumFormat.GetName(), m_strMediumPath, KAccessMode_ReadWrite, KDeviceType_HardDisk);
229 if (!comVBox.isOk())
230 {
231 UINotificationMessage::cannotCreateMediumStorage(comVBox, m_strMediumPath, notificationCenter());
232 return fResult;
233 }
234
235 /* Create base storage for the new virtual-disk: */
236 UINotificationProgressMediumCreate *pNotification = new UINotificationProgressMediumCreate(newVirtualDisk,
237 m_uMediumSize,
238 mediumVariants());
239 if (!handleNotificationProgressNow(pNotification))
240 return fResult;
241
242 /* Inform UICommon about it: */
243 uiCommon().createMedium(UIMedium(newVirtualDisk, UIMediumDeviceType_HardDisk, KMediumState_Created));
244
245 /* Remember created virtual-disk: */
246 m_virtualDisk = newVirtualDisk;
247
248 /* True finally: */
249 fResult = true;
250
251 /* Return result: */
252 return fResult;
253}
254
255void UIWizardNewVM::deleteVirtualDisk()
256{
257 /* Do nothing if an existing disk has been selected: */
258 if (m_enmDiskSource == SelectedDiskSource_Existing)
259 return;
260
261 /* Make sure virtual-disk valid: */
262 if (m_virtualDisk.isNull())
263 return;
264
265 /* Delete storage of existing disk: */
266 UINotificationProgressMediumDeletingStorage *pNotification = new UINotificationProgressMediumDeletingStorage(m_virtualDisk);
267 if (!handleNotificationProgressNow(pNotification))
268 return;
269
270 /* Detach virtual-disk finally: */
271 m_virtualDisk.detach();
272}
273
274bool UIWizardNewVM::attachDefaultDevices()
275{
276 bool success = false;
277 QUuid uMachineId = m_machine.GetId();
278 CSession session = uiCommon().openSession(uMachineId);
279 if (!session.isNull())
280 {
281 CMachine machine = session.GetMachine();
282 if (!m_virtualDisk.isNull())
283 {
284 KStorageBus enmHDDBus = gpGlobalSession->guestOSTypeManager().getRecommendedHDStorageBus(m_guestOSTypeId);
285 CStorageController comHDDController = m_machine.GetStorageControllerByInstance(enmHDDBus, 0);
286 if (!comHDDController.isNull())
287 {
288 machine.AttachDevice(comHDDController.GetName(), 0, 0, KDeviceType_HardDisk, m_virtualDisk);
289 if (!machine.isOk())
290 UINotificationMessage::cannotAttachDevice(machine, UIMediumDeviceType_HardDisk, m_strMediumPath,
291 StorageSlot(enmHDDBus, 0, 0), notificationCenter());
292 }
293 }
294
295 /* Attach optical drive: */
296 KStorageBus enmDVDBus = gpGlobalSession->guestOSTypeManager().getRecommendedDVDStorageBus(m_guestOSTypeId);
297 CStorageController comDVDController = m_machine.GetStorageControllerByInstance(enmDVDBus, 0);
298 if (!comDVDController.isNull())
299 {
300 CMedium opticalDisk;
301 QString strISOFilePath = ISOFilePath();
302 if (!strISOFilePath.isEmpty() && !isUnattendedEnabled())
303 {
304 CVirtualBox vbox = gpGlobalSession->virtualBox();
305 opticalDisk =
306 vbox.OpenMedium(strISOFilePath, KDeviceType_DVD, KAccessMode_ReadWrite, false);
307 if (!vbox.isOk())
308 UINotificationMessage::cannotOpenMedium(vbox, strISOFilePath, notificationCenter());
309 }
310 machine.AttachDevice(comDVDController.GetName(), 1, 0, KDeviceType_DVD, opticalDisk);
311 if (!machine.isOk())
312 UINotificationMessage::cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(),
313 StorageSlot(enmDVDBus, 1, 0), notificationCenter());
314 }
315
316 /* Attach an empty floppy drive if recommended */
317 if (gpGlobalSession->guestOSTypeManager().getRecommendedFloppy(m_guestOSTypeId))
318 {
319 CStorageController comFloppyController = m_machine.GetStorageControllerByInstance(KStorageBus_Floppy, 0);
320 if (!comFloppyController.isNull())
321 {
322 machine.AttachDevice(comFloppyController.GetName(), 0, 0, KDeviceType_Floppy, CMedium());
323 if (!machine.isOk())
324 UINotificationMessage::cannotAttachDevice(machine, UIMediumDeviceType_Floppy, QString(),
325 StorageSlot(KStorageBus_Floppy, 0, 0), notificationCenter());
326 }
327 }
328
329 if (machine.isOk())
330 {
331 machine.SaveSettings();
332 if (machine.isOk())
333 success = true;
334 else
335 UINotificationMessage::cannotSaveMachineSettings(machine, notificationCenter());
336 }
337
338 session.UnlockMachine();
339 }
340 if (!success)
341 {
342 /* Unregister VM on failure: */
343 const QVector<CMedium> media = m_machine.Unregister(KCleanupMode_DetachAllReturnHardDisksOnly);
344 if (!m_machine.isOk())
345 UINotificationMessage::cannotRemoveMachine(m_machine, notificationCenter());
346 else
347 {
348 UINotificationProgressMachineMediaRemove *pNotification =
349 new UINotificationProgressMachineMediaRemove(m_machine, media);
350 handleNotificationProgressNow(pNotification);
351 }
352 }
353
354 /* Make sure we detach CMedium wrapper from IMedium pointer to avoid deletion of IMedium as m_virtualDisk
355 * is deallocated. Or in case of UINotificationProgressMachineMediaRemove handling, IMedium has been
356 * already deleted so detach in this case as well. */
357 if (!m_virtualDisk.isNull())
358 m_virtualDisk.detach();
359
360 return success;
361}
362
363void UIWizardNewVM::sltHandleWizardCancel()
364{
365 cleanWizard();
366}
367
368void UIWizardNewVM::sltRetranslateUI()
369{
370 UINativeWizard::sltRetranslateUI();
371 setWindowTitle(tr("Create Virtual Machine"));
372}
373
374QString UIWizardNewVM::getNextControllerName(KStorageBus type)
375{
376 QString strControllerName;
377 switch (type)
378 {
379 case KStorageBus_IDE:
380 {
381 strControllerName = "IDE";
382 ++m_iIDECount;
383 if (m_iIDECount > 1)
384 strControllerName = QString("%1 %2").arg(strControllerName).arg(m_iIDECount);
385 break;
386 }
387 case KStorageBus_SATA:
388 {
389 strControllerName = "SATA";
390 ++m_iSATACount;
391 if (m_iSATACount > 1)
392 strControllerName = QString("%1 %2").arg(strControllerName).arg(m_iSATACount);
393 break;
394 }
395 case KStorageBus_SCSI:
396 {
397 strControllerName = "SCSI";
398 ++m_iSCSICount;
399 if (m_iSCSICount > 1)
400 strControllerName = QString("%1 %2").arg(strControllerName).arg(m_iSCSICount);
401 break;
402 }
403 case KStorageBus_Floppy:
404 {
405 strControllerName = "Floppy";
406 ++m_iFloppyCount;
407 if (m_iFloppyCount > 1)
408 strControllerName = QString("%1 %2").arg(strControllerName).arg(m_iFloppyCount);
409 break;
410 }
411 case KStorageBus_SAS:
412 {
413 strControllerName = "SAS";
414 ++m_iSASCount;
415 if (m_iSASCount > 1)
416 strControllerName = QString("%1 %2").arg(strControllerName).arg(m_iSASCount);
417 break;
418 }
419 case KStorageBus_USB:
420 {
421 strControllerName = "USB";
422 ++m_iUSBCount;
423 if (m_iUSBCount > 1)
424 strControllerName = QString("%1 %2").arg(strControllerName).arg(m_iUSBCount);
425 break;
426 }
427 default:
428 break;
429 }
430 return strControllerName;
431}
432
433QUuid UIWizardNewVM::createdMachineId() const
434{
435 if (m_machine.isOk())
436 return m_machine.GetId();
437 return QUuid();
438}
439
440CMedium &UIWizardNewVM::virtualDisk()
441{
442 return m_virtualDisk;
443}
444
445void UIWizardNewVM::setVirtualDisk(const CMedium &medium)
446{
447 m_virtualDisk = medium;
448}
449
450void UIWizardNewVM::setVirtualDisk(const QUuid &mediumId)
451{
452 if (m_virtualDisk.isOk() && m_virtualDisk.GetId() == mediumId)
453 return;
454 CMedium medium = uiCommon().medium(mediumId).medium();
455 setVirtualDisk(medium);
456}
457
458const QString &UIWizardNewVM::machineGroup() const
459{
460 return m_strMachineGroup;
461}
462
463const QString &UIWizardNewVM::machineFilePath() const
464{
465 return m_strMachineFilePath;
466}
467
468void UIWizardNewVM::setMachineFilePath(const QString &strMachineFilePath)
469{
470 m_strMachineFilePath = strMachineFilePath;
471}
472
473QString UIWizardNewVM::machineFileName() const
474{
475 return QFileInfo(machineFilePath()).completeBaseName();
476}
477
478const QString &UIWizardNewVM::machineFolder() const
479{
480 return m_strMachineFolder;
481}
482
483void UIWizardNewVM::setMachineFolder(const QString &strMachineFolder)
484{
485 m_strMachineFolder = strMachineFolder;
486}
487
488const QString &UIWizardNewVM::machineBaseName() const
489{
490 return m_strMachineBaseName;
491}
492
493void UIWizardNewVM::setMachineBaseName(const QString &strMachineBaseName)
494{
495 m_strMachineBaseName = strMachineBaseName;
496}
497
498const QString &UIWizardNewVM::createdMachineFolder() const
499{
500 return m_strCreatedFolder;
501}
502
503void UIWizardNewVM::setCreatedMachineFolder(const QString &strCreatedMachineFolder)
504{
505 m_strCreatedFolder = strCreatedMachineFolder;
506}
507
508QString UIWizardNewVM::detectedOSTypeId() const
509{
510 AssertReturn(!m_comUnattended.isNull(), QString());
511 return m_comUnattended.GetDetectedOSTypeId();
512}
513
514const QString &UIWizardNewVM::guestOSFamilyId() const
515{
516 return m_strGuestOSFamilyId;
517}
518
519void UIWizardNewVM::setGuestOSFamilyId(const QString &strGuestOSFamilyId)
520{
521 m_strGuestOSFamilyId = strGuestOSFamilyId;
522}
523
524const QString &UIWizardNewVM::guestOSTypeId() const
525{
526 return m_guestOSTypeId;
527}
528
529void UIWizardNewVM::setGuestOSTypeId(const QString &guestOSTypeId)
530{
531 m_guestOSTypeId = guestOSTypeId;
532}
533
534bool UIWizardNewVM::installGuestAdditions() const
535{
536 AssertReturn(!m_comUnattended.isNull(), false);
537 return m_comUnattended.GetInstallGuestAdditions();
538}
539
540void UIWizardNewVM::setInstallGuestAdditions(bool fInstallGA)
541{
542 AssertReturnVoid(!m_comUnattended.isNull());
543 m_comUnattended.SetInstallGuestAdditions(fInstallGA);
544 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended));
545}
546
547bool UIWizardNewVM::startHeadless() const
548{
549 return m_fStartHeadless;
550}
551
552void UIWizardNewVM::setStartHeadless(bool fStartHeadless)
553{
554 m_fStartHeadless = fStartHeadless;
555}
556
557bool UIWizardNewVM::skipUnattendedInstall() const
558{
559 return m_fSkipUnattendedInstall;
560}
561
562void UIWizardNewVM::setSkipUnattendedInstall(bool fSkipUnattendedInstall)
563{
564 m_fSkipUnattendedInstall = fSkipUnattendedInstall;
565 /* We hide/show unattended install page depending on the value of isUnattendedEnabled: */
566 setUnattendedPageVisible(isUnattendedEnabled());
567}
568
569bool UIWizardNewVM::EFIEnabled() const
570{
571 return m_fEFIEnabled;
572}
573
574void UIWizardNewVM::setEFIEnabled(bool fEnabled)
575{
576 m_fEFIEnabled = fEnabled;
577}
578
579QString UIWizardNewVM::ISOFilePath() const
580{
581 AssertReturn(!m_comUnattended.isNull(), QString());
582 return m_comUnattended.GetIsoPath();
583}
584
585void UIWizardNewVM::setISOFilePath(const QString &strISOFilePath)
586{
587 AssertReturnVoid(!m_comUnattended.isNull());
588 m_comUnattended.SetIsoPath(strISOFilePath);
589 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended));
590
591 m_comUnattended.DetectIsoOS();
592
593 const QVector<ULONG> &indices = m_comUnattended.GetDetectedImageIndices();
594 QVector<ulong> qIndices;
595 for (int i = 0; i < indices.size(); ++i)
596 qIndices << indices[i];
597 setDetectedWindowsImageNamesAndIndices(m_comUnattended.GetDetectedImageNames(), qIndices);
598 /* We hide/show unattended install page depending on the value of isUnattendedEnabled: */
599 setUnattendedPageVisible(isUnattendedEnabled());
600}
601
602QString UIWizardNewVM::userName() const
603{
604 AssertReturn(!m_comUnattended.isNull(), QString());
605 return m_comUnattended.GetUser();
606}
607
608void UIWizardNewVM::setUserName(const QString &strUserName)
609{
610 AssertReturnVoid(!m_comUnattended.isNull());
611 m_comUnattended.SetUser(strUserName);
612 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended));
613}
614
615QString UIWizardNewVM::password() const
616{
617 AssertReturn(!m_comUnattended.isNull(), QString());
618 return m_comUnattended.GetUserPassword();
619}
620
621void UIWizardNewVM::setPassword(const QString &strPassword)
622{
623 AssertReturnVoid(!m_comUnattended.isNull());
624 m_comUnattended.SetUserPassword(strPassword);
625 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended));
626}
627
628QString UIWizardNewVM::guestAdditionsISOPath() const
629{
630 AssertReturn(!m_comUnattended.isNull(), QString());
631 return m_comUnattended.GetAdditionsIsoPath();
632}
633
634void UIWizardNewVM::setGuestAdditionsISOPath(const QString &strGAISOPath)
635{
636 AssertReturnVoid(!m_comUnattended.isNull());
637 m_comUnattended.SetAdditionsIsoPath(strGAISOPath);
638 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended));
639}
640
641QString UIWizardNewVM::hostnameDomainName() const
642{
643 AssertReturn(!m_comUnattended.isNull(), QString());
644 return m_comUnattended.GetHostname();
645}
646
647void UIWizardNewVM::setHostnameDomainName(const QString &strHostnameDomain)
648{
649 AssertReturnVoid(!m_comUnattended.isNull());
650 m_comUnattended.SetHostname(strHostnameDomain);
651 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended));
652}
653
654QString UIWizardNewVM::productKey() const
655{
656 AssertReturn(!m_comUnattended.isNull(), QString());
657 return m_comUnattended.GetProductKey();
658}
659
660void UIWizardNewVM::setProductKey(const QString &productKey)
661{
662 AssertReturnVoid(!m_comUnattended.isNull());
663 m_comUnattended.SetProductKey(productKey);
664 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended));
665}
666
667int UIWizardNewVM::CPUCount() const
668{
669 return m_iCPUCount;
670}
671
672void UIWizardNewVM::setCPUCount(int iCPUCount)
673{
674 m_iCPUCount = iCPUCount;
675}
676
677int UIWizardNewVM::memorySize() const
678{
679 return m_iMemorySize;
680}
681
682void UIWizardNewVM::setMemorySize(int iMemory)
683{
684 m_iMemorySize = iMemory;
685}
686
687
688qulonglong UIWizardNewVM::mediumVariant() const
689{
690 return m_uMediumVariant;
691}
692
693void UIWizardNewVM::setMediumVariant(qulonglong uMediumVariant)
694{
695 m_uMediumVariant = uMediumVariant;
696}
697
698const CMediumFormat &UIWizardNewVM::mediumFormat()
699{
700 return m_comMediumFormat;
701}
702
703void UIWizardNewVM::setMediumFormat(const CMediumFormat &mediumFormat)
704{
705 m_comMediumFormat = mediumFormat;
706}
707
708const QString &UIWizardNewVM::mediumPath() const
709{
710 return m_strMediumPath;
711}
712
713void UIWizardNewVM::setMediumPath(const QString &strMediumPath)
714{
715 m_strMediumPath = strMediumPath;
716}
717
718qulonglong UIWizardNewVM::mediumSize() const
719{
720 return m_uMediumSize;
721}
722
723void UIWizardNewVM::setMediumSize(qulonglong uMediumSize)
724{
725 m_uMediumSize = uMediumSize;
726}
727
728SelectedDiskSource UIWizardNewVM::diskSource() const
729{
730 return m_enmDiskSource;
731}
732
733void UIWizardNewVM::setDiskSource(SelectedDiskSource enmDiskSource)
734{
735 m_enmDiskSource = enmDiskSource;
736}
737
738bool UIWizardNewVM::emptyDiskRecommended() const
739{
740 return m_fEmptyDiskRecommended;
741}
742
743void UIWizardNewVM::setEmptyDiskRecommended(bool fEmptyDiskRecommended)
744{
745 m_fEmptyDiskRecommended = fEmptyDiskRecommended;
746}
747
748void UIWizardNewVM::setDetectedWindowsImageNamesAndIndices(const QVector<QString> &names, const QVector<ulong> &ids)
749{
750 AssertMsg(names.size() == ids.size(),
751 ("Sizes of the arrays for names and indices of the detected images should be equal."));
752 m_detectedWindowsImageNames = names;
753 m_detectedWindowsImageIndices = ids;
754}
755
756const QVector<QString> &UIWizardNewVM::detectedWindowsImageNames() const
757{
758 return m_detectedWindowsImageNames;
759}
760
761const QVector<ulong> &UIWizardNewVM::detectedWindowsImageIndices() const
762{
763 return m_detectedWindowsImageIndices;
764}
765
766void UIWizardNewVM::setSelectedWindowImageIndex(ulong uIndex)
767{
768 AssertReturnVoid(!m_comUnattended.isNull());
769 m_comUnattended.SetImageIndex(uIndex);
770 AssertReturnVoid(checkUnattendedInstallError(m_comUnattended));
771}
772
773ulong UIWizardNewVM::selectedWindowImageIndex() const
774{
775 AssertReturn(!m_comUnattended.isNull(), 0);
776 return m_comUnattended.GetImageIndex();
777}
778
779QVector<KMediumVariant> UIWizardNewVM::mediumVariants() const
780{
781 /* Compose medium-variant: */
782 QVector<KMediumVariant> variants(sizeof(qulonglong)*8);
783 for (int i = 0; i < variants.size(); ++i)
784 {
785 qulonglong temp = m_uMediumVariant;
786 temp &= UINT64_C(1)<<i;
787 variants[i] = (KMediumVariant)temp;
788 }
789 return variants;
790}
791
792QString UIWizardNewVM::getGuestOSTypeDescription() const
793{
794 return gpGlobalSession->guestOSTypeManager().getDescription(m_guestOSTypeId);
795}
796
797bool UIWizardNewVM::isUnattendedEnabled() const
798{
799 if (m_comUnattended.isNull())
800 return false;
801 if (m_comUnattended.GetIsoPath().isEmpty())
802 return false;
803 if (m_fSkipUnattendedInstall)
804 return false;
805 if (!isUnattendedInstallSupported())
806 return false;
807 return true;
808}
809
810bool UIWizardNewVM::isUnattendedInstallSupported() const
811{
812 AssertReturn(!m_comUnattended.isNull(), false);
813 return m_comUnattended.GetIsUnattendedInstallSupported();
814}
815
816bool UIWizardNewVM::isGuestOSTypeWindows() const
817{
818 return m_strGuestOSFamilyId.contains("windows", Qt::CaseInsensitive);
819}
820
821void UIWizardNewVM::setUnattendedPageVisible(bool fVisible)
822{
823 if (m_iUnattendedInstallPageIndex != -1)
824 setPageVisible(m_iUnattendedInstallPageIndex, fVisible);
825}
826
827bool UIWizardNewVM::checkUnattendedInstallError(const CUnattended &comUnattended) const
828{
829 if (!comUnattended.isOk())
830 {
831 UINotificationMessage::cannotRunUnattendedGuestInstall(comUnattended);
832 return false;
833 }
834 return true;
835}
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