1 | /* $Id: UIWizardExportAppPageFormat.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardExportAppPageFormat 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 <QDir>
|
---|
32 | #include <QGridLayout>
|
---|
33 | #include <QLabel>
|
---|
34 | #include <QPushButton>
|
---|
35 | #include <QRadioButton>
|
---|
36 | #include <QStackedWidget>
|
---|
37 | #include <QVBoxLayout>
|
---|
38 |
|
---|
39 | /* GUI includes: */
|
---|
40 | #include "QIComboBox.h"
|
---|
41 | #include "QIRichTextLabel.h"
|
---|
42 | #include "QIToolButton.h"
|
---|
43 | #include "UICloudNetworkingStuff.h"
|
---|
44 | #include "UICommon.h"
|
---|
45 | #include "UIEmptyFilePathSelector.h"
|
---|
46 | #include "UIExtraDataManager.h"
|
---|
47 | #include "UIGlobalSession.h"
|
---|
48 | #include "UIIconPool.h"
|
---|
49 | #include "UINotificationCenter.h"
|
---|
50 | #include "UIVirtualBoxEventHandler.h"
|
---|
51 | #include "UIVirtualBoxManager.h"
|
---|
52 | #include "UIWizardExportApp.h"
|
---|
53 | #include "UIWizardExportAppPageFormat.h"
|
---|
54 |
|
---|
55 | /* COM includes: */
|
---|
56 | #include "CMachine.h"
|
---|
57 | #include "CSystemProperties.h"
|
---|
58 |
|
---|
59 | /* Namespaces: */
|
---|
60 | using namespace UIWizardExportAppFormat;
|
---|
61 |
|
---|
62 |
|
---|
63 | /*********************************************************************************************************************************
|
---|
64 | * Class UIWizardExportAppFormat implementation. *
|
---|
65 | *********************************************************************************************************************************/
|
---|
66 |
|
---|
67 | void UIWizardExportAppFormat::populateFormats(QIComboBox *pCombo, UINotificationCenter *pCenter, bool fExportToOCIByDefault)
|
---|
68 | {
|
---|
69 | /* Sanity check: */
|
---|
70 | AssertPtrReturnVoid(pCombo);
|
---|
71 |
|
---|
72 | /* Remember current item data to be able to restore it: */
|
---|
73 | QString strOldData;
|
---|
74 | if (pCombo->currentIndex() != -1)
|
---|
75 | strOldData = pCombo->currentData(FormatData_ShortName).toString();
|
---|
76 | else
|
---|
77 | {
|
---|
78 | /* Otherwise "OCI" or "ovf-1.0" should be the default one: */
|
---|
79 | if (fExportToOCIByDefault)
|
---|
80 | strOldData = "OCI";
|
---|
81 | else
|
---|
82 | strOldData = "ovf-1.0";
|
---|
83 | }
|
---|
84 |
|
---|
85 | /* Block signals while updating: */
|
---|
86 | pCombo->blockSignals(true);
|
---|
87 |
|
---|
88 | /* Clear combo initially: */
|
---|
89 | pCombo->clear();
|
---|
90 |
|
---|
91 | /* Compose hardcoded format list: */
|
---|
92 | QStringList formats;
|
---|
93 | formats << "ovf-0.9";
|
---|
94 | formats << "ovf-1.0";
|
---|
95 | formats << "ovf-2.0";
|
---|
96 | /* Add that list to combo: */
|
---|
97 | foreach (const QString &strShortName, formats)
|
---|
98 | {
|
---|
99 | /* Compose empty item, fill it's data: */
|
---|
100 | pCombo->addItem(QString());
|
---|
101 | pCombo->setItemData(pCombo->count() - 1, strShortName, FormatData_ShortName);
|
---|
102 | }
|
---|
103 |
|
---|
104 | /* Iterate through existing providers: */
|
---|
105 | foreach (const CCloudProvider &comProvider, listCloudProviders(pCenter))
|
---|
106 | {
|
---|
107 | /* Skip if we have nothing to populate (file missing?): */
|
---|
108 | if (comProvider.isNull())
|
---|
109 | continue;
|
---|
110 | /* Acquire provider name: */
|
---|
111 | QString strProviderName;
|
---|
112 | if (!cloudProviderName(comProvider, strProviderName, pCenter))
|
---|
113 | continue;
|
---|
114 | /* Acquire provider short name: */
|
---|
115 | QString strProviderShortName;
|
---|
116 | if (!cloudProviderShortName(comProvider, strProviderShortName, pCenter))
|
---|
117 | continue;
|
---|
118 |
|
---|
119 | /* Compose empty item, fill it's data: */
|
---|
120 | pCombo->addItem(QString());
|
---|
121 | pCombo->setItemData(pCombo->count() - 1, strProviderName, FormatData_Name);
|
---|
122 | pCombo->setItemData(pCombo->count() - 1, strProviderShortName, FormatData_ShortName);
|
---|
123 | pCombo->setItemData(pCombo->count() - 1, true, FormatData_IsItCloudFormat);
|
---|
124 | }
|
---|
125 |
|
---|
126 | /* Set previous/default item if possible: */
|
---|
127 | int iNewIndex = -1;
|
---|
128 | if ( iNewIndex == -1
|
---|
129 | && !strOldData.isNull())
|
---|
130 | iNewIndex = pCombo->findData(strOldData, FormatData_ShortName);
|
---|
131 | if ( iNewIndex == -1
|
---|
132 | && pCombo->count() > 0)
|
---|
133 | iNewIndex = 0;
|
---|
134 | if (iNewIndex != -1)
|
---|
135 | pCombo->setCurrentIndex(iNewIndex);
|
---|
136 |
|
---|
137 | /* Unblock signals after update: */
|
---|
138 | pCombo->blockSignals(false);
|
---|
139 | }
|
---|
140 |
|
---|
141 | void UIWizardExportAppFormat::populateMACAddressPolicies(QIComboBox *pCombo)
|
---|
142 | {
|
---|
143 | /* Sanity check: */
|
---|
144 | AssertPtrReturnVoid(pCombo);
|
---|
145 | /* We need top-level parent as well: */
|
---|
146 | QWidget *pParent = pCombo->window();
|
---|
147 | AssertPtrReturnVoid(pParent);
|
---|
148 |
|
---|
149 | /* Map known export options to known MAC address export policies: */
|
---|
150 | QMap<KExportOptions, MACAddressExportPolicy> knownOptions;
|
---|
151 | knownOptions[KExportOptions_StripAllMACs] = MACAddressExportPolicy_StripAllMACs;
|
---|
152 | knownOptions[KExportOptions_StripAllNonNATMACs] = MACAddressExportPolicy_StripAllNonNATMACs;
|
---|
153 | /* Load currently supported export options: */
|
---|
154 | const QVector<KExportOptions> supportedOptions =
|
---|
155 | gpGlobalSession->virtualBox().GetSystemProperties().GetSupportedExportOptions();
|
---|
156 | /* Check which of supported options/policies are known: */
|
---|
157 | QList<MACAddressExportPolicy> supportedPolicies;
|
---|
158 | foreach (const KExportOptions &enmOption, supportedOptions)
|
---|
159 | if (knownOptions.contains(enmOption))
|
---|
160 | supportedPolicies << knownOptions.value(enmOption);
|
---|
161 | /* Remember current item data to be able to restore it: */
|
---|
162 | MACAddressExportPolicy enmOldData = MACAddressExportPolicy_MAX;
|
---|
163 | if (pCombo->currentIndex() != -1)
|
---|
164 | enmOldData = pCombo->currentData().value<MACAddressExportPolicy>();
|
---|
165 | else
|
---|
166 | {
|
---|
167 | if (supportedPolicies.contains(MACAddressExportPolicy_StripAllNonNATMACs))
|
---|
168 | enmOldData = MACAddressExportPolicy_StripAllNonNATMACs;
|
---|
169 | else
|
---|
170 | enmOldData = MACAddressExportPolicy_KeepAllMACs;
|
---|
171 | }
|
---|
172 |
|
---|
173 | /* Block signals while updating: */
|
---|
174 | pCombo->blockSignals(true);
|
---|
175 |
|
---|
176 | /* Clear combo initially: */
|
---|
177 | pCombo->clear();
|
---|
178 |
|
---|
179 | /* Add supported policies first: */
|
---|
180 | foreach (const MACAddressExportPolicy &enmPolicy, supportedPolicies)
|
---|
181 | pCombo->addItem(QString(), QVariant::fromValue(enmPolicy));
|
---|
182 |
|
---|
183 | /* Add hardcoded policy finally: */
|
---|
184 | pCombo->addItem(QString(), QVariant::fromValue(MACAddressExportPolicy_KeepAllMACs));
|
---|
185 |
|
---|
186 | /* Set previous/default item if possible: */
|
---|
187 | int iNewIndex = -1;
|
---|
188 | if ( iNewIndex == -1
|
---|
189 | && enmOldData != MACAddressExportPolicy_MAX)
|
---|
190 | iNewIndex = pCombo->findData(QVariant::fromValue(enmOldData));
|
---|
191 | if ( iNewIndex == -1
|
---|
192 | && pCombo->count() > 0)
|
---|
193 | iNewIndex = 0;
|
---|
194 | if (iNewIndex != -1)
|
---|
195 | pCombo->setCurrentIndex(iNewIndex);
|
---|
196 |
|
---|
197 | /* Unblock signals after update: */
|
---|
198 | pCombo->blockSignals(false);
|
---|
199 | }
|
---|
200 |
|
---|
201 | QString UIWizardExportAppFormat::format(QIComboBox *pCombo)
|
---|
202 | {
|
---|
203 | /* Sanity check: */
|
---|
204 | AssertPtrReturn(pCombo, QString());
|
---|
205 |
|
---|
206 | /* Give the actual result: */
|
---|
207 | return pCombo->currentData(FormatData_ShortName).toString();
|
---|
208 | }
|
---|
209 |
|
---|
210 | bool UIWizardExportAppFormat::isFormatCloudOne(QIComboBox *pCombo, int iIndex /* = -1 */)
|
---|
211 | {
|
---|
212 | /* Sanity check: */
|
---|
213 | AssertPtrReturn(pCombo, false);
|
---|
214 |
|
---|
215 | /* Handle special case, -1 means "current one": */
|
---|
216 | if (iIndex == -1)
|
---|
217 | iIndex = pCombo->currentIndex();
|
---|
218 |
|
---|
219 | /* Give the actual result: */
|
---|
220 | return pCombo->itemData(iIndex, FormatData_IsItCloudFormat).toBool();
|
---|
221 | }
|
---|
222 |
|
---|
223 | void UIWizardExportAppFormat::refreshStackedWidget(QStackedWidget *pStackedWidget, bool fIsFormatCloudOne)
|
---|
224 | {
|
---|
225 | /* Update stack appearance according to chosen format: */
|
---|
226 | pStackedWidget->setCurrentIndex((int)fIsFormatCloudOne);
|
---|
227 | }
|
---|
228 |
|
---|
229 | void UIWizardExportAppFormat::refreshFileSelectorName(QString &strFileSelectorName,
|
---|
230 | const QStringList &machineNames,
|
---|
231 | const QString &strDefaultApplianceName,
|
---|
232 | bool fIsFormatCloudOne)
|
---|
233 | {
|
---|
234 | /* If format is cloud one: */
|
---|
235 | if (fIsFormatCloudOne)
|
---|
236 | {
|
---|
237 | /* We use no name: */
|
---|
238 | strFileSelectorName.clear();
|
---|
239 | }
|
---|
240 | /* If format is local one: */
|
---|
241 | else
|
---|
242 | {
|
---|
243 | /* If it's one VM only, we use the VM name as file-name: */
|
---|
244 | if (machineNames.size() == 1)
|
---|
245 | strFileSelectorName = machineNames.first();
|
---|
246 | /* Otherwise => we use the default file-name: */
|
---|
247 | else
|
---|
248 | strFileSelectorName = strDefaultApplianceName;
|
---|
249 | }
|
---|
250 | }
|
---|
251 |
|
---|
252 | void UIWizardExportAppFormat::refreshFileSelectorExtension(QString &strFileSelectorExt,
|
---|
253 | UIEmptyFilePathSelector *pFileSelector,
|
---|
254 | bool fIsFormatCloudOne)
|
---|
255 | {
|
---|
256 | /* If format is cloud one: */
|
---|
257 | if (fIsFormatCloudOne)
|
---|
258 | {
|
---|
259 | /* We use no extension: */
|
---|
260 | strFileSelectorExt.clear();
|
---|
261 |
|
---|
262 | /* Update file chooser accordingly: */
|
---|
263 | pFileSelector->setFileFilters(QString());
|
---|
264 | }
|
---|
265 | /* If format is local one: */
|
---|
266 | else
|
---|
267 | {
|
---|
268 | /* We use the default (.ova) extension: */
|
---|
269 | strFileSelectorExt = ".ova";
|
---|
270 |
|
---|
271 | /* Update file chooser accordingly: */
|
---|
272 | pFileSelector->setFileFilters(UIWizardExportApp::tr("Open Virtualization Format Archive (%1)").arg("*.ova") + ";;" +
|
---|
273 | UIWizardExportApp::tr("Open Virtualization Format (%1)").arg("*.ovf"));
|
---|
274 | }
|
---|
275 | }
|
---|
276 |
|
---|
277 | void UIWizardExportAppFormat::refreshFileSelectorPath(UIEmptyFilePathSelector *pFileSelector,
|
---|
278 | const QString &strFileSelectorName,
|
---|
279 | const QString &strFileSelectorExt,
|
---|
280 | bool fIsFormatCloudOne)
|
---|
281 | {
|
---|
282 | /* If format is cloud one: */
|
---|
283 | if (fIsFormatCloudOne)
|
---|
284 | {
|
---|
285 | /* Clear file selector path: */
|
---|
286 | pFileSelector->setPath(QString());
|
---|
287 | }
|
---|
288 | /* If format is local one: */
|
---|
289 | else
|
---|
290 | {
|
---|
291 | /* Compose file selector path: */
|
---|
292 | const QString strPath = QDir::toNativeSeparators(QString("%1/%2")
|
---|
293 | .arg(uiCommon().documentsPath())
|
---|
294 | .arg(strFileSelectorName + strFileSelectorExt));
|
---|
295 | pFileSelector->setPath(strPath);
|
---|
296 | }
|
---|
297 | }
|
---|
298 |
|
---|
299 | void UIWizardExportAppFormat::refreshManifestCheckBoxAccess(QCheckBox *pCheckBox,
|
---|
300 | bool fIsFormatCloudOne)
|
---|
301 | {
|
---|
302 | /* If format is cloud one: */
|
---|
303 | if (fIsFormatCloudOne)
|
---|
304 | {
|
---|
305 | /* Disable manifest check-box: */
|
---|
306 | pCheckBox->setChecked(false);
|
---|
307 | pCheckBox->setEnabled(false);
|
---|
308 | }
|
---|
309 | /* If format is local one: */
|
---|
310 | else
|
---|
311 | {
|
---|
312 | /* Enable and select manifest check-box: */
|
---|
313 | pCheckBox->setChecked(true);
|
---|
314 | pCheckBox->setEnabled(true);
|
---|
315 | }
|
---|
316 | }
|
---|
317 |
|
---|
318 | void UIWizardExportAppFormat::refreshIncludeISOsCheckBoxAccess(QCheckBox *pCheckBox,
|
---|
319 | bool fIsFormatCloudOne)
|
---|
320 | {
|
---|
321 | /* If format is cloud one: */
|
---|
322 | if (fIsFormatCloudOne)
|
---|
323 | {
|
---|
324 | /* Disable include ISO check-box: */
|
---|
325 | pCheckBox->setChecked(false);
|
---|
326 | pCheckBox->setEnabled(false);
|
---|
327 | }
|
---|
328 | /* If format is local one: */
|
---|
329 | else
|
---|
330 | {
|
---|
331 | /* Enable include ISO check-box: */
|
---|
332 | pCheckBox->setEnabled(true);
|
---|
333 | }
|
---|
334 | }
|
---|
335 |
|
---|
336 | void UIWizardExportAppFormat::refreshLocalStuff(CAppliance &comLocalAppliance,
|
---|
337 | UIWizardExportApp *pWizard,
|
---|
338 | const QList<QUuid> &machineIDs,
|
---|
339 | const QString &strUri)
|
---|
340 | {
|
---|
341 | /* Clear stuff: */
|
---|
342 | comLocalAppliance = CAppliance();
|
---|
343 |
|
---|
344 | /* Create appliance: */
|
---|
345 | CVirtualBox comVBox = gpGlobalSession->virtualBox();
|
---|
346 | CAppliance comAppliance = comVBox.CreateAppliance();
|
---|
347 | if (!comVBox.isOk())
|
---|
348 | return UINotificationMessage::cannotCreateAppliance(comVBox, pWizard->notificationCenter());
|
---|
349 |
|
---|
350 | /* Remember appliance: */
|
---|
351 | comLocalAppliance = comAppliance;
|
---|
352 |
|
---|
353 | /* Iterate over all the selected machine uuids: */
|
---|
354 | foreach (const QUuid &uMachineId, machineIDs)
|
---|
355 | {
|
---|
356 | /* Get the machine with the uMachineId: */
|
---|
357 | CVirtualBox comVBox = gpGlobalSession->virtualBox();
|
---|
358 | CMachine comMachine = comVBox.FindMachine(uMachineId.toString());
|
---|
359 | if (!comVBox.isOk())
|
---|
360 | return UINotificationMessage::cannotFindMachineById(comVBox, uMachineId, pWizard->notificationCenter());
|
---|
361 | /* Add the export description to our appliance object: */
|
---|
362 | CVirtualSystemDescription comVsd = comMachine.ExportTo(comLocalAppliance, strUri);
|
---|
363 | if (!comMachine.isOk())
|
---|
364 | return UINotificationMessage::cannotExportMachine(comMachine, pWizard->notificationCenter());
|
---|
365 | /* Add some additional fields the user may change: */
|
---|
366 | comVsd.AddDescription(KVirtualSystemDescriptionType_Product, "", "");
|
---|
367 | comVsd.AddDescription(KVirtualSystemDescriptionType_ProductUrl, "", "");
|
---|
368 | comVsd.AddDescription(KVirtualSystemDescriptionType_Vendor, "", "");
|
---|
369 | comVsd.AddDescription(KVirtualSystemDescriptionType_VendorUrl, "", "");
|
---|
370 | comVsd.AddDescription(KVirtualSystemDescriptionType_Version, "", "");
|
---|
371 | comVsd.AddDescription(KVirtualSystemDescriptionType_License, "", "");
|
---|
372 | }
|
---|
373 | }
|
---|
374 |
|
---|
375 | void UIWizardExportAppFormat::refreshProfileCombo(QIComboBox *pCombo,
|
---|
376 | UINotificationCenter *pCenter,
|
---|
377 | const QString &strFormat,
|
---|
378 | bool fIsFormatCloudOne)
|
---|
379 | {
|
---|
380 | /* Sanity check: */
|
---|
381 | AssertPtrReturnVoid(pCombo);
|
---|
382 |
|
---|
383 | /* If format is cloud one: */
|
---|
384 | if (fIsFormatCloudOne)
|
---|
385 | {
|
---|
386 | /* Acquire provider: */
|
---|
387 | CCloudProvider comProvider = cloudProviderByShortName(strFormat, pCenter);
|
---|
388 | AssertReturnVoid(comProvider.isNotNull());
|
---|
389 |
|
---|
390 | /* Remember current item data to be able to restore it: */
|
---|
391 | QString strOldData;
|
---|
392 | if (pCombo->currentIndex() != -1)
|
---|
393 | strOldData = pCombo->currentData(ProfileData_Name).toString();
|
---|
394 |
|
---|
395 | /* Block signals while updating: */
|
---|
396 | pCombo->blockSignals(true);
|
---|
397 |
|
---|
398 | /* Clear combo initially: */
|
---|
399 | pCombo->clear();
|
---|
400 |
|
---|
401 | /* Acquire restricted accounts: */
|
---|
402 | const QStringList restrictedProfiles = gEDataManager->cloudProfileManagerRestrictions();
|
---|
403 |
|
---|
404 | /* Iterate through existing profile names: */
|
---|
405 | QStringList allowedProfileNames;
|
---|
406 | QStringList restrictedProfileNames;
|
---|
407 | foreach (const CCloudProfile &comProfile, listCloudProfiles(comProvider, pCenter))
|
---|
408 | {
|
---|
409 | /* Skip if we have nothing to populate (wtf happened?): */
|
---|
410 | if (comProfile.isNull())
|
---|
411 | continue;
|
---|
412 | /* Acquire profile name: */
|
---|
413 | QString strCurrentProfileName;
|
---|
414 | if (!cloudProfileName(comProfile, strCurrentProfileName, pCenter))
|
---|
415 | continue;
|
---|
416 |
|
---|
417 | /* Compose full profile name: */
|
---|
418 | const QString strFullProfileName = QString("/%1/%2").arg(strFormat).arg(strCurrentProfileName);
|
---|
419 | /* Append to appropriate list: */
|
---|
420 | if (restrictedProfiles.contains(strFullProfileName))
|
---|
421 | restrictedProfileNames.append(strCurrentProfileName);
|
---|
422 | else
|
---|
423 | allowedProfileNames.append(strCurrentProfileName);
|
---|
424 | }
|
---|
425 |
|
---|
426 | /* Add allowed items: */
|
---|
427 | foreach (const QString &strAllowedProfileName, allowedProfileNames)
|
---|
428 | {
|
---|
429 | /* Compose item, fill it's data: */
|
---|
430 | pCombo->addItem(strAllowedProfileName);
|
---|
431 | pCombo->setItemData(pCombo->count() - 1, strAllowedProfileName, ProfileData_Name);
|
---|
432 | QFont fnt = pCombo->font();
|
---|
433 | fnt.setBold(true);
|
---|
434 | pCombo->setItemData(pCombo->count() - 1, fnt, Qt::FontRole);
|
---|
435 | }
|
---|
436 | /* Add restricted items: */
|
---|
437 | foreach (const QString &strRestrictedProfileName, restrictedProfileNames)
|
---|
438 | {
|
---|
439 | /* Compose item, fill it's data: */
|
---|
440 | pCombo->addItem(strRestrictedProfileName);
|
---|
441 | pCombo->setItemData(pCombo->count() - 1, strRestrictedProfileName, ProfileData_Name);
|
---|
442 | QBrush brsh;
|
---|
443 | brsh.setColor(Qt::gray);
|
---|
444 | pCombo->setItemData(pCombo->count() - 1, brsh, Qt::ForegroundRole);
|
---|
445 | }
|
---|
446 |
|
---|
447 | /* Set previous/default item if possible: */
|
---|
448 | int iNewIndex = -1;
|
---|
449 | if ( iNewIndex == -1
|
---|
450 | && !strOldData.isNull())
|
---|
451 | iNewIndex = pCombo->findData(strOldData, ProfileData_Name);
|
---|
452 | if ( iNewIndex == -1
|
---|
453 | && pCombo->count() > 0)
|
---|
454 | iNewIndex = 0;
|
---|
455 | if (iNewIndex != -1)
|
---|
456 | pCombo->setCurrentIndex(iNewIndex);
|
---|
457 |
|
---|
458 | /* Unblock signals after update: */
|
---|
459 | pCombo->blockSignals(false);
|
---|
460 | }
|
---|
461 | /* If format is local one: */
|
---|
462 | else
|
---|
463 | {
|
---|
464 | /* Block signals while updating: */
|
---|
465 | pCombo->blockSignals(true);
|
---|
466 |
|
---|
467 | /* Clear combo: */
|
---|
468 | pCombo->clear();
|
---|
469 |
|
---|
470 | /* Unblock signals after update: */
|
---|
471 | pCombo->blockSignals(false);
|
---|
472 | }
|
---|
473 | }
|
---|
474 |
|
---|
475 | void UIWizardExportAppFormat::refreshCloudProfile(CCloudProfile &comCloudProfile,
|
---|
476 | UINotificationCenter *pCenter,
|
---|
477 | const QString &strShortProviderName,
|
---|
478 | const QString &strProfileName,
|
---|
479 | bool fIsFormatCloudOne)
|
---|
480 | {
|
---|
481 | /* If format is cloud one: */
|
---|
482 | if (fIsFormatCloudOne)
|
---|
483 | comCloudProfile = cloudProfileByName(strShortProviderName, strProfileName, pCenter);
|
---|
484 | /* If format is local one: */
|
---|
485 | else
|
---|
486 | comCloudProfile = CCloudProfile();
|
---|
487 | }
|
---|
488 |
|
---|
489 | void UIWizardExportAppFormat::refreshCloudExportMode(const QMap<CloudExportMode, QAbstractButton*> &radios,
|
---|
490 | bool fIsFormatCloudOne)
|
---|
491 | {
|
---|
492 | /* If format is cloud one: */
|
---|
493 | if (fIsFormatCloudOne)
|
---|
494 | {
|
---|
495 | /* Check if something already chosen: */
|
---|
496 | bool fSomethingChosen = false;
|
---|
497 | foreach (QAbstractButton *pButton, radios.values())
|
---|
498 | if (pButton->isChecked())
|
---|
499 | fSomethingChosen = true;
|
---|
500 | /* Choose default cloud export option: */
|
---|
501 | if (!fSomethingChosen)
|
---|
502 | radios.value(CloudExportMode_ExportThenAsk)->setChecked(true);
|
---|
503 | }
|
---|
504 | /* If format is local one: */
|
---|
505 | else
|
---|
506 | {
|
---|
507 | /* Make sure nothing chosen: */
|
---|
508 | foreach (QAbstractButton *pButton, radios.values())
|
---|
509 | pButton->setChecked(false);
|
---|
510 | }
|
---|
511 | }
|
---|
512 |
|
---|
513 | void UIWizardExportAppFormat::refreshCloudStuff(CAppliance &comCloudAppliance,
|
---|
514 | CCloudClient &comCloudClient,
|
---|
515 | CVirtualSystemDescription &comCloudVsd,
|
---|
516 | CVirtualSystemDescriptionForm &comCloudVsdExportForm,
|
---|
517 | UIWizardExportApp *pWizard,
|
---|
518 | const CCloudProfile &comCloudProfile,
|
---|
519 | const QList<QUuid> &machineIDs,
|
---|
520 | const QString &strUri,
|
---|
521 | const CloudExportMode enmCloudExportMode)
|
---|
522 | {
|
---|
523 | /* Clear stuff: */
|
---|
524 | comCloudAppliance = CAppliance();
|
---|
525 | comCloudClient = CCloudClient();
|
---|
526 | comCloudVsd = CVirtualSystemDescription();
|
---|
527 | comCloudVsdExportForm = CVirtualSystemDescriptionForm();
|
---|
528 |
|
---|
529 | /* Sanity check: */
|
---|
530 | if (comCloudProfile.isNull())
|
---|
531 | return;
|
---|
532 | if (machineIDs.isEmpty())
|
---|
533 | return;
|
---|
534 |
|
---|
535 | /* Perform cloud export procedure for first uuid only: */
|
---|
536 | const QUuid uMachineId = machineIDs.first();
|
---|
537 |
|
---|
538 | /* Get the machine with the uMachineId: */
|
---|
539 | CVirtualBox comVBox = gpGlobalSession->virtualBox();
|
---|
540 | CMachine comMachine = comVBox.FindMachine(uMachineId.toString());
|
---|
541 | if (!comVBox.isOk())
|
---|
542 | return UINotificationMessage::cannotFindMachineById(comVBox, uMachineId, pWizard->notificationCenter());
|
---|
543 |
|
---|
544 | /* Create appliance: */
|
---|
545 | CAppliance comAppliance = comVBox.CreateAppliance();
|
---|
546 | if (!comVBox.isOk())
|
---|
547 | return UINotificationMessage::cannotCreateAppliance(comVBox, pWizard->notificationCenter());
|
---|
548 |
|
---|
549 | /* Remember appliance: */
|
---|
550 | comCloudAppliance = comAppliance;
|
---|
551 |
|
---|
552 | /* Add the export virtual system description to our appliance object: */
|
---|
553 | CVirtualSystemDescription comVsd = comMachine.ExportTo(comCloudAppliance, strUri);
|
---|
554 | if (!comMachine.isOk())
|
---|
555 | return UINotificationMessage::cannotExportMachine(comMachine, pWizard->notificationCenter());
|
---|
556 |
|
---|
557 | /* Remember description: */
|
---|
558 | comCloudVsd = comVsd;
|
---|
559 |
|
---|
560 | /* Add Launch Instance flag to virtual system description: */
|
---|
561 | switch (enmCloudExportMode)
|
---|
562 | {
|
---|
563 | case CloudExportMode_AskThenExport:
|
---|
564 | case CloudExportMode_ExportThenAsk:
|
---|
565 | comCloudVsd.AddDescription(KVirtualSystemDescriptionType_CloudLaunchInstance, "true", QString());
|
---|
566 | break;
|
---|
567 | default:
|
---|
568 | comCloudVsd.AddDescription(KVirtualSystemDescriptionType_CloudLaunchInstance, "false", QString());
|
---|
569 | break;
|
---|
570 | }
|
---|
571 | if (!comCloudVsd.isOk())
|
---|
572 | return UINotificationMessage::cannotChangeVirtualSystemDescriptionParameter(comCloudVsd, pWizard->notificationCenter());
|
---|
573 |
|
---|
574 | /* Create Cloud Client: */
|
---|
575 | CCloudClient comClient = cloudClient(comCloudProfile);
|
---|
576 | if (comClient.isNull())
|
---|
577 | return;
|
---|
578 |
|
---|
579 | /* Remember client: */
|
---|
580 | comCloudClient = comClient;
|
---|
581 |
|
---|
582 | /* Read Cloud Client Export description form: */
|
---|
583 | CVirtualSystemDescriptionForm comVsdExportForm;
|
---|
584 | bool fResult = exportDescriptionForm(comCloudClient, comCloudVsd, comVsdExportForm, pWizard->notificationCenter());
|
---|
585 | if (!fResult)
|
---|
586 | return;
|
---|
587 |
|
---|
588 | /* Remember export description form: */
|
---|
589 | comCloudVsdExportForm = comVsdExportForm;
|
---|
590 | }
|
---|
591 |
|
---|
592 | QString UIWizardExportAppFormat::profileName(QIComboBox *pCombo)
|
---|
593 | {
|
---|
594 | return pCombo->currentData(ProfileData_Name).toString();
|
---|
595 | }
|
---|
596 |
|
---|
597 | void UIWizardExportAppFormat::updateFormatComboToolTip(QIComboBox *pCombo)
|
---|
598 | {
|
---|
599 | AssertPtrReturnVoid(pCombo);
|
---|
600 | QString strCurrentToolTip;
|
---|
601 | if (pCombo->count() != 0)
|
---|
602 | {
|
---|
603 | strCurrentToolTip = pCombo->currentData(Qt::ToolTipRole).toString();
|
---|
604 | AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!"));
|
---|
605 | }
|
---|
606 | pCombo->setToolTip(strCurrentToolTip);
|
---|
607 | }
|
---|
608 |
|
---|
609 | void UIWizardExportAppFormat::updateMACAddressExportPolicyComboToolTip(QIComboBox *pCombo)
|
---|
610 | {
|
---|
611 | AssertPtrReturnVoid(pCombo);
|
---|
612 | QString strCurrentToolTip;
|
---|
613 | if (pCombo->count() != 0)
|
---|
614 | {
|
---|
615 | strCurrentToolTip = pCombo->currentData(Qt::ToolTipRole).toString();
|
---|
616 | AssertMsg(!strCurrentToolTip.isEmpty(), ("Data not found!"));
|
---|
617 | }
|
---|
618 | pCombo->setToolTip(strCurrentToolTip);
|
---|
619 | }
|
---|
620 |
|
---|
621 |
|
---|
622 | /*********************************************************************************************************************************
|
---|
623 | * Class UIWizardExportAppPageFormat implementation. *
|
---|
624 | *********************************************************************************************************************************/
|
---|
625 |
|
---|
626 | UIWizardExportAppPageFormat::UIWizardExportAppPageFormat(bool fExportToOCIByDefault)
|
---|
627 | : m_fExportToOCIByDefault(fExportToOCIByDefault)
|
---|
628 | , m_pLabelFormat(0)
|
---|
629 | , m_pLabelSettings(0)
|
---|
630 | , m_pFormatLayout(0)
|
---|
631 | , m_pFormatComboBoxLabel(0)
|
---|
632 | , m_pFormatComboBox(0)
|
---|
633 | , m_pSettingsWidget1(0)
|
---|
634 | , m_pSettingsLayout1(0)
|
---|
635 | , m_pFileSelectorLabel(0)
|
---|
636 | , m_pFileSelector(0)
|
---|
637 | , m_pMACComboBoxLabel(0)
|
---|
638 | , m_pMACComboBox(0)
|
---|
639 | , m_pAdditionalLabel(0)
|
---|
640 | , m_pManifestCheckbox(0)
|
---|
641 | , m_pIncludeISOsCheckbox(0)
|
---|
642 | , m_pSettingsLayout2(0)
|
---|
643 | , m_pProfileLabel(0)
|
---|
644 | , m_pProfileComboBox(0)
|
---|
645 | , m_pProfileToolButton(0)
|
---|
646 | , m_pExportModeLabel(0)
|
---|
647 | , m_pExportModeButtonGroup(0)
|
---|
648 | {
|
---|
649 | /* Create main layout: */
|
---|
650 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
651 | if (pMainLayout)
|
---|
652 | {
|
---|
653 | /* Create format label: */
|
---|
654 | m_pLabelFormat = new QIRichTextLabel(this);
|
---|
655 | if (m_pLabelFormat)
|
---|
656 | pMainLayout->addWidget(m_pLabelFormat);
|
---|
657 |
|
---|
658 | /* Create format layout: */
|
---|
659 | m_pFormatLayout = new QGridLayout;
|
---|
660 | if (m_pFormatLayout)
|
---|
661 | {
|
---|
662 | #ifdef VBOX_WS_MAC
|
---|
663 | m_pFormatLayout->setContentsMargins(0, 10, 0, 10);
|
---|
664 | m_pFormatLayout->setSpacing(10);
|
---|
665 | #else
|
---|
666 | m_pFormatLayout->setContentsMargins(0, qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin),
|
---|
667 | 0, qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
|
---|
668 | #endif
|
---|
669 | m_pFormatLayout->setColumnStretch(0, 0);
|
---|
670 | m_pFormatLayout->setColumnStretch(1, 1);
|
---|
671 |
|
---|
672 | /* Create format combo-box label: */
|
---|
673 | m_pFormatComboBoxLabel = new QLabel(this);
|
---|
674 | if (m_pFormatComboBoxLabel)
|
---|
675 | {
|
---|
676 | m_pFormatComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
---|
677 | m_pFormatLayout->addWidget(m_pFormatComboBoxLabel, 0, 0);
|
---|
678 | }
|
---|
679 | /* Create format combo-box: */
|
---|
680 | m_pFormatComboBox = new QIComboBox(this);
|
---|
681 | if (m_pFormatComboBox)
|
---|
682 | {
|
---|
683 | m_pFormatComboBoxLabel->setBuddy(m_pFormatComboBox);
|
---|
684 | m_pFormatLayout->addWidget(m_pFormatComboBox, 0, 1);
|
---|
685 | }
|
---|
686 |
|
---|
687 | /* Add into layout: */
|
---|
688 | pMainLayout->addLayout(m_pFormatLayout);
|
---|
689 | }
|
---|
690 |
|
---|
691 | /* Create settings label: */
|
---|
692 | m_pLabelSettings = new QIRichTextLabel(this);
|
---|
693 | if (m_pLabelSettings)
|
---|
694 | pMainLayout->addWidget(m_pLabelSettings);
|
---|
695 |
|
---|
696 | /* Create settings widget 1: */
|
---|
697 | m_pSettingsWidget1 = new QStackedWidget(this);
|
---|
698 | if (m_pSettingsWidget1)
|
---|
699 | {
|
---|
700 | /* Create settings pane 1: */
|
---|
701 | QWidget *pSettingsPane1 = new QWidget(m_pSettingsWidget1);
|
---|
702 | if (pSettingsPane1)
|
---|
703 | {
|
---|
704 | /* Create settings layout 1: */
|
---|
705 | m_pSettingsLayout1 = new QGridLayout(pSettingsPane1);
|
---|
706 | if (m_pSettingsLayout1)
|
---|
707 | {
|
---|
708 | #ifdef VBOX_WS_MAC
|
---|
709 | m_pSettingsLayout1->setContentsMargins(0, 10, 0, 10);
|
---|
710 | m_pSettingsLayout1->setSpacing(10);
|
---|
711 | #else
|
---|
712 | m_pSettingsLayout1->setContentsMargins(0, qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin),
|
---|
713 | 0, qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
|
---|
714 | #endif
|
---|
715 | m_pSettingsLayout1->setColumnStretch(0, 0);
|
---|
716 | m_pSettingsLayout1->setColumnStretch(1, 1);
|
---|
717 |
|
---|
718 | /* Create file selector: */
|
---|
719 | m_pFileSelector = new UIEmptyFilePathSelector(pSettingsPane1);
|
---|
720 | if (m_pFileSelector)
|
---|
721 | {
|
---|
722 | m_pFileSelector->setMode(UIEmptyFilePathSelector::Mode_File_Save);
|
---|
723 | m_pFileSelector->setEditable(true);
|
---|
724 | m_pFileSelector->setButtonPosition(UIEmptyFilePathSelector::RightPosition);
|
---|
725 | m_pFileSelector->setDefaultSaveExt("ova");
|
---|
726 | m_pSettingsLayout1->addWidget(m_pFileSelector, 0, 1, 1, 2);
|
---|
727 | }
|
---|
728 | /* Create file selector label: */
|
---|
729 | m_pFileSelectorLabel = new QLabel(pSettingsPane1);
|
---|
730 | if (m_pFileSelectorLabel)
|
---|
731 | {
|
---|
732 | m_pFileSelectorLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
---|
733 | m_pFileSelectorLabel->setBuddy(m_pFileSelector);
|
---|
734 | m_pSettingsLayout1->addWidget(m_pFileSelectorLabel, 0, 0);
|
---|
735 | }
|
---|
736 |
|
---|
737 | /* Create MAC policy combo-box: */
|
---|
738 | m_pMACComboBox = new QIComboBox(pSettingsPane1);
|
---|
739 | if (m_pMACComboBox)
|
---|
740 | m_pSettingsLayout1->addWidget(m_pMACComboBox, 1, 1, 1, 2);
|
---|
741 | /* Create format combo-box label: */
|
---|
742 | m_pMACComboBoxLabel = new QLabel(pSettingsPane1);
|
---|
743 | if (m_pMACComboBoxLabel)
|
---|
744 | {
|
---|
745 | m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
---|
746 | m_pMACComboBoxLabel->setBuddy(m_pMACComboBox);
|
---|
747 | m_pSettingsLayout1->addWidget(m_pMACComboBoxLabel, 1, 0);
|
---|
748 | }
|
---|
749 |
|
---|
750 | /* Create advanced label: */
|
---|
751 | m_pAdditionalLabel = new QLabel(pSettingsPane1);
|
---|
752 | if (m_pAdditionalLabel)
|
---|
753 | {
|
---|
754 | m_pAdditionalLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
---|
755 | m_pSettingsLayout1->addWidget(m_pAdditionalLabel, 2, 0);
|
---|
756 | }
|
---|
757 | /* Create manifest check-box: */
|
---|
758 | m_pManifestCheckbox = new QCheckBox(pSettingsPane1);
|
---|
759 | if (m_pManifestCheckbox)
|
---|
760 | m_pSettingsLayout1->addWidget(m_pManifestCheckbox, 2, 1);
|
---|
761 | /* Create include ISOs check-box: */
|
---|
762 | m_pIncludeISOsCheckbox = new QCheckBox(pSettingsPane1);
|
---|
763 | if (m_pIncludeISOsCheckbox)
|
---|
764 | m_pSettingsLayout1->addWidget(m_pIncludeISOsCheckbox, 3, 1);
|
---|
765 |
|
---|
766 | /* Create placeholder: */
|
---|
767 | QWidget *pPlaceholder = new QWidget(pSettingsPane1);
|
---|
768 | if (pPlaceholder)
|
---|
769 | m_pSettingsLayout1->addWidget(pPlaceholder, 4, 0, 1, 3);
|
---|
770 | }
|
---|
771 |
|
---|
772 | /* Add into layout: */
|
---|
773 | m_pSettingsWidget1->addWidget(pSettingsPane1);
|
---|
774 | }
|
---|
775 |
|
---|
776 | /* Create settings pane 2: */
|
---|
777 | QWidget *pSettingsPane2 = new QWidget(m_pSettingsWidget1);
|
---|
778 | if (pSettingsPane2)
|
---|
779 | {
|
---|
780 | /* Create settings layout 2: */
|
---|
781 | m_pSettingsLayout2 = new QGridLayout(pSettingsPane2);
|
---|
782 | if (m_pSettingsLayout2)
|
---|
783 | {
|
---|
784 | #ifdef VBOX_WS_MAC
|
---|
785 | m_pSettingsLayout2->setContentsMargins(0, 10, 0, 10);
|
---|
786 | m_pSettingsLayout2->setSpacing(10);
|
---|
787 |
|
---|
788 | #else
|
---|
789 | m_pSettingsLayout2->setContentsMargins(0, qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin),
|
---|
790 | 0, qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
|
---|
791 | #endif
|
---|
792 | m_pSettingsLayout2->setColumnStretch(0, 0);
|
---|
793 | m_pSettingsLayout2->setColumnStretch(1, 1);
|
---|
794 | m_pSettingsLayout2->setRowStretch(4, 1);
|
---|
795 |
|
---|
796 | /* Create profile label: */
|
---|
797 | m_pProfileLabel = new QLabel(pSettingsPane2);
|
---|
798 | if (m_pProfileLabel)
|
---|
799 | {
|
---|
800 | m_pProfileLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
---|
801 | m_pSettingsLayout2->addWidget(m_pProfileLabel, 0, 0);
|
---|
802 | }
|
---|
803 | /* Create sub-layout: */
|
---|
804 | QHBoxLayout *pSubLayout = new QHBoxLayout;
|
---|
805 | if (pSubLayout)
|
---|
806 | {
|
---|
807 | pSubLayout->setContentsMargins(0, 0, 0, 0);
|
---|
808 | pSubLayout->setSpacing(1);
|
---|
809 |
|
---|
810 | /* Create profile combo-box: */
|
---|
811 | m_pProfileComboBox = new QIComboBox(pSettingsPane2);
|
---|
812 | if (m_pProfileComboBox)
|
---|
813 | {
|
---|
814 | m_pProfileLabel->setBuddy(m_pProfileComboBox);
|
---|
815 | pSubLayout->addWidget(m_pProfileComboBox);
|
---|
816 | }
|
---|
817 | /* Create profile tool-button: */
|
---|
818 | m_pProfileToolButton = new QIToolButton(pSettingsPane2);
|
---|
819 | if (m_pProfileToolButton)
|
---|
820 | {
|
---|
821 | m_pProfileToolButton->setIcon(UIIconPool::iconSet(":/cloud_profile_manager_16px.png",
|
---|
822 | ":/cloud_profile_manager_disabled_16px.png"));
|
---|
823 | pSubLayout->addWidget(m_pProfileToolButton);
|
---|
824 | }
|
---|
825 |
|
---|
826 | /* Add into layout: */
|
---|
827 | m_pSettingsLayout2->addLayout(pSubLayout, 0, 1);
|
---|
828 | }
|
---|
829 |
|
---|
830 | /* Create profile label: */
|
---|
831 | m_pExportModeLabel = new QLabel(pSettingsPane2);
|
---|
832 | if (m_pExportModeLabel)
|
---|
833 | {
|
---|
834 | m_pExportModeLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
---|
835 | m_pSettingsLayout2->addWidget(m_pExportModeLabel, 1, 0);
|
---|
836 | }
|
---|
837 |
|
---|
838 | /* Create button-group: */
|
---|
839 | m_pExportModeButtonGroup = new QButtonGroup(pSettingsPane2);
|
---|
840 | if (m_pExportModeButtonGroup)
|
---|
841 | {
|
---|
842 | /* Create Do Not Ask button: */
|
---|
843 | m_exportModeButtons[CloudExportMode_DoNotAsk] = new QRadioButton(pSettingsPane2);
|
---|
844 | if (m_exportModeButtons.value(CloudExportMode_DoNotAsk))
|
---|
845 | {
|
---|
846 | m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_DoNotAsk));
|
---|
847 | m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_DoNotAsk), 1, 1);
|
---|
848 | }
|
---|
849 | /* Create Ask Then Export button: */
|
---|
850 | m_exportModeButtons[CloudExportMode_AskThenExport] = new QRadioButton(pSettingsPane2);
|
---|
851 | if (m_exportModeButtons.value(CloudExportMode_AskThenExport))
|
---|
852 | {
|
---|
853 | m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_AskThenExport));
|
---|
854 | m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_AskThenExport), 2, 1);
|
---|
855 | }
|
---|
856 | /* Create Export Then Ask button: */
|
---|
857 | m_exportModeButtons[CloudExportMode_ExportThenAsk] = new QRadioButton(pSettingsPane2);
|
---|
858 | if (m_exportModeButtons.value(CloudExportMode_ExportThenAsk))
|
---|
859 | {
|
---|
860 | m_pExportModeButtonGroup->addButton(m_exportModeButtons.value(CloudExportMode_ExportThenAsk));
|
---|
861 | m_pSettingsLayout2->addWidget(m_exportModeButtons.value(CloudExportMode_ExportThenAsk), 3, 1);
|
---|
862 | }
|
---|
863 | }
|
---|
864 | }
|
---|
865 |
|
---|
866 | /* Add into layout: */
|
---|
867 | m_pSettingsWidget1->addWidget(pSettingsPane2);
|
---|
868 | }
|
---|
869 |
|
---|
870 | /* Add into layout: */
|
---|
871 | pMainLayout->addWidget(m_pSettingsWidget1);
|
---|
872 | }
|
---|
873 | }
|
---|
874 |
|
---|
875 | /* Setup connections: */
|
---|
876 | connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigCloudProfileRegistered,
|
---|
877 | this, &UIWizardExportAppPageFormat::sltHandleFormatComboChange);
|
---|
878 | connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigCloudProfileChanged,
|
---|
879 | this, &UIWizardExportAppPageFormat::sltHandleFormatComboChange);
|
---|
880 | connect(m_pFileSelector, &UIEmptyFilePathSelector::pathChanged,
|
---|
881 | this, &UIWizardExportAppPageFormat::sltHandleFileSelectorChange);
|
---|
882 | connect(m_pFormatComboBox, &QIComboBox::currentIndexChanged,
|
---|
883 | this, &UIWizardExportAppPageFormat::sltHandleFormatComboChange);
|
---|
884 | connect(m_pMACComboBox, &QIComboBox::currentIndexChanged,
|
---|
885 | this, &UIWizardExportAppPageFormat::sltHandleMACAddressExportPolicyComboChange);
|
---|
886 | connect(m_pManifestCheckbox, &QCheckBox::stateChanged,
|
---|
887 | this, &UIWizardExportAppPageFormat::sltHandleManifestCheckBoxChange);
|
---|
888 | connect(m_pIncludeISOsCheckbox, &QCheckBox::stateChanged,
|
---|
889 | this, &UIWizardExportAppPageFormat::sltHandleIncludeISOsCheckBoxChange);
|
---|
890 | connect(m_pProfileComboBox, &QIComboBox::currentIndexChanged,
|
---|
891 | this, &UIWizardExportAppPageFormat::sltHandleProfileComboChange);
|
---|
892 | connect(m_pExportModeButtonGroup, &QButtonGroup::buttonToggled,
|
---|
893 | this, &UIWizardExportAppPageFormat::sltHandleRadioButtonToggled);
|
---|
894 | connect(m_pProfileToolButton, &QIToolButton::clicked,
|
---|
895 | this, &UIWizardExportAppPageFormat::sltHandleProfileButtonClick);
|
---|
896 | }
|
---|
897 |
|
---|
898 | UIWizardExportApp *UIWizardExportAppPageFormat::wizard() const
|
---|
899 | {
|
---|
900 | return qobject_cast<UIWizardExportApp*>(UINativeWizardPage::wizard());
|
---|
901 | }
|
---|
902 |
|
---|
903 | void UIWizardExportAppPageFormat::sltRetranslateUI()
|
---|
904 | {
|
---|
905 | /* Translate page: */
|
---|
906 | setTitle(UIWizardExportApp::tr("Format settings"));
|
---|
907 |
|
---|
908 | /* Translate objects: */
|
---|
909 | m_strDefaultApplianceName = UIWizardExportApp::tr("Appliance");
|
---|
910 | refreshFileSelectorName(m_strFileSelectorName, wizard()->machineNames(), m_strDefaultApplianceName, wizard()->isFormatCloudOne());
|
---|
911 | refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne());
|
---|
912 |
|
---|
913 | /* Translate format label: */
|
---|
914 | m_pLabelFormat->setText(UIWizardExportApp::
|
---|
915 | tr("<p>Please choose a format to export the virtual appliance to.</p>"
|
---|
916 | "<p>The <b>Open Virtualization Format</b> supports only <b>ovf</b> or <b>ova</b> extensions. "
|
---|
917 | "If you use the <b>ovf</b> extension, several files will be written separately. "
|
---|
918 | "If you use the <b>ova</b> extension, all the files will be combined into one Open "
|
---|
919 | "Virtualization Format archive.</p>"
|
---|
920 | "<p>The <b>Oracle Cloud Infrastructure</b> format supports exporting to remote cloud servers only. "
|
---|
921 | "Main virtual disk of each selected machine will be uploaded to remote server.</p>"));
|
---|
922 |
|
---|
923 | /* Translate settings label: */
|
---|
924 | if (wizard()->isFormatCloudOne())
|
---|
925 | m_pLabelSettings->setText(UIWizardExportApp::
|
---|
926 | tr("Please choose one of cloud service profiles you have registered to export virtual "
|
---|
927 | "machines to. It will be used to establish network connection required to upload your "
|
---|
928 | "virtual machine files to a remote cloud facility."));
|
---|
929 | else
|
---|
930 | m_pLabelSettings->setText(UIWizardExportApp::
|
---|
931 | tr("Please choose a filename to export the virtual appliance to. Besides that you can "
|
---|
932 | "specify a certain amount of options which affects the size and content of resulting "
|
---|
933 | "archive."));
|
---|
934 |
|
---|
935 | /* Translate file selector: */
|
---|
936 | m_pFileSelectorLabel->setText(UIWizardExportApp::tr("&File:"));
|
---|
937 | m_pFileSelector->setChooseButtonToolTip(UIWizardExportApp::tr("Choose a file to export the virtual appliance to..."));
|
---|
938 | m_pFileSelector->setFileDialogTitle(UIWizardExportApp::tr("Please choose a file to export the virtual appliance to"));
|
---|
939 |
|
---|
940 | /* Translate hardcoded values of Format combo-box: */
|
---|
941 | m_pFormatComboBoxLabel->setText(UIWizardExportApp::tr("F&ormat:"));
|
---|
942 | m_pFormatComboBox->setItemText(0, UIWizardExportApp::tr("Open Virtualization Format 0.9"));
|
---|
943 | m_pFormatComboBox->setItemText(1, UIWizardExportApp::tr("Open Virtualization Format 1.0"));
|
---|
944 | m_pFormatComboBox->setItemText(2, UIWizardExportApp::tr("Open Virtualization Format 2.0"));
|
---|
945 | m_pFormatComboBox->setItemData(0, UIWizardExportApp::tr("Write in legacy OVF 0.9 format for compatibility "
|
---|
946 | "with other virtualization products."), Qt::ToolTipRole);
|
---|
947 | m_pFormatComboBox->setItemData(1, UIWizardExportApp::tr("Write in standard OVF 1.0 format."), Qt::ToolTipRole);
|
---|
948 | m_pFormatComboBox->setItemData(2, UIWizardExportApp::tr("Write in new OVF 2.0 format."), Qt::ToolTipRole);
|
---|
949 | /* Translate received values of Format combo-box.
|
---|
950 | * We are enumerating starting from 0 for simplicity: */
|
---|
951 | for (int i = 0; i < m_pFormatComboBox->count(); ++i)
|
---|
952 | if (isFormatCloudOne(m_pFormatComboBox, i))
|
---|
953 | {
|
---|
954 | m_pFormatComboBox->setItemText(i, m_pFormatComboBox->itemData(i, FormatData_Name).toString());
|
---|
955 | m_pFormatComboBox->setItemData(i, UIWizardExportApp::tr("Export to cloud service provider."), Qt::ToolTipRole);
|
---|
956 | }
|
---|
957 |
|
---|
958 | /* Translate MAC address policy combo-box: */
|
---|
959 | m_pMACComboBoxLabel->setText(UIWizardExportApp::tr("MAC Address &Policy:"));
|
---|
960 | for (int i = 0; i < m_pMACComboBox->count(); ++i)
|
---|
961 | {
|
---|
962 | const MACAddressExportPolicy enmPolicy = m_pMACComboBox->itemData(i).value<MACAddressExportPolicy>();
|
---|
963 | switch (enmPolicy)
|
---|
964 | {
|
---|
965 | case MACAddressExportPolicy_KeepAllMACs:
|
---|
966 | {
|
---|
967 | m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include all network adapter MAC addresses"));
|
---|
968 | m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include all network adapter MAC addresses in exported "
|
---|
969 | "appliance archive."), Qt::ToolTipRole);
|
---|
970 | break;
|
---|
971 | }
|
---|
972 | case MACAddressExportPolicy_StripAllNonNATMACs:
|
---|
973 | {
|
---|
974 | m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses"));
|
---|
975 | m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Include only NAT network adapter MAC addresses in exported "
|
---|
976 | "appliance archive."), Qt::ToolTipRole);
|
---|
977 | break;
|
---|
978 | }
|
---|
979 | case MACAddressExportPolicy_StripAllMACs:
|
---|
980 | {
|
---|
981 | m_pMACComboBox->setItemText(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses"));
|
---|
982 | m_pMACComboBox->setItemData(i, UIWizardExportApp::tr("Strip all network adapter MAC addresses from exported "
|
---|
983 | "appliance archive."), Qt::ToolTipRole);
|
---|
984 | break;
|
---|
985 | }
|
---|
986 | default:
|
---|
987 | break;
|
---|
988 | }
|
---|
989 | }
|
---|
990 |
|
---|
991 | /* Translate addtional stuff: */
|
---|
992 | m_pAdditionalLabel->setText(UIWizardExportApp::tr("Additionally:"));
|
---|
993 | m_pManifestCheckbox->setToolTip(UIWizardExportApp::tr("Create a Manifest file for automatic data integrity checks on import."));
|
---|
994 | m_pManifestCheckbox->setText(UIWizardExportApp::tr("&Write Manifest file"));
|
---|
995 | m_pIncludeISOsCheckbox->setToolTip(UIWizardExportApp::tr("Include ISO image files into exported VM archive."));
|
---|
996 | m_pIncludeISOsCheckbox->setText(UIWizardExportApp::tr("&Include ISO image files"));
|
---|
997 |
|
---|
998 | /* Translate profile stuff: */
|
---|
999 | m_pProfileLabel->setText(UIWizardExportApp::tr("&Profile:"));
|
---|
1000 | m_pProfileToolButton->setToolTip(UIWizardExportApp::tr("Open Cloud Profile Manager..."));
|
---|
1001 |
|
---|
1002 | /* Translate option label: */
|
---|
1003 | m_pExportModeLabel->setText(UIWizardExportApp::tr("Machine Creation:"));
|
---|
1004 | m_exportModeButtons.value(CloudExportMode_DoNotAsk)->setText(UIWizardExportApp::tr("Do not ask me about it, leave custom &image for future usage"));
|
---|
1005 | m_exportModeButtons.value(CloudExportMode_AskThenExport)->setText(UIWizardExportApp::tr("Ask me about it &before exporting disk as custom image"));
|
---|
1006 | m_exportModeButtons.value(CloudExportMode_ExportThenAsk)->setText(UIWizardExportApp::tr("Ask me about it &after exporting disk as custom image"));
|
---|
1007 |
|
---|
1008 | /* Translate file selector's tooltip: */
|
---|
1009 | if (m_pFileSelector)
|
---|
1010 | m_pFileSelector->setToolTip(UIWizardExportApp::tr("Holds the path of the file selected for export."));
|
---|
1011 |
|
---|
1012 | /* Adjust label widths: */
|
---|
1013 | QList<QWidget*> labels;
|
---|
1014 | labels << m_pFormatComboBoxLabel;
|
---|
1015 | labels << m_pFileSelectorLabel;
|
---|
1016 | labels << m_pMACComboBoxLabel;
|
---|
1017 | labels << m_pAdditionalLabel;
|
---|
1018 | labels << m_pProfileLabel;
|
---|
1019 | labels << m_pExportModeLabel;
|
---|
1020 | int iMaxWidth = 0;
|
---|
1021 | foreach (QWidget *pLabel, labels)
|
---|
1022 | iMaxWidth = qMax(iMaxWidth, pLabel->minimumSizeHint().width());
|
---|
1023 | m_pFormatLayout->setColumnMinimumWidth(0, iMaxWidth);
|
---|
1024 | m_pSettingsLayout1->setColumnMinimumWidth(0, iMaxWidth);
|
---|
1025 | m_pSettingsLayout2->setColumnMinimumWidth(0, iMaxWidth);
|
---|
1026 |
|
---|
1027 | /* Update tool-tips: */
|
---|
1028 | updateFormatComboToolTip(m_pFormatComboBox);
|
---|
1029 | updateMACAddressExportPolicyComboToolTip(m_pMACComboBox);
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 | void UIWizardExportAppPageFormat::initializePage()
|
---|
1033 | {
|
---|
1034 | /* Populate formats: */
|
---|
1035 | populateFormats(m_pFormatComboBox, wizard()->notificationCenter(), m_fExportToOCIByDefault);
|
---|
1036 | /* Populate MAC address policies: */
|
---|
1037 | populateMACAddressPolicies(m_pMACComboBox);
|
---|
1038 | /* Translate page: */
|
---|
1039 | sltRetranslateUI();
|
---|
1040 |
|
---|
1041 | /* Choose initially focused widget: */
|
---|
1042 | if (wizard()->isFormatCloudOne())
|
---|
1043 | m_pProfileComboBox->setFocus();
|
---|
1044 | else
|
---|
1045 | m_pFileSelector->setFocus();
|
---|
1046 |
|
---|
1047 | /* Fetch it, asynchronously: */
|
---|
1048 | QMetaObject::invokeMethod(this, "sltHandleFormatComboChange", Qt::QueuedConnection);
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | bool UIWizardExportAppPageFormat::isComplete() const
|
---|
1052 | {
|
---|
1053 | /* Initial result: */
|
---|
1054 | bool fResult = true;
|
---|
1055 |
|
---|
1056 | /* Check whether there was cloud target selected: */
|
---|
1057 | if (wizard()->isFormatCloudOne())
|
---|
1058 | fResult = m_comCloudProfile.isNotNull();
|
---|
1059 | else
|
---|
1060 | fResult = UICommon::hasAllowedExtension(wizard()->path().toLower(), OVFFileExts);
|
---|
1061 |
|
---|
1062 | /* Return result: */
|
---|
1063 | return fResult;
|
---|
1064 | }
|
---|
1065 |
|
---|
1066 | bool UIWizardExportAppPageFormat::validatePage()
|
---|
1067 | {
|
---|
1068 | /* Initial result: */
|
---|
1069 | bool fResult = true;
|
---|
1070 |
|
---|
1071 | /* Check whether there was cloud target selected: */
|
---|
1072 | if (wizard()->isFormatCloudOne())
|
---|
1073 | {
|
---|
1074 | /* Update cloud stuff: */
|
---|
1075 | updateCloudStuff();
|
---|
1076 | /* Which is required to continue to the next page: */
|
---|
1077 | fResult = wizard()->cloudAppliance().isNotNull()
|
---|
1078 | && wizard()->cloudClient().isNotNull()
|
---|
1079 | && wizard()->vsd().isNotNull()
|
---|
1080 | && wizard()->vsdExportForm().isNotNull();
|
---|
1081 | }
|
---|
1082 | else
|
---|
1083 | {
|
---|
1084 | /* Update local stuff: */
|
---|
1085 | updateLocalStuff();
|
---|
1086 | /* Which is required to continue to the next page: */
|
---|
1087 | fResult = wizard()->localAppliance().isNotNull();
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 | /* Return result: */
|
---|
1091 | return fResult;
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 | void UIWizardExportAppPageFormat::sltHandleFormatComboChange()
|
---|
1095 | {
|
---|
1096 | /* Update combo tool-tip: */
|
---|
1097 | updateFormatComboToolTip(m_pFormatComboBox);
|
---|
1098 |
|
---|
1099 | /* Update wizard fields: */
|
---|
1100 | wizard()->setFormat(format(m_pFormatComboBox));
|
---|
1101 | wizard()->setFormatCloudOne(isFormatCloudOne(m_pFormatComboBox));
|
---|
1102 |
|
---|
1103 | /* Refresh settings widget state: */
|
---|
1104 | refreshStackedWidget(m_pSettingsWidget1, wizard()->isFormatCloudOne());
|
---|
1105 |
|
---|
1106 | /* Update export settings: */
|
---|
1107 | refreshFileSelectorExtension(m_strFileSelectorExt, m_pFileSelector, wizard()->isFormatCloudOne());
|
---|
1108 | refreshFileSelectorPath(m_pFileSelector, m_strFileSelectorName, m_strFileSelectorExt, wizard()->isFormatCloudOne());
|
---|
1109 | refreshManifestCheckBoxAccess(m_pManifestCheckbox, wizard()->isFormatCloudOne());
|
---|
1110 | refreshIncludeISOsCheckBoxAccess(m_pIncludeISOsCheckbox, wizard()->isFormatCloudOne());
|
---|
1111 | refreshProfileCombo(m_pProfileComboBox, wizard()->notificationCenter(), wizard()->format(), wizard()->isFormatCloudOne());
|
---|
1112 | refreshCloudExportMode(m_exportModeButtons, wizard()->isFormatCloudOne());
|
---|
1113 |
|
---|
1114 | /* Update profile: */
|
---|
1115 | sltHandleProfileComboChange();
|
---|
1116 |
|
---|
1117 | /* Notify about changes: */
|
---|
1118 | emit completeChanged();
|
---|
1119 | }
|
---|
1120 |
|
---|
1121 | void UIWizardExportAppPageFormat::sltHandleFileSelectorChange()
|
---|
1122 | {
|
---|
1123 | /* Skip empty paths: */
|
---|
1124 | if (m_pFileSelector->path().isEmpty())
|
---|
1125 | return;
|
---|
1126 |
|
---|
1127 | m_strFileSelectorName = QFileInfo(m_pFileSelector->path()).completeBaseName();
|
---|
1128 | wizard()->setPath(m_pFileSelector->path());
|
---|
1129 | emit completeChanged();
|
---|
1130 | }
|
---|
1131 |
|
---|
1132 | void UIWizardExportAppPageFormat::sltHandleMACAddressExportPolicyComboChange()
|
---|
1133 | {
|
---|
1134 | updateMACAddressExportPolicyComboToolTip(m_pMACComboBox);
|
---|
1135 | wizard()->setMACAddressExportPolicy(m_pMACComboBox->currentData().value<MACAddressExportPolicy>());
|
---|
1136 | emit completeChanged();
|
---|
1137 | }
|
---|
1138 |
|
---|
1139 | void UIWizardExportAppPageFormat::sltHandleManifestCheckBoxChange()
|
---|
1140 | {
|
---|
1141 | wizard()->setManifestSelected(m_pManifestCheckbox->isChecked());
|
---|
1142 | emit completeChanged();
|
---|
1143 | }
|
---|
1144 |
|
---|
1145 | void UIWizardExportAppPageFormat::sltHandleIncludeISOsCheckBoxChange()
|
---|
1146 | {
|
---|
1147 | wizard()->setIncludeISOsSelected(m_pIncludeISOsCheckbox->isChecked());
|
---|
1148 | emit completeChanged();
|
---|
1149 | }
|
---|
1150 |
|
---|
1151 | void UIWizardExportAppPageFormat::sltHandleProfileComboChange()
|
---|
1152 | {
|
---|
1153 | /* Update wizard fields: */
|
---|
1154 | wizard()->setProfileName(profileName(m_pProfileComboBox));
|
---|
1155 |
|
---|
1156 | /* Update export settings: */
|
---|
1157 | refreshCloudProfile(m_comCloudProfile,
|
---|
1158 | wizard()->notificationCenter(),
|
---|
1159 | wizard()->format(),
|
---|
1160 | wizard()->profileName(),
|
---|
1161 | wizard()->isFormatCloudOne());
|
---|
1162 |
|
---|
1163 | /* Notify about changes: */
|
---|
1164 | emit completeChanged();
|
---|
1165 | }
|
---|
1166 |
|
---|
1167 | void UIWizardExportAppPageFormat::sltHandleRadioButtonToggled(QAbstractButton *pButton, bool fToggled)
|
---|
1168 | {
|
---|
1169 | /* Handle checked buttons only: */
|
---|
1170 | if (!fToggled)
|
---|
1171 | return;
|
---|
1172 |
|
---|
1173 | /* Update cloud export mode field value: */
|
---|
1174 | wizard()->setCloudExportMode(m_exportModeButtons.key(pButton));
|
---|
1175 | emit completeChanged();
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | void UIWizardExportAppPageFormat::sltHandleProfileButtonClick()
|
---|
1179 | {
|
---|
1180 | /* Open Cloud Profile Manager: */
|
---|
1181 | if (gpManager)
|
---|
1182 | gpManager->openCloudProfileManager();
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 | void UIWizardExportAppPageFormat::updateLocalStuff()
|
---|
1186 | {
|
---|
1187 | /* Create appliance: */
|
---|
1188 | CAppliance comAppliance;
|
---|
1189 | refreshLocalStuff(comAppliance, wizard(), wizard()->machineIDs(), wizard()->uri());
|
---|
1190 | wizard()->setLocalAppliance(comAppliance);
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | void UIWizardExportAppPageFormat::updateCloudStuff()
|
---|
1194 | {
|
---|
1195 | /* Create appliance, client, VSD and VSD export form: */
|
---|
1196 | CAppliance comAppliance;
|
---|
1197 | CCloudClient comClient;
|
---|
1198 | CVirtualSystemDescription comDescription;
|
---|
1199 | CVirtualSystemDescriptionForm comForm;
|
---|
1200 | wizard()->wizardButton(WizardButtonType_Expert)->setEnabled(false);
|
---|
1201 | refreshCloudStuff(comAppliance,
|
---|
1202 | comClient,
|
---|
1203 | comDescription,
|
---|
1204 | comForm,
|
---|
1205 | wizard(),
|
---|
1206 | m_comCloudProfile,
|
---|
1207 | wizard()->machineIDs(),
|
---|
1208 | wizard()->uri(),
|
---|
1209 | wizard()->cloudExportMode());
|
---|
1210 | wizard()->wizardButton(WizardButtonType_Expert)->setEnabled(true);
|
---|
1211 | wizard()->setCloudAppliance(comAppliance);
|
---|
1212 | wizard()->setCloudClient(comClient);
|
---|
1213 | wizard()->setVsd(comDescription);
|
---|
1214 | wizard()->setVsdExportForm(comForm);
|
---|
1215 | }
|
---|