1 | /* $Id: UIWizardCloneVD.cpp 90755 2021-08-19 16:33:03Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardCloneVD class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2021 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | /* GUI includes: */
|
---|
19 | #include "UICommon.h"
|
---|
20 | #include "UIMedium.h"
|
---|
21 | #include "UIMessageCenter.h"
|
---|
22 | #include "UINotificationCenter.h"
|
---|
23 | #include "UIWizardCloneVD.h"
|
---|
24 | #include "UIWizardCloneVDPageBasic1.h"
|
---|
25 | #include "UIWizardCloneVDPageBasic2.h"
|
---|
26 | #include "UIWizardCloneVDPageBasic3.h"
|
---|
27 | #include "UIWizardCloneVDPageExpert.h"
|
---|
28 |
|
---|
29 | /* COM includes: */
|
---|
30 | #include "CMediumFormat.h"
|
---|
31 |
|
---|
32 |
|
---|
33 | UIWizardCloneVD::UIWizardCloneVD(QWidget *pParent, const CMedium &comSourceVirtualDisk)
|
---|
34 | : UINativeWizard(pParent, WizardType_CloneVD)
|
---|
35 | , m_comSourceVirtualDisk(comSourceVirtualDisk)
|
---|
36 | , m_enmSourceVirtualDiskDeviceType(m_comSourceVirtualDisk.GetDeviceType())
|
---|
37 | , m_iMediumVariantPageIndex(-1)
|
---|
38 | {
|
---|
39 | #ifndef VBOX_WS_MAC
|
---|
40 | /* Assign watermark: */
|
---|
41 | setPixmapName(":/wizard_new_harddisk.png");
|
---|
42 | #else /* VBOX_WS_MAC */
|
---|
43 | /* Assign background image: */
|
---|
44 | setPixmapName(":/wizard_new_harddisk_bg.png");
|
---|
45 | #endif /* VBOX_WS_MAC */
|
---|
46 | }
|
---|
47 |
|
---|
48 | bool UIWizardCloneVD::copyVirtualDisk()
|
---|
49 | {
|
---|
50 | /* Gather attributes: */
|
---|
51 | // const CMediumFormat comMediumFormat = field("mediumFormat").value<CMediumFormat>();
|
---|
52 | // const qulonglong uVariant = field("mediumVariant").toULongLong();
|
---|
53 | // const QString strMediumPath = field("mediumPath").toString();
|
---|
54 | // const qulonglong uSize = field("mediumSize").toULongLong();
|
---|
55 | // /* Check attributes: */
|
---|
56 | // AssertReturn(!strMediumPath.isNull(), false);
|
---|
57 | // AssertReturn(uSize > 0, false);
|
---|
58 |
|
---|
59 | // /* Get VBox object: */
|
---|
60 | // CVirtualBox comVBox = uiCommon().virtualBox();
|
---|
61 |
|
---|
62 | // /* Create new virtual disk image: */
|
---|
63 | // CMedium comVirtualDisk = comVBox.CreateMedium(comMediumFormat.GetName(), strMediumPath, KAccessMode_ReadWrite, m_enmSourceVirtualDiskDeviceType);
|
---|
64 | // if (!comVBox.isOk())
|
---|
65 | // {
|
---|
66 | // msgCenter().cannotCreateMediumStorage(comVBox, strMediumPath, this);
|
---|
67 | // return false;
|
---|
68 | // }
|
---|
69 |
|
---|
70 | // /* Compose medium-variant: */
|
---|
71 | // QVector<KMediumVariant> variants(sizeof(qulonglong) * 8);
|
---|
72 | // for (int i = 0; i < variants.size(); ++i)
|
---|
73 | // {
|
---|
74 | // qulonglong temp = uVariant;
|
---|
75 | // temp &= Q_UINT64_C(1) << i;
|
---|
76 | // variants[i] = (KMediumVariant)temp;
|
---|
77 | // }
|
---|
78 |
|
---|
79 | // /* Copy medium: */
|
---|
80 | // UINotificationProgressMediumCopy *pNotification = new UINotificationProgressMediumCopy(m_comSourceVirtualDisk,
|
---|
81 | // comVirtualDisk,
|
---|
82 | // variants);
|
---|
83 | // connect(pNotification, &UINotificationProgressMediumCopy::sigMediumCopied,
|
---|
84 | // &uiCommon(), &UICommon::sltHandleMediumCreated);
|
---|
85 | // gpNotificationCenter->append(pNotification);
|
---|
86 |
|
---|
87 | /* Positive: */
|
---|
88 | return true;
|
---|
89 | }
|
---|
90 |
|
---|
91 | void UIWizardCloneVD::retranslateUi()
|
---|
92 | {
|
---|
93 | /* Translate wizard: */
|
---|
94 | setWindowTitle(tr("Copy Virtual Disk Image"));
|
---|
95 | UINativeWizard::retranslateUi();
|
---|
96 | }
|
---|
97 |
|
---|
98 | void UIWizardCloneVD::populatePages()
|
---|
99 | {
|
---|
100 | /* Create corresponding pages: */
|
---|
101 | switch (mode())
|
---|
102 | {
|
---|
103 | case WizardMode_Basic:
|
---|
104 | case WizardMode_Expert:
|
---|
105 | {
|
---|
106 | addPage(new UIWizardCloneVDPageBasic1(m_enmSourceVirtualDiskDeviceType));
|
---|
107 | m_iMediumVariantPageIndex = addPage(new UIWizardCloneVDPageBasic2(m_enmSourceVirtualDiskDeviceType));
|
---|
108 | addPage(new UIWizardCloneVDPageBasic3);
|
---|
109 | break;
|
---|
110 | }
|
---|
111 | // case WizardMode_Expert:
|
---|
112 | // {
|
---|
113 | // setPage(PageExpert, new UIWizardCloneVDPageExpert(m_enmSourceVirtualDiskDeviceType));
|
---|
114 | // break;
|
---|
115 | // }
|
---|
116 | default:
|
---|
117 | {
|
---|
118 | AssertMsgFailed(("Invalid mode: %d", mode()));
|
---|
119 | break;
|
---|
120 | }
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | const CMediumFormat &UIWizardCloneVD::mediumFormat() const
|
---|
125 | {
|
---|
126 | return m_comMediumFormat;
|
---|
127 | }
|
---|
128 |
|
---|
129 | void UIWizardCloneVD::setMediumFormat(const CMediumFormat &comMediumFormat)
|
---|
130 | {
|
---|
131 | m_comMediumFormat = comMediumFormat;
|
---|
132 | if (mode() == WizardMode_Basic)
|
---|
133 | setMediumVariantPageVisibility();
|
---|
134 | }
|
---|
135 |
|
---|
136 | qulonglong UIWizardCloneVD::mediumVariant() const
|
---|
137 | {
|
---|
138 | return m_uMediumVariant;
|
---|
139 | }
|
---|
140 |
|
---|
141 | void UIWizardCloneVD::setMediumVariant(qulonglong uMediumVariant)
|
---|
142 | {
|
---|
143 | m_uMediumVariant = uMediumVariant;
|
---|
144 | }
|
---|
145 |
|
---|
146 | void UIWizardCloneVD::setMediumVariantPageVisibility()
|
---|
147 | {
|
---|
148 | AssertReturnVoid(!m_comMediumFormat.isNull());
|
---|
149 | ULONG uCapabilities = 0;
|
---|
150 | QVector<KMediumFormatCapabilities> capabilities;
|
---|
151 | capabilities = m_comMediumFormat.GetCapabilities();
|
---|
152 | for (int i = 0; i < capabilities.size(); i++)
|
---|
153 | uCapabilities |= capabilities[i];
|
---|
154 |
|
---|
155 | int cTest = 0;
|
---|
156 | if (uCapabilities & KMediumFormatCapabilities_CreateDynamic)
|
---|
157 | ++cTest;
|
---|
158 | if (uCapabilities & KMediumFormatCapabilities_CreateFixed)
|
---|
159 | ++cTest;
|
---|
160 | if (uCapabilities & KMediumFormatCapabilities_CreateSplit2G)
|
---|
161 | ++cTest;
|
---|
162 | setPageVisible(m_iMediumVariantPageIndex, cTest > 1);
|
---|
163 | }
|
---|