VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.cpp

Last change on this file was 103950, checked in by vboxsync, 2 months ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in wizard classes. part 3.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.0 KB
Line 
1/* $Id: UIWizardCloneVMEditors.cpp 103950 2024-03-20 11:41:04Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIUserNamePasswordEditor 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 <QButtonGroup>
30#include <QCheckBox>
31#include <QComboBox>
32#include <QDir>
33#include <QLabel>
34#include <QRadioButton>
35#include <QGridLayout>
36
37/* GUI includes: */
38#include "QILineEdit.h"
39#include "UIFilePathSelector.h"
40#include "UIGlobalSession.h"
41#include "UITranslationEventListener.h"
42#include "UIWizardCloneVM.h"
43#include "UIWizardCloneVMEditors.h"
44
45/* Other VBox includes: */
46#include "iprt/assert.h"
47#include "CSystemProperties.h"
48
49
50/*********************************************************************************************************************************
51* UICloneVMNamePathEditor implementation. *
52*********************************************************************************************************************************/
53
54UICloneVMNamePathEditor::UICloneVMNamePathEditor(const QString &strOriginalName, const QString &strDefaultPath, QWidget *pParent /* = 0 */)
55 : QGroupBox(pParent)
56 , m_pContainerLayout(0)
57 , m_pNameLineEdit(0)
58 , m_pPathSelector(0)
59 , m_pNameLabel(0)
60 , m_pPathLabel(0)
61 , m_strOriginalName(strOriginalName)
62 , m_strDefaultPath(strDefaultPath)
63{
64 prepare();
65}
66
67bool UICloneVMNamePathEditor::isComplete(const QString &strMachineGroup)
68{
69 AssertReturn(m_pNameLineEdit && m_pPathSelector, false);
70
71 bool fInvalidName = m_pNameLineEdit->text().isEmpty();
72 m_pNameLineEdit->mark(fInvalidName, UIWizardCloneVM::tr("Clone name cannot be empty"));
73
74 const QString &strPath = m_pPathSelector->path();
75 QDir dir(strPath);
76 bool fInvalidPath = strPath.isEmpty() || !dir.exists() || !dir.isReadable();
77 m_pPathSelector->mark(fInvalidPath, UIWizardCloneVM::tr("Path is invalid"));
78
79 /* Check if there is already a machine folder for this name and path: */
80 bool fExists = false;
81 if (!fInvalidName)
82 {
83 CVirtualBox vbox = gpGlobalSession->virtualBox();
84 QString strCloneFilePath =
85 vbox.ComposeMachineFilename(m_pNameLineEdit->text(), strMachineGroup, QString(), m_pPathSelector->path());
86 fExists = QDir(QDir::toNativeSeparators(QFileInfo(strCloneFilePath).absolutePath())).exists();
87 m_pNameLineEdit->mark(fExists, UIWizardCloneVM::tr("The clone name is not unique"));
88 }
89
90 return !fInvalidName && !fInvalidPath && !fExists;
91}
92
93QString UICloneVMNamePathEditor::cloneName() const
94{
95 if (m_pNameLineEdit)
96 return m_pNameLineEdit->text();
97 return QString();
98}
99
100void UICloneVMNamePathEditor::setCloneName(const QString &strName)
101{
102 if (m_pNameLineEdit)
103 m_pNameLineEdit->setText(strName);
104}
105
106QString UICloneVMNamePathEditor::clonePath() const
107{
108 if (m_pPathSelector)
109 return m_pPathSelector->path();
110 return QString();
111}
112
113void UICloneVMNamePathEditor::setClonePath(const QString &strPath)
114{
115 if (m_pPathSelector)
116 m_pPathSelector->setPath(strPath);
117}
118
119void UICloneVMNamePathEditor::setFirstColumnWidth(int iWidth)
120{
121 if (m_pContainerLayout)
122 m_pContainerLayout->setColumnMinimumWidth(0, iWidth);
123}
124
125int UICloneVMNamePathEditor::firstColumnWidth() const
126{
127 int iMaxWidth = 0;
128 if (m_pNameLabel)
129 iMaxWidth = qMax(iMaxWidth, m_pNameLabel->minimumSizeHint().width());
130 if (m_pPathLabel)
131 iMaxWidth = qMax(iMaxWidth, m_pPathLabel->minimumSizeHint().width());
132 return iMaxWidth;
133}
134
135void UICloneVMNamePathEditor::setLayoutContentsMargins(int iLeft, int iTop, int iRight, int iBottom)
136{
137 if (m_pContainerLayout)
138 m_pContainerLayout->setContentsMargins(iLeft, iTop, iRight, iBottom);
139}
140
141void UICloneVMNamePathEditor::prepare()
142{
143 m_pContainerLayout = new QGridLayout(this);
144
145
146 m_pNameLabel = new QLabel;
147 if (m_pNameLabel)
148 {
149 m_pNameLabel->setAlignment(Qt::AlignRight);
150 m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
151 m_pContainerLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
152 }
153
154 m_pNameLineEdit = new UIMarkableLineEdit();
155 if (m_pNameLineEdit)
156 {
157 m_pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
158 m_pNameLineEdit->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
159 connect(m_pNameLineEdit, &UIMarkableLineEdit::textChanged,
160 this, &UICloneVMNamePathEditor::sigCloneNameChanged);
161 if (m_pNameLabel)
162 m_pNameLabel->setBuddy(m_pNameLineEdit);
163 }
164
165 m_pPathLabel = new QLabel(this);
166 if (m_pPathLabel)
167 {
168 m_pPathLabel->setAlignment(Qt::AlignRight);
169 m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
170 m_pContainerLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
171 }
172
173 m_pPathSelector = new UIFilePathSelector(this);
174 if (m_pPathSelector)
175 {
176 m_pContainerLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
177 m_pPathSelector->setPath(m_strDefaultPath);
178 connect(m_pPathSelector, &UIFilePathSelector::pathChanged,
179 this, &UICloneVMNamePathEditor::sigClonePathChanged);
180 if (m_pPathLabel)
181 m_pPathLabel->setBuddy(m_pPathSelector);
182
183 }
184
185 sltRetranslateUI();
186 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
187 this, &UICloneVMNamePathEditor::sltRetranslateUI);
188}
189
190void UICloneVMNamePathEditor::sltRetranslateUI()
191{
192 if (m_pNameLabel)
193 m_pNameLabel->setText(UIWizardCloneVM::tr("&Name:"));
194 if (m_pPathLabel)
195 m_pPathLabel->setText(UIWizardCloneVM::tr("&Path:"));
196 if (m_pNameLineEdit)
197 m_pNameLineEdit->setToolTip(UIWizardCloneVM::tr("Holds a name for the new virtual machine."));
198 if (m_pPathSelector)
199 m_pPathSelector->setToolTip(UIWizardCloneVM::tr("Specifies The location of the new virtual machine in host's storage."));
200}
201
202
203/*********************************************************************************************************************************
204* UICloneVMAdditionalOptionsEditor implementation. *
205*********************************************************************************************************************************/
206
207
208UICloneVMAdditionalOptionsEditor::UICloneVMAdditionalOptionsEditor(QWidget *pParent /* = 0 */)
209 : QGroupBox(pParent)
210 , m_pContainerLayout(0)
211 , m_pMACComboBoxLabel(0)
212 , m_pMACComboBox(0)
213 , m_pAdditionalOptionsLabel(0)
214 , m_pKeepDiskNamesCheckBox(0)
215 , m_pKeepHWUUIDsCheckBox(0)
216{
217 prepare();
218}
219
220void UICloneVMAdditionalOptionsEditor::setLayoutContentsMargins(int iLeft, int iTop, int iRight, int iBottom)
221{
222 if (m_pContainerLayout)
223 m_pContainerLayout->setContentsMargins(iLeft, iTop, iRight, iBottom);
224}
225
226void UICloneVMAdditionalOptionsEditor::setFirstColumnWidth(int iWidth)
227{
228 if (m_pContainerLayout)
229 m_pContainerLayout->setColumnMinimumWidth(0, iWidth);
230}
231
232int UICloneVMAdditionalOptionsEditor::firstColumnWidth() const
233{
234 int iMaxWidth = 0;
235 if (m_pMACComboBoxLabel)
236 iMaxWidth = qMax(iMaxWidth, m_pMACComboBoxLabel->minimumSizeHint().width());
237 if (m_pAdditionalOptionsLabel)
238 iMaxWidth = qMax(iMaxWidth, m_pAdditionalOptionsLabel->minimumSizeHint().width());
239 return iMaxWidth;
240}
241
242MACAddressClonePolicy UICloneVMAdditionalOptionsEditor::macAddressClonePolicy() const
243{
244 return m_pMACComboBox->currentData().value<MACAddressClonePolicy>();
245}
246
247void UICloneVMAdditionalOptionsEditor::setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy)
248{
249 const int iIndex = m_pMACComboBox->findData(QVariant::fromValue(enmMACAddressClonePolicy));
250 AssertMsg(iIndex != -1, ("Data not found!"));
251 m_pMACComboBox->setCurrentIndex(iIndex);
252}
253
254bool UICloneVMAdditionalOptionsEditor::keepHardwareUUIDs() const
255{
256 if (m_pKeepHWUUIDsCheckBox)
257 return m_pKeepHWUUIDsCheckBox->isChecked();
258 return false;
259}
260
261bool UICloneVMAdditionalOptionsEditor::keepDiskNames() const
262{
263 if (m_pKeepDiskNamesCheckBox)
264 m_pKeepDiskNamesCheckBox->isChecked();
265 return false;
266}
267
268void UICloneVMAdditionalOptionsEditor::prepare()
269{
270 m_pContainerLayout = new QGridLayout(this);
271
272 m_pMACComboBoxLabel = new QLabel;
273 if (m_pMACComboBoxLabel)
274 {
275 m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
276 m_pContainerLayout->addWidget(m_pMACComboBoxLabel, 2, 0, 1, 1);
277 }
278
279 m_pMACComboBox = new QComboBox;
280 if (m_pMACComboBox)
281 {
282 m_pContainerLayout->addWidget(m_pMACComboBox, 2, 1, 1, 1);
283 connect(m_pMACComboBox, &QComboBox::currentIndexChanged,
284 this, &UICloneVMAdditionalOptionsEditor::sltMACAddressClonePolicyChanged);
285 if (m_pMACComboBoxLabel)
286 m_pMACComboBoxLabel->setBuddy(m_pMACComboBox);
287 }
288 m_pMACComboBox->blockSignals(true);
289 populateMACAddressClonePolicies();
290 m_pMACComboBox->blockSignals(false);
291
292 /* Load currently supported clone options: */
293 CSystemProperties comProperties = gpGlobalSession->virtualBox().GetSystemProperties();
294 const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
295 /* Check whether we support additional clone options at all: */
296 int iVerticalPosition = 3;
297 const bool fSupportedKeepDiskNames = supportedOptions.contains(KCloneOptions_KeepDiskNames);
298 const bool fSupportedKeepHWUUIDs = supportedOptions.contains(KCloneOptions_KeepHwUUIDs);
299 if (fSupportedKeepDiskNames || fSupportedKeepHWUUIDs)
300 {
301 m_pAdditionalOptionsLabel = new QLabel;
302 if (m_pAdditionalOptionsLabel)
303 {
304 m_pAdditionalOptionsLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
305 m_pContainerLayout->addWidget(m_pAdditionalOptionsLabel, iVerticalPosition, 0, 1, 1);
306 }
307 }
308 if (fSupportedKeepDiskNames)
309 {
310 m_pKeepDiskNamesCheckBox = new QCheckBox;
311 if (m_pKeepDiskNamesCheckBox)
312 {
313 m_pContainerLayout->addWidget(m_pKeepDiskNamesCheckBox, iVerticalPosition++, 1, 1, 1);
314 connect(m_pKeepDiskNamesCheckBox, &QCheckBox::toggled,
315 this, &UICloneVMAdditionalOptionsEditor::sigKeepDiskNamesToggled);
316 }
317 }
318 if (fSupportedKeepHWUUIDs)
319 {
320 m_pKeepHWUUIDsCheckBox = new QCheckBox;
321 if (m_pKeepHWUUIDsCheckBox)
322 {
323 m_pContainerLayout->addWidget(m_pKeepHWUUIDsCheckBox, iVerticalPosition++, 1, 1, 1);
324 connect(m_pKeepHWUUIDsCheckBox, &QCheckBox::toggled,
325 this, &UICloneVMAdditionalOptionsEditor::sigKeepHardwareUUIDsToggled);
326 }
327 }
328
329 sltRetranslateUI();
330 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
331 this, &UICloneVMAdditionalOptionsEditor::sltRetranslateUI);
332}
333
334void UICloneVMAdditionalOptionsEditor::sltRetranslateUI()
335{
336 m_pMACComboBoxLabel->setText(UIWizardCloneVM::tr("MAC Address P&olicy:"));
337 m_pMACComboBox->setToolTip(UIWizardCloneVM::tr("Determines MAC address policy for clonning:"));
338 for (int i = 0; i < m_pMACComboBox->count(); ++i)
339 {
340 const MACAddressClonePolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressClonePolicy>();
341 switch (enmPolicy)
342 {
343 case MACAddressClonePolicy_KeepAllMACs:
344 {
345 m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses"));
346 m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include all network adapter MAC addresses during "
347 "cloning."), Qt::ToolTipRole);
348 break;
349 }
350 case MACAddressClonePolicy_KeepNATMACs:
351 {
352 m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses"));
353 m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Include only NAT network adapter MAC addresses during "
354 "cloning."), Qt::ToolTipRole);
355 break;
356 }
357 case MACAddressClonePolicy_StripAllMACs:
358 {
359 m_pMACComboBox->setItemText(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters"));
360 m_pMACComboBox->setItemData(i, UIWizardCloneVM::tr("Generate new MAC addresses for all network adapters during "
361 "cloning."), Qt::ToolTipRole);
362 break;
363 }
364 default:
365 break;
366 }
367 }
368
369 if (m_pAdditionalOptionsLabel)
370 m_pAdditionalOptionsLabel->setText(UIWizardCloneVM::tr("Additional Options:"));
371 if (m_pKeepDiskNamesCheckBox)
372 {
373 m_pKeepDiskNamesCheckBox->setToolTip(UIWizardCloneVM::tr("When checked, disk names will be preserved during cloning."));
374 m_pKeepDiskNamesCheckBox->setText(UIWizardCloneVM::tr("Keep &Disk Names"));
375 }
376 if (m_pKeepHWUUIDsCheckBox)
377 {
378 m_pKeepHWUUIDsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked, hardware UUIDs will be preserved during cloning."));
379 m_pKeepHWUUIDsCheckBox->setText(UIWizardCloneVM::tr("Keep Hard&ware UUIDs"));
380 }
381}
382
383void UICloneVMAdditionalOptionsEditor::sltMACAddressClonePolicyChanged()
384{
385 emit sigMACAddressClonePolicyChanged(macAddressClonePolicy());
386 updateMACAddressClonePolicyComboToolTip();
387}
388
389void UICloneVMAdditionalOptionsEditor::updateMACAddressClonePolicyComboToolTip()
390{
391 if (!m_pMACComboBox)
392 return;
393 const QString strCurrentToolTip = m_pMACComboBox->currentData(Qt::ToolTipRole).toString();
394 AssertMsg(!strCurrentToolTip.isEmpty(), ("Tool-tip data not found!"));
395 m_pMACComboBox->setToolTip(strCurrentToolTip);
396}
397
398void UICloneVMAdditionalOptionsEditor::populateMACAddressClonePolicies()
399{
400 AssertReturnVoid(m_pMACComboBox && m_pMACComboBox->count() == 0);
401
402 /* Map known clone options to known MAC address export policies: */
403 QMap<KCloneOptions, MACAddressClonePolicy> knownOptions;
404 knownOptions[KCloneOptions_KeepAllMACs] = MACAddressClonePolicy_KeepAllMACs;
405 knownOptions[KCloneOptions_KeepNATMACs] = MACAddressClonePolicy_KeepNATMACs;
406
407 /* Load currently supported clone options: */
408 CSystemProperties comProperties = gpGlobalSession->virtualBox().GetSystemProperties();
409 const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
410
411 /* Check which of supported options/policies are known: */
412 QList<MACAddressClonePolicy> supportedPolicies;
413 foreach (const KCloneOptions &enmOption, supportedOptions)
414 if (knownOptions.contains(enmOption))
415 supportedPolicies << knownOptions.value(enmOption);
416
417 /* Add supported policies first: */
418 foreach (const MACAddressClonePolicy &enmPolicy, supportedPolicies)
419 m_pMACComboBox->addItem(QString(), QVariant::fromValue(enmPolicy));
420
421 /* Add hardcoded policy finally: */
422 m_pMACComboBox->addItem(QString(), QVariant::fromValue(MACAddressClonePolicy_StripAllMACs));
423
424 /* Set default: */
425 if (supportedPolicies.contains(MACAddressClonePolicy_KeepNATMACs))
426 setMACAddressClonePolicy(MACAddressClonePolicy_KeepNATMACs);
427 else
428 setMACAddressClonePolicy(MACAddressClonePolicy_StripAllMACs);
429}
430
431
432/*********************************************************************************************************************************
433* UICloneVMAdditionalOptionsEditor implementation. *
434*********************************************************************************************************************************/
435
436UICloneVMCloneTypeGroupBox::UICloneVMCloneTypeGroupBox(QWidget *pParent /* = 0 */)
437 : QGroupBox(pParent)
438 , m_pButtonGroup(0)
439 , m_pFullCloneRadio(0)
440 , m_pLinkedCloneRadio(0)
441{
442 prepare();
443}
444
445bool UICloneVMCloneTypeGroupBox::isFullClone() const
446{
447 if (m_pFullCloneRadio)
448 return m_pFullCloneRadio->isChecked();
449 return true;
450}
451
452void UICloneVMCloneTypeGroupBox::prepare()
453{
454 QVBoxLayout *pMainLayout = new QVBoxLayout(this);
455 AssertReturnVoid(pMainLayout);
456 /* Prepare clone-type options button-group: */
457 m_pButtonGroup = new QButtonGroup(this);
458 if (m_pButtonGroup)
459 {
460 /* Prepare full clone option radio-button: */
461 m_pFullCloneRadio = new QRadioButton(this);
462 if (m_pFullCloneRadio)
463 {
464 m_pFullCloneRadio->setChecked(true);
465 m_pButtonGroup->addButton(m_pFullCloneRadio);
466 pMainLayout->addWidget(m_pFullCloneRadio);
467 }
468
469 /* Load currently supported clone options: */
470 CSystemProperties comProperties = gpGlobalSession->virtualBox().GetSystemProperties();
471 const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
472 /* Check whether we support linked clone option at all: */
473 const bool fSupportedLinkedClone = supportedOptions.contains(KCloneOptions_Link);
474
475 /* Prepare linked clone option radio-button: */
476 if (fSupportedLinkedClone)
477 {
478 m_pLinkedCloneRadio = new QRadioButton(this);
479 if (m_pLinkedCloneRadio)
480 {
481 m_pButtonGroup->addButton(m_pLinkedCloneRadio);
482 pMainLayout->addWidget(m_pLinkedCloneRadio);
483 }
484 }
485 }
486
487 connect(m_pButtonGroup, &QButtonGroup::buttonClicked,
488 this, &UICloneVMCloneTypeGroupBox::sltButtonClicked);
489
490 sltRetranslateUI();
491 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
492 this, &UICloneVMCloneTypeGroupBox::sltRetranslateUI);
493}
494
495void UICloneVMCloneTypeGroupBox::sltRetranslateUI()
496{
497 if (m_pFullCloneRadio)
498 {
499 m_pFullCloneRadio->setText(UIWizardCloneVM::tr("&Full clone"));
500 m_pFullCloneRadio->setToolTip(UIWizardCloneVM::tr("When chosen, all the virtual disks of the source vm are also cloned."));
501 }
502 if (m_pLinkedCloneRadio)
503 {
504 m_pLinkedCloneRadio->setText(UIWizardCloneVM::tr("&Linked clone"));
505 m_pLinkedCloneRadio->setToolTip(UIWizardCloneVM::tr("When chosen, the cloned vm will save space by sharing the source VM's disk images."));
506 }
507}
508
509void UICloneVMCloneTypeGroupBox::sltButtonClicked(QAbstractButton *)
510{
511 emit sigFullCloneSelected(m_pFullCloneRadio && m_pFullCloneRadio->isChecked());
512}
513
514
515/*********************************************************************************************************************************
516* UICloneVMAdditionalOptionsEditor implementation. *
517*********************************************************************************************************************************/
518
519UICloneVMCloneModeGroupBox::UICloneVMCloneModeGroupBox(bool fShowChildsOption, QWidget *pParent /* = 0 */)
520 : QGroupBox(pParent)
521 , m_fShowChildsOption(fShowChildsOption)
522 , m_pMachineRadio(0)
523 , m_pMachineAndChildsRadio(0)
524 , m_pAllRadio(0)
525{
526 prepare();
527}
528
529void UICloneVMCloneModeGroupBox::prepare()
530{
531 QVBoxLayout *pMainLayout = new QVBoxLayout(this);
532 AssertReturnVoid(pMainLayout);
533
534 QButtonGroup *pButtonGroup = new QButtonGroup(this);
535 m_pMachineRadio = new QRadioButton(this);
536 if (m_pMachineRadio)
537 {
538 m_pMachineRadio->setChecked(true);
539 pButtonGroup->addButton(m_pMachineRadio);
540 }
541 m_pMachineAndChildsRadio = new QRadioButton(this);
542 if (m_pMachineAndChildsRadio)
543 {
544 if (!m_fShowChildsOption)
545 m_pMachineAndChildsRadio->hide();
546 pButtonGroup->addButton(m_pMachineAndChildsRadio);
547 }
548
549 m_pAllRadio = new QRadioButton(this);
550 if (m_pAllRadio)
551 pButtonGroup->addButton(m_pAllRadio);
552
553 pMainLayout->addWidget(m_pMachineRadio);
554 pMainLayout->addWidget(m_pMachineAndChildsRadio);
555 pMainLayout->addWidget(m_pAllRadio);
556 pMainLayout->addStretch();
557
558 connect(pButtonGroup, &QButtonGroup::buttonClicked,
559 this, &UICloneVMCloneModeGroupBox::sltButtonClicked);
560
561 sltRetranslateUI();
562 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
563 this, &UICloneVMCloneModeGroupBox::sltRetranslateUI);
564}
565
566void UICloneVMCloneModeGroupBox::sltRetranslateUI()
567{
568 if (m_pMachineRadio)
569 {
570 m_pMachineRadio->setText(UIWizardCloneVM::tr("Current &machine state"));
571 m_pMachineRadio->setToolTip(UIWizardCloneVM::tr("When chosen, only the current state of the source vm is cloned."));
572 }
573 if (m_pMachineAndChildsRadio)
574 m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current &snapshot tree branch"));
575 if (m_pAllRadio)
576 {
577 m_pAllRadio->setText(UIWizardCloneVM::tr("&Everything"));
578 m_pAllRadio->setToolTip(UIWizardCloneVM::tr("When chosen, all the saved states of the source vm are also cloned."));
579 }
580}
581
582
583void UICloneVMCloneModeGroupBox::sltButtonClicked()
584{
585 emit sigCloneModeChanged(cloneMode());
586}
587
588KCloneMode UICloneVMCloneModeGroupBox::cloneMode() const
589{
590 KCloneMode enmCloneMode = KCloneMode_MachineState;
591 if (m_pMachineAndChildsRadio && m_pMachineAndChildsRadio->isChecked())
592 enmCloneMode = KCloneMode_MachineAndChildStates;
593 else if (m_pAllRadio && m_pAllRadio->isChecked())
594 enmCloneMode = KCloneMode_AllStates;
595 return enmCloneMode;
596}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use