VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDVariantPage.cpp

Last change on this file was 103957, checked in by vboxsync, 3 months ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in wizard page class hierarchy.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* $Id: UIWizardNewVDVariantPage.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIWizardNewVDVariantPage class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QVBoxLayout>
30
31/* GUI includes: */
32#include "UIWizardDiskEditors.h"
33#include "UIWizardNewVDVariantPage.h"
34#include "UIWizardNewVD.h"
35#include "QIRichTextLabel.h"
36
37/* COM includes: */
38#include "CMediumFormat.h"
39
40UIWizardNewVDVariantPage::UIWizardNewVDVariantPage()
41 : m_pDescriptionLabel(0)
42 , m_pDynamicLabel(0)
43 , m_pFixedLabel(0)
44 , m_pSplitLabel(0)
45 , m_pVariantWidget(0)
46{
47 prepare();
48}
49
50void UIWizardNewVDVariantPage::prepare()
51{
52 QVBoxLayout *pMainLayout = new QVBoxLayout(this);
53 AssertReturnVoid(pMainLayout);
54
55 m_pDescriptionLabel = new QIRichTextLabel;
56 m_pDynamicLabel = new QIRichTextLabel;
57 m_pFixedLabel = new QIRichTextLabel;
58 m_pSplitLabel = new QIRichTextLabel;
59
60 pMainLayout->addWidget(m_pDescriptionLabel);
61 pMainLayout->addWidget(m_pDynamicLabel);
62 pMainLayout->addWidget(m_pFixedLabel);
63 pMainLayout->addWidget(m_pSplitLabel);
64
65 m_pVariantWidget = new UIDiskVariantWidget(0);
66 pMainLayout->addWidget(m_pVariantWidget);
67 pMainLayout->addStretch();
68
69 connect(m_pVariantWidget, &UIDiskVariantWidget::sigMediumVariantChanged,
70 this, &UIWizardNewVDVariantPage::sltMediumVariantChanged);
71 sltRetranslateUI();
72}
73
74void UIWizardNewVDVariantPage::sltRetranslateUI()
75{
76 setTitle(UIWizardNewVD::tr("Storage on physical hard disk"));
77
78 if (m_pDescriptionLabel)
79 m_pDescriptionLabel->setText(UIWizardNewVD::tr("Please choose whether the new virtual hard disk file should grow as it is used "
80 "(dynamically allocated) or if it should be created at its maximum size (fixed size)."));
81 if (m_pDynamicLabel)
82 m_pDynamicLabel->setText(UIWizardNewVD::tr("<p>A <b>dynamically allocated</b> hard disk file will only use space "
83 "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), "
84 "although it will not shrink again automatically when space on it is freed.</p>"));
85 if (m_pFixedLabel)
86 m_pFixedLabel->setText(UIWizardNewVD::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some "
87 "systems but is often faster to use.</p>"));
88 if (m_pSplitLabel)
89 m_pSplitLabel->setText(UIWizardNewVD::tr("<p>You can also choose to <b>split</b> the hard disk file into several files "
90 "of up to two gigabytes each. This is mainly useful if you wish to store the "
91 "virtual machine on removable USB devices or old systems, some of which cannot "
92 "handle very large files."));
93}
94
95void UIWizardNewVDVariantPage::initializePage()
96{
97 UIWizardNewVD *pWizard = wizardWindow<UIWizardNewVD>();
98 AssertReturnVoid(pWizard && m_pVariantWidget);
99 setWidgetVisibility(pWizard->mediumFormat());
100 pWizard->setMediumVariant(m_pVariantWidget->mediumVariant());
101 sltRetranslateUI();
102}
103
104bool UIWizardNewVDVariantPage::isComplete() const
105{
106 if (m_pVariantWidget && m_pVariantWidget->mediumVariant() != (qulonglong)KMediumVariant_Max)
107 return true;
108 return false;
109}
110
111void UIWizardNewVDVariantPage::setWidgetVisibility(const CMediumFormat &mediumFormat)
112{
113 AssertReturnVoid(m_pVariantWidget);
114 m_pVariantWidget->updateMediumVariantWidgetsAfterFormatChange(mediumFormat);
115 if (m_pDynamicLabel)
116 m_pDynamicLabel->setHidden(!m_pVariantWidget->isCreateDynamicPossible());
117 if (m_pFixedLabel)
118 m_pFixedLabel->setHidden(!m_pVariantWidget->isCreateFixedPossible());
119 if (m_pSplitLabel)
120 m_pSplitLabel->setHidden(!m_pVariantWidget->isCreateSplitPossible());
121}
122
123void UIWizardNewVDVariantPage::sltMediumVariantChanged(qulonglong uVariant)
124{
125 AssertReturnVoid(wizardWindow<UIWizardNewVD>());
126 wizardWindow<UIWizardNewVD>()->setMediumVariant(uVariant);
127}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use