UIWizardFirstRunPageBasic.cpp revision 9f4ab406d222cd081a1522169822c3e7c2d6a718
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync/* $Id$ */
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync/** @file
ecd27a5c936b5767a6c08e21e204f2d4340ec926vboxsync *
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * VBox frontends: Qt4 GUI ("VirtualBox"):
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * UIWizardFirstRunPageBasic class implementation
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync */
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync/*
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * Copyright (C) 2008-2013 Oracle Corporation
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync *
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * available from http://www.virtualbox.org. This file is free software;
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * you can redistribute it and/or modify it under the terms of the GNU
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * General Public License (GPL) as published by the Free Software
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync */
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync/* Qt includes: */
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include <QVBoxLayout>
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include <QHBoxLayout>
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync/* GUI includes: */
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include "UIWizardFirstRunPageBasic.h"
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include "UIWizardFirstRun.h"
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include "UIIconPool.h"
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include "VBoxGlobal.h"
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include "UIMessageCenter.h"
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include "VBoxMediaComboBox.h"
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include "QIToolButton.h"
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include "QIRichTextLabel.h"
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync#include "UIMedium.h"
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsyncUIWizardFirstRunPage::UIWizardFirstRunPage(bool fBootHardDiskWasSet)
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync : m_fBootHardDiskWasSet(fBootHardDiskWasSet)
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync{
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync}
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsyncvoid UIWizardFirstRunPage::onOpenMediumWithFileOpenDialog()
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync{
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync /* Get opened vboxMedium id: */
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(m_pMediaSelector->type(), thisImp());
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync /* Update medium-combo if necessary: */
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync if (!strMediumId.isNull())
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync m_pMediaSelector->setCurrentItem(strMediumId);
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync}
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsyncQString UIWizardFirstRunPage::id() const
85fc7dbf8f928aea2a6fddde85a77950f69284ddvboxsync{
return m_pMediaSelector->id();
}
void UIWizardFirstRunPage::setId(const QString &strId)
{
m_pMediaSelector->setCurrentItem(strId);
}
UIWizardFirstRunPageBasic::UIWizardFirstRunPageBasic(const QString &strMachineId, bool fBootHardDiskWasSet)
: UIWizardFirstRunPage(fBootHardDiskWasSet)
{
/* Create widgets: */
QVBoxLayout *pMainLayout = new QVBoxLayout(this);
{
pMainLayout->setContentsMargins(8, 0, 8, 0);
pMainLayout->setSpacing(10);
m_pLabel = new QIRichTextLabel(this);
QHBoxLayout *pSourceDiskLayout = new QHBoxLayout;
{
m_pMediaSelector = new VBoxMediaComboBox(this);
{
m_pMediaSelector->setMachineId(strMachineId);
m_pMediaSelector->setType(UIMediumType_DVD);
m_pMediaSelector->repopulate();
}
m_pSelectMediaButton = new QIToolButton(this);
{
m_pSelectMediaButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png"));
m_pSelectMediaButton->setAutoRaise(true);
}
pSourceDiskLayout->addWidget(m_pMediaSelector);
pSourceDiskLayout->addWidget(m_pSelectMediaButton);
}
pMainLayout->addWidget(m_pLabel);
pMainLayout->addLayout(pSourceDiskLayout);
pMainLayout->addStretch();
}
/* Setup connections: */
connect(m_pMediaSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged()));
connect(m_pSelectMediaButton, SIGNAL(clicked()), this, SLOT(sltOpenMediumWithFileOpenDialog()));
/* Register fields: */
registerField("source", this, "source");
registerField("id", this, "id");
}
void UIWizardFirstRunPageBasic::sltOpenMediumWithFileOpenDialog()
{
/* Call to base-class: */
onOpenMediumWithFileOpenDialog();
}
void UIWizardFirstRunPageBasic::retranslateUi()
{
/* Translate widgets: */
if (m_fBootHardDiskWasSet)
m_pLabel->setText(UIWizardFirstRun::tr("<p>Please select a virtual optical disk file "
"or a physical optical drive containing a disk "
"to start your new virtual machine from.</p>"
"<p>The disk should be suitable for starting a computer from "
"and should contain the operating system you wish to install "
"on the virtual machine if you want to do that now. "
"The disk will be ejected from the virtual drive "
"automatically next time you switch the virtual machine off, "
"but you can also do this yourself if needed using the Devices menu.</p>"));
else
m_pLabel->setText(UIWizardFirstRun::tr("<p>Please select a virtual optical disk file "
"or a physical optical drive containing a disk "
"to start your new virtual machine from.</p>"
"<p>The disk should be suitable for starting a computer from. "
"As this virtual machine has no hard drive "
"you will not be able to install an operating system on it at the moment.</p>"));
m_pSelectMediaButton->setToolTip(UIWizardFirstRun::tr("Choose a virtual optical disk file..."));
}
void UIWizardFirstRunPageBasic::initializePage()
{
/* Translate page: */
retranslateUi();
}
bool UIWizardFirstRunPageBasic::isComplete() const
{
/* Make sure valid medium chosen: */
return !vboxGlobal().medium(id()).isNull();
}
bool UIWizardFirstRunPageBasic::validatePage()
{
/* Initial result: */
bool fResult = true;
/* Lock finish button: */
startProcessing();
/* Try to insert chosen medium: */
if (fResult)
fResult = qobject_cast<UIWizardFirstRun*>(wizard())->insertMedium();
/* Unlock finish button: */
endProcessing();
/* Return result: */
return fResult;
}
QString UIWizardFirstRunPageBasic::source() const
{
return m_pMediaSelector->currentText();
}