ca87590cb28f22bccab88dc2f87c5ce2682b1ba1vboxsync * VBox Qt GUI - UIWizardNewVMPageExpert class implementation.
ec36440940ba71033f9d8853bb1ba3758f34d8e2vboxsync * Copyright (C) 2006-2013 Oracle Corporation
8d8dfc00d014a62894327907a04f148b00a08529vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
8d8dfc00d014a62894327907a04f148b00a08529vboxsync * available from http://www.virtualbox.org. This file is free software;
8d8dfc00d014a62894327907a04f148b00a08529vboxsync * you can redistribute it and/or modify it under the terms of the GNU
8d8dfc00d014a62894327907a04f148b00a08529vboxsync * General Public License (GPL) as published by the Free Software
8d8dfc00d014a62894327907a04f148b00a08529vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
8d8dfc00d014a62894327907a04f148b00a08529vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8d8dfc00d014a62894327907a04f148b00a08529vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync/* Global includes: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync/* Local includes: */
a9b62afc62b28da7a1a77f34259f8013892d9664vboxsync#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
1f37cfc44ea630e28fd964240a80b6255ed6d64dvboxsyncUIWizardNewVMPageExpert::UIWizardNewVMPageExpert(const QString &strGroup)
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Create widgets: */
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync m_pNameAndSystemCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
8217a57ae45881066a43752d7ab6ba5d9c2d1d38vboxsync QHBoxLayout *pNameAndSystemCntLayout = new QHBoxLayout(m_pNameAndSystemCnt);
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync m_pNameAndSystemEditor = new UINameAndSystemEditor(m_pNameAndSystemCnt);
8217a57ae45881066a43752d7ab6ba5d9c2d1d38vboxsync pNameAndSystemCntLayout->addWidget(m_pNameAndSystemEditor);
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pMemoryCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
8217a57ae45881066a43752d7ab6ba5d9c2d1d38vboxsync QGridLayout *pMemoryCntLayout = new QGridLayout(m_pMemoryCnt);
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pRamSlider = new VBoxGuestRAMSlider(m_pMemoryCnt);
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pRamSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync m_pRamSlider->setValue(m_pNameAndSystemEditor->type().GetRecommendedRAM());
c6d3207fc42ec44a5c8256687f406bf2f20bc33evboxsync vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pRamEditor, 5);
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pRamUnits->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pRamMin->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pRamMax->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
8217a57ae45881066a43752d7ab6ba5d9c2d1d38vboxsync pMemoryCntLayout->addWidget(m_pRamSlider, 0, 0, 1, 3);
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
8217a57ae45881066a43752d7ab6ba5d9c2d1d38vboxsync QGridLayout *pDiskCntLayout = new QGridLayout(m_pDiskCnt);
5d74c7672f6c2d1f2ab95efcb6713e97ca361113vboxsync int iWidth = m_pDiskPresent->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth, &options, m_pDiskPresent);
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pDiskSelector = new VBoxMediaComboBox(m_pDiskCnt);
17c97778b6d189200ba110f10f016b3d973c5595vboxsync m_pVMMButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png"));
8217a57ae45881066a43752d7ab6ba5d9c2d1d38vboxsync pDiskCntLayout->addWidget(m_pDiskSkip, 0, 0, 1, 3);
8217a57ae45881066a43752d7ab6ba5d9c2d1d38vboxsync pDiskCntLayout->addWidget(m_pDiskCreate, 1, 0, 1, 3);
8217a57ae45881066a43752d7ab6ba5d9c2d1d38vboxsync pDiskCntLayout->addWidget(m_pDiskPresent, 2, 0, 1, 3);
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Setup connections: */
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &)));
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(sltOsTypeChanged()));
c6d3207fc42ec44a5c8256687f406bf2f20bc33evboxsync connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged()));
c6d3207fc42ec44a5c8256687f406bf2f20bc33evboxsync connect(m_pRamEditor, SIGNAL(valueChanged(int)), this, SLOT(sltRamEditorValueChanged()));
5d74c7672f6c2d1f2ab95efcb6713e97ca361113vboxsync connect(m_pDiskSkip, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync connect(m_pDiskCreate, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync connect(m_pDiskPresent, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync connect(m_pDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltVirtualDiskSourceChanged()));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(sltGetWithFileOpenDialog()));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Register classes: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Register fields: */
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync registerField("machineFolder", this, "machineFolder");
8d8dfc00d014a62894327907a04f148b00a08529vboxsync registerField("machineBaseName", this, "machineBaseName");
8d8dfc00d014a62894327907a04f148b00a08529vboxsync registerField("ram", m_pRamSlider, "value", SIGNAL(valueChanged(int)));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync registerField("virtualDiskId", this, "virtualDiskId");
8d8dfc00d014a62894327907a04f148b00a08529vboxsync registerField("virtualDiskLocation", this, "virtualDiskLocation");
8d8dfc00d014a62894327907a04f148b00a08529vboxsyncvoid UIWizardNewVMPageExpert::sltNameChanged(const QString &strNewText)
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Call to base-class: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Fetch recommended RAM value: */
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync CGuestOSType type = m_pNameAndSystemEditor->type();
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Broadcast complete-change: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Call to base-class: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Fetch recommended RAM value: */
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync CGuestOSType type = m_pNameAndSystemEditor->type();
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Broadcast complete-change: */
c6d3207fc42ec44a5c8256687f406bf2f20bc33evboxsyncvoid UIWizardNewVMPageExpert::sltRamSliderValueChanged()
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Call to base-class: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Broadcast complete-change: */
c6d3207fc42ec44a5c8256687f406bf2f20bc33evboxsyncvoid UIWizardNewVMPageExpert::sltRamEditorValueChanged()
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Call to base-class: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Broadcast complete-change: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsyncvoid UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged()
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Call to base-class: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Broadcast complete-change: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsyncvoid UIWizardNewVMPageExpert::sltGetWithFileOpenDialog()
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Call to base-class: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Translate widgets: */
6e9130e5552f77fc3e844b0d6f12332a1f1003bcvboxsync m_pNameAndSystemCnt->setTitle(UIWizardNewVM::tr("Name and operating system"));
9ab0743fd2e00994c4657ca9e67ab5dafa78e1afvboxsync m_pMemoryCnt->setTitle(UIWizardNewVM::tr("&Memory size"));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pRamUnits->setText(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes"));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pRamMin->setText(QString("%1 %2").arg(m_pRamSlider->minRAM()).arg(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes")));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync m_pRamMax->setText(QString("%1 %2").arg(m_pRamSlider->maxRAM()).arg(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes")));
5d74c7672f6c2d1f2ab95efcb6713e97ca361113vboxsync m_pDiskCnt->setTitle(UIWizardNewVM::tr("Hard drive"));
a3d33059b39a600e1e4595dc37b58104840f0910vboxsync m_pDiskSkip->setText(UIWizardNewVM::tr("&Do not add a virtual hard drive"));
a3d33059b39a600e1e4595dc37b58104840f0910vboxsync m_pDiskCreate->setText(UIWizardNewVM::tr("&Create a virtual hard drive now"));
a3d33059b39a600e1e4595dc37b58104840f0910vboxsync m_pDiskPresent->setText(UIWizardNewVM::tr("&Use an existing virtual hard drive file"));
9ab0743fd2e00994c4657ca9e67ab5dafa78e1afvboxsync m_pVMMButton->setToolTip(UIWizardNewVM::tr("Choose a virtual hard drive file..."));
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Translate page: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Call to base-class: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Make sure mandatory fields are complete,
8d8dfc00d014a62894327907a04f148b00a08529vboxsync * 'ram' field feats the bounds,
8d8dfc00d014a62894327907a04f148b00a08529vboxsync * 'virtualDisk' field feats the rules: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync (m_pRamSlider->value() >= qMax(1, (int)m_pRamSlider->minRAM()) && m_pRamSlider->value() <= (int)m_pRamSlider->maxRAM()) &&
c371a0f6f78033721d8faa94fec7a8b2792fe165vboxsync (m_pDiskSkip->isChecked() || !m_pDiskPresent->isChecked() || !vboxGlobal().medium(m_pDiskSelector->id()).isNull());
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Initial result: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Lock finish button: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Try to create machine folder: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Try to assign boot virtual-disk: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Ensure there is no virtual-disk created yet: */
9ab0743fd2e00994c4657ca9e67ab5dafa78e1afvboxsync /* Show the New Virtual Hard Drive wizard if necessary: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Try to create VM: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync fResult = qobject_cast<UIWizardNewVM*>(wizard())->createVM();
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Unlock finish button: */
8d8dfc00d014a62894327907a04f148b00a08529vboxsync /* Return result: */