1 | /* $Id: UIWizardNewVMPageBasic1.cpp 77592 2019-03-07 08:46:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardNewVMPageBasic1 class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2019 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 <QDir>
|
---|
20 | #include <QLineEdit>
|
---|
21 | #include <QHBoxLayout>
|
---|
22 | #include <QVBoxLayout>
|
---|
23 |
|
---|
24 | /* GUI includes: */
|
---|
25 | #include "QIRichTextLabel.h"
|
---|
26 | #include "VBoxGlobal.h"
|
---|
27 | #include "UIMessageCenter.h"
|
---|
28 | #include "UINameAndSystemEditor.h"
|
---|
29 | #include "UIWizardNewVMPageBasic1.h"
|
---|
30 | #include "UIWizardNewVM.h"
|
---|
31 |
|
---|
32 | /* COM includes: */
|
---|
33 | #include "CHost.h"
|
---|
34 | #include "CSystemProperties.h"
|
---|
35 |
|
---|
36 |
|
---|
37 | /* Defines some patterns to guess the right OS type. Should be in sync with
|
---|
38 | * VirtualBox-settings-common.xsd in Main. The list is sorted by priority. The
|
---|
39 | * first matching string found, will be used. */
|
---|
40 | struct osTypePattern
|
---|
41 | {
|
---|
42 | QRegExp pattern;
|
---|
43 | const char *pcstId;
|
---|
44 | };
|
---|
45 |
|
---|
46 | static const osTypePattern gs_OSTypePattern[] =
|
---|
47 | {
|
---|
48 | /* DOS: */
|
---|
49 | { QRegExp("DOS", Qt::CaseInsensitive), "DOS" },
|
---|
50 |
|
---|
51 | /* Windows: */
|
---|
52 | { QRegExp( "Wi.*98", Qt::CaseInsensitive), "Windows98" },
|
---|
53 | { QRegExp( "Wi.*95", Qt::CaseInsensitive), "Windows95" },
|
---|
54 | { QRegExp( "Wi.*Me", Qt::CaseInsensitive), "WindowsMe" },
|
---|
55 | { QRegExp( "(Wi.*NT)|(NT[-._v]*4)", Qt::CaseInsensitive), "WindowsNT4" },
|
---|
56 | { QRegExp( "NT[-._v]*3[.,]*[51x]", Qt::CaseInsensitive), "WindowsNT3x" },
|
---|
57 | /* Note: Do not automatically set WindowsXP_64 on 64-bit hosts, as Windows XP 64-bit
|
---|
58 | * is extremely rare -- most users never heard of it even. So always default to 32-bit. */
|
---|
59 | { QRegExp("((Wi.*XP)|(XP)).*", Qt::CaseInsensitive), "WindowsXP" },
|
---|
60 | { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*64", Qt::CaseInsensitive), "Windows2003_64" },
|
---|
61 | { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*32", Qt::CaseInsensitive), "Windows2003" },
|
---|
62 | { QRegExp("((Wi.*Vis)|(Vista)).*64", Qt::CaseInsensitive), "WindowsVista_64" },
|
---|
63 | { QRegExp("((Wi.*Vis)|(Vista)).*32", Qt::CaseInsensitive), "WindowsVista" },
|
---|
64 | { QRegExp( "(Wi.*2016)|(W2K16)|(Win2K16)", Qt::CaseInsensitive), "Windows2016_64" },
|
---|
65 | { QRegExp( "(Wi.*2012)|(W2K12)|(Win2K12)", Qt::CaseInsensitive), "Windows2012_64" },
|
---|
66 | { QRegExp("((Wi.*2008)|(W2K8)|(Win2k8)).*64", Qt::CaseInsensitive), "Windows2008_64" },
|
---|
67 | { QRegExp("((Wi.*2008)|(W2K8)|(Win2K8)).*32", Qt::CaseInsensitive), "Windows2008" },
|
---|
68 | { QRegExp( "(Wi.*2000)|(W2K)|(Win2K)", Qt::CaseInsensitive), "Windows2000" },
|
---|
69 | { QRegExp( "(Wi.*7.*64)|(W7.*64)", Qt::CaseInsensitive), "Windows7_64" },
|
---|
70 | { QRegExp( "(Wi.*7.*32)|(W7.*32)", Qt::CaseInsensitive), "Windows7" },
|
---|
71 | { QRegExp( "(Wi.*8.*1.*64)|(W8.*64)", Qt::CaseInsensitive), "Windows81_64" },
|
---|
72 | { QRegExp( "(Wi.*8.*1.*32)|(W8.*32)", Qt::CaseInsensitive), "Windows81" },
|
---|
73 | { QRegExp( "(Wi.*8.*64)|(W8.*64)", Qt::CaseInsensitive), "Windows8_64" },
|
---|
74 | { QRegExp( "(Wi.*8.*32)|(W8.*32)", Qt::CaseInsensitive), "Windows8" },
|
---|
75 | { QRegExp( "(Wi.*10.*64)|(W10.*64)", Qt::CaseInsensitive), "Windows10_64" },
|
---|
76 | { QRegExp( "(Wi.*10.*32)|(W10.*32)", Qt::CaseInsensitive), "Windows10" },
|
---|
77 | { QRegExp( "Wi.*3.*1", Qt::CaseInsensitive), "Windows31" },
|
---|
78 | /* Set Windows 7 as default for "Windows". */
|
---|
79 | { QRegExp( "Wi.*64", Qt::CaseInsensitive), "Windows7_64" },
|
---|
80 | { QRegExp( "Wi.*32", Qt::CaseInsensitive), "Windows7" },
|
---|
81 | /* ReactOS wants to be considered as Windows 2003 */
|
---|
82 | { QRegExp( "Reac.*", Qt::CaseInsensitive), "Windows2003" },
|
---|
83 |
|
---|
84 | /* Solaris: */
|
---|
85 | { QRegExp("Sol.*11", Qt::CaseInsensitive), "Solaris11_64" },
|
---|
86 | { QRegExp("((Op.*Sol)|(os20[01][0-9])|(Sol.*10)|(India)|(Neva)).*64", Qt::CaseInsensitive), "OpenSolaris_64" },
|
---|
87 | { QRegExp("((Op.*Sol)|(os20[01][0-9])|(Sol.*10)|(India)|(Neva)).*32", Qt::CaseInsensitive), "OpenSolaris" },
|
---|
88 | { QRegExp("Sol.*64", Qt::CaseInsensitive), "Solaris_64" },
|
---|
89 | { QRegExp("Sol.*32", Qt::CaseInsensitive), "Solaris" },
|
---|
90 |
|
---|
91 | /* OS/2: */
|
---|
92 | { QRegExp( "OS[/|!-]{,1}2.*W.*4.?5", Qt::CaseInsensitive), "OS2Warp45" },
|
---|
93 | { QRegExp( "OS[/|!-]{,1}2.*W.*4", Qt::CaseInsensitive), "OS2Warp4" },
|
---|
94 | { QRegExp( "OS[/|!-]{,1}2.*W", Qt::CaseInsensitive), "OS2Warp3" },
|
---|
95 | { QRegExp("(OS[/|!-]{,1}2.*e)|(eCS.*)", Qt::CaseInsensitive), "OS2eCS" },
|
---|
96 | { QRegExp( "OS[/|!-]{,1}2", Qt::CaseInsensitive), "OS2" },
|
---|
97 | { QRegExp( "eComS.*", Qt::CaseInsensitive), "OS2eCS" },
|
---|
98 |
|
---|
99 | /* Other: Must come before Ubuntu/Maverick and before Linux??? */
|
---|
100 | { QRegExp("QN", Qt::CaseInsensitive), "QNX" },
|
---|
101 |
|
---|
102 | /* Mac OS X: Must come before Ubuntu/Maverick and before Linux: */
|
---|
103 | { QRegExp("((mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)).64", Qt::CaseInsensitive), "MacOS_64" },
|
---|
104 | { QRegExp("((mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)).32", Qt::CaseInsensitive), "MacOS" },
|
---|
105 | { QRegExp("((mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)).*64", Qt::CaseInsensitive), "MacOS_64" },
|
---|
106 | { QRegExp("((mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)).*32", Qt::CaseInsensitive), "MacOS" },
|
---|
107 | { QRegExp("((mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)).*64", Qt::CaseInsensitive), "MacOS106_64" },
|
---|
108 | { QRegExp("((mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)).*32", Qt::CaseInsensitive), "MacOS106" },
|
---|
109 | { QRegExp( "(mac.*10[.,]{0,1}7)|(os.*x.*10[.,]{0,1}7)|(mac.*ML)|(os.*x.*ML)|(Mount)", Qt::CaseInsensitive), "MacOS108_64" },
|
---|
110 | { QRegExp( "(mac.*10[.,]{0,1}8)|(os.*x.*10[.,]{0,1}8)|(Lion)", Qt::CaseInsensitive), "MacOS107_64" },
|
---|
111 | { QRegExp( "(mac.*10[.,]{0,1}9)|(os.*x.*10[.,]{0,1}9)|(mac.*mav)|(os.*x.*mav)|(Mavericks)", Qt::CaseInsensitive), "MacOS109_64" },
|
---|
112 | { QRegExp( "(mac.*yos)|(os.*x.*yos)|(Yosemite)", Qt::CaseInsensitive), "MacOS1010_64" },
|
---|
113 | { QRegExp( "(mac.*cap)|(os.*x.*capit)|(Capitan)", Qt::CaseInsensitive), "MacOS1011_64" },
|
---|
114 | { QRegExp( "(mac.*hig)|(os.*x.*high.*sierr)|(High Sierra)", Qt::CaseInsensitive), "MacOS1013_64" },
|
---|
115 | { QRegExp( "(mac.*sie)|(os.*x.*sierr)|(Sierra)", Qt::CaseInsensitive), "MacOS1012_64" },
|
---|
116 | { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*64", Qt::CaseInsensitive), "MacOS_64" },
|
---|
117 | { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*32", Qt::CaseInsensitive), "MacOS" },
|
---|
118 |
|
---|
119 | /* Code names for Linux distributions: */
|
---|
120 | { 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" },
|
---|
121 | { 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" },
|
---|
122 | { 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" },
|
---|
123 | { 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" },
|
---|
124 | { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(stretch)|(buster)|(sid)).*64", Qt::CaseInsensitive), "Debian_64" },
|
---|
125 | { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(stretch)|(buster)|(sid)).*32", Qt::CaseInsensitive), "Debian" },
|
---|
126 | { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*64", Qt::CaseInsensitive), "Fedora_64" },
|
---|
127 | { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*32", Qt::CaseInsensitive), "Fedora" },
|
---|
128 |
|
---|
129 | /* Regular names of Linux distributions: */
|
---|
130 | { QRegExp("Arc.*64", Qt::CaseInsensitive), "ArchLinux_64" },
|
---|
131 | { QRegExp("Arc.*32", Qt::CaseInsensitive), "ArchLinux" },
|
---|
132 | { QRegExp("Deb.*64", Qt::CaseInsensitive), "Debian_64" },
|
---|
133 | { QRegExp("Deb.*32", Qt::CaseInsensitive), "Debian" },
|
---|
134 | { QRegExp("((SU)|(Nov)|(SLE)).*64", Qt::CaseInsensitive), "OpenSUSE_64" },
|
---|
135 | { QRegExp("((SU)|(Nov)|(SLE)).*32", Qt::CaseInsensitive), "OpenSUSE" },
|
---|
136 | { QRegExp("Fe.*64", Qt::CaseInsensitive), "Fedora_64" },
|
---|
137 | { QRegExp("Fe.*32", Qt::CaseInsensitive), "Fedora" },
|
---|
138 | { QRegExp("((Gen)|(Sab)).*64", Qt::CaseInsensitive), "Gentoo_64" },
|
---|
139 | { QRegExp("((Gen)|(Sab)).*32", Qt::CaseInsensitive), "Gentoo" },
|
---|
140 | { QRegExp("((Man)|(Mag)).*64", Qt::CaseInsensitive), "Mandriva_64" },
|
---|
141 | { QRegExp("((Man)|(Mag)).*32", Qt::CaseInsensitive), "Mandriva" },
|
---|
142 | { QRegExp("((Red)|(rhel)|(cen)).*64", Qt::CaseInsensitive), "RedHat_64" },
|
---|
143 | { QRegExp("((Red)|(rhel)|(cen)).*32", Qt::CaseInsensitive), "RedHat" },
|
---|
144 | { QRegExp("Tur.*64", Qt::CaseInsensitive), "Turbolinux_64" },
|
---|
145 | { QRegExp("Tur.*32", Qt::CaseInsensitive), "Turbolinux" },
|
---|
146 | { QRegExp("(Ub)|(Min).*64", Qt::CaseInsensitive), "Ubuntu_64" },
|
---|
147 | { QRegExp("(Ub)|(Min).*32", Qt::CaseInsensitive), "Ubuntu" },
|
---|
148 | { QRegExp("Xa.*64", Qt::CaseInsensitive), "Xandros_64" },
|
---|
149 | { QRegExp("Xa.*32", Qt::CaseInsensitive), "Xandros" },
|
---|
150 | { QRegExp("((Or)|(oel)|(ol)).*64", Qt::CaseInsensitive), "Oracle_64" },
|
---|
151 | { QRegExp("((Or)|(oel)|(ol)).*32", Qt::CaseInsensitive), "Oracle" },
|
---|
152 | { QRegExp("Knoppix", Qt::CaseInsensitive), "Linux26" },
|
---|
153 | { QRegExp("Dsl", Qt::CaseInsensitive), "Linux24" },
|
---|
154 | { QRegExp("((Lin)|(lnx)).*2.?2", Qt::CaseInsensitive), "Linux22" },
|
---|
155 | { QRegExp("((Lin)|(lnx)).*2.?4.*64", Qt::CaseInsensitive), "Linux24_64" },
|
---|
156 | { QRegExp("((Lin)|(lnx)).*2.?4.*32", Qt::CaseInsensitive), "Linux24" },
|
---|
157 | { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*64", Qt::CaseInsensitive), "Linux26_64" },
|
---|
158 | { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*32", Qt::CaseInsensitive), "Linux26" },
|
---|
159 | { QRegExp("((Lin)|(lnx)).*64", Qt::CaseInsensitive), "Linux26_64" },
|
---|
160 | { QRegExp("((Lin)|(lnx)).*32", Qt::CaseInsensitive), "Linux26" },
|
---|
161 |
|
---|
162 | /* Other: */
|
---|
163 | { QRegExp("L4", Qt::CaseInsensitive), "L4" },
|
---|
164 | { QRegExp("((Fr.*B)|(fbsd)).*64", Qt::CaseInsensitive), "FreeBSD_64" },
|
---|
165 | { QRegExp("((Fr.*B)|(fbsd)).*32", Qt::CaseInsensitive), "FreeBSD" },
|
---|
166 | { QRegExp("Op.*B.*64", Qt::CaseInsensitive), "OpenBSD_64" },
|
---|
167 | { QRegExp("Op.*B.*32", Qt::CaseInsensitive), "OpenBSD" },
|
---|
168 | { QRegExp("Ne.*B.*64", Qt::CaseInsensitive), "NetBSD_64" },
|
---|
169 | { QRegExp("Ne.*B.*32", Qt::CaseInsensitive), "NetBSD" },
|
---|
170 | { QRegExp("Net", Qt::CaseInsensitive), "Netware" },
|
---|
171 | { QRegExp("Rocki", Qt::CaseInsensitive), "JRockitVE" },
|
---|
172 | { QRegExp("bs[23]{0,1}-", Qt::CaseInsensitive), "VBoxBS_64" }, /* bootsector tests */
|
---|
173 | { QRegExp("Ot", Qt::CaseInsensitive), "Other" },
|
---|
174 | };
|
---|
175 |
|
---|
176 | UIWizardNewVMPage1::UIWizardNewVMPage1(const QString &strGroup)
|
---|
177 | : m_pNameAndSystemEditor(0)
|
---|
178 | , m_strGroup(strGroup)
|
---|
179 |
|
---|
180 | {
|
---|
181 | CHost host = vboxGlobal().host();
|
---|
182 | m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
|
---|
183 | m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
|
---|
184 | }
|
---|
185 |
|
---|
186 | void UIWizardNewVMPage1::onNameChanged(QString strNewName)
|
---|
187 | {
|
---|
188 | /* Do not forget about achitecture bits, if not yet specified: */
|
---|
189 | if (!strNewName.contains("32") && !strNewName.contains("64"))
|
---|
190 | strNewName += ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode ? "64" : "32";
|
---|
191 |
|
---|
192 | /* Search for a matching OS type based on the string the user typed already. */
|
---|
193 | for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
|
---|
194 | if (strNewName.contains(gs_OSTypePattern[i].pattern))
|
---|
195 | {
|
---|
196 | if (m_pNameAndSystemEditor)
|
---|
197 | {
|
---|
198 | m_pNameAndSystemEditor->blockSignals(true);
|
---|
199 | m_pNameAndSystemEditor->setType(vboxGlobal().vmGuestOSType(gs_OSTypePattern[i].pcstId));
|
---|
200 | m_pNameAndSystemEditor->blockSignals(false);
|
---|
201 | }
|
---|
202 | break;
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 | void UIWizardNewVMPage1::onOsTypeChanged()
|
---|
207 | {
|
---|
208 | /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore.
|
---|
209 | * So simply disconnect the text-edit signal. */
|
---|
210 | if (m_pNameAndSystemEditor)
|
---|
211 | m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &)));
|
---|
212 | }
|
---|
213 |
|
---|
214 | void UIWizardNewVMPage1::composeMachineFilePath()
|
---|
215 | {
|
---|
216 | if (!m_pNameAndSystemEditor)
|
---|
217 | return;
|
---|
218 | if (m_pNameAndSystemEditor->name().isEmpty() || m_pNameAndSystemEditor->path().isEmpty())
|
---|
219 | return;
|
---|
220 | /* Get VBox: */
|
---|
221 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
222 |
|
---|
223 | /* Compose machine filename: */
|
---|
224 | m_strMachineFilePath = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(),
|
---|
225 | m_strGroup,
|
---|
226 | QString(),
|
---|
227 | m_pNameAndSystemEditor->path());
|
---|
228 | /* Compose machine folder/basename: */
|
---|
229 | const QFileInfo fileInfo(m_strMachineFilePath);
|
---|
230 | m_strMachineFolder = fileInfo.absolutePath();
|
---|
231 | m_strMachineBaseName = fileInfo.completeBaseName();
|
---|
232 | }
|
---|
233 |
|
---|
234 | bool UIWizardNewVMPage1::createMachineFolder()
|
---|
235 | {
|
---|
236 | if (!m_pNameAndSystemEditor)
|
---|
237 | return false;
|
---|
238 | /* Cleanup previosly created folder if any: */
|
---|
239 | if (!cleanupMachineFolder())
|
---|
240 | {
|
---|
241 | msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
|
---|
242 | return false;
|
---|
243 | }
|
---|
244 |
|
---|
245 | composeMachineFilePath();
|
---|
246 |
|
---|
247 | /* Check if the folder already exists and check if it has been created by this wizard */
|
---|
248 | if (QDir(m_strMachineFolder).exists())
|
---|
249 | {
|
---|
250 | /* Looks like we have already created this folder for this run of the wizard. Just return */
|
---|
251 | if (m_strCreatedFolder == m_strMachineFolder)
|
---|
252 | return true;
|
---|
253 | /* The folder is there but not because of this wizard. Avoid overwriting a existing machine's folder */
|
---|
254 | else
|
---|
255 | {
|
---|
256 | msgCenter().cannotRewriteMachineFolder(m_strMachineFolder, thisImp());
|
---|
257 | return false;
|
---|
258 | }
|
---|
259 | }
|
---|
260 |
|
---|
261 | /* Try to create new folder (and it's predecessors): */
|
---|
262 | bool fMachineFolderCreated = QDir().mkpath(m_strMachineFolder);
|
---|
263 | if (!fMachineFolderCreated)
|
---|
264 | {
|
---|
265 | msgCenter().cannotCreateMachineFolder(m_strMachineFolder, thisImp());
|
---|
266 | return false;
|
---|
267 | }
|
---|
268 | m_strCreatedFolder = m_strMachineFolder;
|
---|
269 | return true;
|
---|
270 | }
|
---|
271 |
|
---|
272 | bool UIWizardNewVMPage1::cleanupMachineFolder(bool fWizardCancel /* = false */)
|
---|
273 | {
|
---|
274 | /* Make sure folder was previosly created: */
|
---|
275 | if (m_strCreatedFolder.isEmpty())
|
---|
276 | return true;
|
---|
277 | /* Clean this folder if the machine folder has been changed by the user or we are cancelling the wizard: */
|
---|
278 | if (m_strCreatedFolder != m_strMachineFolder || fWizardCancel)
|
---|
279 | {
|
---|
280 | /* Try to cleanup folder (and it's predecessors): */
|
---|
281 | bool fMachineFolderRemoved = QDir().rmpath(m_strCreatedFolder);
|
---|
282 | /* Reset machine folder value: */
|
---|
283 | if (fMachineFolderRemoved)
|
---|
284 | m_strCreatedFolder = QString();
|
---|
285 | /* Return cleanup result: */
|
---|
286 | return fMachineFolderRemoved;
|
---|
287 | }
|
---|
288 | return true;
|
---|
289 | }
|
---|
290 |
|
---|
291 | QString UIWizardNewVMPage1::machineFilePath() const
|
---|
292 | {
|
---|
293 | return m_strMachineFilePath;
|
---|
294 | }
|
---|
295 |
|
---|
296 | void UIWizardNewVMPage1::setMachineFilePath(const QString &strMachineFilePath)
|
---|
297 | {
|
---|
298 | m_strMachineFilePath = strMachineFilePath;
|
---|
299 | }
|
---|
300 |
|
---|
301 | QString UIWizardNewVMPage1::machineFolder() const
|
---|
302 | {
|
---|
303 | return m_strMachineFolder;
|
---|
304 | }
|
---|
305 |
|
---|
306 | void UIWizardNewVMPage1::setMachineFolder(const QString &strMachineFolder)
|
---|
307 | {
|
---|
308 | m_strMachineFolder = strMachineFolder;
|
---|
309 | }
|
---|
310 |
|
---|
311 | QString UIWizardNewVMPage1::machineBaseName() const
|
---|
312 | {
|
---|
313 | return m_strMachineBaseName;
|
---|
314 | }
|
---|
315 |
|
---|
316 | void UIWizardNewVMPage1::setMachineBaseName(const QString &strMachineBaseName)
|
---|
317 | {
|
---|
318 | m_strMachineBaseName = strMachineBaseName;
|
---|
319 | }
|
---|
320 |
|
---|
321 | UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1(const QString &strGroup)
|
---|
322 | : UIWizardNewVMPage1(strGroup)
|
---|
323 | {
|
---|
324 | /* Create widgets: */
|
---|
325 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
326 | {
|
---|
327 | m_pLabel = new QIRichTextLabel(this);
|
---|
328 | m_pNameAndSystemEditor = new UINameAndSystemEditor(this, true);
|
---|
329 | pMainLayout->addWidget(m_pLabel);
|
---|
330 | pMainLayout->addWidget(m_pNameAndSystemEditor);
|
---|
331 | pMainLayout->addStretch();
|
---|
332 | }
|
---|
333 |
|
---|
334 | /* Setup connections: */
|
---|
335 | connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMPageBasic1::sltNameChanged);
|
---|
336 | connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageBasic1::sltPathChanged);
|
---|
337 | connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageBasic1::sltOsTypeChanged);
|
---|
338 |
|
---|
339 | /* Register fields: */
|
---|
340 | registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
|
---|
341 | registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
|
---|
342 | registerField("machineFilePath", this, "machineFilePath");
|
---|
343 | registerField("machineFolder", this, "machineFolder");
|
---|
344 | registerField("machineBaseName", this, "machineBaseName");
|
---|
345 | }
|
---|
346 |
|
---|
347 | void UIWizardNewVMPageBasic1::sltNameChanged(const QString &strNewName)
|
---|
348 | {
|
---|
349 | /* Call to base-class: */
|
---|
350 | onNameChanged(strNewName);
|
---|
351 | composeMachineFilePath();
|
---|
352 | }
|
---|
353 |
|
---|
354 | void UIWizardNewVMPageBasic1::sltPathChanged(const QString &strNewPath)
|
---|
355 | {
|
---|
356 | Q_UNUSED(strNewPath);
|
---|
357 | composeMachineFilePath();
|
---|
358 | }
|
---|
359 |
|
---|
360 | void UIWizardNewVMPageBasic1::sltOsTypeChanged()
|
---|
361 | {
|
---|
362 | /* Call to base-class: */
|
---|
363 | onOsTypeChanged();
|
---|
364 | }
|
---|
365 |
|
---|
366 | void UIWizardNewVMPageBasic1::retranslateUi()
|
---|
367 | {
|
---|
368 | /* Translate page: */
|
---|
369 | setTitle(UIWizardNewVM::tr("Name and operating system"));
|
---|
370 |
|
---|
371 | /* Translate widgets: */
|
---|
372 | m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new virtual machine "
|
---|
373 | "and select the type of operating system you intend to install on it. "
|
---|
374 | "The name you choose will be used throughout VirtualBox "
|
---|
375 | "to identify this machine."));
|
---|
376 | }
|
---|
377 |
|
---|
378 | void UIWizardNewVMPageBasic1::initializePage()
|
---|
379 | {
|
---|
380 | /* Translate page: */
|
---|
381 | retranslateUi();
|
---|
382 | if (m_pNameAndSystemEditor)
|
---|
383 | m_pNameAndSystemEditor->setFocus();
|
---|
384 | }
|
---|
385 |
|
---|
386 | void UIWizardNewVMPageBasic1::cleanupPage()
|
---|
387 | {
|
---|
388 | /* Cleanup: */
|
---|
389 | cleanupMachineFolder();
|
---|
390 | /* Call to base-class: */
|
---|
391 | UIWizardPage::cleanupPage();
|
---|
392 | }
|
---|
393 |
|
---|
394 | bool UIWizardNewVMPageBasic1::validatePage()
|
---|
395 | {
|
---|
396 | /* Try to create machine folder: */
|
---|
397 | return createMachineFolder();
|
---|
398 | }
|
---|