VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMExpertPage.cpp@ 104158

Last change on this file since 104158 was 103957, checked in by vboxsync, 10 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: 7.6 KB
Line 
1/* $Id: UIWizardCloneVMExpertPage.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIWizardCloneVMExpertPage class implementation.
4 */
5
6/*
7 * Copyright (C) 2011-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 <QButtonGroup>
30#include <QCheckBox>
31#include <QGridLayout>
32#include <QGroupBox>
33#include <QLabel>
34#include <QRadioButton>
35
36/* GUI includes: */
37#include "QILineEdit.h"
38#include "UIFilePathSelector.h"
39#include "UIWizardCloneVMExpertPage.h"
40#include "UIWizardCloneVM.h"
41#include "UIWizardCloneVMNamePathPage.h"
42
43/* COM includes: */
44#include "CSystemProperties.h"
45
46
47UIWizardCloneVMExpertPage::UIWizardCloneVMExpertPage(const QString &strOriginalName, const QString &strDefaultPath,
48 bool /*fAdditionalInfo*/, bool fShowChildsOption, const QString &strGroup)
49 : m_pNamePathGroupBox(0)
50 , m_pCloneTypeGroupBox(0)
51 , m_pCloneModeGroupBox(0)
52 , m_pAdditionalOptionsGroupBox(0)
53 , m_strGroup(strGroup)
54{
55 prepare(strOriginalName, strDefaultPath, fShowChildsOption);
56}
57
58void UIWizardCloneVMExpertPage::prepare(const QString &strOriginalName, const QString &strDefaultPath, bool fShowChildsOption)
59{
60 QGridLayout *pMainLayout = new QGridLayout(this);
61 AssertReturnVoid(pMainLayout);
62 m_pNamePathGroupBox = new UICloneVMNamePathEditor(strOriginalName, strDefaultPath);
63 if (m_pNamePathGroupBox)
64 {
65 pMainLayout->addWidget(m_pNamePathGroupBox, 0, 0, 3, 2);
66 connect(m_pNamePathGroupBox, &UICloneVMNamePathEditor::sigCloneNameChanged,
67 this, &UIWizardCloneVMExpertPage::sltCloneNameChanged);
68 connect(m_pNamePathGroupBox, &UICloneVMNamePathEditor::sigClonePathChanged,
69 this, &UIWizardCloneVMExpertPage::sltClonePathChanged);
70 }
71
72 m_pCloneTypeGroupBox = new UICloneVMCloneTypeGroupBox;
73 if (m_pCloneTypeGroupBox)
74 pMainLayout->addWidget(m_pCloneTypeGroupBox, 3, 0, 2, 1);
75
76 m_pCloneModeGroupBox = new UICloneVMCloneModeGroupBox(fShowChildsOption);
77 if (m_pCloneModeGroupBox)
78 pMainLayout->addWidget(m_pCloneModeGroupBox, 3, 1, 2, 1);
79
80 m_pAdditionalOptionsGroupBox = new UICloneVMAdditionalOptionsEditor;
81 if (m_pAdditionalOptionsGroupBox)
82 {
83 pMainLayout->addWidget(m_pAdditionalOptionsGroupBox, 5, 0, 2, 2);
84 connect(m_pAdditionalOptionsGroupBox, &UICloneVMAdditionalOptionsEditor::sigMACAddressClonePolicyChanged,
85 this, &UIWizardCloneVMExpertPage::sltMACAddressClonePolicyChanged);
86 connect(m_pAdditionalOptionsGroupBox, &UICloneVMAdditionalOptionsEditor::sigKeepDiskNamesToggled,
87 this, &UIWizardCloneVMExpertPage::sltKeepDiskNamesToggled);
88 connect(m_pAdditionalOptionsGroupBox, &UICloneVMAdditionalOptionsEditor::sigKeepHardwareUUIDsToggled,
89 this, &UIWizardCloneVMExpertPage::sltKeepHardwareUUIDsToggled);
90 }
91 if (m_pCloneTypeGroupBox)
92 connect(m_pCloneTypeGroupBox, &UICloneVMCloneTypeGroupBox::sigFullCloneSelected,
93 this, &UIWizardCloneVMExpertPage::sltCloneTypeChanged);
94
95 sltRetranslateUI();
96}
97
98void UIWizardCloneVMExpertPage::sltRetranslateUI()
99{
100 /* Translate widgets: */
101 if (m_pNamePathGroupBox)
102 m_pNamePathGroupBox->setTitle(UIWizardCloneVM::tr("New machine &name and path"));
103 if (m_pCloneTypeGroupBox)
104 m_pCloneTypeGroupBox->setTitle(UIWizardCloneVM::tr("Clone type"));
105 if (m_pCloneModeGroupBox)
106 m_pCloneModeGroupBox->setTitle(UIWizardCloneVM::tr("Snapshots"));
107 if (m_pAdditionalOptionsGroupBox)
108 m_pAdditionalOptionsGroupBox->setTitle(UIWizardCloneVM::tr("Additional options"));
109}
110
111void UIWizardCloneVMExpertPage::initializePage()
112{
113 UIWizardCloneVM *pWizard = wizardWindow<UIWizardCloneVM>();
114 AssertReturnVoid(pWizard);
115 if (m_pNamePathGroupBox)
116 {
117 m_pNamePathGroupBox->setFocus();
118 pWizard->setCloneName(m_pNamePathGroupBox->cloneName());
119 pWizard->setCloneFilePath(
120 UIWizardCloneVMNamePathCommon::composeCloneFilePath(m_pNamePathGroupBox->cloneName(), m_strGroup, m_pNamePathGroupBox->clonePath()));
121 }
122 if (m_pAdditionalOptionsGroupBox)
123 {
124 pWizard->setMacAddressPolicy(m_pAdditionalOptionsGroupBox->macAddressClonePolicy());
125 pWizard->setKeepDiskNames(m_pAdditionalOptionsGroupBox->keepDiskNames());
126 pWizard->setKeepHardwareUUIDs(m_pAdditionalOptionsGroupBox->keepHardwareUUIDs());
127 }
128 if (m_pCloneTypeGroupBox)
129 pWizard->setLinkedClone(!m_pCloneTypeGroupBox->isFullClone());
130 if (m_pCloneModeGroupBox)
131 pWizard->setCloneMode(m_pCloneModeGroupBox->cloneMode());
132
133 setCloneModeGroupBoxEnabled();
134
135 sltRetranslateUI();
136}
137
138void UIWizardCloneVMExpertPage::setCloneModeGroupBoxEnabled()
139{
140 UIWizardCloneVM *pWizard = wizardWindow<UIWizardCloneVM>();
141 AssertReturnVoid(pWizard);
142
143 if (m_pCloneModeGroupBox)
144 m_pCloneModeGroupBox->setEnabled(pWizard->machineHasSnapshot() && !pWizard->linkedClone());
145}
146
147bool UIWizardCloneVMExpertPage::isComplete() const
148{
149 return m_pNamePathGroupBox && m_pNamePathGroupBox->isComplete(m_strGroup);
150}
151
152bool UIWizardCloneVMExpertPage::validatePage()
153{
154 AssertReturn(wizardWindow<UIWizardCloneVM>(), false);
155 return wizardWindow<UIWizardCloneVM>()->cloneVM();
156}
157
158void UIWizardCloneVMExpertPage::sltCloneNameChanged(const QString &strCloneName)
159{
160 UIWizardCloneVM *pWizard = wizardWindow<UIWizardCloneVM>();
161 AssertReturnVoid(pWizard);
162 AssertReturnVoid(m_pNamePathGroupBox);
163 pWizard->setCloneName(strCloneName);
164 pWizard->setCloneFilePath(
165 UIWizardCloneVMNamePathCommon::composeCloneFilePath(strCloneName, m_strGroup, m_pNamePathGroupBox->clonePath()));
166 emit completeChanged();
167}
168
169void UIWizardCloneVMExpertPage::sltClonePathChanged(const QString &strClonePath)
170{
171 AssertReturnVoid(m_pNamePathGroupBox && wizardWindow<UIWizardCloneVM>());
172 wizardWindow<UIWizardCloneVM>()->setCloneFilePath(
173 UIWizardCloneVMNamePathCommon::composeCloneFilePath(m_pNamePathGroupBox->cloneName(), m_strGroup, strClonePath));
174 emit completeChanged();
175}
176
177void UIWizardCloneVMExpertPage::sltMACAddressClonePolicyChanged(MACAddressClonePolicy enmMACAddressClonePolicy)
178{
179 AssertReturnVoid(wizardWindow<UIWizardCloneVM>());
180 wizardWindow<UIWizardCloneVM>()->setMacAddressPolicy(enmMACAddressClonePolicy);
181}
182
183void UIWizardCloneVMExpertPage::sltKeepDiskNamesToggled(bool fKeepDiskNames)
184{
185 AssertReturnVoid(wizardWindow<UIWizardCloneVM>());
186 wizardWindow<UIWizardCloneVM>()->setKeepDiskNames(fKeepDiskNames);
187}
188
189void UIWizardCloneVMExpertPage::sltKeepHardwareUUIDsToggled(bool fKeepHardwareUUIDs)
190{
191 AssertReturnVoid(wizardWindow<UIWizardCloneVM>());
192 wizardWindow<UIWizardCloneVM>()->setKeepHardwareUUIDs(fKeepHardwareUUIDs);
193}
194
195void UIWizardCloneVMExpertPage::sltCloneTypeChanged(bool fIsFullClone)
196{
197 UIWizardCloneVM *pWizard = wizardWindow<UIWizardCloneVM>();
198 AssertReturnVoid(pWizard);
199 pWizard->setLinkedClone(!fIsFullClone);
200 setCloneModeGroupBoxEnabled();
201}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette