UIWizardNewVMPageBasic1.cpp revision 12cbe990234bb127e4e4d2ab6c98511304193889
/* $Id$ */
/** @file
*
* VBox frontends: Qt4 GUI ("VirtualBox"):
* UIWizardNewVMPageBasic1 class implementation
*/
/*
* Copyright (C) 2006-2012 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.
*/
/* Qt includes: */
#include <QDir>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLineEdit>
/* GUI includes: */
#include "UIWizardNewVMPageBasic1.h"
#include "UIWizardNewVM.h"
#include "UIMessageCenter.h"
#include "UINameAndSystemEditor.h"
#include "QIRichTextLabel.h"
/* COM includes: */
#include "CSystemProperties.h"
/* Defines some patterns to guess the right OS type. Should be in sync with
* VirtualBox-settings-common.xsd in Main. The list is sorted by priority. The
* first matching string found, will be used. */
struct osTypePattern
{
const char *pcstId;
};
static const osTypePattern gs_OSTypePattern[] =
{
/* DOS: */
/* Windows: */
/* Solaris: */
{ QRegExp("((Op.*So)|(os20[01][0-9])|(So.*10)|(India)|(Neva)).*64", Qt::CaseInsensitive), "OpenSolaris_64" },
{ QRegExp("(Op.*So)|(os20[01][0-9])|(So.*10)|(India)|(Neva)", Qt::CaseInsensitive), "OpenSolaris" },
/* OS/2: */
{ QRegExp("((mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)).64", Qt::CaseInsensitive), "MacOS_64" },
{ QRegExp( "(mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)", Qt::CaseInsensitive), "MacOS" },
{ QRegExp("((mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)).*64", Qt::CaseInsensitive), "MacOS_64" },
{ QRegExp( "(mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)", Qt::CaseInsensitive), "MacOS" },
{ QRegExp("((mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)).*64", Qt::CaseInsensitive), "MacOS106_64" },
{ QRegExp( "(mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)", Qt::CaseInsensitive), "MacOS106" },
{ QRegExp( "(mac.*10[.,]{0,1}7)|(os.*x.*10[.,]{0,1}7)|(mac.*ML)|(os.*x.*ML)|(Mount)", Qt::CaseInsensitive), "MacOS108_64" },
{ QRegExp( "(mac.*10[.,]{0,1}8)|(os.*x.*10[.,]{0,1}8)|(Lion)", Qt::CaseInsensitive), "MacOS107_64" },
{ QRegExp( "(mac.*10[.,]{0,1}9)|(os.*x.*10[.,]{0,1}9)|(mac.*mav)|(os.*x.*mav)|(Mavericks)", Qt::CaseInsensitive), "MacOS109_64" },
/* Code names for Linux distributions: */
{ QRegExp("((edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)).*64", Qt::CaseInsensitive), "Ubuntu_64" },
{ QRegExp("(edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)", Qt::CaseInsensitive), "Ubuntu" },
{ QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(sid)).*64", Qt::CaseInsensitive), "Debian_64" },
{ QRegExp("(sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(sid)", Qt::CaseInsensitive), "Debian" },
{ QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*64", Qt::CaseInsensitive), "Fedora_64" },
{ QRegExp("(moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)", Qt::CaseInsensitive), "Fedora" },
/* Regular names of Linux distributions: */
/* Other: */
};
{
}
{
/* Search for a matching OS type based on the string the user typed already. */
{
m_pNameAndSystemEditor->blockSignals(true);
m_pNameAndSystemEditor->blockSignals(false);
break;
}
}
void UIWizardNewVMPage1::onOsTypeChanged()
{
/* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore.
* So simply disconnect the text-edit signal. */
m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &)));
}
{
return !m_strMachineFolder.isEmpty();
}
{
/* Cleanup previosly created folder if any: */
if (machineFolderCreated() && !cleanupMachineFolder())
{
return false;
}
/* Get VBox: */
/* Get default machines directory: */
/* Compose machine filename: */
QString strMachineFilename = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(), m_strGroup, QString::null, strDefaultMachinesFolder);
/* Make sure that folder doesn't exists: */
{
return false;
}
/* Try to create new folder (and it's predecessors): */
if (!fMachineFolderCreated)
{
return false;
}
/* Initialize fields: */
return true;
}
{
/* Make sure folder was previosly created: */
if (m_strMachineFolder.isEmpty())
return false;
/* Try to cleanup folder (and it's predecessors): */
/* Reset machine folder value: */
/* Return cleanup result: */
return fMachineFolderRemoved;
}
{
/* Create widgets: */
{
m_pLabel = new QIRichTextLabel(this);
m_pNameAndSystemEditor = new UINameAndSystemEditor(this);
}
/* Setup connections: */
connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &)));
/* Register fields: */
}
{
/* Call to base-class: */
}
{
/* Call to base-class: */
}
void UIWizardNewVMPageBasic1::retranslateUi()
{
/* Translate page: */
/* Translate widgets: */
"and select the type of operating system you intend to install on it. "
"The name you choose will be used throughout VirtualBox "
"to identify this machine."));
}
{
/* Translate page: */
}
void UIWizardNewVMPageBasic1::cleanupPage()
{
/* Cleanup: */
/* Call to base-class: */
}
bool UIWizardNewVMPageBasic1::validatePage()
{
/* Try to create machine folder: */
return createMachineFolder();
}