1 | /* $Id: UIWizardImportAppPageExpert.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardImportAppPageExpert 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 <QCheckBox>
|
---|
30 | #include <QFileInfo>
|
---|
31 | #include <QGroupBox>
|
---|
32 | #include <QHeaderView>
|
---|
33 | #include <QLabel>
|
---|
34 | #include <QListWidget>
|
---|
35 | #include <QPushButton>
|
---|
36 | #include <QStackedWidget>
|
---|
37 | #include <QTableWidget>
|
---|
38 | #include <QVBoxLayout>
|
---|
39 |
|
---|
40 | /* GUI includes: */
|
---|
41 | #include "QIComboBox.h"
|
---|
42 | #include "QIToolButton.h"
|
---|
43 | #include "UIApplianceImportEditorWidget.h"
|
---|
44 | #include "UICommon.h"
|
---|
45 | #include "UIEmptyFilePathSelector.h"
|
---|
46 | #include "UIFilePathSelector.h"
|
---|
47 | #include "UIFormEditorWidget.h"
|
---|
48 | #include "UIGlobalSession.h"
|
---|
49 | #include "UIIconPool.h"
|
---|
50 | #include "UINotificationCenter.h"
|
---|
51 | #include "UIToolBox.h"
|
---|
52 | #include "UIVirtualBoxEventHandler.h"
|
---|
53 | #include "UIVirtualBoxManager.h"
|
---|
54 | #include "UIWizardImportApp.h"
|
---|
55 | #include "UIWizardImportAppPageExpert.h"
|
---|
56 | #include "UIWizardImportAppPageSettings.h"
|
---|
57 | #include "UIWizardImportAppPageSource.h"
|
---|
58 |
|
---|
59 | /* COM includes: */
|
---|
60 | #include "CSystemProperties.h"
|
---|
61 |
|
---|
62 | /* Namespaces: */
|
---|
63 | using namespace UIWizardImportAppSettings;
|
---|
64 | using namespace UIWizardImportAppSource;
|
---|
65 |
|
---|
66 |
|
---|
67 | UIWizardImportAppPageExpert::UIWizardImportAppPageExpert(bool fImportFromOCIByDefault, const QString &strFileName)
|
---|
68 | : m_fImportFromOCIByDefault(fImportFromOCIByDefault)
|
---|
69 | , m_strFileName(strFileName)
|
---|
70 | , m_pToolBox(0)
|
---|
71 | , m_pSourceLayout(0)
|
---|
72 | , m_pSourceLabel(0)
|
---|
73 | , m_pSourceComboBox(0)
|
---|
74 | , m_pSettingsWidget1(0)
|
---|
75 | , m_pLocalContainerLayout(0)
|
---|
76 | , m_pFileSelector(0)
|
---|
77 | , m_pCloudContainerLayout(0)
|
---|
78 | , m_pProfileComboBox(0)
|
---|
79 | , m_pProfileToolButton(0)
|
---|
80 | , m_pProfileInstanceList(0)
|
---|
81 | , m_pSettingsWidget2(0)
|
---|
82 | , m_pApplianceWidget(0)
|
---|
83 | , m_pLabelImportFilePath(0)
|
---|
84 | , m_pEditorImportFilePath(0)
|
---|
85 | , m_pLabelMACImportPolicy(0)
|
---|
86 | , m_pComboMACImportPolicy(0)
|
---|
87 | , m_pLabelAdditionalOptions(0)
|
---|
88 | , m_pCheckboxImportHDsAsVDI(0)
|
---|
89 | , m_pFormEditor(0)
|
---|
90 | {
|
---|
91 | /* Prepare main layout: */
|
---|
92 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
93 | if (pMainLayout)
|
---|
94 | {
|
---|
95 | /* Prepare tool-box: */
|
---|
96 | m_pToolBox = new UIToolBox(this);
|
---|
97 | if (m_pToolBox)
|
---|
98 | {
|
---|
99 | /* Prepare source widget: */
|
---|
100 | QWidget *pWidgetSource = new QWidget(m_pToolBox);
|
---|
101 | if (pWidgetSource)
|
---|
102 | {
|
---|
103 | /* Prepare source layout: */
|
---|
104 | m_pSourceLayout = new QGridLayout(pWidgetSource);
|
---|
105 | if (m_pSourceLayout)
|
---|
106 | {
|
---|
107 | m_pSourceLayout->setContentsMargins(0, 0, 0, 0);
|
---|
108 |
|
---|
109 | /* Prepare source combo: */
|
---|
110 | m_pSourceComboBox = new QIComboBox(pWidgetSource);
|
---|
111 | if (m_pSourceComboBox)
|
---|
112 | m_pSourceLayout->addWidget(m_pSourceComboBox, 0, 0);
|
---|
113 |
|
---|
114 | /* Prepare settings widget 1: */
|
---|
115 | m_pSettingsWidget1 = new QStackedWidget(pWidgetSource);
|
---|
116 | if (m_pSettingsWidget1)
|
---|
117 | {
|
---|
118 | /* Prepare local container: */
|
---|
119 | QWidget *pContainerLocal = new QWidget(m_pSettingsWidget1);
|
---|
120 | if (pContainerLocal)
|
---|
121 | {
|
---|
122 | /* Prepare local widget layout: */
|
---|
123 | m_pLocalContainerLayout = new QGridLayout(pContainerLocal);
|
---|
124 | if (m_pLocalContainerLayout)
|
---|
125 | {
|
---|
126 | m_pLocalContainerLayout->setContentsMargins(0, 0, 0, 0);
|
---|
127 | m_pLocalContainerLayout->setRowStretch(1, 1);
|
---|
128 |
|
---|
129 | /* Prepare file-path selector: */
|
---|
130 | m_pFileSelector = new UIEmptyFilePathSelector(pContainerLocal);
|
---|
131 | if (m_pFileSelector)
|
---|
132 | {
|
---|
133 | m_pFileSelector->setHomeDir(uiCommon().documentsPath());
|
---|
134 | m_pFileSelector->setMode(UIEmptyFilePathSelector::Mode_File_Open);
|
---|
135 | m_pFileSelector->setButtonPosition(UIEmptyFilePathSelector::RightPosition);
|
---|
136 | m_pFileSelector->setEditable(true);
|
---|
137 | m_pLocalContainerLayout->addWidget(m_pFileSelector, 0, 0);
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | /* Add into widget: */
|
---|
142 | m_pSettingsWidget1->addWidget(pContainerLocal);
|
---|
143 | }
|
---|
144 |
|
---|
145 | /* Prepare cloud container: */
|
---|
146 | QWidget *pContainerCloud = new QWidget(m_pSettingsWidget1);
|
---|
147 | if (pContainerCloud)
|
---|
148 | {
|
---|
149 | /* Prepare cloud container layout: */
|
---|
150 | m_pCloudContainerLayout = new QGridLayout(pContainerCloud);
|
---|
151 | if (m_pCloudContainerLayout)
|
---|
152 | {
|
---|
153 | m_pCloudContainerLayout->setContentsMargins(0, 0, 0, 0);
|
---|
154 | m_pCloudContainerLayout->setRowStretch(1, 1);
|
---|
155 |
|
---|
156 | /* Prepare profile layout: */
|
---|
157 | QHBoxLayout *pLayoutProfile = new QHBoxLayout;
|
---|
158 | if (pLayoutProfile)
|
---|
159 | {
|
---|
160 | pLayoutProfile->setContentsMargins(0, 0, 0, 0);
|
---|
161 | pLayoutProfile->setSpacing(1);
|
---|
162 |
|
---|
163 | /* Prepare profile combo-box: */
|
---|
164 | m_pProfileComboBox = new QIComboBox(pContainerCloud);
|
---|
165 | if (m_pProfileComboBox)
|
---|
166 | pLayoutProfile->addWidget(m_pProfileComboBox);
|
---|
167 |
|
---|
168 | /* Prepare profile tool-button: */
|
---|
169 | m_pProfileToolButton = new QIToolButton(pContainerCloud);
|
---|
170 | if (m_pProfileToolButton)
|
---|
171 | {
|
---|
172 | m_pProfileToolButton->setIcon(UIIconPool::iconSet(":/cloud_profile_manager_16px.png",
|
---|
173 | ":/cloud_profile_manager_disabled_16px.png"));
|
---|
174 | pLayoutProfile->addWidget(m_pProfileToolButton);
|
---|
175 | }
|
---|
176 |
|
---|
177 | /* Add into layout: */
|
---|
178 | m_pCloudContainerLayout->addLayout(pLayoutProfile, 0, 0);
|
---|
179 | }
|
---|
180 |
|
---|
181 | /* Create profile instances table: */
|
---|
182 | m_pProfileInstanceList = new QListWidget(pContainerCloud);
|
---|
183 | if (m_pProfileInstanceList)
|
---|
184 | {
|
---|
185 | const QFontMetrics fm(m_pProfileInstanceList->font());
|
---|
186 | #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
---|
187 | const int iFontWidth = fm.horizontalAdvance('x');
|
---|
188 | #else
|
---|
189 | const int iFontWidth = fm.width('x');
|
---|
190 | #endif
|
---|
191 | const int iTotalWidth = 50 * iFontWidth;
|
---|
192 | const int iFontHeight = fm.height();
|
---|
193 | const int iTotalHeight = 4 * iFontHeight;
|
---|
194 | m_pProfileInstanceList->setMinimumSize(QSize(iTotalWidth, iTotalHeight));
|
---|
195 | // m_pProfileInstanceList->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
---|
196 | m_pProfileInstanceList->setAlternatingRowColors(true);
|
---|
197 | m_pCloudContainerLayout->addWidget(m_pProfileInstanceList, 1, 0);
|
---|
198 | }
|
---|
199 | }
|
---|
200 |
|
---|
201 | /* Add into widget: */
|
---|
202 | m_pSettingsWidget1->addWidget(pContainerCloud);
|
---|
203 | }
|
---|
204 |
|
---|
205 | /* Add into layout: */
|
---|
206 | m_pSourceLayout->addWidget(m_pSettingsWidget1, 1, 0);
|
---|
207 | }
|
---|
208 | }
|
---|
209 |
|
---|
210 | /* Add into tool-box: */
|
---|
211 | m_pToolBox->insertPage(0, pWidgetSource, QString());
|
---|
212 | }
|
---|
213 |
|
---|
214 | /* Prepare settings widget 2: */
|
---|
215 | m_pSettingsWidget2 = new QStackedWidget(m_pToolBox);
|
---|
216 | if (m_pSettingsWidget2)
|
---|
217 | {
|
---|
218 | /* Prepare appliance container: */
|
---|
219 | QWidget *pContainerAppliance = new QWidget(m_pSettingsWidget2);
|
---|
220 | if (pContainerAppliance)
|
---|
221 | {
|
---|
222 | /* Prepare appliance layout: */
|
---|
223 | QGridLayout *pLayoutAppliance = new QGridLayout(pContainerAppliance);
|
---|
224 | if (pLayoutAppliance)
|
---|
225 | {
|
---|
226 | pLayoutAppliance->setContentsMargins(0, 0, 0, 0);
|
---|
227 |
|
---|
228 | /* Prepare appliance widget: */
|
---|
229 | m_pApplianceWidget = new UIApplianceImportEditorWidget(pContainerAppliance);
|
---|
230 | if (m_pApplianceWidget)
|
---|
231 | {
|
---|
232 | m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
|
---|
233 | pLayoutAppliance->addWidget(m_pApplianceWidget, 0, 0, 1, 3);
|
---|
234 | }
|
---|
235 |
|
---|
236 | /* Prepare import path label: */
|
---|
237 | m_pLabelImportFilePath = new QLabel(pContainerAppliance);
|
---|
238 | if (m_pLabelImportFilePath)
|
---|
239 | {
|
---|
240 | m_pLabelImportFilePath->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
241 | pLayoutAppliance->addWidget(m_pLabelImportFilePath, 1, 0);
|
---|
242 | }
|
---|
243 | /* Prepare import path selector: */
|
---|
244 | m_pEditorImportFilePath = new UIFilePathSelector(pContainerAppliance);
|
---|
245 | if (m_pEditorImportFilePath)
|
---|
246 | {
|
---|
247 | m_pEditorImportFilePath->setResetEnabled(true);
|
---|
248 | m_pEditorImportFilePath->setDefaultPath(gpGlobalSession->virtualBox().GetSystemProperties().GetDefaultMachineFolder());
|
---|
249 | m_pEditorImportFilePath->setPath(gpGlobalSession->virtualBox().GetSystemProperties().GetDefaultMachineFolder());
|
---|
250 | m_pLabelImportFilePath->setBuddy(m_pEditorImportFilePath);
|
---|
251 | pLayoutAppliance->addWidget(m_pEditorImportFilePath, 1, 1, 1, 2);
|
---|
252 | }
|
---|
253 |
|
---|
254 | /* Prepare MAC address policy label: */
|
---|
255 | m_pLabelMACImportPolicy = new QLabel(pContainerAppliance);
|
---|
256 | if (m_pLabelMACImportPolicy)
|
---|
257 | {
|
---|
258 | m_pLabelMACImportPolicy->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
259 | pLayoutAppliance->addWidget(m_pLabelMACImportPolicy, 2, 0);
|
---|
260 | }
|
---|
261 | /* Prepare MAC address policy combo: */
|
---|
262 | m_pComboMACImportPolicy = new QIComboBox(pContainerAppliance);
|
---|
263 | if (m_pComboMACImportPolicy)
|
---|
264 | {
|
---|
265 | m_pComboMACImportPolicy->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
---|
266 | m_pLabelMACImportPolicy->setBuddy(m_pComboMACImportPolicy);
|
---|
267 | pLayoutAppliance->addWidget(m_pComboMACImportPolicy, 2, 1, 1, 2);
|
---|
268 | }
|
---|
269 |
|
---|
270 | /* Prepare additional options label: */
|
---|
271 | m_pLabelAdditionalOptions = new QLabel(pContainerAppliance);
|
---|
272 | if (m_pLabelAdditionalOptions)
|
---|
273 | {
|
---|
274 | m_pLabelAdditionalOptions->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
---|
275 | pLayoutAppliance->addWidget(m_pLabelAdditionalOptions, 3, 0);
|
---|
276 | }
|
---|
277 | /* Prepare import HDs as VDIs checkbox: */
|
---|
278 | m_pCheckboxImportHDsAsVDI = new QCheckBox(pContainerAppliance);
|
---|
279 | {
|
---|
280 | m_pCheckboxImportHDsAsVDI->setCheckState(Qt::Checked);
|
---|
281 | pLayoutAppliance->addWidget(m_pCheckboxImportHDsAsVDI, 3, 1);
|
---|
282 | }
|
---|
283 | }
|
---|
284 |
|
---|
285 | /* Add into layout: */
|
---|
286 | m_pSettingsWidget2->addWidget(pContainerAppliance);
|
---|
287 | }
|
---|
288 |
|
---|
289 | /* Prepare form editor container: */
|
---|
290 | QWidget *pContainerFormEditor = new QWidget(m_pSettingsWidget2);
|
---|
291 | if (pContainerFormEditor)
|
---|
292 | {
|
---|
293 | /* Prepare form editor layout: */
|
---|
294 | QVBoxLayout *pLayoutFormEditor = new QVBoxLayout(pContainerFormEditor);
|
---|
295 | if (pLayoutFormEditor)
|
---|
296 | {
|
---|
297 | pLayoutFormEditor->setContentsMargins(0, 0, 0, 0);
|
---|
298 |
|
---|
299 | /* Prepare form editor widget: */
|
---|
300 | m_pFormEditor = new UIFormEditorWidget(pContainerFormEditor);
|
---|
301 | if (m_pFormEditor)
|
---|
302 | pLayoutFormEditor->addWidget(m_pFormEditor);
|
---|
303 | }
|
---|
304 |
|
---|
305 | /* Add into layout: */
|
---|
306 | m_pSettingsWidget2->addWidget(pContainerFormEditor);
|
---|
307 | }
|
---|
308 |
|
---|
309 | /* Add into tool-box: */
|
---|
310 | m_pToolBox->insertPage(1, m_pSettingsWidget2, QString());
|
---|
311 | }
|
---|
312 |
|
---|
313 | /* Add into layout: */
|
---|
314 | pMainLayout->addWidget(m_pToolBox);
|
---|
315 | }
|
---|
316 |
|
---|
317 | /* Add stretch: */
|
---|
318 | pMainLayout->addStretch(1);
|
---|
319 | }
|
---|
320 |
|
---|
321 | /* Setup connections: */
|
---|
322 | connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigCloudProfileRegistered,
|
---|
323 | this, &UIWizardImportAppPageExpert::sltHandleSourceComboChange);
|
---|
324 | connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigCloudProfileChanged,
|
---|
325 | this, &UIWizardImportAppPageExpert::sltHandleSourceComboChange);
|
---|
326 | connect(m_pSourceComboBox, &QIComboBox::activated,
|
---|
327 | this, &UIWizardImportAppPageExpert::sltHandleSourceComboChange);
|
---|
328 | connect(m_pFileSelector, &UIEmptyFilePathSelector::pathChanged,
|
---|
329 | this, &UIWizardImportAppPageExpert::sltHandleImportedFileSelectorChange);
|
---|
330 | connect(m_pProfileComboBox, &QIComboBox::currentIndexChanged,
|
---|
331 | this, &UIWizardImportAppPageExpert::sltHandleProfileComboChange);
|
---|
332 | connect(m_pProfileToolButton, &QIToolButton::clicked,
|
---|
333 | this, &UIWizardImportAppPageExpert::sltHandleProfileButtonClick);
|
---|
334 | connect(m_pProfileInstanceList, &QListWidget::currentRowChanged,
|
---|
335 | this, &UIWizardImportAppPageExpert::sltHandleInstanceListChange);
|
---|
336 | connect(m_pEditorImportFilePath, &UIFilePathSelector::pathChanged,
|
---|
337 | this, &UIWizardImportAppPageExpert::sltHandleImportPathEditorChange);
|
---|
338 | connect(m_pComboMACImportPolicy, &QIComboBox::currentIndexChanged,
|
---|
339 | this, &UIWizardImportAppPageExpert::sltHandleMACImportPolicyComboChange);
|
---|
340 | connect(m_pCheckboxImportHDsAsVDI, &QCheckBox::stateChanged,
|
---|
341 | this, &UIWizardImportAppPageExpert::sltHandleImportHDsAsVDICheckBoxChange);
|
---|
342 |
|
---|
343 | /* Parse passed full group name if any: */
|
---|
344 | if ( m_fImportFromOCIByDefault
|
---|
345 | && !m_strFileName.isEmpty())
|
---|
346 | {
|
---|
347 | const QString strProviderShortName = m_strFileName.section('/', 1, 1);
|
---|
348 | const QString strProfileName = m_strFileName.section('/', 2, 2);
|
---|
349 | if (!strProviderShortName.isEmpty() && !strProfileName.isEmpty())
|
---|
350 | {
|
---|
351 | m_strSource = strProviderShortName;
|
---|
352 | m_strProfileName = strProfileName;
|
---|
353 | }
|
---|
354 | }
|
---|
355 | }
|
---|
356 |
|
---|
357 | UIWizardImportApp *UIWizardImportAppPageExpert::wizard() const
|
---|
358 | {
|
---|
359 | return qobject_cast<UIWizardImportApp*>(UINativeWizardPage::wizard());
|
---|
360 | }
|
---|
361 |
|
---|
362 | void UIWizardImportAppPageExpert::sltRetranslateUI()
|
---|
363 | {
|
---|
364 | /* Translate tool-box: */
|
---|
365 | if (m_pToolBox)
|
---|
366 | {
|
---|
367 | m_pToolBox->setPageTitle(0, UIWizardImportApp::tr("Source"));
|
---|
368 | m_pToolBox->setPageTitle(1, UIWizardImportApp::tr("Settings"));
|
---|
369 | }
|
---|
370 |
|
---|
371 | /* Translate hardcoded values of Source combo-box: */
|
---|
372 | if (m_pSourceComboBox)
|
---|
373 | {
|
---|
374 | m_pSourceComboBox->setItemText(0, UIWizardImportApp::tr("Local File System"));
|
---|
375 | m_pSourceComboBox->setItemData(0, UIWizardImportApp::tr("Import from local file system."), Qt::ToolTipRole);
|
---|
376 |
|
---|
377 | /* Translate received values of Source combo-box.
|
---|
378 | * We are enumerating starting from 0 for simplicity: */
|
---|
379 | for (int i = 0; i < m_pSourceComboBox->count(); ++i)
|
---|
380 | if (isSourceCloudOne(m_pSourceComboBox, i))
|
---|
381 | {
|
---|
382 | m_pSourceComboBox->setItemText(i, m_pSourceComboBox->itemData(i, SourceData_Name).toString());
|
---|
383 | m_pSourceComboBox->setItemData(i, UIWizardImportApp::tr("Import from cloud service provider."), Qt::ToolTipRole);
|
---|
384 | }
|
---|
385 | }
|
---|
386 |
|
---|
387 | /* Translate file selector: */
|
---|
388 | if (m_pFileSelector)
|
---|
389 | {
|
---|
390 | m_pFileSelector->setChooseButtonToolTip(UIWizardImportApp::tr("Choose a virtual appliance file to import..."));
|
---|
391 | m_pFileSelector->setFileDialogTitle(UIWizardImportApp::tr("Please choose a virtual appliance file to import"));
|
---|
392 | m_pFileSelector->setFileFilters(UIWizardImportApp::tr("Open Virtualization Format (%1)").arg("*.ova *.ovf"));
|
---|
393 | }
|
---|
394 |
|
---|
395 | /* Translate profile stuff: */
|
---|
396 | if (m_pProfileToolButton)
|
---|
397 | m_pProfileToolButton->setToolTip(UIWizardImportApp::tr("Open Cloud Profile Manager..."));
|
---|
398 |
|
---|
399 | /* Translate path selector label: */
|
---|
400 | if (m_pLabelImportFilePath)
|
---|
401 | m_pLabelImportFilePath->setText(UIWizardImportApp::tr("&Machine Base Folder:"));
|
---|
402 |
|
---|
403 | /* Translate MAC import policy label: */
|
---|
404 | if (m_pLabelMACImportPolicy)
|
---|
405 | m_pLabelMACImportPolicy->setText(UIWizardImportApp::tr("MAC Address &Policy:"));
|
---|
406 |
|
---|
407 | /* Translate additional options label: */
|
---|
408 | if (m_pLabelAdditionalOptions)
|
---|
409 | m_pLabelAdditionalOptions->setText(UIWizardImportApp::tr("Additional Options:"));
|
---|
410 | /* Translate additional option check-box: */
|
---|
411 | if (m_pCheckboxImportHDsAsVDI)
|
---|
412 | {
|
---|
413 | m_pCheckboxImportHDsAsVDI->setText(UIWizardImportApp::tr("&Import hard drives as VDI"));
|
---|
414 | m_pCheckboxImportHDsAsVDI->setToolTip(UIWizardImportApp::tr("When checked, all the hard drives that belong to this "
|
---|
415 | "appliance will be imported in VDI format."));
|
---|
416 | }
|
---|
417 | /* Translate file selector's tooltip: */
|
---|
418 | if (m_pFileSelector)
|
---|
419 | m_pFileSelector->setToolTip(UIWizardImportApp::tr("Holds the path of the file selected for import."));
|
---|
420 |
|
---|
421 | /* Translate separate stuff: */
|
---|
422 | retranslateMACImportPolicyCombo(m_pComboMACImportPolicy);
|
---|
423 |
|
---|
424 | /* Update tool-tips: */
|
---|
425 | updateSourceComboToolTip(m_pSourceComboBox);
|
---|
426 | updateMACImportPolicyComboToolTip(m_pComboMACImportPolicy);
|
---|
427 | }
|
---|
428 |
|
---|
429 | void UIWizardImportAppPageExpert::initializePage()
|
---|
430 | {
|
---|
431 | /* Make sure form-editor knows notification-center: */
|
---|
432 | m_pFormEditor->setNotificationCenter(wizard()->notificationCenter());
|
---|
433 | /* Choose 1st tool to be chosen initially: */
|
---|
434 | m_pToolBox->setCurrentPage(0);
|
---|
435 | /* Populate sources: */
|
---|
436 | populateSources(m_pSourceComboBox,
|
---|
437 | wizard()->notificationCenter(),
|
---|
438 | m_fImportFromOCIByDefault,
|
---|
439 | m_strSource);
|
---|
440 | /* Translate page: */
|
---|
441 | sltRetranslateUI();
|
---|
442 |
|
---|
443 | /* Choose initially focused widget: */
|
---|
444 | if (wizard()->isSourceCloudOne())
|
---|
445 | m_pProfileInstanceList->setFocus();
|
---|
446 | else
|
---|
447 | m_pFileSelector->setFocus();
|
---|
448 |
|
---|
449 | /* Fetch it, asynchronously: */
|
---|
450 | QMetaObject::invokeMethod(this, "sltAsyncInit", Qt::QueuedConnection);
|
---|
451 | }
|
---|
452 |
|
---|
453 | bool UIWizardImportAppPageExpert::isComplete() const
|
---|
454 | {
|
---|
455 | /* Initial result: */
|
---|
456 | bool fResult = true;
|
---|
457 |
|
---|
458 | /* Check whether there was cloud source selected: */
|
---|
459 | if (wizard()->isSourceCloudOne())
|
---|
460 | fResult = wizard()->cloudAppliance().isNotNull()
|
---|
461 | && wizard()->vsdImportForm().isNotNull();
|
---|
462 | else
|
---|
463 | fResult = wizard()->localAppliance().isNotNull();
|
---|
464 |
|
---|
465 | /* Return result: */
|
---|
466 | return fResult;
|
---|
467 | }
|
---|
468 |
|
---|
469 | bool UIWizardImportAppPageExpert::validatePage()
|
---|
470 | {
|
---|
471 | /* Initial result: */
|
---|
472 | bool fResult = true;
|
---|
473 |
|
---|
474 | /* Check whether there was cloud source selected: */
|
---|
475 | if (wizard()->isSourceCloudOne())
|
---|
476 | {
|
---|
477 | /* Make sure table has own data committed: */
|
---|
478 | m_pFormEditor->makeSureEditorDataCommitted();
|
---|
479 |
|
---|
480 | /* Check whether we have proper VSD form: */
|
---|
481 | CVirtualSystemDescriptionForm comForm = wizard()->vsdImportForm();
|
---|
482 | fResult = comForm.isNotNull();
|
---|
483 |
|
---|
484 | /* Give changed VSD back to appliance: */
|
---|
485 | if (fResult)
|
---|
486 | {
|
---|
487 | comForm.GetVirtualSystemDescription();
|
---|
488 | fResult = comForm.isOk();
|
---|
489 | if (!fResult)
|
---|
490 | UINotificationMessage::cannotAcquireVirtualSystemDescriptionFormParameter(comForm, wizard()->notificationCenter());
|
---|
491 | }
|
---|
492 | }
|
---|
493 | else
|
---|
494 | {
|
---|
495 | /* Make sure widget has own data committed: */
|
---|
496 | m_pApplianceWidget->prepareImport();
|
---|
497 | }
|
---|
498 |
|
---|
499 | /* Try to import appliance: */
|
---|
500 | if (fResult)
|
---|
501 | fResult = wizard()->importAppliance();
|
---|
502 |
|
---|
503 | /* Return result: */
|
---|
504 | return fResult;
|
---|
505 | }
|
---|
506 |
|
---|
507 | void UIWizardImportAppPageExpert::sltAsyncInit()
|
---|
508 | {
|
---|
509 | /* If we have file name passed for local OVA file: */
|
---|
510 | if ( !m_fImportFromOCIByDefault
|
---|
511 | && !m_strFileName.isEmpty())
|
---|
512 | m_pFileSelector->setPath(m_strFileName);
|
---|
513 |
|
---|
514 | /* Refresh page widgets: */
|
---|
515 | sltHandleSourceComboChange();
|
---|
516 | }
|
---|
517 |
|
---|
518 | void UIWizardImportAppPageExpert::sltHandleSourceComboChange()
|
---|
519 | {
|
---|
520 | /* Update combo tool-tip: */
|
---|
521 | updateSourceComboToolTip(m_pSourceComboBox);
|
---|
522 |
|
---|
523 | /* Update wizard fields: */
|
---|
524 | wizard()->setSourceCloudOne(isSourceCloudOne(m_pSourceComboBox));
|
---|
525 |
|
---|
526 | /* Refresh page widgets: */
|
---|
527 | UIWizardImportAppSource::refreshStackedWidget(m_pSettingsWidget1,
|
---|
528 | wizard()->isSourceCloudOne());
|
---|
529 | UIWizardImportAppSettings::refreshStackedWidget(m_pSettingsWidget2,
|
---|
530 | wizard()->isSourceCloudOne());
|
---|
531 |
|
---|
532 | // WORKAROUND:
|
---|
533 | // We want to free some vertical space from m_pSettingsWidget1:
|
---|
534 | const bool fCloudCase = wizard()->isSourceCloudOne();
|
---|
535 | m_pProfileComboBox->setVisible(fCloudCase);
|
---|
536 | m_pProfileToolButton->setVisible(fCloudCase);
|
---|
537 | m_pProfileInstanceList->setVisible(fCloudCase);
|
---|
538 |
|
---|
539 | /* Refresh local stuff: */
|
---|
540 | sltHandleImportedFileSelectorChange();
|
---|
541 | refreshMACAddressImportPolicies(m_pComboMACImportPolicy,
|
---|
542 | wizard()->isSourceCloudOne());
|
---|
543 | sltHandleMACImportPolicyComboChange();
|
---|
544 | sltHandleImportHDsAsVDICheckBoxChange();
|
---|
545 |
|
---|
546 | /* Refresh cloud stuff: */
|
---|
547 | refreshProfileCombo(m_pProfileComboBox,
|
---|
548 | wizard()->notificationCenter(),
|
---|
549 | source(m_pSourceComboBox),
|
---|
550 | m_strProfileName,
|
---|
551 | wizard()->isSourceCloudOne());
|
---|
552 | sltHandleProfileComboChange();
|
---|
553 |
|
---|
554 | /* Notify about changes: */
|
---|
555 | emit completeChanged();
|
---|
556 | }
|
---|
557 |
|
---|
558 | void UIWizardImportAppPageExpert::sltHandleImportedFileSelectorChange()
|
---|
559 | {
|
---|
560 | /* Update local stuff (only if something changed): */
|
---|
561 | if (m_pFileSelector->isModified())
|
---|
562 | {
|
---|
563 | /* Create local appliance: */
|
---|
564 | wizard()->setFile(path(m_pFileSelector));
|
---|
565 | m_pFileSelector->resetModified();
|
---|
566 | }
|
---|
567 |
|
---|
568 | /* Refresh appliance widget: */
|
---|
569 | refreshApplianceWidget(m_pApplianceWidget,
|
---|
570 | wizard()->localAppliance(),
|
---|
571 | wizard()->isSourceCloudOne());
|
---|
572 |
|
---|
573 | /* Update import path: */
|
---|
574 | sltHandleImportPathEditorChange();
|
---|
575 |
|
---|
576 | /* Notify about changes: */
|
---|
577 | emit completeChanged();
|
---|
578 | }
|
---|
579 |
|
---|
580 | void UIWizardImportAppPageExpert::sltHandleProfileComboChange()
|
---|
581 | {
|
---|
582 | /* Refresh profile instances: */
|
---|
583 | wizard()->wizardButton(WizardButtonType_Expert)->setEnabled(false);
|
---|
584 | refreshCloudProfileInstances(m_pProfileInstanceList,
|
---|
585 | wizard()->notificationCenter(),
|
---|
586 | source(m_pSourceComboBox),
|
---|
587 | profileName(m_pProfileComboBox),
|
---|
588 | wizard()->isSourceCloudOne());
|
---|
589 | wizard()->wizardButton(WizardButtonType_Expert)->setEnabled(true);
|
---|
590 | sltHandleInstanceListChange();
|
---|
591 |
|
---|
592 | /* Notify about changes: */
|
---|
593 | emit completeChanged();
|
---|
594 | }
|
---|
595 |
|
---|
596 | void UIWizardImportAppPageExpert::sltHandleProfileButtonClick()
|
---|
597 | {
|
---|
598 | /* Open Cloud Profile Manager: */
|
---|
599 | if (gpManager)
|
---|
600 | gpManager->openCloudProfileManager();
|
---|
601 | }
|
---|
602 |
|
---|
603 | void UIWizardImportAppPageExpert::sltHandleInstanceListChange()
|
---|
604 | {
|
---|
605 | /* Create cloud appliance and VSD import form: */
|
---|
606 | CAppliance comAppliance;
|
---|
607 | CVirtualSystemDescriptionForm comForm;
|
---|
608 | wizard()->wizardButton(WizardButtonType_Expert)->setEnabled(false);
|
---|
609 | refreshCloudStuff(comAppliance,
|
---|
610 | comForm,
|
---|
611 | wizard(),
|
---|
612 | machineId(m_pProfileInstanceList),
|
---|
613 | source(m_pSourceComboBox),
|
---|
614 | profileName(m_pProfileComboBox),
|
---|
615 | wizard()->isSourceCloudOne());
|
---|
616 | wizard()->wizardButton(WizardButtonType_Expert)->setEnabled(true);
|
---|
617 | wizard()->setCloudAppliance(comAppliance);
|
---|
618 | wizard()->setVsdImportForm(comForm);
|
---|
619 |
|
---|
620 | /* Refresh form properties table: */
|
---|
621 | refreshFormPropertiesTable(m_pFormEditor,
|
---|
622 | wizard()->vsdImportForm(),
|
---|
623 | wizard()->isSourceCloudOne());
|
---|
624 |
|
---|
625 | /* Notify about changes: */
|
---|
626 | emit completeChanged();
|
---|
627 | }
|
---|
628 |
|
---|
629 | void UIWizardImportAppPageExpert::sltHandleImportPathEditorChange()
|
---|
630 | {
|
---|
631 | AssertPtrReturnVoid(m_pApplianceWidget);
|
---|
632 | AssertPtrReturnVoid(m_pEditorImportFilePath);
|
---|
633 | m_pApplianceWidget->setVirtualSystemBaseFolder(m_pEditorImportFilePath->path());
|
---|
634 | }
|
---|
635 |
|
---|
636 | void UIWizardImportAppPageExpert::sltHandleMACImportPolicyComboChange()
|
---|
637 | {
|
---|
638 | /* Update combo tool-tip: */
|
---|
639 | updateMACImportPolicyComboToolTip(m_pComboMACImportPolicy);
|
---|
640 |
|
---|
641 | /* Update wizard fields: */
|
---|
642 | wizard()->setMACAddressImportPolicy(macAddressImportPolicy(m_pComboMACImportPolicy));
|
---|
643 | }
|
---|
644 |
|
---|
645 | void UIWizardImportAppPageExpert::sltHandleImportHDsAsVDICheckBoxChange()
|
---|
646 | {
|
---|
647 | /* Update wizard fields: */
|
---|
648 | wizard()->setImportHDsAsVDI(isImportHDsAsVDI(m_pCheckboxImportHDsAsVDI));
|
---|
649 | }
|
---|