VBoxNewHDWzd.ui.h revision dcea3eadf1ecc8f4ac868185a05a63be42a199e4
/**
*
* VBox frontends: Qt GUI ("VirtualBox"):
* "New hard disk" wizard UI include (Qt Designer)
*/
/*
* Copyright (C) 2006-2008 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/****************************************************************************
** 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. See IMedum::location for
* details.
*/
{
/* Note: the logic below must match the logic of the IMedum::location
* setter, otherwise the returned path may differ from the path actually
* set for the hard disk by the VirtualBox API */
{
/* no path info at all, use defaultFolder */
}
else if (fi.isRelative())
{
/* resolve relatively to homeFolder */
}
}
{
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 */
/* Storage 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 mMaxVDISize */
mSliderScale = 0;
{
if (tickMB < mMaxVDISize)
{
/// @todo (r=dmik) overflow may happen if mMaxVDISize is TOO big
}
}
/* we ask revalidate only when mCurrentSize 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
* ---------------------------------------------------------------------- */
/* Storage type page */
/* Name and Size page */
/// @todo NEWMEDIA use extension as reported by CHardDiskFormat
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());
}
{
}
{
}
{
/* remove all trailing dots to avoid multiple dots before .vdi */
int len;
name += ".vdi";
return name;
}
bool VBoxNewHDWzd::isDynamicStorage()
{
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)
{
mSummaryText->setFocus();
}
}
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 (mCurrentSize > 0, false);
{
progress);
return false;
}
if (isDynamicStorage())
else
{
progress);
return false;
}
{
progress);
return false;
}
/* inform everybody there is a new medium */
return true;
}
{
if (focusWidget() == slSize)
{
}
}
{
if (focusWidget() == leSize)
{
mCurrentSize /= _1M;
}
}
void VBoxNewHDWzd::tbNameSelect_clicked()
{
/* set the first parent directory that exists as the current */
do
{
}
{
}
// QFileDialog fd (this, "NewMediaDialog", 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,
"NewMediaDialog",
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";
}
}