1 | /* $Id: UIWizardNewCloudVMPageProperties.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardNewCloudVMPageProperties class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-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 <QHeaderView>
|
---|
30 | #include <QVBoxLayout>
|
---|
31 |
|
---|
32 | /* GUI includes: */
|
---|
33 | #include "QIRichTextLabel.h"
|
---|
34 | #include "UIFormEditorWidget.h"
|
---|
35 | #include "UINotificationCenter.h"
|
---|
36 | #include "UIWizardNewCloudVM.h"
|
---|
37 | #include "UIWizardNewCloudVMPageProperties.h"
|
---|
38 |
|
---|
39 | /* Namespaces: */
|
---|
40 | using namespace UIWizardNewCloudVMProperties;
|
---|
41 |
|
---|
42 |
|
---|
43 | /*********************************************************************************************************************************
|
---|
44 | * Namespace UIWizardNewCloudVMProperties implementation. *
|
---|
45 | *********************************************************************************************************************************/
|
---|
46 |
|
---|
47 | void UIWizardNewCloudVMProperties::refreshFormPropertiesTable(UIFormEditorWidget *pFormEditor,
|
---|
48 | const CVirtualSystemDescriptionForm &comForm)
|
---|
49 | {
|
---|
50 | /* Sanity check: */
|
---|
51 | AssertPtrReturnVoid(pFormEditor);
|
---|
52 | AssertReturnVoid(comForm.isNotNull());
|
---|
53 |
|
---|
54 | /* Make sure the properties table get the new description form: */
|
---|
55 | pFormEditor->setVirtualSystemDescriptionForm(comForm);
|
---|
56 | }
|
---|
57 |
|
---|
58 |
|
---|
59 | /*********************************************************************************************************************************
|
---|
60 | * Class UIWizardNewCloudVMPageProperties implementation. *
|
---|
61 | *********************************************************************************************************************************/
|
---|
62 |
|
---|
63 | UIWizardNewCloudVMPageProperties::UIWizardNewCloudVMPageProperties()
|
---|
64 | : m_pLabel(0)
|
---|
65 | , m_pFormEditor(0)
|
---|
66 | {
|
---|
67 | /* Prepare main layout: */
|
---|
68 | QVBoxLayout *pLayoutMain = new QVBoxLayout(this);
|
---|
69 | if (pLayoutMain)
|
---|
70 | {
|
---|
71 | /* Prepare label: */
|
---|
72 | m_pLabel = new QIRichTextLabel(this);
|
---|
73 | if (m_pLabel)
|
---|
74 | pLayoutMain->addWidget(m_pLabel);
|
---|
75 |
|
---|
76 | /* Prepare form editor widget: */
|
---|
77 | m_pFormEditor = new UIFormEditorWidget(this);
|
---|
78 | if (m_pFormEditor)
|
---|
79 | {
|
---|
80 | /* Make form-editor fit 8 sections in height by default: */
|
---|
81 | const int iDefaultSectionHeight = m_pFormEditor->verticalHeader()
|
---|
82 | ? m_pFormEditor->verticalHeader()->defaultSectionSize()
|
---|
83 | : 0;
|
---|
84 | if (iDefaultSectionHeight > 0)
|
---|
85 | m_pFormEditor->setMinimumHeight(8 * iDefaultSectionHeight);
|
---|
86 |
|
---|
87 | /* Add into layout: */
|
---|
88 | pLayoutMain->addWidget(m_pFormEditor);
|
---|
89 | }
|
---|
90 | }
|
---|
91 | }
|
---|
92 |
|
---|
93 | UIWizardNewCloudVM *UIWizardNewCloudVMPageProperties::wizard() const
|
---|
94 | {
|
---|
95 | return qobject_cast<UIWizardNewCloudVM*>(UINativeWizardPage::wizard());
|
---|
96 | }
|
---|
97 |
|
---|
98 | void UIWizardNewCloudVMPageProperties::sltRetranslateUI()
|
---|
99 | {
|
---|
100 | /* Translate page: */
|
---|
101 | setTitle(UIWizardNewCloudVM::tr("Cloud Virtual Machine settings"));
|
---|
102 |
|
---|
103 | /* Translate description label: */
|
---|
104 | m_pLabel->setText(UIWizardNewCloudVM::tr("These are the the suggested settings of the cloud VM creation procedure, they are "
|
---|
105 | "influencing the resulting cloud VM instance. You can change many of the "
|
---|
106 | "properties shown by double-clicking on the items and disable others using the "
|
---|
107 | "check boxes below."));
|
---|
108 | }
|
---|
109 |
|
---|
110 | void UIWizardNewCloudVMPageProperties::initializePage()
|
---|
111 | {
|
---|
112 | /* Make sure form-editor knows notification-center: */
|
---|
113 | m_pFormEditor->setNotificationCenter(wizard()->notificationCenter());
|
---|
114 | /* Generate VSD form, asynchronously: */
|
---|
115 | QMetaObject::invokeMethod(this, "sltInitShortWizardForm", Qt::QueuedConnection);
|
---|
116 | }
|
---|
117 |
|
---|
118 | bool UIWizardNewCloudVMPageProperties::isComplete() const
|
---|
119 | {
|
---|
120 | /* Initial result: */
|
---|
121 | bool fResult = true;
|
---|
122 |
|
---|
123 | /* Check cloud settings: */
|
---|
124 | fResult = wizard()->client().isNotNull()
|
---|
125 | && wizard()->vsd().isNotNull();
|
---|
126 |
|
---|
127 | /* Return result: */
|
---|
128 | return fResult;
|
---|
129 | }
|
---|
130 |
|
---|
131 | bool UIWizardNewCloudVMPageProperties::validatePage()
|
---|
132 | {
|
---|
133 | /* Initial result: */
|
---|
134 | bool fResult = true;
|
---|
135 |
|
---|
136 | /* Make sure table has own data committed: */
|
---|
137 | m_pFormEditor->makeSureEditorDataCommitted();
|
---|
138 |
|
---|
139 | /* Check whether we have proper VSD form: */
|
---|
140 | CVirtualSystemDescriptionForm comForm = wizard()->vsdForm();
|
---|
141 | /* Give changed VSD back: */
|
---|
142 | if (comForm.isNotNull())
|
---|
143 | {
|
---|
144 | comForm.GetVirtualSystemDescription();
|
---|
145 | fResult = comForm.isOk();
|
---|
146 | if (!fResult)
|
---|
147 | UINotificationMessage::cannotAcquireVirtualSystemDescriptionFormParameter(comForm, wizard()->notificationCenter());
|
---|
148 | }
|
---|
149 |
|
---|
150 | /* Try to create cloud VM: */
|
---|
151 | if (fResult)
|
---|
152 | {
|
---|
153 | fResult = wizard()->createCloudVM();
|
---|
154 |
|
---|
155 | /* If the final step failed we could try
|
---|
156 | * sugest user more valid form this time: */
|
---|
157 | if (!fResult)
|
---|
158 | {
|
---|
159 | wizard()->setVSDForm(CVirtualSystemDescriptionForm());
|
---|
160 | sltInitShortWizardForm();
|
---|
161 | }
|
---|
162 | }
|
---|
163 |
|
---|
164 | /* Return result: */
|
---|
165 | return fResult;
|
---|
166 | }
|
---|
167 |
|
---|
168 | void UIWizardNewCloudVMPageProperties::sltInitShortWizardForm()
|
---|
169 | {
|
---|
170 | /* Create Virtual System Description Form: */
|
---|
171 | if (wizard()->vsdForm().isNull())
|
---|
172 | wizard()->createVSDForm();
|
---|
173 |
|
---|
174 | /* Refresh form properties table: */
|
---|
175 | refreshFormPropertiesTable(m_pFormEditor, wizard()->vsdForm());
|
---|
176 | emit completeChanged();
|
---|
177 | }
|
---|