VBoxNewHDWzd.ui.h revision 773d8767a22a85e02ba1f6d646c6dd40cea4b41e
/**
*
* VBox frontends: Qt GUI ("VirtualBox"):
* "New hard disk" wizard UI include (Qt Designer)
*/
/*
* Copyright (C) 2006-2007 innotek 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.
*/
/****************************************************************************
** 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.
*****************************************************************************/
/** Minimum VDI size in MB */
/** Initial VDI size in MB */
/**
* 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 */
}
}
/// @todo (r=dmik) not currently used
#if 0
{
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;
}
}
};
#endif
{
int pow = -1;
while (n)
{
++ pow;
n >>= 1;
}
return pow;
}
{
}
{
}
void VBoxNewHDWzd::init()
{
/* disable help buttons */
helpButton()->setShown (false);
/* fix tab order to get the proper direction
/* setup connections and set validation for pages
* ---------------------------------------------------------------------- */
/* setup the label clolors for nice scaling */
/* Image type page */
/* Name and Size page */
/* Detect how many steps to recognize between adjacent powers of 2
* to ensure that the last slider step is exactly maxVDISize */
sliderScale = 0;
{
if (tickMB < maxVDISize)
{
/// @todo (r=dmik) overflow may happen if maxVDISize is TOO big
}
}
/* we ask revalidate only when currentSize is changed after manually
* editing the line edit field; the slider cannot produce invalid values */
/* 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 */
slSize->setTickInterval (0);
/* 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);
/* setup minimum width for the sizeHint to be calculated correctly */
}
{
/* one may think that QWidget::polish() is the right place to do things
* below, but apparently, by the time when QWidget::polish() is called,
* the widget style & layout are not fully done, at least the minimum
* size hint is not properly calculated. Since this is sometimes necessary,
* we provide our own "polish" implementation. */
/* resize to the miminum possible size */
resize (minimumSize());
}
{
}
{
currentSize = aSize;
}
{
/* remove all trailing dots to avoid multiple dots before .vdi */
int len;
/* compare against the proper case */
#if defined (Q_OS_FREEBSD) || defined (Q_OS_LINUX) || defined (Q_OS_NETBSD) || defined (Q_OS_OPENBSD) || defined (Q_OS_SOLARIS)
#else
#endif
if (ext != "vdi")
name += ".vdi";
return name;
}
{
return currentSize;
}
bool VBoxNewHDWzd::isDynamicImage()
{
return rbDynamicType->isOn();
}
{
}
{
/* do individual validations for pages */
if (pg == pageNameAndSize)
{
}
}
{
}
{
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 (%4 Bytes)</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)
{
currentSize /= _1M;
}
}
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";
}
}