1 | /* $Id: UIWizardNewVMPageBasic1.cpp 87318 2021-01-20 10:17:56Z 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_pNameAndSystemEditor(0)
|
---|
187 | , m_pUnattendedLabel(0)
|
---|
188 | , m_pNameOSTypeLabel(0)
|
---|
189 | , m_strGroup(strGroup)
|
---|
190 | {
|
---|
191 | CHost host = uiCommon().host();
|
---|
192 | m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
|
---|
193 | m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
|
---|
194 | }
|
---|
195 |
|
---|
196 | void UIWizardNewVMPage1::onNameChanged(QString strNewName)
|
---|
197 | {
|
---|
198 | /* Do not forget about achitecture bits, if not yet specified: */
|
---|
199 | if (!strNewName.contains("32") && !strNewName.contains("64"))
|
---|
200 | strNewName += ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode ? "64" : "32";
|
---|
201 |
|
---|
202 | /* Search for a matching OS type based on the string the user typed already. */
|
---|
203 | for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
|
---|
204 | if (strNewName.contains(gs_OSTypePattern[i].pattern))
|
---|
205 | {
|
---|
206 | if (m_pNameAndSystemEditor)
|
---|
207 | m_pNameAndSystemEditor->setType(uiCommon().vmGuestOSType(gs_OSTypePattern[i].pcstId));
|
---|
208 | break;
|
---|
209 | }
|
---|
210 | }
|
---|
211 |
|
---|
212 | void UIWizardNewVMPage1::onOsTypeChanged()
|
---|
213 | {
|
---|
214 | /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore.
|
---|
215 | * So simply disconnect the text-edit signal. */
|
---|
216 | if (m_pNameAndSystemEditor)
|
---|
217 | m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &)));
|
---|
218 | }
|
---|
219 |
|
---|
220 | bool UIWizardNewVMPage1::determineOSType(const QString &strISOPath)
|
---|
221 | {
|
---|
222 | QFileInfo isoFileInfo(strISOPath);
|
---|
223 | if (!isoFileInfo.exists())
|
---|
224 | {
|
---|
225 | m_strDetectedOSTypeId.clear();
|
---|
226 | // m_strDetectedOSVersion.clear();
|
---|
227 | // m_strDetectedOSFlavor.clear();
|
---|
228 | // m_strDetectedOSLanguages.clear();
|
---|
229 | // m_strDetectedOSHints.clear();
|
---|
230 | // updateStatusLabel();
|
---|
231 | return false;
|
---|
232 | }
|
---|
233 |
|
---|
234 | CUnattended comUnatteded = uiCommon().virtualBox().CreateUnattendedInstaller();
|
---|
235 | comUnatteded.SetIsoPath(strISOPath);
|
---|
236 | comUnatteded.DetectIsoOS();
|
---|
237 |
|
---|
238 | m_strDetectedOSTypeId = comUnatteded.GetDetectedOSTypeId();
|
---|
239 | // m_strDetectedOSVersion = comUnatteded.GetDetectedOSVersion();
|
---|
240 | // m_strDetectedOSFlavor = comUnatteded.GetDetectedOSFlavor();
|
---|
241 | // m_strDetectedOSLanguages = comUnatteded.GetDetectedOSLanguages();
|
---|
242 | // m_strDetectedOSHints = comUnatteded.GetDetectedOSHints();
|
---|
243 |
|
---|
244 | //updateStatusLabel();
|
---|
245 | return true;
|
---|
246 | }
|
---|
247 |
|
---|
248 | void UIWizardNewVMPage1::composeMachineFilePath()
|
---|
249 | {
|
---|
250 | if (!m_pNameAndSystemEditor)
|
---|
251 | return;
|
---|
252 | if (m_pNameAndSystemEditor->name().isEmpty() || m_pNameAndSystemEditor->path().isEmpty())
|
---|
253 | return;
|
---|
254 | /* Get VBox: */
|
---|
255 | CVirtualBox vbox = uiCommon().virtualBox();
|
---|
256 |
|
---|
257 | /* Compose machine filename: */
|
---|
258 | m_strMachineFilePath = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(),
|
---|
259 | m_strGroup,
|
---|
260 | QString(),
|
---|
261 | m_pNameAndSystemEditor->path());
|
---|
262 | /* Compose machine folder/basename: */
|
---|
263 | const QFileInfo fileInfo(m_strMachineFilePath);
|
---|
264 | m_strMachineFolder = fileInfo.absolutePath();
|
---|
265 | m_strMachineBaseName = fileInfo.completeBaseName();
|
---|
266 | }
|
---|
267 |
|
---|
268 | bool UIWizardNewVMPage1::checkISOFile() const
|
---|
269 | {
|
---|
270 | if (isUnattendedEnabled())
|
---|
271 | {
|
---|
272 | QString strISOFilePath = m_pISOFilePathSelector ? m_pISOFilePathSelector->path() : QString();
|
---|
273 | if (!QFileInfo(strISOFilePath).exists())
|
---|
274 | return false;
|
---|
275 | }
|
---|
276 | return true;
|
---|
277 | }
|
---|
278 |
|
---|
279 | QFrame *UIWizardNewVMPage1::horizontalLine()
|
---|
280 | {
|
---|
281 | QFrame *line = new QFrame;
|
---|
282 | line->setFrameShape(QFrame::HLine);
|
---|
283 | line->setFrameShadow(QFrame::Sunken);
|
---|
284 | return line;
|
---|
285 | }
|
---|
286 |
|
---|
287 | QWidget *UIWizardNewVMPage1::createNameOSTypeWidgets(bool fIncreaseLeftIndent,
|
---|
288 | bool fCreateUnattendedWidgets,
|
---|
289 | bool fCreateLabels)
|
---|
290 | {
|
---|
291 | Q_UNUSED(fIncreaseLeftIndent);
|
---|
292 | QWidget *pContainer = new QWidget;
|
---|
293 | QGridLayout *pLayout = new QGridLayout(pContainer);
|
---|
294 | if (fIncreaseLeftIndent)
|
---|
295 | UIWizardNewVM::increaseLayoutLeftMargin(pLayout);
|
---|
296 |
|
---|
297 | int iRow = 0;
|
---|
298 | if (fCreateLabels)
|
---|
299 | {
|
---|
300 | m_pNameOSTypeLabel = new QIRichTextLabel;
|
---|
301 | if (m_pNameOSTypeLabel)
|
---|
302 | pLayout->addWidget(m_pNameOSTypeLabel, iRow++, 0, 1, 6);
|
---|
303 | }
|
---|
304 |
|
---|
305 | m_pNameAndSystemEditor = new UINameAndSystemEditor(0, true, true, true);
|
---|
306 | if (m_pNameAndSystemEditor)
|
---|
307 | pLayout->addWidget(m_pNameAndSystemEditor, iRow++, 0, 1, 6);
|
---|
308 |
|
---|
309 | pLayout->addWidget(horizontalLine(), iRow++, 0, 1, 6);
|
---|
310 |
|
---|
311 | if (fCreateLabels)
|
---|
312 | {
|
---|
313 | m_pUnattendedLabel = new QIRichTextLabel;
|
---|
314 | if (m_pUnattendedLabel)
|
---|
315 | pLayout->addWidget(m_pUnattendedLabel, iRow++, 0, 1, 6);
|
---|
316 | }
|
---|
317 |
|
---|
318 | if (fCreateUnattendedWidgets)
|
---|
319 | {
|
---|
320 | m_pEnableUnattendedInstallCheckBox = new QCheckBox;
|
---|
321 | pLayout->addWidget(m_pEnableUnattendedInstallCheckBox, iRow++, 0, 1, 1);
|
---|
322 |
|
---|
323 | m_pISOSelectorLabel = new QLabel;
|
---|
324 | if (m_pISOSelectorLabel)
|
---|
325 | {
|
---|
326 | m_pISOSelectorLabel->setAlignment(Qt::AlignRight);
|
---|
327 | m_pISOSelectorLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
|
---|
328 | m_pISOSelectorLabel->setEnabled(false);
|
---|
329 | pLayout->addWidget(m_pISOSelectorLabel, iRow, 1, 1, 1);
|
---|
330 | }
|
---|
331 | m_pISOFilePathSelector = new UIFilePathSelector;
|
---|
332 | if (m_pISOFilePathSelector)
|
---|
333 | {
|
---|
334 | m_pISOFilePathSelector->setResetEnabled(false);
|
---|
335 | m_pISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
|
---|
336 | m_pISOFilePathSelector->setFileDialogFilters("*.iso *.ISO");
|
---|
337 | m_pISOFilePathSelector->setEnabled(false);
|
---|
338 | pLayout->addWidget(m_pISOFilePathSelector, iRow++, 2, 1, 4);
|
---|
339 | }
|
---|
340 |
|
---|
341 | m_pStartHeadlessCheckBox = new QCheckBox;
|
---|
342 | if (m_pStartHeadlessCheckBox)
|
---|
343 | {
|
---|
344 | m_pStartHeadlessCheckBox->setEnabled(false);
|
---|
345 | pLayout->addWidget(m_pStartHeadlessCheckBox, iRow++, 1, 1, 5);
|
---|
346 | }
|
---|
347 |
|
---|
348 | pLayout->addWidget(horizontalLine(), iRow++, 0, 1, 4);
|
---|
349 | }
|
---|
350 | return pContainer;
|
---|
351 | }
|
---|
352 |
|
---|
353 | bool UIWizardNewVMPage1::createMachineFolder()
|
---|
354 | {
|
---|
355 | if (!m_pNameAndSystemEditor)
|
---|
356 | return false;
|
---|
357 | /* Cleanup previosly created folder if any: */
|
---|
358 | if (!cleanupMachineFolder())
|
---|
359 | {
|
---|
360 | msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
|
---|
361 | return false;
|
---|
362 | }
|
---|
363 |
|
---|
364 | composeMachineFilePath();
|
---|
365 |
|
---|
366 | /* Check if the folder already exists and check if it has been created by this wizard */
|
---|
367 | if (QDir(m_strMachineFolder).exists())
|
---|
368 | {
|
---|
369 | /* Looks like we have already created this folder for this run of the wizard. Just return */
|
---|
370 | if (m_strCreatedFolder == m_strMachineFolder)
|
---|
371 | return true;
|
---|
372 | /* The folder is there but not because of this wizard. Avoid overwriting a existing machine's folder */
|
---|
373 | else
|
---|
374 | {
|
---|
375 | msgCenter().cannotRewriteMachineFolder(m_strMachineFolder, thisImp());
|
---|
376 | return false;
|
---|
377 | }
|
---|
378 | }
|
---|
379 |
|
---|
380 | /* Try to create new folder (and it's predecessors): */
|
---|
381 | bool fMachineFolderCreated = QDir().mkpath(m_strMachineFolder);
|
---|
382 | if (!fMachineFolderCreated)
|
---|
383 | {
|
---|
384 | msgCenter().cannotCreateMachineFolder(m_strMachineFolder, thisImp());
|
---|
385 | return false;
|
---|
386 | }
|
---|
387 | m_strCreatedFolder = m_strMachineFolder;
|
---|
388 | return true;
|
---|
389 | }
|
---|
390 |
|
---|
391 | bool UIWizardNewVMPage1::cleanupMachineFolder(bool fWizardCancel /* = false */)
|
---|
392 | {
|
---|
393 | /* Make sure folder was previosly created: */
|
---|
394 | if (m_strCreatedFolder.isEmpty())
|
---|
395 | return true;
|
---|
396 | /* Clean this folder if the machine folder has been changed by the user or we are cancelling the wizard: */
|
---|
397 | if (m_strCreatedFolder != m_strMachineFolder || fWizardCancel)
|
---|
398 | {
|
---|
399 | /* Try to cleanup folder (and it's predecessors): */
|
---|
400 | bool fMachineFolderRemoved = QDir().rmpath(m_strCreatedFolder);
|
---|
401 | /* Reset machine folder value: */
|
---|
402 | if (fMachineFolderRemoved)
|
---|
403 | m_strCreatedFolder = QString();
|
---|
404 | /* Return cleanup result: */
|
---|
405 | return fMachineFolderRemoved;
|
---|
406 | }
|
---|
407 | return true;
|
---|
408 | }
|
---|
409 |
|
---|
410 | QString UIWizardNewVMPage1::machineFilePath() const
|
---|
411 | {
|
---|
412 | return m_strMachineFilePath;
|
---|
413 | }
|
---|
414 |
|
---|
415 | void UIWizardNewVMPage1::setMachineFilePath(const QString &strMachineFilePath)
|
---|
416 | {
|
---|
417 | m_strMachineFilePath = strMachineFilePath;
|
---|
418 | }
|
---|
419 |
|
---|
420 | QString UIWizardNewVMPage1::machineFolder() const
|
---|
421 | {
|
---|
422 | return m_strMachineFolder;
|
---|
423 | }
|
---|
424 |
|
---|
425 | void UIWizardNewVMPage1::setMachineFolder(const QString &strMachineFolder)
|
---|
426 | {
|
---|
427 | m_strMachineFolder = strMachineFolder;
|
---|
428 | }
|
---|
429 |
|
---|
430 | QString UIWizardNewVMPage1::machineBaseName() const
|
---|
431 | {
|
---|
432 | return m_strMachineBaseName;
|
---|
433 | }
|
---|
434 |
|
---|
435 | void UIWizardNewVMPage1::setMachineBaseName(const QString &strMachineBaseName)
|
---|
436 | {
|
---|
437 | m_strMachineBaseName = strMachineBaseName;
|
---|
438 | }
|
---|
439 |
|
---|
440 | QString UIWizardNewVMPage1::guestOSFamiyId() const
|
---|
441 | {
|
---|
442 | if (!m_pNameAndSystemEditor)
|
---|
443 | return QString();
|
---|
444 | return m_pNameAndSystemEditor->familyId();
|
---|
445 | }
|
---|
446 |
|
---|
447 | QString UIWizardNewVMPage1::ISOFilePath() const
|
---|
448 | {
|
---|
449 | if (!m_pISOFilePathSelector)
|
---|
450 | return QString();
|
---|
451 | return m_pISOFilePathSelector->path();
|
---|
452 | }
|
---|
453 |
|
---|
454 | bool UIWizardNewVMPage1::isUnattendedEnabled() const
|
---|
455 | {
|
---|
456 | if (!m_pEnableUnattendedInstallCheckBox)
|
---|
457 | return false;
|
---|
458 | return m_pEnableUnattendedInstallCheckBox->isChecked();
|
---|
459 | }
|
---|
460 |
|
---|
461 | bool UIWizardNewVMPage1::startHeadless() const
|
---|
462 | {
|
---|
463 | if (!m_pStartHeadlessCheckBox)
|
---|
464 | return false;
|
---|
465 | return m_pStartHeadlessCheckBox->isChecked();
|
---|
466 | }
|
---|
467 |
|
---|
468 | const QString &UIWizardNewVMPage1::detectedOSTypeId() const
|
---|
469 | {
|
---|
470 | return m_strDetectedOSTypeId;
|
---|
471 | }
|
---|
472 |
|
---|
473 | void UIWizardNewVMPage1::setTypeByISODetectedOSType(const QString &strDetectedOSType)
|
---|
474 | {
|
---|
475 | if (!strDetectedOSType.isEmpty())
|
---|
476 | onNameChanged(strDetectedOSType);
|
---|
477 | }
|
---|
478 |
|
---|
479 | void UIWizardNewVMPage1::markWidgets() const
|
---|
480 | {
|
---|
481 | if (m_pISOFilePathSelector)
|
---|
482 | m_pISOFilePathSelector->mark(!isISOFileSelectorComplete());
|
---|
483 | if (m_pNameAndSystemEditor)
|
---|
484 | m_pNameAndSystemEditor->markNameLineEdit(m_pNameAndSystemEditor->name().isEmpty());
|
---|
485 | }
|
---|
486 |
|
---|
487 | bool UIWizardNewVMPage1::isISOFileSelectorComplete() const
|
---|
488 | {
|
---|
489 | if (!m_pISOFilePathSelector)
|
---|
490 | return false;
|
---|
491 | return checkISOFile();
|
---|
492 | }
|
---|
493 |
|
---|
494 | void UIWizardNewVMPage1::retranslateWidgets()
|
---|
495 | {
|
---|
496 | if (m_pEnableUnattendedInstallCheckBox)
|
---|
497 | {
|
---|
498 | m_pEnableUnattendedInstallCheckBox->setText(UIWizardNewVM::tr("Unattended Install"));
|
---|
499 | m_pEnableUnattendedInstallCheckBox->setToolTip(UIWizardNewVM::tr("When checked, an unattended guest OS installation will be started "
|
---|
500 | "after this wizard is closed if not the virtual machine's disk will "
|
---|
501 | "be left empty."));
|
---|
502 | }
|
---|
503 |
|
---|
504 | if (m_pISOSelectorLabel)
|
---|
505 | m_pISOSelectorLabel->setText(UIWizardNewVM::tr("Installer:"));
|
---|
506 |
|
---|
507 | if (m_pStartHeadlessCheckBox)
|
---|
508 | {
|
---|
509 | m_pStartHeadlessCheckBox->setText(UIWizardNewVM::tr("Start VM Headless"));
|
---|
510 | m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("When checked, the unattended install will start the virtual "
|
---|
511 | "machine in headless mode after the guest OS install."));
|
---|
512 | }
|
---|
513 | }
|
---|
514 |
|
---|
515 | UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1(const QString &strGroup)
|
---|
516 | : UIWizardNewVMPage1(strGroup)
|
---|
517 | {
|
---|
518 | prepare();
|
---|
519 | }
|
---|
520 |
|
---|
521 | void UIWizardNewVMPageBasic1::prepare()
|
---|
522 | {
|
---|
523 | QVBoxLayout *pPageLayout = new QVBoxLayout(this);
|
---|
524 | pPageLayout->addWidget(createNameOSTypeWidgets(/* fIncreaseLeftIndent */ false,
|
---|
525 | /* fCreateUnattendedWidget */ false,
|
---|
526 | /* fCreateLabels */false));
|
---|
527 | pPageLayout->addStretch();
|
---|
528 |
|
---|
529 | createConnections();
|
---|
530 | /* Register fields: */
|
---|
531 | registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
|
---|
532 | registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
|
---|
533 | registerField("machineFilePath", this, "machineFilePath");
|
---|
534 | registerField("machineFolder", this, "machineFolder");
|
---|
535 | registerField("machineBaseName", this, "machineBaseName");
|
---|
536 | registerField("guestOSFamiyId", this, "guestOSFamiyId");
|
---|
537 | registerField("ISOFilePath", this, "ISOFilePath");
|
---|
538 | registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
|
---|
539 | registerField("startHeadless", this, "startHeadless");
|
---|
540 | registerField("detectedOSTypeId", this, "detectedOSTypeId");
|
---|
541 | }
|
---|
542 |
|
---|
543 | void UIWizardNewVMPageBasic1::createConnections()
|
---|
544 | {
|
---|
545 | connect(m_pEnableUnattendedInstallCheckBox, &QCheckBox::clicked, this, &UIWizardNewVMPageBasic1::sltUnattendedCheckBoxToggle);
|
---|
546 | connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardNewVMPageBasic1::sltISOPathChanged);
|
---|
547 | connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMPageBasic1::sltNameChanged);
|
---|
548 | connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageBasic1::sltPathChanged);
|
---|
549 | connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageBasic1::sltOsTypeChanged);
|
---|
550 | }
|
---|
551 |
|
---|
552 | int UIWizardNewVMPageBasic1::nextId() const
|
---|
553 | {
|
---|
554 | UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
|
---|
555 | if (!pWizard || !pWizard->isUnattendedInstallEnabled())
|
---|
556 | return UIWizardNewVM::Page3;
|
---|
557 | return UIWizardNewVM::Page2;
|
---|
558 | }
|
---|
559 |
|
---|
560 | bool UIWizardNewVMPageBasic1::isComplete() const
|
---|
561 | {
|
---|
562 | markWidgets();
|
---|
563 | if (m_pNameAndSystemEditor->name().isEmpty())
|
---|
564 | return false;
|
---|
565 | return isISOFileSelectorComplete();
|
---|
566 | }
|
---|
567 |
|
---|
568 | void UIWizardNewVMPageBasic1::sltNameChanged(const QString &strNewName)
|
---|
569 | {
|
---|
570 | onNameChanged(strNewName);
|
---|
571 | composeMachineFilePath();
|
---|
572 | }
|
---|
573 |
|
---|
574 | void UIWizardNewVMPageBasic1::sltPathChanged(const QString &strNewPath)
|
---|
575 | {
|
---|
576 | Q_UNUSED(strNewPath);
|
---|
577 | composeMachineFilePath();
|
---|
578 | }
|
---|
579 |
|
---|
580 | void UIWizardNewVMPageBasic1::sltOsTypeChanged()
|
---|
581 | {
|
---|
582 | /* Call to base-class: */
|
---|
583 | onOsTypeChanged();
|
---|
584 | }
|
---|
585 |
|
---|
586 | void UIWizardNewVMPageBasic1::sltISOPathChanged(const QString &strPath)
|
---|
587 | {
|
---|
588 | determineOSType(strPath);
|
---|
589 | setTypeByISODetectedOSType(m_strDetectedOSTypeId);
|
---|
590 | emit completeChanged();
|
---|
591 | }
|
---|
592 |
|
---|
593 | void UIWizardNewVMPageBasic1::sltUnattendedCheckBoxToggle(bool fEnabled)
|
---|
594 | {
|
---|
595 | if (m_pISOSelectorLabel)
|
---|
596 | m_pISOSelectorLabel->setEnabled(fEnabled);
|
---|
597 | if (m_pISOFilePathSelector)
|
---|
598 | m_pISOFilePathSelector->setEnabled(fEnabled);
|
---|
599 | if (m_pStartHeadlessCheckBox)
|
---|
600 | m_pStartHeadlessCheckBox->setEnabled(fEnabled);
|
---|
601 | emit completeChanged();
|
---|
602 | }
|
---|
603 |
|
---|
604 |
|
---|
605 | void UIWizardNewVMPageBasic1::retranslateUi()
|
---|
606 | {
|
---|
607 | retranslateWidgets();
|
---|
608 | /* Translate page: */
|
---|
609 | setTitle(UIWizardNewVM::tr("Virtual machine name and operating system"));
|
---|
610 |
|
---|
611 | if (m_pUnattendedLabel)
|
---|
612 | m_pUnattendedLabel->setText(UIWizardNewVM::tr("Please decide whether you want to start an unattended guest os install "
|
---|
613 | "in which case you will have to select a valid installation medium. If not, "
|
---|
614 | "your virtual disk will have an empty virtual hard disk."));
|
---|
615 |
|
---|
616 |
|
---|
617 | if (m_pNameOSTypeLabel)
|
---|
618 | m_pNameOSTypeLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new virtual machine "
|
---|
619 | "and select the type of operating system you intend to install on it. "
|
---|
620 | "The name you choose will be used throughout VirtualBox "
|
---|
621 | "to identify this machine."));
|
---|
622 |
|
---|
623 | // if ( m_pNameAndSystemEditor
|
---|
624 | // && m_pSystemTypeEditor
|
---|
625 | // && m_pISOSelectorLabel)
|
---|
626 | // {
|
---|
627 | // int iMinWidthHint = 0;
|
---|
628 | // iMinWidthHint = qMax(iMinWidthHint, m_pISOSelectorLabel->minimumSizeHint().width());
|
---|
629 | // m_pNameAndSystemEditor->setMinimumLayoutIndent(iMinWidthHint);
|
---|
630 | // m_pSystemTypeEditor->setMinimumLayoutIndent(iMinWidthHint);
|
---|
631 | // }
|
---|
632 | }
|
---|
633 |
|
---|
634 | void UIWizardNewVMPageBasic1::initializePage()
|
---|
635 | {
|
---|
636 | /* Translate page: */
|
---|
637 | retranslateUi();
|
---|
638 | if (m_pNameAndSystemEditor)
|
---|
639 | m_pNameAndSystemEditor->setFocus();
|
---|
640 | }
|
---|
641 |
|
---|
642 | void UIWizardNewVMPageBasic1::cleanupPage()
|
---|
643 | {
|
---|
644 | /* Cleanup: */
|
---|
645 | cleanupMachineFolder();
|
---|
646 | /* Call to base-class: */
|
---|
647 | UIWizardPage::cleanupPage();
|
---|
648 | }
|
---|
649 |
|
---|
650 | bool UIWizardNewVMPageBasic1::validatePage()
|
---|
651 | {
|
---|
652 | /* Try to create machine folder: */
|
---|
653 | return createMachineFolder();
|
---|
654 | }
|
---|