UINewHDWzd.cpp revision 293b40a351e7cd8db46b9e10afe2603b93a53efb
/* $Id$ */
/** @file
*
* VBox frontends: Qt4 GUI ("VirtualBox"):
* UINewHDWzd class implementation
*/
/*
* Copyright (C) 2006-2010 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.
*/
/* Local includes */
#include "UIIconPool.h"
#include "UINewHDWzd.h"
#include "VBoxGlobal.h"
#include "VBoxProblemReporter.h"
/* Global includes */
#include <QFileDialog>
#include <QRegExpValidator>
{
/* Create & add pages */
addPage(new UINewHDWzdPage1);
addPage(new UINewHDWzdPage2);
addPage(new UINewHDWzdPage3);
addPage(new UINewHDWzdPage4);
/* Initial translate */
/* Initial translate all pages */
/* Resize to 'golden ratio' */
#ifdef Q_WS_MAC
/* Assign background image */
assignBackground(":/vmw_new_harddisk_bg.png");
#else /* Q_WS_MAC */
/* Assign watermark */
assignWatermark(":/vmw_new_harddisk.png");
#endif /* Q_WS_MAC */
}
{
/* Get 'hardDisk' field value from page 4 */
}
{
/* Set 'initialName' field value for page 3 */
}
{
/* Set 'initialSize' field value for page 3 */
}
{
}
{
/* Wrap file-info around received file name: */
/* If there is no path info at all or its relative: */
{
/* Resolve path on the basis of m_strDefaultPath: */
}
/* Return full absolute hard disk file path: */
}
void UINewHDWzd::retranslateUi()
{
/* Wizard title */
}
{
/* Decorate page */
}
void UINewHDWzdPage1::retranslateUi()
{
/* Translate uic generated strings */
/* Wizard page 1 title */
"for your virtual machine.</p><p>%1</p>")
.arg(standardHelpText()));
}
void UINewHDWzdPage1::initializePage()
{
/* Fill and translate */
}
, m_bFixed(false)
{
/* Decorate page */
/* Register 'type', 'fixed' fields */
/* Setup connections */
}
void UINewHDWzdPage2::retranslateUi()
{
/* Translate uic generated strings */
/* Wizard page 2 title */
}
void UINewHDWzdPage2::initializePage()
{
/* Fill and translate */
/* Prepare initial choice */
m_pTypeDynamic->click();
/* 'Dynamic' choice should have focus initially */
}
void UINewHDWzdPage2::onTypeChanged()
{
if (m_pTypeDynamic->isChecked())
{
/* 'Dynamic' storage type */
m_bFixed = false;
}
else if (m_pTypeFixed->isChecked())
{
/* 'Fixed' storage type */
m_bFixed = true;
}
else
{
/* Not complete */
m_bFixed = false;
}
}
: m_strInitialName("NewHardDisk1.vdi")
, m_strCurrentName(QString())
, m_strLocation(QString())
, m_uCurrentSize(0)
, m_uMinVDISize(_4M)
, m_iSliderScale(0)
{
/* Decorate page */
/* Register 'initialName', 'currentName', 'location' &
* 'initialSize', 'currentSize' fields */
/* Detect how many steps to recognize between adjacent powers of 2
* to ensure that the last slider step is exactly m_uMaxVDISize */
if (uTickMB < m_uMaxVDISize)
{
}
/* Setup size-editor field */
/* Setup size-slider */
/* Attach button icon */
"select_file_dis_16px.png"));
/* Setup page connections */
connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SLOT(onLocationEditorTextChanged(const QString &)));
connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(onSizeEditorTextChanged(const QString &)));
}
void UINewHDWzdPage3::retranslateUi()
{
/* Translate uic generated strings */
/* Wizard page 3 title */
}
void UINewHDWzdPage3::initializePage()
{
/* Fill and translate */
/* Initialise location */
/* Initialise size */
/* 'Size' editor should have focus initially */
}
void UINewHDWzdPage3::cleanupPage()
{
/* Do not call superclass method! */
}
bool UINewHDWzdPage3::isComplete() const
{
/* Check what 'currentSize' field value feats the bounds &
* what 'currentName' field text is not empty! */
}
bool UINewHDWzdPage3::validatePage()
{
{
return false;
}
return true;
}
{
/* Set current name */
/* Set current fileName */
/* Notify wizard sub-system about complete status changed: */
}
{
/* Get parent wizard: */
/* Get current folder and filename: */
/* Set the first parent foler that exists as the current: */
/* But if it doesn't exists at all: */
{
/* Use recommended one folder: */
}
QString selected = QFileDialog::getSaveFileName(this, tr("Select a file for the new hard disk image file"),
{
selected += ".vdi";
}
}
{
/* Update currently stored size: */
/* Update tooltip: */
/* Notify size-editor about size had changed preventing callback: */
m_pSizeEditor->blockSignals(true);
m_pSizeEditor->blockSignals(false);
/* Notify wizard sub-system about complete status changed: */
}
{
/* Update currently stored size: */
/* Update tooltip: */
/* Notify size-slider about size had changed preventing callback: */
m_pSizeSlider->blockSignals(true);
m_pSizeSlider->blockSignals(false);
/* Notify wizard sub-system about complete status changed: */
}
{
/* Remove all trailing dots to avoid multiple dots before .vdi */
int len;
fileName += ".vdi";
return fileName;
}
{
int iPower = -1;
while (uValue)
{
++ iPower;
uValue >>= 1;
}
return iPower;
}
{
}
{
}
{
}
{
/* Decorate page */
/* Register CMedium class */
/* Register 'hardDisk' field */
/* Disable the background painting of the summary widget */
/* Make the summary field read-only */
m_pSummaryText->setReadOnly (true);
}
void UINewHDWzdPage4::retranslateUi()
{
/* Translate uic generated strings */
/* Wizard page 4 title */
/* Compose common summary */
QString location = qobject_cast<UINewHDWzd*>(wizard())->absoluteFilePath(field("location").toString());
(
"<tr><td><nobr>%1: </nobr></td><td><nobr>%2</nobr></td></tr>"
"<tr><td><nobr>%3: </nobr></td><td><nobr>%4</nobr></td></tr>"
"<tr><td><nobr>%5: </nobr></td><td><nobr>%6 (%7)</nobr></td></tr>"
)
;
/* Feat summary to 3 lines */
"Once you press it, a new hard disk will be created.")
.arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton)))));
}
void UINewHDWzdPage4::initializePage()
{
/* Fill and translate */
/* Summary should have focus initially */
}
bool UINewHDWzdPage4::validatePage()
{
/* Try to construct hard disk */
return createHardDisk();
}
bool UINewHDWzdPage4::createHardDisk()
{
QString location = qobject_cast<UINewHDWzd*>(wizard())->absoluteFilePath(field("location").toString());
AssertReturn(size > 0, false);
{
return false;
}
if (isFixed)
{
return false;
}
if (progress.GetCanceled())
return false;
{
return false;
}
/* Inform everybody there is a new medium */
vboxGlobal().addMedium(VBoxMedium(CMedium(hardDisk), VBoxDefs::MediumType_HardDisk, KMediumState_Created));
return true;
}