1 | /* $Id: UIWizardNewVD.cpp 90370 2021-07-28 14:18:54Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardNewVD class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 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 | /* Qt includes: */
|
---|
19 | #include <QVariant>
|
---|
20 | #include <QPushButton>
|
---|
21 |
|
---|
22 | /* GUI includes: */
|
---|
23 | #include "UICommon.h"
|
---|
24 | #include "UIMedium.h"
|
---|
25 | #include "UIMessageCenter.h"
|
---|
26 | #include "UINotificationCenter.h"
|
---|
27 | #include "UIWizardNewVD.h"
|
---|
28 | #include "UIWizardNewVDPageFileType.h"
|
---|
29 | #include "UIWizardNewVDPageVariant.h"
|
---|
30 | #include "UIWizardNewVDPageSizeLocation.h"
|
---|
31 | #include "UIWizardNewVDPageExpert.h"
|
---|
32 |
|
---|
33 | /* COM includes: */
|
---|
34 | #include "CMediumFormat.h"
|
---|
35 |
|
---|
36 |
|
---|
37 | UIWizardNewVD::UIWizardNewVD(QWidget *pParent,
|
---|
38 | const QString &strDefaultName,
|
---|
39 | const QString &strDefaultPath,
|
---|
40 | qulonglong uDefaultSize,
|
---|
41 | WizardMode mode)
|
---|
42 | : UINativeWizard(pParent, WizardType_NewVD, mode)
|
---|
43 | , m_strDefaultName(strDefaultName)
|
---|
44 | , m_strDefaultPath(strDefaultPath)
|
---|
45 | , m_uDefaultSize(uDefaultSize)
|
---|
46 | {
|
---|
47 | #ifndef VBOX_WS_MAC
|
---|
48 | /* Assign watermark: */
|
---|
49 | setPixmapName(":/wizard_new_harddisk.png");
|
---|
50 | #else /* VBOX_WS_MAC */
|
---|
51 | /* Assign background image: */
|
---|
52 | setPixmapName(":/wizard_new_harddisk_bg.png");
|
---|
53 | #endif /* VBOX_WS_MAC */
|
---|
54 | }
|
---|
55 |
|
---|
56 | qulonglong UIWizardNewVD::mediumVariant() const
|
---|
57 | {
|
---|
58 | return m_uMediumVariant;
|
---|
59 | }
|
---|
60 |
|
---|
61 | void UIWizardNewVD::setMediumVariant(qulonglong uMediumVariant)
|
---|
62 | {
|
---|
63 | m_uMediumVariant = uMediumVariant;
|
---|
64 | }
|
---|
65 |
|
---|
66 | const CMediumFormat &UIWizardNewVD::mediumFormat()
|
---|
67 | {
|
---|
68 | return m_comMediumFormat;
|
---|
69 | }
|
---|
70 |
|
---|
71 | void UIWizardNewVD::setMediumFormat(const CMediumFormat &mediumFormat)
|
---|
72 | {
|
---|
73 | m_comMediumFormat = mediumFormat;
|
---|
74 | }
|
---|
75 |
|
---|
76 | const QString &UIWizardNewVD::mediumPath() const
|
---|
77 | {
|
---|
78 | return m_strMediumPath;
|
---|
79 | }
|
---|
80 |
|
---|
81 | void UIWizardNewVD::setMediumPath(const QString &strMediumPath)
|
---|
82 | {
|
---|
83 | m_strMediumPath = strMediumPath;
|
---|
84 | }
|
---|
85 |
|
---|
86 | qulonglong UIWizardNewVD::mediumSize() const
|
---|
87 | {
|
---|
88 | return m_uMediumSize;
|
---|
89 | }
|
---|
90 |
|
---|
91 | void UIWizardNewVD::setMediumSize(qulonglong uMediumSize)
|
---|
92 | {
|
---|
93 | m_uMediumSize = uMediumSize;
|
---|
94 | }
|
---|
95 |
|
---|
96 | void UIWizardNewVD::populatePages()
|
---|
97 | {
|
---|
98 | switch (mode())
|
---|
99 | {
|
---|
100 | case WizardMode_Basic:
|
---|
101 | case WizardMode_Expert:
|
---|
102 | {
|
---|
103 | addPage(new UIWizardNewVDPageFileType);
|
---|
104 | addPage(new UIWizardNewVDPageVariant);
|
---|
105 | addPage(new UIWizardNewVDPageSizeLocation(m_strDefaultName, m_strDefaultPath, m_uDefaultSize));
|
---|
106 | break;
|
---|
107 | }
|
---|
108 |
|
---|
109 | // {
|
---|
110 | // //addPage(new UIWizardNewVDPageExpert);
|
---|
111 | // break;
|
---|
112 | // }
|
---|
113 | default:
|
---|
114 | {
|
---|
115 | AssertMsgFailed(("Invalid mode: %d", mode()));
|
---|
116 | break;
|
---|
117 | }
|
---|
118 | }
|
---|
119 | }
|
---|
120 |
|
---|
121 | bool UIWizardNewVD::createVirtualDisk()
|
---|
122 | {
|
---|
123 | /* Gather attributes: */
|
---|
124 | // const CMediumFormat comMediumFormat = field("mediumFormat").value<CMediumFormat>();
|
---|
125 | // const qulonglong uVariant = field("mediumVariant").toULongLong();
|
---|
126 | // const QString strMediumPath = field("mediumPath").toString();
|
---|
127 | // const qulonglong uSize = field("mediumSize").toULongLong();
|
---|
128 | // /* Check attributes: */
|
---|
129 | // AssertReturn(!strMediumPath.isNull(), false);
|
---|
130 | // AssertReturn(uSize > 0, false);
|
---|
131 |
|
---|
132 | // /* Get VBox object: */
|
---|
133 | // CVirtualBox comVBox = uiCommon().virtualBox();
|
---|
134 |
|
---|
135 | // /* Create new virtual disk image: */
|
---|
136 | // CMedium comVirtualDisk = comVBox.CreateMedium(comMediumFormat.GetName(), strMediumPath, KAccessMode_ReadWrite, KDeviceType_HardDisk);
|
---|
137 | // if (!comVBox.isOk())
|
---|
138 | // {
|
---|
139 | // msgCenter().cannotCreateMediumStorage(comVBox, strMediumPath, this);
|
---|
140 | // return false;
|
---|
141 | // }
|
---|
142 |
|
---|
143 | // /* Compose medium-variant: */
|
---|
144 | // QVector<KMediumVariant> variants(sizeof(qulonglong) * 8);
|
---|
145 | // for (int i = 0; i < variants.size(); ++i)
|
---|
146 | // {
|
---|
147 | // qulonglong temp = uVariant;
|
---|
148 | // temp &= Q_UINT64_C(1) << i;
|
---|
149 | // variants[i] = (KMediumVariant)temp;
|
---|
150 | // }
|
---|
151 |
|
---|
152 | // /* Copy medium: */
|
---|
153 | // UINotificationProgressMediumCreate *pNotification = new UINotificationProgressMediumCreate(comVirtualDisk,
|
---|
154 | // uSize,
|
---|
155 | // variants);
|
---|
156 | // connect(pNotification, &UINotificationProgressMediumCreate::sigMediumCreated,
|
---|
157 | // &uiCommon(), &UICommon::sltHandleMediumCreated);
|
---|
158 | // notificationCenter().append(pNotification);
|
---|
159 |
|
---|
160 | /* Positive: */
|
---|
161 | return true;
|
---|
162 | }
|
---|
163 |
|
---|
164 | void UIWizardNewVD::retranslateUi()
|
---|
165 | {
|
---|
166 | UINativeWizard::retranslateUi();
|
---|
167 | setWindowTitle(tr("Create Virtual Hard Disk"));
|
---|
168 | }
|
---|