1
/* $Id: UIWizardCloneVDPageBasic3.cpp $ */
4
* VBox frontends: Qt4 GUI ("VirtualBox"):
5
* UIWizardCloneVDPageBasic3 class implementation
9
* Copyright (C) 2006-2012 Oracle Corporation
11
* This file is part of VirtualBox Open Source Edition (OSE), as
12
* available from http://www.virtualbox.org. This file is free software;
13
* you can redistribute it and/or modify it under the terms of the GNU
14
* General Public License (GPL) as published by the Free Software
15
* Foundation, in version 2 as it comes in the "COPYING" file of the
16
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
21
#include <QVBoxLayout>
22
#include <QButtonGroup>
23
#include <QRadioButton>
27
#include "UIWizardCloneVDPageBasic3.h"
28
#include "UIWizardCloneVD.h"
29
#include "QIRichTextLabel.h"
32
#include "CMediumFormat.h"
34
UIWizardCloneVDPage3::UIWizardCloneVDPage3()
38
qulonglong UIWizardCloneVDPage3::mediumVariant() const
41
qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max;
43
/* Exclusive options: */
44
if (m_pDynamicalButton->isChecked())
45
uMediumVariant = (qulonglong)KMediumVariant_Standard;
46
else if (m_pFixedButton->isChecked())
47
uMediumVariant = (qulonglong)KMediumVariant_Fixed;
49
/* Additional options: */
50
if (m_pSplitBox->isChecked())
51
uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G;
54
return uMediumVariant;
57
void UIWizardCloneVDPage3::setMediumVariant(qulonglong uMediumVariant)
59
/* Exclusive options: */
60
if (uMediumVariant & (qulonglong)KMediumVariant_Fixed)
62
m_pFixedButton->click();
63
m_pFixedButton->setFocus();
67
m_pDynamicalButton->click();
68
m_pDynamicalButton->setFocus();
71
/* Additional options: */
72
m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G);
75
UIWizardCloneVDPageBasic3::UIWizardCloneVDPageBasic3()
78
QVBoxLayout *pMainLayout = new QVBoxLayout(this);
80
m_pDescriptionLabel = new QIRichTextLabel(this);
81
m_pDynamicLabel = new QIRichTextLabel(this);
82
m_pFixedLabel = new QIRichTextLabel(this);
83
m_pSplitLabel = new QIRichTextLabel(this);
84
QVBoxLayout *pVariantLayout = new QVBoxLayout;
86
m_pVariantButtonGroup = new QButtonGroup(this);
88
m_pDynamicalButton = new QRadioButton(this);
90
m_pDynamicalButton->click();
91
m_pDynamicalButton->setFocus();
93
m_pFixedButton = new QRadioButton(this);
94
m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
95
m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
97
m_pSplitBox = new QCheckBox(this);
98
pVariantLayout->addWidget(m_pDynamicalButton);
99
pVariantLayout->addWidget(m_pFixedButton);
100
pVariantLayout->addWidget(m_pSplitBox);
102
pMainLayout->addWidget(m_pDescriptionLabel);
103
pMainLayout->addWidget(m_pDynamicLabel);
104
pMainLayout->addWidget(m_pFixedLabel);
105
pMainLayout->addWidget(m_pSplitLabel);
106
pMainLayout->addLayout(pVariantLayout);
107
pMainLayout->addStretch();
110
/* Setup connections: */
111
connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged()));
112
connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged()));
114
/* Register fields: */
115
registerField("mediumVariant", this, "mediumVariant");
118
void UIWizardCloneVDPageBasic3::retranslateUi()
120
/* Translate page: */
121
setTitle(UIWizardCloneVD::tr("Storage on physical hard drive"));
123
/* Translate widgets: */
124
m_pDescriptionLabel->setText(UIWizardCloneVD::tr("Please choose whether the new virtual hard drive file should grow as it is used "
125
"(dynamically allocated) or if it should be created at its maximum size (fixed size)."));
126
m_pDynamicLabel->setText(UIWizardCloneVD::tr("<p>A <b>dynamically allocated</b> hard drive file will only use space "
127
"on your physical hard drive as it fills up (up to a maximum <b>fixed size</b>), "
128
"although it will not shrink again automatically when space on it is freed.</p>"));
129
m_pFixedLabel->setText(UIWizardCloneVD::tr("<p>A <b>fixed size</b> hard drive file may take longer to create on some "
130
"systems but is often faster to use.</p>"));
131
m_pSplitLabel->setText(UIWizardCloneVD::tr("<p>You can also choose to <b>split</b> the hard drive file into several files "
132
"of up to two gigabytes each. This is mainly useful if you wish to store the "
133
"virtual machine on removable USB devices or old systems, some of which cannot "
134
"handle very large files."));
135
m_pDynamicalButton->setText(UIWizardCloneVD::tr("&Dynamically allocated"));
136
m_pFixedButton->setText(UIWizardCloneVD::tr("&Fixed size"));
137
m_pSplitBox->setText(UIWizardCloneVD::tr("&Split into files of less than 2GB"));
140
void UIWizardCloneVDPageBasic3::initializePage()
142
/* Translate page: */
145
/* Setup visibility: */
146
CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
147
ULONG uCapabilities = mediumFormat.GetCapabilities();
148
bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
149
bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
150
bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
151
m_pDynamicLabel->setHidden(!fIsCreateDynamicPossible);
152
m_pDynamicalButton->setHidden(!fIsCreateDynamicPossible);
153
m_pFixedLabel->setHidden(!fIsCreateFixedPossible);
154
m_pFixedButton->setHidden(!fIsCreateFixedPossible);
155
m_pSplitLabel->setHidden(!fIsCreateSplitPossible);
156
m_pSplitBox->setHidden(!fIsCreateSplitPossible);
159
bool UIWizardCloneVDPageBasic3::isComplete() const
161
/* Make sure medium variant is correct: */
162
return mediumVariant() != (qulonglong)KMediumVariant_Max;