VBoxNewHDWzd.ui.h revision 2162ed290319349d7c9548c189f1730e594e1a2c
/**
*
* VBox frontends: Qt GUI ("VirtualBox"):
* "New hard disk" wizard UI include (Qt Designer)
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
static const int MinVDISize = 4;
/**
* Composes a file name from the given relative or full file name
* based on the home directory and the default VDI directory.
*/
{
{
// no path info at all, use defaultFolder
}
else if (fi.isRelative())
{
// resolve relatively to homeFolder
}
}
{
const char * aName = 0) :
~QISizeValidator() {}
{
if (position == -1)
return Invalid;
else
{
return Invalid;
return Intermediate;
return Intermediate;
bool result = false;
bool warning = false;
{
size += "0";
warning = true;
}
warning = true;
if (result)
else
return Invalid;
}
}
};
void VBoxNewHDWzd::init()
{
// disable help buttons
helpButton()->setShown( false );
// fix tab order to get the proper direction
// setup connections and set validation for pages
// ----------------------------------------------------------------------
// Image type page
// Name and Size page
);
// Summary page
// filter out Enter keys in order to direct them to the default dlg button
// set initial values
// ----------------------------------------------------------------------
// Image type page
// Name and Size page
sliderStep = 50;
slSize->setTickInterval (0);
// initial HD size value = pow(2.0, 11) = 2048 MB
// limit the max. size of QLineEdit (STUPID Qt has NO correct means for that)
);
// Summary page
// update the next button state for pages with validation
// (validityChanged() connected to enableNext() will do the job)
// the finish button on the Summary page is always enabled
setFinishEnabled (pageSummary, true);
}
{
}
{
currentSize = aSize;
}
{
name += ".vdi";
return name;
}
{
return currentSize;
}
bool VBoxNewHDWzd::isDynamicImage()
{
return rbDynamicType->isOn();
}
{
}
{
// do individual validations for pages
// template:
// QWidget *pg = wval->widget();
// bool valid = wval->isOtherValid();
//
// if ( pg == pageXXX ) {
// valid = XXX;
// }
//
// wval->setOtherValid( valid );
}
{
if (currentPage() == pageNameAndSize)
{
{
return;
}
}
if (page == pageSummary)
{
: rbFixedType->text();
// compose summary
"<table>"
"<tr><td>Type:</td><td>%1</td></tr>"
"<tr><td>Location:</td><td>%2</td></tr>"
"<tr><td>Size:</td><td>%3 MB</td></tr>"
"</table>"
))
// set Finish to default
finishButton()->setDefault (true);
}
else
{
// always set Next to default
nextButton()->setDefault (true);
}
// fix focus on the last page. when we go to the last page
// having the Next in focus the focus goes to the Cancel
// button because when the Next hides Finish is not yet shown.
finishButton()->setFocus();
// setup focus for individual pages
} else if (page == pageNameAndSize) {
} else if (page == pageSummary) {
}
}
void VBoxNewHDWzd::accept()
{
/*
* Try to create the hard disk when the Finish button is pressed.
* On failure, the wisard will remain open to give it another try.
*/
if (createHardDisk())
}
/**
* Performs steps necessary to create a hard disk. This method handles all
* errors and shows the corresponding messages when appropriate.
*
* @return wheter the creation was successful or not
*/
bool VBoxNewHDWzd::createHardDisk()
{
AssertReturn (size > 0, false);
/// @todo (dmik) later, change wrappers so that converting
// to CUnknown is not necessary for cross-assignments
{
return false;
}
if (isDynamicImage())
else
{
return false;
}
if (progress.GetResultCode() != 0)
{
return false;
}
{
vdi.GetFilePath());
/* delete the image file on failure */
vdi.DeleteImage();
return false;
}
return true;
}
{
if (focusWidget() == slSize)
{
}
}
{
if (focusWidget() == leSize)
{
}
}
void VBoxNewHDWzd::tbNameSelect_clicked()
{
// set the first parent directory that exists as the current
do
{
}
{
}
// QFileDialog fd (this, "NewDiskImageDialog", TRUE);
// fd.setMode (QFileDialog::AnyFile);
// fd.setViewMode (QFileDialog::List);
// fd.addFilter (tr( "Hard disk images (*.vdi)" ));
// fd.setCaption (tr( "Select a file for the new hard disk image file" ));
// fd.setDir (d);
fld.absFilePath(),
tr ("Hard disk images (*.vdi)"),
this,
"NewDiskImageDialog",
tr ("Select a file for the new hard disk image file"));
// if ( fd.exec() == QDialog::Accepted ) {
// leName->setText (QDir::convertSeparators (fd.selectedFile()));
if (selected)
{
selected += ".vdi";
}
}