UIWizardNewVM.cpp revision a9b62afc62b28da7a1a77f34259f8013892d9664
/* $Id$ */
/** @file
* VBox Qt GUI - UIWizardNewVM class implementation.
*/
/*
* Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
# include <precomp.h>
#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
/* GUI includes: */
# include "VBoxGlobal.h"
# include "UIWizardNewVM.h"
# include "UIWizardNewVMPageBasic1.h"
# include "UIWizardNewVMPageBasic2.h"
# include "UIWizardNewVMPageBasic3.h"
# include "UIWizardNewVMPageExpert.h"
# include "UIMessageCenter.h"
# include "UIMedium.h"
/* COM includes: */
# include "CAudioAdapter.h"
# include "CUSBController.h"
# include "CUSBDeviceFilters.h"
# include "CExtPackManager.h"
# include "CStorageController.h"
#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
/* Namespaces: */
using namespace UIExtraDataDefs;
, m_iIDECount(0)
, m_iSATACount(0)
, m_iSCSICount(0)
, m_iFloppyCount(0)
, m_iSASCount(0)
{
#ifndef Q_WS_MAC
/* Assign watermark: */
assignWatermark(":/vmw_new_welcome.png");
#else /* Q_WS_MAC */
/* Assign background image: */
assignBackground(":/vmw_new_welcome_bg.png");
#endif /* Q_WS_MAC */
}
bool UIWizardNewVM::createVM()
{
/* Get VBox object: */
/* OS type: */
/* Create virtual machine: */
{
if (!m_strGroup.isEmpty())
groups << m_strGroup;
m_machine = vbox.CreateMachine(QString(), field("name").toString(), groups, strTypeId, QString::null);
{
return false;
}
/* The First RUN Wizard is to be shown:
* 1. if we don't attach any virtual hard-drive
* 2. or attach a new (empty) one.
* Usually we are assigning extra-data values through UIExtraDataManager,
* but in that special case VM was not registered yet, so UIExtraDataManager is unaware of it. */
}
/* RAM size: */
/* VRAM size - select maximum between recommended and minimum for fullscreen: */
m_machine.SetVRAMSize(qMax(type.GetRecommendedVRAM(), (ULONG)(VBoxGlobal::requiredVideoMemory(strTypeId) / _1M)));
/* Selecting recommended chipset type: */
/* Selecting recommended Audio Controller: */
/* Enabling audio by default: */
/* Enable the OHCI and EHCI controller by default for new VMs. (new in 2.2): */
bool fOhciEnabled = false;
{
fOhciEnabled = true;
/* USB 2.0 is only available if the proper ExtPack is installed.
* Note. Configuring EHCI here and providing messages about
* the missing extpack isn't exactly clean, but it is a
* necessary evil to patch over legacy compatability issues
* introduced by the new distribution model. */
}
/* Create a floppy controller if recommended: */
if (type.GetRecommendedFloppy())
{
}
/* Create recommended DVD storage controller: */
/* Set recommended DVD storage controller type: */
/* Create recommended HD storage controller if it's not the same as the DVD controller: */
{
}
else
{
/* The HD controller is the same as DVD: */
}
/* Liomit the AHCI port count if it's used because windows has trouble with
too many ports and other guest (OS X in particular) may take extra long
to boot: */
else if (dvdStorageControllerType == KStorageControllerType_IntelAhci)
/* Turn on PAE, if recommended: */
/* Set the recommended triple fault behavior: */
/* Set recommended firmware type: */
/* Set recommended human interface device types: */
if (type.GetRecommendedUSBHID())
{
}
if (type.GetRecommendedUSBTablet())
{
}
/* Set HPET flag: */
/* Set UTC flags: */
/* Set graphic bits: */
if (type.GetRecommended3DAcceleration())
/* Register the VM prior to attaching hard disks: */
{
return false;
}
/* Attach default devices: */
{
bool success = false;
{
/* Boot virtual hard drive: */
{
msgCenter().cannotAttachDevice(machine, UIMediumType_HardDisk, field("virtualDiskLocation").toString(),
StorageSlot(ctrHDBus, 0, 0), this);
}
msgCenter().cannotAttachDevice(machine, UIMediumType_DVD, QString(), StorageSlot(strDVDBus, 1, 0), this);
/* Attach an empty floppy drive if recommended */
if (type.GetRecommendedFloppy()) {
StorageSlot(KStorageBus_Floppy, 0, 0), this);
}
{
success = true;
else
}
}
if (!success)
{
/* Unregister on failure */
QVector<CMedium> aMedia = m_machine.Unregister(KCleanupMode_UnregisterOnly); // @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below
{
progress.WaitForCompletion(-1); // @todo do this nicely with a progress dialog, this can delete lots of files
}
return false;
}
}
/* Ensure we don't try to delete a newly created virtual hard drive on success: */
return true;
}
void UIWizardNewVM::retranslateUi()
{
/* Call to base-class: */
/* Translate wizard: */
}
void UIWizardNewVM::prepare()
{
/* Create corresponding pages: */
switch (mode())
{
case WizardMode_Basic:
{
break;
}
case WizardMode_Expert:
{
break;
}
default:
{
break;
}
}
/* Call to base-class: */
}
{
switch (type)
{
case KStorageBus_IDE:
{
strControllerName = "IDE";
++m_iIDECount;
if (m_iIDECount > 1)
break;
}
case KStorageBus_SATA:
{
strControllerName = "SATA";
++m_iSATACount;
if (m_iSATACount > 1)
break;
}
case KStorageBus_SCSI:
{
strControllerName = "SCSI";
++m_iSCSICount;
if (m_iSCSICount > 1)
break;
}
case KStorageBus_Floppy:
{
strControllerName = "Floppy";
if (m_iFloppyCount > 1)
break;
}
case KStorageBus_SAS:
{
strControllerName = "SAS";
++m_iSASCount;
if (m_iSASCount > 1)
break;
}
default:
break;
}
return strControllerName;
}