1 | /* $Id: UIWizardNewVMPageBasic1.cpp 87073 2020-12-09 17:30:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardNewVMPageBasic1 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 <QButtonGroup>
|
---|
20 | #include <QCheckBox>
|
---|
21 | #include <QDir>
|
---|
22 | #include <QGridLayout>
|
---|
23 | #include <QHBoxLayout>
|
---|
24 | #include <QLabel>
|
---|
25 | #include <QRadioButton>
|
---|
26 | #include <QVBoxLayout>
|
---|
27 |
|
---|
28 | /* GUI includes: */
|
---|
29 | #include "QIRichTextLabel.h"
|
---|
30 | #include "UICommon.h"
|
---|
31 | #include "UIFilePathSelector.h"
|
---|
32 | #include "UIMessageCenter.h"
|
---|
33 | #include "UINameAndSystemEditor.h"
|
---|
34 | #include "UIWizardNewVMPageBasic1.h"
|
---|
35 | #include "UIWizardNewVM.h"
|
---|
36 |
|
---|
37 | /* COM includes: */
|
---|
38 | #include "CHost.h"
|
---|
39 | #include "CSystemProperties.h"
|
---|
40 | #include "CUnattended.h"
|
---|
41 |
|
---|
42 | /* Defines some patterns to guess the right OS type. Should be in sync with
|
---|
43 | * VirtualBox-settings-common.xsd in Main. The list is sorted by priority. The
|
---|
44 | * first matching string found, will be used. */
|
---|
45 | struct osTypePattern
|
---|
46 | {
|
---|
47 | QRegExp pattern;
|
---|
48 | const char *pcstId;
|
---|
49 | };
|
---|
50 |
|
---|
51 | static const osTypePattern gs_OSTypePattern[] =
|
---|
52 | {
|
---|
53 | /* DOS: */
|
---|
54 | { QRegExp("DOS", Qt::CaseInsensitive), "DOS" },
|
---|
55 |
|
---|
56 | /* Windows: */
|
---|
57 | { QRegExp( "Wi.*98", Qt::CaseInsensitive), "Windows98" },
|
---|
58 | { QRegExp( "Wi.*95", Qt::CaseInsensitive), "Windows95" },
|
---|
59 | { QRegExp( "Wi.*Me", Qt::CaseInsensitive), "WindowsMe" },
|
---|
60 | { QRegExp( "(Wi.*NT)|(NT[-._v]*4)", Qt::CaseInsensitive), "WindowsNT4" },
|
---|
61 | { QRegExp( "NT[-._v]*3[.,]*[51x]", Qt::CaseInsensitive), "WindowsNT3x" },
|
---|
62 | /* Note: Do not automatically set WindowsXP_64 on 64-bit hosts, as Windows XP 64-bit
|
---|
63 | * is extremely rare -- most users never heard of it even. So always default to 32-bit. */
|
---|
64 | { QRegExp("((Wi.*XP)|(XP)).*", Qt::CaseInsensitive), "WindowsXP" },
|
---|
65 | { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*64", Qt::CaseInsensitive), "Windows2003_64" },
|
---|
66 | { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*32", Qt::CaseInsensitive), "Windows2003" },
|
---|
67 | { QRegExp("((Wi.*Vis)|(Vista)).*64", Qt::CaseInsensitive), "WindowsVista_64" },
|
---|
68 | { QRegExp("((Wi.*Vis)|(Vista)).*32", Qt::CaseInsensitive), "WindowsVista" },
|
---|
69 | { QRegExp( "(Wi.*2016)|(W2K16)|(Win2K16)", Qt::CaseInsensitive), "Windows2016_64" },
|
---|
70 | { QRegExp( "(Wi.*2012)|(W2K12)|(Win2K12)", Qt::CaseInsensitive), "Windows2012_64" },
|
---|
71 | { QRegExp("((Wi.*2008)|(W2K8)|(Win2k8)).*64", Qt::CaseInsensitive), "Windows2008_64" },
|
---|
72 | { QRegExp("((Wi.*2008)|(W2K8)|(Win2K8)).*32", Qt::CaseInsensitive), "Windows2008" },
|
---|
73 | { QRegExp( "(Wi.*2000)|(W2K)|(Win2K)", Qt::CaseInsensitive), "Windows2000" },
|
---|
74 | { QRegExp( "(Wi.*7.*64)|(W7.*64)", Qt::CaseInsensitive), "Windows7_64" },
|
---|
75 | { QRegExp( "(Wi.*7.*32)|(W7.*32)", Qt::CaseInsensitive), "Windows7" },
|
---|
76 | { QRegExp( "(Wi.*8.*1.*64)|(W8.*64)", Qt::CaseInsensitive), "Windows81_64" },
|
---|
77 | { QRegExp( "(Wi.*8.*1.*32)|(W8.*32)", Qt::CaseInsensitive), "Windows81" },
|
---|
78 | { QRegExp( "(Wi.*8.*64)|(W8.*64)", Qt::CaseInsensitive), "Windows8_64" },
|
---|
79 | { QRegExp( "(Wi.*8.*32)|(W8.*32)", Qt::CaseInsensitive), "Windows8" },
|
---|
80 | { QRegExp( "(Wi.*10.*64)|(W10.*64)", Qt::CaseInsensitive), "Windows10_64" },
|
---|
81 | { QRegExp( "(Wi.*10.*32)|(W10.*32)", Qt::CaseInsensitive), "Windows10" },
|
---|
82 | { QRegExp( "Wi.*3.*1", Qt::CaseInsensitive), "Windows31" },
|
---|
83 | /* Set Windows 7 as default for "Windows". */
|
---|
84 | { QRegExp( "Wi.*64", Qt::CaseInsensitive), "Windows7_64" },
|
---|
85 | { QRegExp( "Wi.*32", Qt::CaseInsensitive), "Windows7" },
|
---|
86 | /* ReactOS wants to be considered as Windows 2003 */
|
---|
87 | { QRegExp( "Reac.*", Qt::CaseInsensitive), "Windows2003" },
|
---|
88 |
|
---|
89 | /* Solaris: */
|
---|
90 | { QRegExp("Sol.*11", Qt::CaseInsensitive), "Solaris11_64" },
|
---|
91 | { QRegExp("((Op.*Sol)|(os20[01][0-9])|(Sol.*10)|(India)|(Neva)).*64", Qt::CaseInsensitive), "OpenSolaris_64" },
|
---|
92 | { QRegExp("((Op.*Sol)|(os20[01][0-9])|(Sol.*10)|(India)|(Neva)).*32", Qt::CaseInsensitive), "OpenSolaris" },
|
---|
93 | { QRegExp("Sol.*64", Qt::CaseInsensitive), "Solaris_64" },
|
---|
94 | { QRegExp("Sol.*32", Qt::CaseInsensitive), "Solaris" },
|
---|
95 |
|
---|
96 | /* OS/2: */
|
---|
97 | { QRegExp( "OS[/|!-]{,1}2.*W.*4.?5", Qt::CaseInsensitive), "OS2Warp45" },
|
---|
98 | { QRegExp( "OS[/|!-]{,1}2.*W.*4", Qt::CaseInsensitive), "OS2Warp4" },
|
---|
99 | { QRegExp( "OS[/|!-]{,1}2.*W", Qt::CaseInsensitive), "OS2Warp3" },
|
---|
100 | { QRegExp("(OS[/|!-]{,1}2.*e)|(eCS.*)", Qt::CaseInsensitive), "OS2eCS" },
|
---|
101 | { QRegExp( "OS[/|!-]{,1}2", Qt::CaseInsensitive), "OS2" },
|
---|
102 | { QRegExp( "eComS.*", Qt::CaseInsensitive), "OS2eCS" },
|
---|
103 |
|
---|
104 | /* Other: Must come before Ubuntu/Maverick and before Linux??? */
|
---|
105 | { QRegExp("QN", Qt::CaseInsensitive), "QNX" },
|
---|
106 |
|
---|
107 | /* Mac OS X: Must come before Ubuntu/Maverick and before Linux: */
|
---|
108 | { QRegExp("((mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)).64", Qt::CaseInsensitive), "MacOS_64" },
|
---|
109 | { QRegExp("((mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)).32", Qt::CaseInsensitive), "MacOS" },
|
---|
110 | { QRegExp("((mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)).*64", Qt::CaseInsensitive), "MacOS_64" },
|
---|
111 | { QRegExp("((mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)).*32", Qt::CaseInsensitive), "MacOS" },
|
---|
112 | { QRegExp("((mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)).*64", Qt::CaseInsensitive), "MacOS106_64" },
|
---|
113 | { QRegExp("((mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)).*32", Qt::CaseInsensitive), "MacOS106" },
|
---|
114 | { QRegExp( "(mac.*10[.,]{0,1}7)|(os.*x.*10[.,]{0,1}7)|(mac.*ML)|(os.*x.*ML)|(Mount)", Qt::CaseInsensitive), "MacOS108_64" },
|
---|
115 | { QRegExp( "(mac.*10[.,]{0,1}8)|(os.*x.*10[.,]{0,1}8)|(Lion)", Qt::CaseInsensitive), "MacOS107_64" },
|
---|
116 | { QRegExp( "(mac.*10[.,]{0,1}9)|(os.*x.*10[.,]{0,1}9)|(mac.*mav)|(os.*x.*mav)|(Mavericks)", Qt::CaseInsensitive), "MacOS109_64" },
|
---|
117 | { QRegExp( "(mac.*yos)|(os.*x.*yos)|(Yosemite)", Qt::CaseInsensitive), "MacOS1010_64" },
|
---|
118 | { QRegExp( "(mac.*cap)|(os.*x.*capit)|(Capitan)", Qt::CaseInsensitive), "MacOS1011_64" },
|
---|
119 | { QRegExp( "(mac.*hig)|(os.*x.*high.*sierr)|(High Sierra)", Qt::CaseInsensitive), "MacOS1013_64" },
|
---|
120 | { QRegExp( "(mac.*sie)|(os.*x.*sierr)|(Sierra)", Qt::CaseInsensitive), "MacOS1012_64" },
|
---|
121 | { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*64", Qt::CaseInsensitive), "MacOS_64" },
|
---|
122 | { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*32", Qt::CaseInsensitive), "MacOS" },
|
---|
123 |
|
---|
124 | /* Code names for Linux distributions: */
|
---|
125 | { QRegExp("((bianca)|(cassandra)|(celena)|(daryna)|(elyssa)|(felicia)|(gloria)|(helena)|(isadora)|(julia)|(katya)|(lisa)|(maya)|(nadia)|(olivia)|(petra)|(qiana)|(rebecca)|(rafaela)|(rosa)).*64", Qt::CaseInsensitive), "Ubuntu_64" },
|
---|
126 | { QRegExp("((bianca)|(cassandra)|(celena)|(daryna)|(elyssa)|(felicia)|(gloria)|(helena)|(isadora)|(julia)|(katya)|(lisa)|(maya)|(nadia)|(olivia)|(petra)|(qiana)|(rebecca)|(rafaela)|(rosa)).*32", Qt::CaseInsensitive), "Ubuntu" },
|
---|
127 | { QRegExp("((edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)|(saucy)|(trusty)|(utopic)|(vivid)|(wily)|(xenial)|(yakkety)|(zesty)).*64", Qt::CaseInsensitive), "Ubuntu_64" },
|
---|
128 | { QRegExp("((edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)|(saucy)|(trusty)|(utopic)|(vivid)|(wily)|(xenial)|(yakkety)|(zesty)).*32", Qt::CaseInsensitive), "Ubuntu" },
|
---|
129 | { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(stretch)|(buster)|(sid)).*64", Qt::CaseInsensitive), "Debian_64" },
|
---|
130 | { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(stretch)|(buster)|(sid)).*32", Qt::CaseInsensitive), "Debian" },
|
---|
131 | { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*64", Qt::CaseInsensitive), "Fedora_64" },
|
---|
132 | { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*32", Qt::CaseInsensitive), "Fedora" },
|
---|
133 |
|
---|
134 | /* Regular names of Linux distributions: */
|
---|
135 | { QRegExp("Arc.*64", Qt::CaseInsensitive), "ArchLinux_64" },
|
---|
136 | { QRegExp("Arc.*32", Qt::CaseInsensitive), "ArchLinux" },
|
---|
137 | { QRegExp("Deb.*64", Qt::CaseInsensitive), "Debian_64" },
|
---|
138 | { QRegExp("Deb.*32", Qt::CaseInsensitive), "Debian" },
|
---|
139 | { QRegExp("((SU)|(Nov)|(SLE)).*64", Qt::CaseInsensitive), "OpenSUSE_64" },
|
---|
140 | { QRegExp("((SU)|(Nov)|(SLE)).*32", Qt::CaseInsensitive), "OpenSUSE" },
|
---|
141 | { QRegExp("Fe.*64", Qt::CaseInsensitive), "Fedora_64" },
|
---|
142 | { QRegExp("Fe.*32", Qt::CaseInsensitive), "Fedora" },
|
---|
143 | { QRegExp("((Gen)|(Sab)).*64", Qt::CaseInsensitive), "Gentoo_64" },
|
---|
144 | { QRegExp("((Gen)|(Sab)).*32", Qt::CaseInsensitive), "Gentoo" },
|
---|
145 | { QRegExp("((Man)|(Mag)).*64", Qt::CaseInsensitive), "Mandriva_64" },
|
---|
146 | { QRegExp("((Man)|(Mag)).*32", Qt::CaseInsensitive), "Mandriva" },
|
---|
147 | { QRegExp("((Red)|(rhel)|(cen)).*64", Qt::CaseInsensitive), "RedHat_64" },
|
---|
148 | { QRegExp("((Red)|(rhel)|(cen)).*32", Qt::CaseInsensitive), "RedHat" },
|
---|
149 | { QRegExp("Tur.*64", Qt::CaseInsensitive), "Turbolinux_64" },
|
---|
150 | { QRegExp("Tur.*32", Qt::CaseInsensitive), "Turbolinux" },
|
---|
151 | { QRegExp("(Ub)|(Min).*64", Qt::CaseInsensitive), "Ubuntu_64" },
|
---|
152 | { QRegExp("(Ub)|(Min).*32", Qt::CaseInsensitive), "Ubuntu" },
|
---|
153 | { QRegExp("Xa.*64", Qt::CaseInsensitive), "Xandros_64" },
|
---|
154 | { QRegExp("Xa.*32", Qt::CaseInsensitive), "Xandros" },
|
---|
155 | { QRegExp("((Or)|(oel)|(ol)).*64", Qt::CaseInsensitive), "Oracle_64" },
|
---|
156 | { QRegExp("((Or)|(oel)|(ol)).*32", Qt::CaseInsensitive), "Oracle" },
|
---|
157 | { QRegExp("Knoppix", Qt::CaseInsensitive), "Linux26" },
|
---|
158 | { QRegExp("Dsl", Qt::CaseInsensitive), "Linux24" },
|
---|
159 | { QRegExp("((Lin)|(lnx)).*2.?2", Qt::CaseInsensitive), "Linux22" },
|
---|
160 | { QRegExp("((Lin)|(lnx)).*2.?4.*64", Qt::CaseInsensitive), "Linux24_64" },
|
---|
161 | { QRegExp("((Lin)|(lnx)).*2.?4.*32", Qt::CaseInsensitive), "Linux24" },
|
---|
162 | { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*64", Qt::CaseInsensitive), "Linux26_64" },
|
---|
163 | { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*32", Qt::CaseInsensitive), "Linux26" },
|
---|
164 | { QRegExp("((Lin)|(lnx)).*64", Qt::CaseInsensitive), "Linux26_64" },
|
---|
165 | { QRegExp("((Lin)|(lnx)).*32", Qt::CaseInsensitive), "Linux26" },
|
---|
166 |
|
---|
167 | /* Other: */
|
---|
168 | { QRegExp("L4", Qt::CaseInsensitive), "L4" },
|
---|
169 | { QRegExp("((Fr.*B)|(fbsd)).*64", Qt::CaseInsensitive), "FreeBSD_64" },
|
---|
170 | { QRegExp("((Fr.*B)|(fbsd)).*32", Qt::CaseInsensitive), "FreeBSD" },
|
---|
171 | { QRegExp("Op.*B.*64", Qt::CaseInsensitive), "OpenBSD_64" },
|
---|
172 | { QRegExp("Op.*B.*32", Qt::CaseInsensitive), "OpenBSD" },
|
---|
173 | { QRegExp("Ne.*B.*64", Qt::CaseInsensitive), "NetBSD_64" },
|
---|
174 | { QRegExp("Ne.*B.*32", Qt::CaseInsensitive), "NetBSD" },
|
---|
175 | { QRegExp("Net", Qt::CaseInsensitive), "Netware" },
|
---|
176 | { QRegExp("Rocki", Qt::CaseInsensitive), "JRockitVE" },
|
---|
177 | { QRegExp("bs[23]{0,1}-", Qt::CaseInsensitive), "VBoxBS_64" }, /* bootsector tests */
|
---|
178 | { QRegExp("Ot", Qt::CaseInsensitive), "Other" },
|
---|
179 | };
|
---|
180 |
|
---|
181 | UIWizardNewVMPage1::UIWizardNewVMPage1(const QString &strGroup)
|
---|
182 | : m_pISOSelectorLabel(0)
|
---|
183 | , m_pISOFilePathSelector(0)
|
---|
184 | , m_pEnableUnattendedInstallCheckBox(0)
|
---|
185 | , m_pStartHeadlessCheckBox(0)
|
---|
186 | , m_pNameAndFolderEditor(0)
|
---|
187 | , m_pSystemTypeEditor(0)
|
---|
188 | , m_pUnattendedLabel(0)
|
---|
189 | , m_pNameOSTypeLabel(0)
|
---|
190 | , m_strGroup(strGroup)
|
---|
191 | {
|
---|
192 | CHost host = uiCommon().host();
|
---|
193 | m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
|
---|
194 | m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
|
---|
195 | }
|
---|
196 |
|
---|
197 | void UIWizardNewVMPage1::onNameChanged(QString strNewName)
|
---|
198 | {
|
---|
199 | /* Do not forget about achitecture bits, if not yet specified: */
|
---|
200 | if (!strNewName.contains("32") && !strNewName.contains("64"))
|
---|
201 | strNewName += ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode ? "64" : "32";
|
---|
202 |
|
---|
203 | /* Search for a matching OS type based on the string the user typed already. */
|
---|
204 | for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
|
---|
205 | if (strNewName.contains(gs_OSTypePattern[i].pattern))
|
---|
206 | {
|
---|
207 | if (m_pSystemTypeEditor)
|
---|
208 | m_pSystemTypeEditor->setType(uiCommon().vmGuestOSType(gs_OSTypePattern[i].pcstId));
|
---|
209 | break;
|
---|
210 | }
|
---|
211 | }
|
---|
212 |
|
---|
213 | void UIWizardNewVMPage1::onOsTypeChanged()
|
---|
214 | {
|
---|
215 | /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore.
|
---|
216 | * So simply disconnect the text-edit signal. */
|
---|
217 | if (m_pNameAndFolderEditor)
|
---|
218 | m_pNameAndFolderEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &)));
|
---|
219 | }
|
---|
220 |
|
---|
221 | bool UIWizardNewVMPage1::determineOSType(const QString &strISOPath)
|
---|
222 | {
|
---|
223 | QFileInfo isoFileInfo(strISOPath);
|
---|
224 | if (!isoFileInfo.exists())
|
---|
225 | {
|
---|
226 | m_strDetectedOSTypeId.clear();
|
---|
227 | // m_strDetectedOSVersion.clear();
|
---|
228 | // m_strDetectedOSFlavor.clear();
|
---|
229 | // m_strDetectedOSLanguages.clear();
|
---|
230 | // m_strDetectedOSHints.clear();
|
---|
231 | // updateStatusLabel();
|
---|
232 | return false;
|
---|
233 | }
|
---|
234 |
|
---|
235 | CUnattended comUnatteded = uiCommon().virtualBox().CreateUnattendedInstaller();
|
---|
236 | comUnatteded.SetIsoPath(strISOPath);
|
---|
237 | comUnatteded.DetectIsoOS();
|
---|
238 |
|
---|
239 | m_strDetectedOSTypeId = comUnatteded.GetDetectedOSTypeId();
|
---|
240 | // m_strDetectedOSVersion = comUnatteded.GetDetectedOSVersion();
|
---|
241 | // m_strDetectedOSFlavor = comUnatteded.GetDetectedOSFlavor();
|
---|
242 | // m_strDetectedOSLanguages = comUnatteded.GetDetectedOSLanguages();
|
---|
243 | // m_strDetectedOSHints = comUnatteded.GetDetectedOSHints();
|
---|
244 |
|
---|
245 | //updateStatusLabel();
|
---|
246 | return true;
|
---|
247 | }
|
---|
248 |
|
---|
249 | void UIWizardNewVMPage1::composeMachineFilePath()
|
---|
250 | {
|
---|
251 | if (!m_pNameAndFolderEditor)
|
---|
252 | return;
|
---|
253 | if (m_pNameAndFolderEditor->name().isEmpty() || m_pNameAndFolderEditor->path().isEmpty())
|
---|
254 | return;
|
---|
255 | /* Get VBox: */
|
---|
256 | CVirtualBox vbox = uiCommon().virtualBox();
|
---|
257 |
|
---|
258 | /* Compose machine filename: */
|
---|
259 | m_strMachineFilePath = vbox.ComposeMachineFilename(m_pNameAndFolderEditor->name(),
|
---|
260 | m_strGroup,
|
---|
261 | QString(),
|
---|
262 | m_pNameAndFolderEditor->path());
|
---|
263 | /* Compose machine folder/basename: */
|
---|
264 | const QFileInfo fileInfo(m_strMachineFilePath);
|
---|
265 | m_strMachineFolder = fileInfo.absolutePath();
|
---|
266 | m_strMachineBaseName = fileInfo.completeBaseName();
|
---|
267 | }
|
---|
268 |
|
---|
269 | bool UIWizardNewVMPage1::checkISOFile() const
|
---|
270 | {
|
---|
271 | if (m_pEnableUnattendedInstallCheckBox && m_pEnableUnattendedInstallCheckBox->isChecked())
|
---|
272 | {
|
---|
273 | QString strISOFilePath = m_pISOFilePathSelector ? m_pISOFilePathSelector->path() : QString();
|
---|
274 | if (!QFileInfo(strISOFilePath).exists())
|
---|
275 | return false;
|
---|
276 | }
|
---|
277 | return true;
|
---|
278 | }
|
---|
279 |
|
---|
280 | void UIWizardNewVMPage1::createNameOSTypeWidgets(QVBoxLayout *pLayout, bool fCreateLabels /* = true */)
|
---|
281 | {
|
---|
282 | AssertReturnVoid(pLayout);
|
---|
283 |
|
---|
284 | if (fCreateLabels)
|
---|
285 | {
|
---|
286 | m_pNameOSTypeLabel = new QIRichTextLabel;
|
---|
287 | if (m_pNameOSTypeLabel)
|
---|
288 | pLayout->addWidget(m_pNameOSTypeLabel);
|
---|
289 | }
|
---|
290 |
|
---|
291 | m_pNameAndFolderEditor = new UINameAndSystemEditor(0, true, true, false);
|
---|
292 | if (m_pNameAndFolderEditor)
|
---|
293 | pLayout->addWidget(m_pNameAndFolderEditor);
|
---|
294 |
|
---|
295 | if (fCreateLabels)
|
---|
296 | {
|
---|
297 | m_pUnattendedLabel = new QIRichTextLabel;
|
---|
298 | if (m_pUnattendedLabel)
|
---|
299 | pLayout->addWidget(m_pUnattendedLabel);
|
---|
300 | }
|
---|
301 |
|
---|
302 | QGridLayout *pUnattendedInstall = new QGridLayout;
|
---|
303 | m_pEnableUnattendedInstallCheckBox = new QCheckBox;
|
---|
304 | pUnattendedInstall->addWidget(m_pEnableUnattendedInstallCheckBox, 0, 0, 1, 4, Qt::AlignLeft);
|
---|
305 |
|
---|
306 | m_pISOSelectorLabel = new QLabel;
|
---|
307 | if (m_pISOSelectorLabel)
|
---|
308 | {
|
---|
309 | m_pISOSelectorLabel->setAlignment(Qt::AlignRight);
|
---|
310 | m_pISOSelectorLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
---|
311 | m_pISOSelectorLabel->setEnabled(false);
|
---|
312 | pUnattendedInstall->addWidget(m_pISOSelectorLabel, 1, 0, 1, 1, Qt::AlignRight);
|
---|
313 | }
|
---|
314 | m_pISOFilePathSelector = new UIFilePathSelector;
|
---|
315 | if (m_pISOFilePathSelector)
|
---|
316 | {
|
---|
317 | m_pISOFilePathSelector->setResetEnabled(false);
|
---|
318 | m_pISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
|
---|
319 | m_pISOFilePathSelector->setFileDialogFilters("*.iso *.ISO");
|
---|
320 | m_pISOFilePathSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
---|
321 | m_pISOFilePathSelector->setEnabled(false);
|
---|
322 | pUnattendedInstall->addWidget(m_pISOFilePathSelector, 1, 1, 1, 4);
|
---|
323 | }
|
---|
324 |
|
---|
325 | m_pStartHeadlessCheckBox = new QCheckBox;
|
---|
326 | if (m_pStartHeadlessCheckBox)
|
---|
327 | {
|
---|
328 | m_pStartHeadlessCheckBox->setEnabled(false);
|
---|
329 | pUnattendedInstall->addWidget(m_pStartHeadlessCheckBox, 2, 1, 1, 1);
|
---|
330 | }
|
---|
331 | pLayout->addLayout(pUnattendedInstall);
|
---|
332 | m_pSystemTypeEditor = new UINameAndSystemEditor(0, false, false, true);
|
---|
333 | if (m_pSystemTypeEditor)
|
---|
334 | pLayout->addWidget(m_pSystemTypeEditor);
|
---|
335 |
|
---|
336 | }
|
---|
337 |
|
---|
338 | bool UIWizardNewVMPage1::createMachineFolder()
|
---|
339 | {
|
---|
340 | if (!m_pNameAndFolderEditor)
|
---|
341 | return false;
|
---|
342 | /* Cleanup previosly created folder if any: */
|
---|
343 | if (!cleanupMachineFolder())
|
---|
344 | {
|
---|
345 | msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
|
---|
346 | return false;
|
---|
347 | }
|
---|
348 |
|
---|
349 | composeMachineFilePath();
|
---|
350 |
|
---|
351 | /* Check if the folder already exists and check if it has been created by this wizard */
|
---|
352 | if (QDir(m_strMachineFolder).exists())
|
---|
353 | {
|
---|
354 | /* Looks like we have already created this folder for this run of the wizard. Just return */
|
---|
355 | if (m_strCreatedFolder == m_strMachineFolder)
|
---|
356 | return true;
|
---|
357 | /* The folder is there but not because of this wizard. Avoid overwriting a existing machine's folder */
|
---|
358 | else
|
---|
359 | {
|
---|
360 | msgCenter().cannotRewriteMachineFolder(m_strMachineFolder, thisImp());
|
---|
361 | return false;
|
---|
362 | }
|
---|
363 | }
|
---|
364 |
|
---|
365 | /* Try to create new folder (and it's predecessors): */
|
---|
366 | bool fMachineFolderCreated = QDir().mkpath(m_strMachineFolder);
|
---|
367 | if (!fMachineFolderCreated)
|
---|
368 | {
|
---|
369 | msgCenter().cannotCreateMachineFolder(m_strMachineFolder, thisImp());
|
---|
370 | return false;
|
---|
371 | }
|
---|
372 | m_strCreatedFolder = m_strMachineFolder;
|
---|
373 | return true;
|
---|
374 | }
|
---|
375 |
|
---|
376 | bool UIWizardNewVMPage1::cleanupMachineFolder(bool fWizardCancel /* = false */)
|
---|
377 | {
|
---|
378 | /* Make sure folder was previosly created: */
|
---|
379 | if (m_strCreatedFolder.isEmpty())
|
---|
380 | return true;
|
---|
381 | /* Clean this folder if the machine folder has been changed by the user or we are cancelling the wizard: */
|
---|
382 | if (m_strCreatedFolder != m_strMachineFolder || fWizardCancel)
|
---|
383 | {
|
---|
384 | /* Try to cleanup folder (and it's predecessors): */
|
---|
385 | bool fMachineFolderRemoved = QDir().rmpath(m_strCreatedFolder);
|
---|
386 | /* Reset machine folder value: */
|
---|
387 | if (fMachineFolderRemoved)
|
---|
388 | m_strCreatedFolder = QString();
|
---|
389 | /* Return cleanup result: */
|
---|
390 | return fMachineFolderRemoved;
|
---|
391 | }
|
---|
392 | return true;
|
---|
393 | }
|
---|
394 |
|
---|
395 | QString UIWizardNewVMPage1::machineFilePath() const
|
---|
396 | {
|
---|
397 | return m_strMachineFilePath;
|
---|
398 | }
|
---|
399 |
|
---|
400 | void UIWizardNewVMPage1::setMachineFilePath(const QString &strMachineFilePath)
|
---|
401 | {
|
---|
402 | m_strMachineFilePath = strMachineFilePath;
|
---|
403 | }
|
---|
404 |
|
---|
405 | QString UIWizardNewVMPage1::machineFolder() const
|
---|
406 | {
|
---|
407 | return m_strMachineFolder;
|
---|
408 | }
|
---|
409 |
|
---|
410 | void UIWizardNewVMPage1::setMachineFolder(const QString &strMachineFolder)
|
---|
411 | {
|
---|
412 | m_strMachineFolder = strMachineFolder;
|
---|
413 | }
|
---|
414 |
|
---|
415 | QString UIWizardNewVMPage1::machineBaseName() const
|
---|
416 | {
|
---|
417 | return m_strMachineBaseName;
|
---|
418 | }
|
---|
419 |
|
---|
420 | void UIWizardNewVMPage1::setMachineBaseName(const QString &strMachineBaseName)
|
---|
421 | {
|
---|
422 | m_strMachineBaseName = strMachineBaseName;
|
---|
423 | }
|
---|
424 |
|
---|
425 | QString UIWizardNewVMPage1::guestOSFamiyId() const
|
---|
426 | {
|
---|
427 | if (!m_pSystemTypeEditor)
|
---|
428 | return QString();
|
---|
429 | return m_pSystemTypeEditor->familyId();
|
---|
430 | }
|
---|
431 |
|
---|
432 | QString UIWizardNewVMPage1::ISOFilePath() const
|
---|
433 | {
|
---|
434 | if (!m_pISOFilePathSelector)
|
---|
435 | return QString();
|
---|
436 | return m_pISOFilePathSelector->path();
|
---|
437 | }
|
---|
438 |
|
---|
439 | bool UIWizardNewVMPage1::isUnattendedEnabled() const
|
---|
440 | {
|
---|
441 | if (!m_pEnableUnattendedInstallCheckBox)
|
---|
442 | return false;
|
---|
443 | return m_pEnableUnattendedInstallCheckBox->isChecked();
|
---|
444 | }
|
---|
445 |
|
---|
446 | bool UIWizardNewVMPage1::startHeadless() const
|
---|
447 | {
|
---|
448 | if (!m_pStartHeadlessCheckBox)
|
---|
449 | return false;
|
---|
450 | return m_pStartHeadlessCheckBox->isChecked();
|
---|
451 | }
|
---|
452 |
|
---|
453 | const QString &UIWizardNewVMPage1::detectedOSTypeId() const
|
---|
454 | {
|
---|
455 | return m_strDetectedOSTypeId;
|
---|
456 | }
|
---|
457 |
|
---|
458 | void UIWizardNewVMPage1::setTypeByISODetectedOSType(const QString &strDetectedOSType)
|
---|
459 | {
|
---|
460 | if (!strDetectedOSType.isEmpty())
|
---|
461 | onNameChanged(strDetectedOSType);
|
---|
462 | }
|
---|
463 |
|
---|
464 | void UIWizardNewVMPage1::markWidgets() const
|
---|
465 | {
|
---|
466 | if (m_pISOFilePathSelector)
|
---|
467 | m_pISOFilePathSelector->mark(!isISOFileSelectorComplete());
|
---|
468 | if (m_pNameAndFolderEditor)
|
---|
469 | m_pNameAndFolderEditor->markNameLineEdit(m_pNameAndFolderEditor->name().isEmpty());
|
---|
470 | }
|
---|
471 |
|
---|
472 | bool UIWizardNewVMPage1::isISOFileSelectorComplete() const
|
---|
473 | {
|
---|
474 | if (!m_pISOFilePathSelector)
|
---|
475 | return false;
|
---|
476 | return checkISOFile();
|
---|
477 | }
|
---|
478 |
|
---|
479 | void UIWizardNewVMPage1::retranslateWidgets()
|
---|
480 | {
|
---|
481 | if (m_pEnableUnattendedInstallCheckBox)
|
---|
482 | {
|
---|
483 | m_pEnableUnattendedInstallCheckBox->setText(UIWizardNewVM::tr("Unattended Install"));
|
---|
484 | m_pEnableUnattendedInstallCheckBox->setToolTip(UIWizardNewVM::tr("When checked, an unattended guest OS installation will be started "
|
---|
485 | "after this wizard is closed if not the virtual machine's disk will "
|
---|
486 | "be left empty."));
|
---|
487 | }
|
---|
488 |
|
---|
489 | if (m_pISOSelectorLabel)
|
---|
490 | m_pISOSelectorLabel->setText(UIWizardNewVM::tr("Installer:"));
|
---|
491 |
|
---|
492 | if (m_pStartHeadlessCheckBox)
|
---|
493 | {
|
---|
494 | m_pStartHeadlessCheckBox->setText(UIWizardNewVM::tr("Start VM Headless"));
|
---|
495 | m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("When checked, the unattended install will start the virtual "
|
---|
496 | "machine in headless mode after the guest OS install."));
|
---|
497 | }
|
---|
498 | }
|
---|
499 |
|
---|
500 | UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1(const QString &strGroup)
|
---|
501 | : UIWizardNewVMPage1(strGroup)
|
---|
502 | {
|
---|
503 | prepare();
|
---|
504 | }
|
---|
505 |
|
---|
506 | void UIWizardNewVMPageBasic1::prepare()
|
---|
507 | {
|
---|
508 | QVBoxLayout *pPageLayout = new QVBoxLayout(this);
|
---|
509 | createNameOSTypeWidgets(pPageLayout, false);
|
---|
510 | pPageLayout->addStretch();
|
---|
511 | createConnections();
|
---|
512 | /* Register fields: */
|
---|
513 | registerField("name*", m_pNameAndFolderEditor, "name", SIGNAL(sigNameChanged(const QString &)));
|
---|
514 | registerField("type", m_pSystemTypeEditor, "type", SIGNAL(sigOsTypeChanged()));
|
---|
515 | registerField("machineFilePath", this, "machineFilePath");
|
---|
516 | registerField("machineFolder", this, "machineFolder");
|
---|
517 | registerField("machineBaseName", this, "machineBaseName");
|
---|
518 | registerField("guestOSFamiyId", this, "guestOSFamiyId");
|
---|
519 | registerField("ISOFilePath", this, "ISOFilePath");
|
---|
520 | registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
|
---|
521 | registerField("startHeadless", this, "startHeadless");
|
---|
522 | registerField("detectedOSTypeId", this, "detectedOSTypeId");
|
---|
523 | }
|
---|
524 |
|
---|
525 | void UIWizardNewVMPageBasic1::createConnections()
|
---|
526 | {
|
---|
527 | connect(m_pEnableUnattendedInstallCheckBox, &QCheckBox::clicked, this, &UIWizardNewVMPageBasic1::sltUnattendedCheckBoxToggle);
|
---|
528 | connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardNewVMPageBasic1::sltISOPathChanged);
|
---|
529 | connect(m_pNameAndFolderEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMPageBasic1::sltNameChanged);
|
---|
530 | connect(m_pNameAndFolderEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageBasic1::sltPathChanged);
|
---|
531 | connect(m_pSystemTypeEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageBasic1::sltOsTypeChanged);
|
---|
532 | }
|
---|
533 |
|
---|
534 | int UIWizardNewVMPageBasic1::nextId() const
|
---|
535 | {
|
---|
536 | UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
|
---|
537 | if (!pWizard || !pWizard->isUnattendedInstallEnabled())
|
---|
538 | return UIWizardNewVM::Page3;
|
---|
539 | return UIWizardNewVM::Page2;
|
---|
540 | }
|
---|
541 |
|
---|
542 | bool UIWizardNewVMPageBasic1::isComplete() const
|
---|
543 | {
|
---|
544 | markWidgets();
|
---|
545 | if (m_pNameAndFolderEditor->name().isEmpty())
|
---|
546 | return false;
|
---|
547 | return isISOFileSelectorComplete();
|
---|
548 | }
|
---|
549 |
|
---|
550 | void UIWizardNewVMPageBasic1::sltNameChanged(const QString &strNewName)
|
---|
551 | {
|
---|
552 | onNameChanged(strNewName);
|
---|
553 | composeMachineFilePath();
|
---|
554 | }
|
---|
555 |
|
---|
556 | void UIWizardNewVMPageBasic1::sltPathChanged(const QString &strNewPath)
|
---|
557 | {
|
---|
558 | Q_UNUSED(strNewPath);
|
---|
559 | composeMachineFilePath();
|
---|
560 | }
|
---|
561 |
|
---|
562 | void UIWizardNewVMPageBasic1::sltOsTypeChanged()
|
---|
563 | {
|
---|
564 | /* Call to base-class: */
|
---|
565 | onOsTypeChanged();
|
---|
566 | }
|
---|
567 |
|
---|
568 | void UIWizardNewVMPageBasic1::sltISOPathChanged(const QString &strPath)
|
---|
569 | {
|
---|
570 | determineOSType(strPath);
|
---|
571 | setTypeByISODetectedOSType(m_strDetectedOSTypeId);
|
---|
572 | emit completeChanged();
|
---|
573 | }
|
---|
574 |
|
---|
575 | void UIWizardNewVMPageBasic1::sltUnattendedCheckBoxToggle(bool fEnabled)
|
---|
576 | {
|
---|
577 | if (m_pISOSelectorLabel)
|
---|
578 | m_pISOSelectorLabel->setEnabled(fEnabled);
|
---|
579 | if (m_pISOFilePathSelector)
|
---|
580 | m_pISOFilePathSelector->setEnabled(fEnabled);
|
---|
581 | if (m_pStartHeadlessCheckBox)
|
---|
582 | m_pStartHeadlessCheckBox->setEnabled(fEnabled);
|
---|
583 | emit completeChanged();
|
---|
584 | }
|
---|
585 |
|
---|
586 |
|
---|
587 | void UIWizardNewVMPageBasic1::retranslateUi()
|
---|
588 | {
|
---|
589 | retranslateWidgets();
|
---|
590 | /* Translate page: */
|
---|
591 | setTitle(UIWizardNewVM::tr("Virtual machine name and operating system"));
|
---|
592 |
|
---|
593 | if (m_pUnattendedLabel)
|
---|
594 | m_pUnattendedLabel->setText(UIWizardNewVM::tr("Please decide whether you want to start an unattended guest os install "
|
---|
595 | "in which case you will have to select a valid installation medium. If not, "
|
---|
596 | "your virtual disk will have an empty virtual hard disk."));
|
---|
597 |
|
---|
598 |
|
---|
599 | if (m_pNameOSTypeLabel)
|
---|
600 | m_pNameOSTypeLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new virtual machine "
|
---|
601 | "and select the type of operating system you intend to install on it. "
|
---|
602 | "The name you choose will be used throughout VirtualBox "
|
---|
603 | "to identify this machine."));
|
---|
604 |
|
---|
605 | // if ( m_pNameAndFolderEditor
|
---|
606 | // && m_pSystemTypeEditor
|
---|
607 | // && m_pISOSelectorLabel)
|
---|
608 | // {
|
---|
609 | // int iMinWidthHint = 0;
|
---|
610 | // iMinWidthHint = qMax(iMinWidthHint, m_pISOSelectorLabel->minimumSizeHint().width());
|
---|
611 | // m_pNameAndFolderEditor->setMinimumLayoutIndent(iMinWidthHint);
|
---|
612 | // m_pSystemTypeEditor->setMinimumLayoutIndent(iMinWidthHint);
|
---|
613 | // }
|
---|
614 | }
|
---|
615 |
|
---|
616 | void UIWizardNewVMPageBasic1::initializePage()
|
---|
617 | {
|
---|
618 | /* Translate page: */
|
---|
619 | retranslateUi();
|
---|
620 | if (m_pNameAndFolderEditor)
|
---|
621 | m_pNameAndFolderEditor->setFocus();
|
---|
622 | }
|
---|
623 |
|
---|
624 | void UIWizardNewVMPageBasic1::cleanupPage()
|
---|
625 | {
|
---|
626 | /* Cleanup: */
|
---|
627 | cleanupMachineFolder();
|
---|
628 | /* Call to base-class: */
|
---|
629 | UIWizardPage::cleanupPage();
|
---|
630 | }
|
---|
631 |
|
---|
632 | bool UIWizardNewVMPageBasic1::validatePage()
|
---|
633 | {
|
---|
634 | /* Try to create machine folder: */
|
---|
635 | return createMachineFolder();
|
---|
636 | }
|
---|