1 | /* $Id: UIWizardCloneVMTypePage.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardCloneVMTypePage 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 <QVBoxLayout>
|
---|
30 |
|
---|
31 | /* GUI includes: */
|
---|
32 | #include "UIWizardCloneVMTypePage.h"
|
---|
33 | #include "UIWizardCloneVM.h"
|
---|
34 | #include "QIRichTextLabel.h"
|
---|
35 | #include "UIWizardCloneVMEditors.h"
|
---|
36 |
|
---|
37 | UIWizardCloneVMTypePage::UIWizardCloneVMTypePage(bool fAdditionalInfo)
|
---|
38 | : m_pLabel(0)
|
---|
39 | , m_fAdditionalInfo(fAdditionalInfo)
|
---|
40 | , m_pCloneTypeGroupBox(0)
|
---|
41 | {
|
---|
42 | prepare();
|
---|
43 | }
|
---|
44 |
|
---|
45 | void UIWizardCloneVMTypePage::prepare()
|
---|
46 | {
|
---|
47 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
48 | AssertReturnVoid(pMainLayout);
|
---|
49 | m_pLabel = new QIRichTextLabel(this);
|
---|
50 | if (m_pLabel)
|
---|
51 | pMainLayout->addWidget(m_pLabel);
|
---|
52 |
|
---|
53 | m_pCloneTypeGroupBox = new UICloneVMCloneTypeGroupBox;
|
---|
54 | if (m_pCloneTypeGroupBox)
|
---|
55 | {
|
---|
56 | m_pCloneTypeGroupBox->setFlat(true);
|
---|
57 | pMainLayout->addWidget(m_pCloneTypeGroupBox);
|
---|
58 | connect(m_pCloneTypeGroupBox, &UICloneVMCloneTypeGroupBox::sigFullCloneSelected,
|
---|
59 | this, &UIWizardCloneVMTypePage::sltCloneTypeChanged);
|
---|
60 | }
|
---|
61 |
|
---|
62 | pMainLayout->addStretch();
|
---|
63 | }
|
---|
64 |
|
---|
65 | void UIWizardCloneVMTypePage::sltCloneTypeChanged(bool fIsFullClone)
|
---|
66 | {
|
---|
67 | UIWizardCloneVM *pWizard = wizardWindow<UIWizardCloneVM>();
|
---|
68 | AssertReturnVoid(pWizard);
|
---|
69 | m_userModifiedParameters << "LinkedClone";
|
---|
70 | pWizard->setLinkedClone(!fIsFullClone);
|
---|
71 | /* Show/hide 3rd page according to linked clone toggle: */
|
---|
72 | pWizard->setCloneModePageVisible(fIsFullClone);
|
---|
73 | }
|
---|
74 |
|
---|
75 | void UIWizardCloneVMTypePage::sltRetranslateUI()
|
---|
76 | {
|
---|
77 | /* Translate page: */
|
---|
78 | setTitle(UIWizardCloneVM::tr("Clone type"));
|
---|
79 |
|
---|
80 | /* Translate widgets: */
|
---|
81 | QString strLabel = UIWizardCloneVM::tr("<p>Please choose the type of clone you wish to create.</p>"
|
---|
82 | "<p>If you choose <b>Full clone</b>, "
|
---|
83 | "an exact copy (including all virtual hard disk files) "
|
---|
84 | "of the original virtual machine will be created.</p>"
|
---|
85 | "<p>If you choose <b>Linked clone</b>, "
|
---|
86 | "a new machine will be created, but the virtual hard disk files "
|
---|
87 | "will be tied to the virtual hard disk files of original machine "
|
---|
88 | "and you will not be able to move the new virtual machine "
|
---|
89 | "to a different computer without moving the original as well.</p>");
|
---|
90 | if (m_fAdditionalInfo)
|
---|
91 | strLabel += UIWizardCloneVM::tr("<p>If you create a <b>Linked clone</b> then a new snapshot will be created "
|
---|
92 | "in the original virtual machine as part of the cloning process.</p>");
|
---|
93 | if (m_pLabel)
|
---|
94 | m_pLabel->setText(strLabel);
|
---|
95 | }
|
---|
96 |
|
---|
97 | void UIWizardCloneVMTypePage::initializePage()
|
---|
98 | {
|
---|
99 | AssertReturnVoid(wizardWindow<UIWizardCloneVM>());
|
---|
100 | sltRetranslateUI();
|
---|
101 | if (m_pCloneTypeGroupBox && !m_userModifiedParameters.contains("LinkedClone"))
|
---|
102 | wizardWindow<UIWizardCloneVM>()->setLinkedClone(!m_pCloneTypeGroupBox->isFullClone());
|
---|
103 | }
|
---|
104 |
|
---|
105 | bool UIWizardCloneVMTypePage::validatePage()
|
---|
106 | {
|
---|
107 | UIWizardCloneVM *pWizard = wizardWindow<UIWizardCloneVM>();
|
---|
108 | AssertReturn(pWizard, false);
|
---|
109 |
|
---|
110 | /* This page could be final: */
|
---|
111 | if (!pWizard->isCloneModePageVisible())
|
---|
112 | {
|
---|
113 | /* Initial result: */
|
---|
114 | bool fResult = true;
|
---|
115 |
|
---|
116 | /* Trying to clone VM: */
|
---|
117 | fResult = pWizard->cloneVM();
|
---|
118 |
|
---|
119 | /* Return result: */
|
---|
120 | return fResult;
|
---|
121 | }
|
---|
122 | else
|
---|
123 | return true;
|
---|
124 | }
|
---|