VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp@ 103551

Last change on this file since 103551 was 101563, checked in by vboxsync, 14 months ago

FE/Qt: bugref:10450: Get rid of Qt5 stuff; This one is about signal connection ambiguity stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.2 KB
Line 
1/* $Id: UIWizardExportAppPageExpert.cpp 101563 2023-10-23 23:36:38Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIWizardExportAppPageExpert 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 <QButtonGroup>
30#include <QCheckBox>
31#include <QGridLayout>
32#include <QGroupBox>
33#include <QHeaderView>
34#include <QLabel>
35#include <QLineEdit>
36#include <QListWidget>
37#include <QPushButton>
38#include <QRadioButton>
39#include <QStackedWidget>
40#include <QTableWidget>
41#include <QVBoxLayout>
42
43/* GUI includes: */
44#include "QIComboBox.h"
45#include "QIToolButton.h"
46#include "UICommon.h"
47#include "UIApplianceExportEditorWidget.h"
48#include "UIConverter.h"
49#include "UIEmptyFilePathSelector.h"
50#include "UIFormEditorWidget.h"
51#include "UIIconPool.h"
52#include "UIMessageCenter.h"
53#include "UINotificationCenter.h"
54#include "UIToolBox.h"
55#include "UIVirtualBoxEventHandler.h"
56#include "UIVirtualBoxManager.h"
57#include "UIWizardExportApp.h"
58#include "UIWizardExportAppPageExpert.h"
59#include "UIWizardExportAppPageFormat.h"
60#include "UIWizardExportAppPageSettings.h"
61#include "UIWizardExportAppPageVMs.h"
62
63/* Namespaces: */
64using namespace UIWizardExportAppFormat;
65using namespace UIWizardExportAppSettings;
66using namespace UIWizardExportAppVMs;
67
68
69/*********************************************************************************************************************************
70* Class UIWizardExportAppPageExpert implementation. *
71*********************************************************************************************************************************/
72
73UIWizardExportAppPageExpert::UIWizardExportAppPageExpert(const QStringList &selectedVMNames, bool fExportToOCIByDefault)
74 : m_selectedVMNames(selectedVMNames)
75 , m_fExportToOCIByDefault(fExportToOCIByDefault)
76 , m_pToolBox(0)
77 , m_pVMSelector(0)
78 , m_pFormatLayout(0)
79 , m_pFormatComboBoxLabel(0)
80 , m_pFormatComboBox(0)
81 , m_pSettingsWidget1(0)
82 , m_pSettingsLayout1(0)
83 , m_pFileSelectorLabel(0)
84 , m_pFileSelector(0)
85 , m_pMACComboBoxLabel(0)
86 , m_pMACComboBox(0)
87 , m_pAdditionalLabel(0)
88 , m_pManifestCheckbox(0)
89 , m_pIncludeISOsCheckbox(0)
90 , m_pSettingsLayout2(0)
91 , m_pProfileLabel(0)
92 , m_pProfileComboBox(0)
93 , m_pProfileToolButton(0)
94 , m_pExportModeLabel(0)
95 , m_pExportModeButtonGroup(0)
96 , m_pSettingsWidget2(0)
97 , m_pApplianceWidget(0)
98 , m_pFormEditor(0)
99 , m_fLaunching(false)
100{
101 /* Create widgets: */
102 QVBoxLayout *pMainLayout = new QVBoxLayout(this);
103 if (pMainLayout)
104 {
105 /* Create tool-box: */
106 m_pToolBox = new UIToolBox(this);
107 if (m_pToolBox)
108 {
109 /* Create VM selector: */
110 m_pVMSelector = new QListWidget(m_pToolBox);
111 if (m_pVMSelector)
112 {
113 m_pVMSelector->setAlternatingRowColors(true);
114 m_pVMSelector->setSelectionMode(QAbstractItemView::ExtendedSelection);
115
116 /* Add into tool-box: */
117 m_pToolBox->insertPage(0, m_pVMSelector, QString());
118 }
119
120 /* Create settings widget container: */
121 QWidget *pWidgetSettings = new QWidget(m_pToolBox);
122 if (pWidgetSettings)
123 {
124 /* Create settings widget container layout: */
125 QVBoxLayout *pSettingsCntLayout = new QVBoxLayout(pWidgetSettings);
126 if (pSettingsCntLayout)
127 {
128 pSettingsCntLayout->setContentsMargins(0, 0, 0, 0);
129#ifdef VBOX_WS_MAC
130 pSettingsCntLayout->setSpacing(5);
131#endif
132
133 /* Create format layout: */
134 m_pFormatLayout = new QGridLayout;
135 if (m_pFormatLayout)
136 {
137 m_pFormatLayout->setContentsMargins(0, 0, 0, 0);
138#ifdef VBOX_WS_MAC
139 m_pFormatLayout->setSpacing(10);
140#endif
141 m_pFormatLayout->setColumnStretch(0, 0);
142 m_pFormatLayout->setColumnStretch(1, 1);
143
144 /* Create format combo-box label: */
145 m_pFormatComboBoxLabel = new QLabel(pWidgetSettings);
146 if (m_pFormatComboBoxLabel)
147 {
148 m_pFormatComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
149 m_pFormatLayout->addWidget(m_pFormatComboBoxLabel, 0, 0);
150 }
151 /* Create format combo-box: */
152 m_pFormatComboBox = new QIComboBox(pWidgetSettings);
153 if (m_pFormatComboBox)
154 {
155 m_pFormatComboBoxLabel->setBuddy(m_pFormatComboBox);
156 m_pFormatLayout->addWidget(m_pFormatComboBox, 0, 1);
157 }
158
159 /* Add into layout: */
160 pSettingsCntLayout->addLayout(m_pFormatLayout);
161 }
162
163 /* Create 1st settings widget: */
164 m_pSettingsWidget1 = new QStackedWidget(pWidgetSettings);
165 if (m_pSettingsWidget1)
166 {
167 /* Create settings pane 1: */
168 QWidget *pSettingsPane1 = new QWidget(m_pSettingsWidget1);
169 if (pSettingsPane1)
170 {
171 /* Create settings layout 1: */
172 m_pSettingsLayout1 = new QGridLayout(pSettingsPane1);
173 if (m_pSettingsLayout1)
174 {
175#ifdef VBOX_WS_MAC
176 m_pSettingsLayout1->setSpacing(10);
177#endif
178 m_pSettingsLayout1->setContentsMargins(0, 0, 0, 0);
179 m_pSettingsLayout1->setColumnStretch(0, 0);
180 m_pSettingsLayout1->setColumnStretch(1, 1);
181
182 /* Create file selector label: */
183 m_pFileSelectorLabel = new QLabel(pSettingsPane1);
184 if (m_pFileSelectorLabel)
185 {
186 m_pFileSelectorLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
187 m_pSettingsLayout1->addWidget(m_pFileSelectorLabel, 0, 0);
188 }
189 /* Create file selector: */
190 m_pFileSelector = new UIEmptyFilePathSelector(pSettingsPane1);
191 if (m_pFileSelector)
192 {
193 m_pFileSelectorLabel->setBuddy(m_pFileSelector);
194 m_pFileSelector->setMode(UIEmptyFilePathSelector::Mode_File_Save);
195 m_pFileSelector->setEditable(true);
196 m_pFileSelector->setButtonPosition(UIEmptyFilePathSelector::RightPosition);
197 m_pFileSelector->setDefaultSaveExt("ova");
198 m_pSettingsLayout1->addWidget(m_pFileSelector, 0, 1, 1, 2);
199 }
200
201 /* Create MAC policy combo-box label: */
202 m_pMACComboBoxLabel = new QLabel(pSettingsPane1);
203 if (m_pMACComboBoxLabel)
204 {
205 m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
206 m_pSettingsLayout1->addWidget(m_pMACComboBoxLabel, 1, 0);
207 }
208 /* Create MAC policy combo-box: */
209 m_pMACComboBox = new QIComboBox(pSettingsPane1);
210 if (m_pMACComboBox)
211 {
212 m_pMACComboBoxLabel->setBuddy(m_pMACComboBox);
213 m_pSettingsLayout1->addWidget(m_pMACComboBox, 1, 1, 1, 2);
214 }
215
216 /* Create advanced label: */
217 m_pAdditionalLabel = new QLabel(pSettingsPane1);
218 if (m_pAdditionalLabel)
219 {
220 m_pAdditionalLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
221 m_pSettingsLayout1->addWidget(m_pAdditionalLabel, 2, 0);
222 }
223 /* Create manifest check-box editor: */
224 m_pManifestCheckbox = new QCheckBox(pSettingsPane1);
225 if (m_pManifestCheckbox)
226 m_pSettingsLayout1->addWidget(m_pManifestCheckbox, 2, 1);
227 /* Create include ISOs check-box: */
228 m_pIncludeISOsCheckbox = new QCheckBox(pSettingsPane1);
229 if (m_pIncludeISOsCheckbox)
230 m_pSettingsLayout1->addWidget(m_pIncludeISOsCheckbox, 3, 1);
231
232 /* Create placeholder: */
233 QWidget *pPlaceholder = new QWidget(pSettingsPane1);
234 if (pPlaceholder)
235 m_pSettingsLayout1->addWidget(pPlaceholder, 4, 0, 1, 3);
236 }
237
238 /* Add into layout: */
239 m_pSettingsWidget1->addWidget(pSettingsPane1);
240 }
241
242 /* Create settings pane 2: */
243 QWidget *pSettingsPane2 = new QWidget(m_pSettingsWidget1);
244 if (pSettingsPane2)
245 {
246 /* Create settings layout 2: */
247 m_pSettingsLayout2 = new QGridLayout(pSettingsPane2);
248 if (m_pSettingsLayout2)
249 {
250#ifdef VBOX_WS_MAC
251 m_pSettingsLayout2->setSpacing(10);
252#endif
253 m_pSettingsLayout2->setContentsMargins(0, 0, 0, 0);
254 m_pSettingsLayout2->setColumnStretch(0, 0);
255 m_pSettingsLayout2->setColumnStretch(1, 1);
256
257 /* Create profile label: */
258 m_pProfileLabel = new QLabel(pSettingsPane2);
259 if (m_pProfileLabel)
260 {
261 m_pProfileLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
262 m_pSettingsLayout2->addWidget(m_pProfileLabel, 0, 0);
263 }
264 /* Create sub-layout: */
265 QHBoxLayout *pSubLayout = new QHBoxLayout;
266 if (pSubLayout)
267 {
268 pSubLayout->setContentsMargins(0, 0, 0, 0);
269 pSubLayout->setSpacing(1);
270
271 /* Create profile combo-box: */
272 m_pProfileComboBox = new QIComboBox(pSettingsPane2);
273 if (m_pProfileComboBox)
274 {
275 m_pProfileLabel->setBuddy(m_pProfileComboBox);
276 pSubLayout->addWidget(m_pProfileComboBox);
277 }
278 /* Create profile tool-button: */
279 m_pProfileToolButton = new QIToolButton(pSettingsPane2);
280 if (m_pProfileToolButton)
281 {
282 m_pProfileToolButton->setIcon(UIIconPool::iconSet(":/cloud_profile_manager_16px.png",
283 ":/cloud_profile_manager_disabled_16px.png"));
284 pSubLayout->addWidget(m_pProfileToolButton);
285 }
286
287 /* Add into layout: */
288 m_pSettingsLayout2->addLayout(pSubLayout, 0, 1);
289 }
290
291 /* Create profile label: */
292 m_pExportModeLabel = new QLabel(pSettingsPane2);
293 if (m_pExportModeLabel)
294 {
295 m_pExportModeLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
296 m_pSettingsLayout2->addWidget(m_pExportModeLabel, 1, 0);
297 }
298 /* Create button-group: */
299 m_pExportModeButtonGroup = new QButtonGroup(pSettingsPane2);
300 if (m_pExportModeButtonGroup)
301 {
302 /* Create Do Not Ask button: */
303 m_exportModeButtons[CloudExportMode_DoNotAsk] = new QRadioButton(pSettingsPane2);
304 if (m_exportModeButtons.value(CloudExportMode_DoNotAsk))
305 {
306 m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_DoNotAsk));
307 m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_DoNotAsk), 1, 1);
308 }
309 /* Create Ask Then Export button: */
310 m_exportModeButtons[CloudExportMode_AskThenExport] = new QRadioButton(pSettingsPane2);
311 if (m_exportModeButtons.value(CloudExportMode_AskThenExport))
312 {
313 m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_AskThenExport));
314 m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_AskThenExport), 2, 1);
315 }
316 /* Create Export Then Ask button: */
317 m_exportModeButtons[CloudExportMode_ExportThenAsk] = new QRadioButton(pSettingsPane2);
318 if (m_exportModeButtons.value(CloudExportMode_ExportThenAsk))
319 {
320 m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_ExportThenAsk));
321 m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_ExportThenAsk), 3, 1);
322 }
323 }
324
325 /* Create placeholder: */
326 QWidget *pPlaceholder = new QWidget(pSettingsPane2);
327 if (pPlaceholder)
328 m_pSettingsLayout2->addWidget(pPlaceholder, 4, 0, 1, 3);
329 }
330
331 /* Add into layout: */
332 m_pSettingsWidget1->addWidget(pSettingsPane2);
333 }
334
335 /* Add into layout: */
336 pSettingsCntLayout->addWidget(m_pSettingsWidget1);
337 }
338 }
339
340 /* Add into tool-box: */
341 m_pToolBox->insertPage(1, pWidgetSettings, QString());
342 }
343
344 /* Create 2nd settings widget: */
345 m_pSettingsWidget2 = new QStackedWidget(m_pToolBox);
346 if (m_pSettingsWidget2)
347 {
348 /* Create appliance widget container: */
349 QWidget *pApplianceWidgetCnt = new QWidget(this);
350 if (pApplianceWidgetCnt)
351 {
352 /* Create appliance widget layout: */
353 QVBoxLayout *pApplianceWidgetLayout = new QVBoxLayout(pApplianceWidgetCnt);
354 if (pApplianceWidgetLayout)
355 {
356 pApplianceWidgetLayout->setContentsMargins(0, 0, 0, 0);
357
358 /* Create appliance widget: */
359 m_pApplianceWidget = new UIApplianceExportEditorWidget(pApplianceWidgetCnt);
360 if (m_pApplianceWidget)
361 {
362 m_pApplianceWidget->setMinimumHeight(250);
363 m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
364 pApplianceWidgetLayout->addWidget(m_pApplianceWidget);
365 }
366 }
367
368 /* Add into layout: */
369 m_pSettingsWidget2->addWidget(pApplianceWidgetCnt);
370 }
371
372 /* Create form editor container: */
373 QWidget *pFormEditorCnt = new QWidget(this);
374 if (pFormEditorCnt)
375 {
376 /* Create form editor layout: */
377 QVBoxLayout *pFormEditorLayout = new QVBoxLayout(pFormEditorCnt);
378 if (pFormEditorLayout)
379 {
380 pFormEditorLayout->setContentsMargins(0, 0, 0, 0);
381
382 /* Create form editor widget: */
383 m_pFormEditor = new UIFormEditorWidget(pFormEditorCnt);
384 if (m_pFormEditor)
385 pFormEditorLayout->addWidget(m_pFormEditor);
386 }
387
388 /* Add into layout: */
389 m_pSettingsWidget2->addWidget(pFormEditorCnt);
390 }
391
392 /* Add into tool-box: */
393 m_pToolBox->insertPage(2, m_pSettingsWidget2, QString());
394 }
395
396 /* Add into layout: */
397 pMainLayout->addWidget(m_pToolBox);
398 }
399
400 /* Add stretch: */
401 pMainLayout->addStretch();
402 }
403
404 /* Setup connections: */
405 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigCloudProfileRegistered,
406 this, &UIWizardExportAppPageExpert::sltHandleFormatComboChange);
407 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigCloudProfileChanged,
408 this, &UIWizardExportAppPageExpert::sltHandleFormatComboChange);
409 connect(m_pVMSelector, &QListWidget::itemSelectionChanged,
410 this, &UIWizardExportAppPageExpert::sltHandleVMItemSelectionChanged);
411 connect(m_pFileSelector, &UIEmptyFilePathSelector::pathChanged,
412 this, &UIWizardExportAppPageExpert::sltHandleFileSelectorChange);
413 connect(m_pFormatComboBox, &QIComboBox::currentIndexChanged,
414 this, &UIWizardExportAppPageExpert::sltHandleFormatComboChange);
415 connect(m_pMACComboBox, &QIComboBox::currentIndexChanged,
416 this, &UIWizardExportAppPageExpert::sltHandleMACAddressExportPolicyComboChange);
417 connect(m_pManifestCheckbox, &QCheckBox::stateChanged,
418 this, &UIWizardExportAppPageExpert::sltHandleManifestCheckBoxChange);
419 connect(m_pIncludeISOsCheckbox, &QCheckBox::stateChanged,
420 this, &UIWizardExportAppPageExpert::sltHandleIncludeISOsCheckBoxChange);
421 connect(m_pProfileComboBox, &QIComboBox::currentIndexChanged,
422 this, &UIWizardExportAppPageExpert::sltHandleProfileComboChange);
423 connect(m_pExportModeButtonGroup, &QButtonGroup::buttonToggled,
424 this, &UIWizardExportAppPageExpert::sltHandleRadioButtonToggled);
425 connect(m_pProfileToolButton, &QIToolButton::clicked,
426 this, &UIWizardExportAppPageExpert::sltHandleProfileButtonClick);
427}
428
429UIWizardExportApp *UIWizardExportAppPageExpert::wizard() const
430{
431 return qobject_cast<UIWizardExportApp*>(UINativeWizardPage::wizard());
432}
433
434void UIWizardExportAppPageExpert::retranslateUi()
435{
436 /* Translate objects: */
437 m_strDefaultApplianceName = UIWizardExportApp::tr("Appliance");
438 refreshFileSelectorName(m_strFileSelectorName, wizard()->machineNames(), m_strDefaultApplianceName, wizard()->isFormatCloudOne());
439 refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne());
440
441 /* Translate tool-box: */
442 m_pToolBox->setPageTitle(0, UIWizardExportApp::tr("Virtual &machines"));
443 m_pToolBox->setPageTitle(1, UIWizardExportApp::tr("Format &settings"));
444 m_pToolBox->setPageTitle(2, UIWizardExportApp::tr("&Appliance settings"));
445
446 /* Translate File selector: */
447 m_pFileSelectorLabel->setText(UIWizardExportApp::tr("&File:"));
448 m_pFileSelector->setChooseButtonToolTip(UIWizardExportApp::tr("Choose a file to export the virtual appliance to..."));
449 m_pFileSelector->setFileDialogTitle(UIWizardExportApp::tr("Please choose a file to export the virtual appliance to"));
450
451 /* Translate hard-coded values of Format combo-box: */
452 m_pFormatComboBoxLabel->setText(UIWizardExportApp::tr("F&ormat:"));
453 m_pFormatComboBox->setItemText(0, UIWizardExportApp::tr("Open Virtualization Format 0.9"));
454 m_pFormatComboBox->setItemText(1, UIWizardExportApp::tr("Open Virtualization Format 1.0"));
455 m_pFormatComboBox->setItemText(2, UIWizardExportApp::tr("Open Virtualization Format 2.0"));
456 m_pFormatComboBox->setItemData(0, UIWizardExportApp::tr("Write in legacy OVF 0.9 format for compatibility "
457 "with other virtualization products."), Qt::ToolTipRole);
458 m_pFormatComboBox->setItemData(1, UIWizardExportApp::tr("Write in standard OVF 1.0 format."), Qt::ToolTipRole);
459 m_pFormatComboBox->setItemData(2, UIWizardExportApp::tr("Write in new OVF 2.0 format."), Qt::ToolTipRole);
460 /* Translate received values of Format combo-box.
461 * We are enumerating starting from 0 for simplicity: */
462 for (int i = 0; i < m_pFormatComboBox->count(); ++i)
463 if (isFormatCloudOne(m_pFormatComboBox, i))
464 {
465 m_pFormatComboBox->setItemText(i, m_pFormatComboBox->itemData(i, FormatData_Name).toString());
466 m_pFormatComboBox->setItemData(i, UIWizardExportApp::tr("Export to cloud service provider."), Qt::ToolTipRole);
467 }
468
469 /* Translate MAC address policy combo-box: */
470 m_pMACComboBoxLabel->setText(UIWizardExportApp::tr("MAC Address &Policy:"));
471 for (int i = 0; i < m_pMACComboBox->count(); ++i)
472 {
473 const MACAddressExportPolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressExportPolicy>();
474 switch (enmPolicy)
475 {
476 case MACAddressExportPolicy_KeepAllMACs:
477 {
478 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include all network adapter MAC addresses"));
479 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include all network adapter MAC addresses in exported "
480 "appliance archive."), Qt::ToolTipRole);
481 break;
482 }
483 case MACAddressExportPolicy_StripAllNonNATMACs:
484 {
485 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses"));
486 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported "
487 "appliance archive."), Qt::ToolTipRole);
488 break;
489 }
490 case MACAddressExportPolicy_StripAllMACs:
491 {
492 m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses"));
493 m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported "
494 "appliance archive."), Qt::ToolTipRole);
495 break;
496 }
497 default:
498 break;
499 }
500 }
501
502 /* Translate addtional stuff: */
503 m_pAdditionalLabel->setText(UIWizardExportApp::tr("Additionally:"));
504 m_pManifestCheckbox->setToolTip(UIWizardExportApp::tr("Create a Manifest file for automatic data integrity checks on import."));
505 m_pManifestCheckbox->setText(UIWizardExportApp::tr("&Write Manifest file"));
506 m_pIncludeISOsCheckbox->setToolTip(UIWizardExportApp::tr("Include ISO image files into exported VM archive."));
507 m_pIncludeISOsCheckbox->setText(UIWizardExportApp::tr("&Include ISO image files"));
508
509 /* Translate profile stuff: */
510 m_pProfileLabel->setText(UIWizardExportApp::tr("&Profile:"));
511 m_pProfileToolButton->setToolTip(UIWizardExportApp::tr("Open Cloud Profile Manager..."));
512
513 /* Translate option label: */
514 m_pExportModeLabel->setText(UIWizardExportApp::tr("Machine Creation:"));
515 m_exportModeButtons.value(CloudExportMode_DoNotAsk)->setText(UIWizardExportApp::tr("Do not ask me about it, leave custom &image for future usage"));
516 m_exportModeButtons.value(CloudExportMode_AskThenExport)->setText(UIWizardExportApp::tr("Ask me about it &before exporting disk as custom image"));
517 m_exportModeButtons.value(CloudExportMode_ExportThenAsk)->setText(UIWizardExportApp::tr("Ask me about it &after exporting disk as custom image"));
518
519 /* Translate file selector's tooltip: */
520 if (m_pFileSelector)
521 m_pFileSelector->setToolTip(UIWizardExportApp::tr("Holds the path of the file selected for export."));
522
523 /* Adjust label widths: */
524 QList<QWidget*> labels;
525 labels << m_pFormatComboBoxLabel;
526 labels << m_pFileSelectorLabel;
527 labels << m_pMACComboBoxLabel;
528 labels << m_pAdditionalLabel;
529 labels << m_pProfileLabel;
530 labels << m_pExportModeLabel;
531 int iMaxWidth = 0;
532 foreach (QWidget *pLabel, labels)
533 iMaxWidth = qMax(iMaxWidth, pLabel->minimumSizeHint().width());
534 m_pFormatLayout->setColumnMinimumWidth(0, iMaxWidth);
535 m_pSettingsLayout1->setColumnMinimumWidth(0, iMaxWidth);
536 m_pSettingsLayout2->setColumnMinimumWidth(0, iMaxWidth);
537
538 /* Update tool-tips: */
539 updateFormatComboToolTip(m_pFormatComboBox);
540 updateMACAddressExportPolicyComboToolTip(m_pMACComboBox);
541}
542
543void UIWizardExportAppPageExpert::initializePage()
544{
545 /* Make sure form-editor knows notification-center: */
546 m_pFormEditor->setNotificationCenter(wizard()->notificationCenter());
547 /* Choose 1st tool to be chosen initially: */
548 m_pToolBox->setCurrentPage(0);
549 /* Populate VM items: */
550 populateVMItems(m_pVMSelector, m_selectedVMNames);
551 /* Populate formats: */
552 populateFormats(m_pFormatComboBox, wizard()->notificationCenter(), m_fExportToOCIByDefault);
553 /* Populate MAC address policies: */
554 populateMACAddressPolicies(m_pMACComboBox);
555 /* Translate page: */
556 retranslateUi();
557
558 /* Fetch it, asynchronously: */
559 QMetaObject::invokeMethod(this, "sltHandleFormatComboChange", Qt::QueuedConnection);
560}
561
562bool UIWizardExportAppPageExpert::isComplete() const
563{
564 /* Initial result: */
565 bool fResult = true;
566
567 /* There should be at least one vm selected: */
568 if (fResult)
569 fResult = wizard()->machineNames().size() > 0;
570
571 /* Check appliance settings: */
572 if (fResult)
573 {
574 const bool fOVF = wizard()->format() == "ovf-0.9"
575 || wizard()->format() == "ovf-1.0"
576 || wizard()->format() == "ovf-2.0";
577 const bool fCSP = wizard()->isFormatCloudOne();
578
579 fResult = ( fOVF
580 && UICommon::hasAllowedExtension(wizard()->path().toLower(), OVFFileExts))
581 || ( fCSP
582 && wizard()->cloudAppliance().isNotNull()
583 && wizard()->cloudClient().isNotNull()
584 && wizard()->vsd().isNotNull()
585 && wizard()->vsdExportForm().isNotNull());
586 }
587
588 /* Return result: */
589 return fResult;
590}
591
592bool UIWizardExportAppPageExpert::validatePage()
593{
594 /* Initial result: */
595 bool fResult = true;
596
597 /* Check whether there was cloud target selected: */
598 if (wizard()->isFormatCloudOne())
599 {
600 /* Make sure table has own data committed: */
601 m_pFormEditor->makeSureEditorDataCommitted();
602
603 /* Init VSD form: */
604 CVirtualSystemDescriptionForm comForm;
605 /* Check whether we have proper VSD form: */
606 if (!m_fLaunching)
607 {
608 /* We are going to upload image: */
609 comForm = wizard()->vsdExportForm();
610 fResult = comForm.isNotNull();
611 }
612 else
613 {
614 /* We are going to launch VM: */
615 comForm = wizard()->vsdLaunchForm();
616 fResult = comForm.isNotNull();
617 }
618 /* Give changed VSD back: */
619 if (fResult)
620 {
621 comForm.GetVirtualSystemDescription();
622 fResult = comForm.isOk();
623 if (!fResult)
624 UINotificationMessage::cannotAcquireVirtualSystemDescriptionFormParameter(comForm, wizard()->notificationCenter());
625 }
626
627 /* Final stage? */
628 if (fResult)
629 {
630 if (!m_fLaunching)
631 {
632 /* For modes other than AskThenExport, try to export appliance first: */
633 if (wizard()->cloudExportMode() != CloudExportMode_AskThenExport)
634 fResult = wizard()->exportAppliance();
635
636 /* For modes other than DoNotAsk, switch from uploading image to launching VM: */
637 if ( fResult
638 && wizard()->cloudExportMode() != CloudExportMode_DoNotAsk)
639 {
640 /* Invert flags: */
641 fResult = false;
642 m_fLaunching = true;
643
644 /* Disable wizard buttons: */
645 wizard()->disableButtons();
646
647 /* Disable unrelated widgets: */
648 m_pToolBox->setCurrentPage(2);
649 m_pToolBox->setPageEnabled(0, false);
650 m_pToolBox->setPageEnabled(1, false);
651
652 /* Refresh corresponding widgets: */
653 wizard()->createVsdLaunchForm();
654 refreshFormPropertiesTable(m_pFormEditor, wizard()->vsdLaunchForm(), wizard()->isFormatCloudOne());
655 }
656 }
657 else
658 {
659 /* For AskThenExport mode, try to export appliance in the end: */
660 if (wizard()->cloudExportMode() == CloudExportMode_AskThenExport)
661 fResult = wizard()->exportAppliance();
662
663 /* Try to create cloud VM: */
664 if (fResult)
665 fResult = wizard()->createCloudVM();
666 }
667 }
668 }
669 /* Otherwise if there was local target selected: */
670 else
671 {
672 /* Ask user about machines which are in Saved state currently: */
673 QStringList savedMachines;
674 refreshSavedMachines(savedMachines, m_pVMSelector);
675 if (!savedMachines.isEmpty())
676 fResult = msgCenter().confirmExportMachinesInSaveState(savedMachines, this);
677
678 /* Prepare export: */
679 if (fResult)
680 m_pApplianceWidget->prepareExport();
681
682 /* Try to export appliance: */
683 if (fResult)
684 fResult = wizard()->exportAppliance();
685 }
686
687 /* Return result: */
688 return fResult;
689}
690
691void UIWizardExportAppPageExpert::sltHandleVMItemSelectionChanged()
692{
693 /* Update wizard fields: */
694 wizard()->setMachineNames(machineNames(m_pVMSelector));
695 wizard()->setMachineIDs(machineIDs(m_pVMSelector));
696
697 /* Refresh required settings: */
698 refreshFileSelectorName(m_strFileSelectorName, wizard()->machineNames(), m_strDefaultApplianceName, wizard()->isFormatCloudOne());
699 refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne());
700
701 /* Update local stuff: */
702 updateLocalStuff();
703 /* Update cloud stuff: */
704 updateCloudStuff();
705
706 /* Notify about changes: */
707 emit completeChanged();
708}
709
710void UIWizardExportAppPageExpert::sltHandleFormatComboChange()
711{
712 /* Update combo tool-tip: */
713 updateFormatComboToolTip(m_pFormatComboBox);
714
715 /* Update wizard fields: */
716 wizard()->setFormat(format(m_pFormatComboBox));
717 wizard()->setFormatCloudOne(isFormatCloudOne(m_pFormatComboBox));
718
719 /* Refresh settings widget state: */
720 UIWizardExportAppFormat::refreshStackedWidget(m_pSettingsWidget1, wizard()->isFormatCloudOne());
721 UIWizardExportAppSettings::refreshStackedWidget(m_pSettingsWidget2, wizard()->isFormatCloudOne());
722
723 /* Update export settings: */
724 refreshFileSelectorExtension(m_strFileSelectorExt, m_pFileSelector, wizard()->isFormatCloudOne());
725 refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne());
726 refreshManifestCheckBoxAccess(m_pManifestCheckbox, wizard()->isFormatCloudOne());
727 refreshIncludeISOsCheckBoxAccess(m_pIncludeISOsCheckbox, wizard()->isFormatCloudOne());
728 refreshProfileCombo(m_pProfileComboBox, wizard()->notificationCenter(), wizard()->format(), wizard()->isFormatCloudOne());
729 refreshCloudExportMode(m_exportModeButtons, wizard()->isFormatCloudOne());
730
731 /* Update local stuff: */
732 updateLocalStuff();
733 /* Update profile: */
734 sltHandleProfileComboChange();
735
736 /* Notify about changes: */
737 emit completeChanged();
738}
739
740void UIWizardExportAppPageExpert::sltHandleFileSelectorChange()
741{
742 /* Skip empty paths: */
743 if (m_pFileSelector->path().isEmpty())
744 return;
745
746 m_strFileSelectorName = QFileInfo(m_pFileSelector->path()).completeBaseName();
747 wizard()->setPath(m_pFileSelector->path());
748 emit completeChanged();
749}
750
751void UIWizardExportAppPageExpert::sltHandleMACAddressExportPolicyComboChange()
752{
753 updateMACAddressExportPolicyComboToolTip(m_pMACComboBox);
754 wizard()->setMACAddressExportPolicy(m_pMACComboBox->currentData().value<MACAddressExportPolicy>());
755 emit completeChanged();
756}
757
758void UIWizardExportAppPageExpert::sltHandleManifestCheckBoxChange()
759{
760 wizard()->setManifestSelected(m_pManifestCheckbox->isChecked());
761 emit completeChanged();
762}
763
764void UIWizardExportAppPageExpert::sltHandleIncludeISOsCheckBoxChange()
765{
766 wizard()->setIncludeISOsSelected(m_pIncludeISOsCheckbox->isChecked());
767 emit completeChanged();
768}
769
770void UIWizardExportAppPageExpert::sltHandleProfileComboChange()
771{
772 /* Update wizard fields: */
773 wizard()->setProfileName(profileName(m_pProfileComboBox));
774
775 /* Update export settings: */
776 refreshCloudProfile(m_comCloudProfile,
777 wizard()->notificationCenter(),
778 wizard()->format(),
779 wizard()->profileName(),
780 wizard()->isFormatCloudOne());
781
782 /* Update cloud stuff: */
783 updateCloudStuff();
784
785 /* Notify about changes: */
786 emit completeChanged();
787}
788
789void UIWizardExportAppPageExpert::sltHandleRadioButtonToggled(QAbstractButton *pButton, bool fToggled)
790{
791 /* Handle checked buttons only: */
792 if (!fToggled)
793 return;
794
795 /* Update cloud export mode field value: */
796 wizard()->setCloudExportMode(m_exportModeButtons.key(pButton));
797 emit completeChanged();
798}
799
800void UIWizardExportAppPageExpert::sltHandleProfileButtonClick()
801{
802 /* Open Cloud Profile Manager: */
803 if (gpManager)
804 gpManager->openCloudProfileManager();
805}
806
807void UIWizardExportAppPageExpert::updateLocalStuff()
808{
809 /* Create appliance: */
810 CAppliance comAppliance;
811 refreshLocalStuff(comAppliance, wizard(), wizard()->machineIDs(), wizard()->uri());
812 wizard()->setLocalAppliance(comAppliance);
813}
814
815void UIWizardExportAppPageExpert::updateCloudStuff()
816{
817 /* Create appliance, client, VSD and VSD export form: */
818 CAppliance comAppliance;
819 CCloudClient comClient;
820 CVirtualSystemDescription comDescription;
821 CVirtualSystemDescriptionForm comForm;
822 wizard()->wizardButton(WizardButtonType_Expert)->setEnabled(false);
823 refreshCloudStuff(comAppliance,
824 comClient,
825 comDescription,
826 comForm,
827 wizard(),
828 m_comCloudProfile,
829 wizard()->machineIDs(),
830 wizard()->uri(),
831 wizard()->cloudExportMode());
832 wizard()->wizardButton(WizardButtonType_Expert)->setEnabled(true);
833 wizard()->setCloudAppliance(comAppliance);
834 wizard()->setCloudClient(comClient);
835 wizard()->setVsd(comDescription);
836 wizard()->setVsdExportForm(comForm);
837
838 /* Refresh corresponding widgets: */
839 refreshApplianceSettingsWidget(m_pApplianceWidget, wizard()->localAppliance(), wizard()->isFormatCloudOne());
840 refreshFormPropertiesTable(m_pFormEditor, wizard()->vsdExportForm(), wizard()->isFormatCloudOne());
841}
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