VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMModePage.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: 4.7 KB
Line 
1/* $Id: UIWizardCloneVMModePage.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIWizardCloneVMModePage 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/* Global includes: */
29#include <QVBoxLayout>
30
31/* Local includes: */
32#include "UIWizardCloneVM.h"
33#include "UIWizardCloneVMEditors.h"
34#include "UIWizardCloneVMModePage.h"
35#include "QIRichTextLabel.h"
36
37UIWizardCloneVMModePage::UIWizardCloneVMModePage(bool fShowChildsOption)
38 : m_pLabel(0)
39 , m_pCloneModeGroupBox(0)
40 , m_fShowChildsOption(fShowChildsOption)
41{
42 prepare();
43}
44
45void UIWizardCloneVMModePage::prepare()
46{
47 QVBoxLayout *pMainLayout = new QVBoxLayout(this);
48 AssertReturnVoid(pMainLayout);
49 m_pLabel = new QIRichTextLabel(this);
50
51 if (m_pLabel)
52 pMainLayout->addWidget(m_pLabel);
53
54 m_pCloneModeGroupBox = new UICloneVMCloneModeGroupBox(m_fShowChildsOption);
55 if (m_pCloneModeGroupBox)
56 {
57 pMainLayout->addWidget(m_pCloneModeGroupBox);
58 m_pCloneModeGroupBox->setFlat(true);
59 connect(m_pCloneModeGroupBox, &UICloneVMCloneModeGroupBox::sigCloneModeChanged,
60 this, &UIWizardCloneVMModePage::sltCloneModeChanged);
61 }
62 pMainLayout->addStretch();
63
64 sltRetranslateUI();
65}
66
67void UIWizardCloneVMModePage::sltRetranslateUI()
68{
69 /* Translate page: */
70 setTitle(UIWizardCloneVM::tr("Snapshots"));
71
72 /* Translate widgets: */
73 const QString strGeneral = UIWizardCloneVM::tr("<p>Please choose which parts of the snapshot tree "
74 "should be cloned with the machine.</p>");
75 const QString strOpt1 = UIWizardCloneVM::tr("<p>If you choose <b>Current machine state</b>, "
76 "the new machine will reflect the current state "
77 "of the original machine and will have no snapshots.</p>");
78 const QString strOpt2 = UIWizardCloneVM::tr("<p>If you choose <b>Current snapshot tree branch</b>, "
79 "the new machine will reflect the current state "
80 "of the original machine and will have matching snapshots "
81 "for all snapshots in the tree branch "
82 "starting at the current state in the original machine.</p>");
83 const QString strOpt3 = UIWizardCloneVM::tr("<p>If you choose <b>Everything</b>, "
84 "the new machine will reflect the current state "
85 "of the original machine and will have matching snapshots "
86 "for all snapshots in the original machine.</p>");
87 if (m_fShowChildsOption)
88 m_pLabel->setText(QString("<p>%1</p><p>%2 %3 %4</p>")
89 .arg(strGeneral)
90 .arg(strOpt1)
91 .arg(strOpt2)
92 .arg(strOpt3));
93 else
94 m_pLabel->setText(QString("<p>%1</p><p>%2 %3</p>")
95 .arg(strGeneral)
96 .arg(strOpt1)
97 .arg(strOpt3));
98}
99
100void UIWizardCloneVMModePage::initializePage()
101{
102
103 AssertReturnVoid(wizardWindow<UIWizardCloneVM>());
104 if (m_pCloneModeGroupBox && !m_userModifiedParameters.contains("CloneMode"))
105 wizardWindow<UIWizardCloneVM>()->setCloneMode(m_pCloneModeGroupBox->cloneMode());
106
107 sltRetranslateUI();
108}
109
110bool UIWizardCloneVMModePage::validatePage()
111{
112 bool fResult = true;
113
114 UIWizardCloneVM *pWizard = wizardWindow<UIWizardCloneVM>();
115 AssertReturn(pWizard, false);
116 /* Try to clone VM: */
117 fResult = pWizard->cloneVM();
118
119 return fResult;
120}
121
122void UIWizardCloneVMModePage::sltCloneModeChanged(KCloneMode enmCloneMode)
123{
124 AssertReturnVoid(wizardWindow<UIWizardCloneVM>());
125 m_userModifiedParameters << "CloneMode";
126 wizardWindow<UIWizardCloneVM>()->setCloneMode(enmCloneMode);
127}
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