1 | /* $Id: UIWizardNewVMPageBasic1.cpp 60930 2016-05-10 15:28:15Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardNewVMPageBasic1 class implementation.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2012 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 | #ifdef VBOX_WITH_PRECOMPILED_HEADERS
|
---|
19 | # include <precomp.h>
|
---|
20 | #else /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
21 |
|
---|
22 | /* Qt includes: */
|
---|
23 | # include <QDir>
|
---|
24 | # include <QVBoxLayout>
|
---|
25 | # include <QHBoxLayout>
|
---|
26 | # include <QLineEdit>
|
---|
27 |
|
---|
28 | /* GUI includes: */
|
---|
29 | # include "UIWizardNewVMPageBasic1.h"
|
---|
30 | # include "UIWizardNewVM.h"
|
---|
31 | # include "UIMessageCenter.h"
|
---|
32 | # include "UINameAndSystemEditor.h"
|
---|
33 | # include "QIRichTextLabel.h"
|
---|
34 |
|
---|
35 | /* COM includes: */
|
---|
36 | # include "CSystemProperties.h"
|
---|
37 |
|
---|
38 | #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
39 |
|
---|
40 |
|
---|
41 | /* Defines some patterns to guess the right OS type. Should be in sync with
|
---|
42 | * VirtualBox-settings-common.xsd in Main. The list is sorted by priority. The
|
---|
43 | * first matching string found, will be used. */
|
---|
44 | struct osTypePattern
|
---|
45 | {
|
---|
46 | QRegExp pattern;
|
---|
47 | const char *pcstId;
|
---|
48 | };
|
---|
49 |
|
---|
50 | static const osTypePattern gs_OSTypePattern[] =
|
---|
51 | {
|
---|
52 | /* DOS: */
|
---|
53 | { QRegExp("DOS", Qt::CaseInsensitive), "DOS" },
|
---|
54 |
|
---|
55 | /* Windows: */
|
---|
56 | { QRegExp( "Wi.*98", Qt::CaseInsensitive), "Windows98" },
|
---|
57 | { QRegExp( "Wi.*95", Qt::CaseInsensitive), "Windows95" },
|
---|
58 | { QRegExp( "Wi.*Me", Qt::CaseInsensitive), "WindowsMe" },
|
---|
59 | { QRegExp( "(Wi.*NT)|(NT4)", Qt::CaseInsensitive), "WindowsNT4" },
|
---|
60 | /* Note: Do not automatically set WindowsXP_64 on 64-bit hosts, as Windows XP 64-bit
|
---|
61 | * is extremely rare -- most users never heard of it even. So always default to 32-bit. */
|
---|
62 | { QRegExp("((Wi.*XP)|(XP)).*", Qt::CaseInsensitive), "WindowsXP" },
|
---|
63 | { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*64", Qt::CaseInsensitive), "Windows2003_64" },
|
---|
64 | { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*32", Qt::CaseInsensitive), "Windows2003" },
|
---|
65 | { QRegExp("((Wi.*Vis)|(Vista)).*64", Qt::CaseInsensitive), "WindowsVista_64" },
|
---|
66 | { QRegExp("((Wi.*Vis)|(Vista)).*32", Qt::CaseInsensitive), "WindowsVista" },
|
---|
67 | { QRegExp( "(Wi.*2012)|(W2K12)|(Win2K12)", Qt::CaseInsensitive), "Windows2012_64" },
|
---|
68 | { QRegExp("((Wi.*2008)|(W2K8)|(Win2k8)).*64", Qt::CaseInsensitive), "Windows2008_64" },
|
---|
69 | { QRegExp("((Wi.*2008)|(W2K8)|(Win2K8)).*32", Qt::CaseInsensitive), "Windows2008" },
|
---|
70 | { QRegExp( "(Wi.*2000)|(W2K)|(Win2K)", Qt::CaseInsensitive), "Windows2000" },
|
---|
71 | { QRegExp( "(Wi.*7.*64)|(W7.*64)", Qt::CaseInsensitive), "Windows7_64" },
|
---|
72 | { QRegExp( "(Wi.*7.*32)|(W7.*32)", Qt::CaseInsensitive), "Windows7" },
|
---|
73 | { QRegExp( "(Wi.*8.*1.*64)|(W8.*64)", Qt::CaseInsensitive), "Windows81_64" },
|
---|
74 | { QRegExp( "(Wi.*8.*1.*32)|(W8.*32)", Qt::CaseInsensitive), "Windows81" },
|
---|
75 | { QRegExp( "(Wi.*8.*64)|(W8.*64)", Qt::CaseInsensitive), "Windows8_64" },
|
---|
76 | { QRegExp( "(Wi.*8.*32)|(W8.*32)", Qt::CaseInsensitive), "Windows8" },
|
---|
77 | { QRegExp( "(Wi.*10.*64)|(W10.*64)", Qt::CaseInsensitive), "Windows10_64" },
|
---|
78 | { QRegExp( "(Wi.*10.*32)|(W10.*32)", Qt::CaseInsensitive), "Windows10" },
|
---|
79 | { QRegExp( "Wi.*3.*1", Qt::CaseInsensitive), "Windows31" },
|
---|
80 | /* Set Windows 7 as default for "Windows". */
|
---|
81 | { QRegExp( "Wi.*64", Qt::CaseInsensitive), "Windows7_64" },
|
---|
82 | { QRegExp( "Wi.*32", Qt::CaseInsensitive), "Windows7" },
|
---|
83 |
|
---|
84 | /* Solaris: */
|
---|
85 | { QRegExp("So.*11", Qt::CaseInsensitive), "Solaris11_64" },
|
---|
86 | { QRegExp("((Op.*So)|(os20[01][0-9])|(So.*10)|(India)|(Neva)).*64", Qt::CaseInsensitive), "OpenSolaris_64" },
|
---|
87 | { QRegExp("((Op.*So)|(os20[01][0-9])|(So.*10)|(India)|(Neva)).*32", Qt::CaseInsensitive), "OpenSolaris" },
|
---|
88 | { QRegExp("So.*64", Qt::CaseInsensitive), "Solaris_64" },
|
---|
89 | { QRegExp("So.*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.*yos)|(os.*x.*yos)|(Capitan)", Qt::CaseInsensitive), "MacOS1011_64" },
|
---|
114 | { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*64", Qt::CaseInsensitive), "MacOS_64" },
|
---|
115 | { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*32", Qt::CaseInsensitive), "MacOS" },
|
---|
116 |
|
---|
117 | /* Code names for Linux distributions: */
|
---|
118 | { 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" },
|
---|
119 | { 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" },
|
---|
120 | { QRegExp("((edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)|(saucy)|(trusty)|(utopic)|(vivid)|(wily)|(xenial)).*64", Qt::CaseInsensitive), "Ubuntu_64" },
|
---|
121 | { QRegExp("((edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)|(saucy)|(trusty)|(utopic)|(vivid)|(wily)|(xenial)).*32", Qt::CaseInsensitive), "Ubuntu" },
|
---|
122 | { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(sid)).*64", Qt::CaseInsensitive), "Debian_64" },
|
---|
123 | { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(sid)).*32", Qt::CaseInsensitive), "Debian" },
|
---|
124 | { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*64", Qt::CaseInsensitive), "Fedora_64" },
|
---|
125 | { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*32", Qt::CaseInsensitive), "Fedora" },
|
---|
126 |
|
---|
127 | /* Regular names of Linux distributions: */
|
---|
128 | { QRegExp("Arc.*64", Qt::CaseInsensitive), "ArchLinux_64" },
|
---|
129 | { QRegExp("Arc.*32", Qt::CaseInsensitive), "ArchLinux" },
|
---|
130 | { QRegExp("Deb.*64", Qt::CaseInsensitive), "Debian_64" },
|
---|
131 | { QRegExp("Deb.*32", Qt::CaseInsensitive), "Debian" },
|
---|
132 | { QRegExp("((SU)|(Nov)|(SLE)).*64", Qt::CaseInsensitive), "OpenSUSE_64" },
|
---|
133 | { QRegExp("((SU)|(Nov)|(SLE)).*32", Qt::CaseInsensitive), "OpenSUSE" },
|
---|
134 | { QRegExp("Fe.*64", Qt::CaseInsensitive), "Fedora_64" },
|
---|
135 | { QRegExp("Fe.*32", Qt::CaseInsensitive), "Fedora" },
|
---|
136 | { QRegExp("((Gen)|(Sab)).*64", Qt::CaseInsensitive), "Gentoo_64" },
|
---|
137 | { QRegExp("((Gen)|(Sab)).*32", Qt::CaseInsensitive), "Gentoo" },
|
---|
138 | { QRegExp("((Man)|(Mag)).*64", Qt::CaseInsensitive), "Mandriva_64" },
|
---|
139 | { QRegExp("((Man)|(Mag)).*32", Qt::CaseInsensitive), "Mandriva" },
|
---|
140 | { QRegExp("((Red)|(rhel)|(cen)).*64", Qt::CaseInsensitive), "RedHat_64" },
|
---|
141 | { QRegExp("((Red)|(rhel)|(cen)).*32", Qt::CaseInsensitive), "RedHat" },
|
---|
142 | { QRegExp("Tur.*64", Qt::CaseInsensitive), "Turbolinux_64" },
|
---|
143 | { QRegExp("Tur.*32", Qt::CaseInsensitive), "Turbolinux" },
|
---|
144 | { QRegExp("(Ub)|(Min).*64", Qt::CaseInsensitive), "Ubuntu_64" },
|
---|
145 | { QRegExp("(Ub)|(Min).*32", Qt::CaseInsensitive), "Ubuntu" },
|
---|
146 | { QRegExp("Xa.*64", Qt::CaseInsensitive), "Xandros_64" },
|
---|
147 | { QRegExp("Xa.*32", Qt::CaseInsensitive), "Xandros" },
|
---|
148 | { QRegExp("((Or)|(oel)|(ol)).*64", Qt::CaseInsensitive), "Oracle_64" },
|
---|
149 | { QRegExp("((Or)|(oel)|(ol)).*32", Qt::CaseInsensitive), "Oracle" },
|
---|
150 | { QRegExp("Knoppix", Qt::CaseInsensitive), "Linux26" },
|
---|
151 | { QRegExp("Dsl", Qt::CaseInsensitive), "Linux24" },
|
---|
152 | { QRegExp("((Lin)|(lnx)).*2.?2", Qt::CaseInsensitive), "Linux22" },
|
---|
153 | { QRegExp("((Lin)|(lnx)).*2.?4.*64", Qt::CaseInsensitive), "Linux24_64" },
|
---|
154 | { QRegExp("((Lin)|(lnx)).*2.?4.*32", Qt::CaseInsensitive), "Linux24" },
|
---|
155 | { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*64", Qt::CaseInsensitive), "Linux26_64" },
|
---|
156 | { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*32", Qt::CaseInsensitive), "Linux26" },
|
---|
157 | { QRegExp("((Lin)|(lnx)).*64", Qt::CaseInsensitive), "Linux26_64" },
|
---|
158 | { QRegExp("((Lin)|(lnx)).*32", Qt::CaseInsensitive), "Linux26" },
|
---|
159 |
|
---|
160 | /* Other: */
|
---|
161 | { QRegExp("L4", Qt::CaseInsensitive), "L4" },
|
---|
162 | { QRegExp("((Fr.*B)|(fbsd)).*64", Qt::CaseInsensitive), "FreeBSD_64" },
|
---|
163 | { QRegExp("((Fr.*B)|(fbsd)).*32", Qt::CaseInsensitive), "FreeBSD" },
|
---|
164 | { QRegExp("Op.*B.*64", Qt::CaseInsensitive), "OpenBSD_64" },
|
---|
165 | { QRegExp("Op.*B.*32", Qt::CaseInsensitive), "OpenBSD" },
|
---|
166 | { QRegExp("Ne.*B.*64", Qt::CaseInsensitive), "NetBSD_64" },
|
---|
167 | { QRegExp("Ne.*B.*32", Qt::CaseInsensitive), "NetBSD" },
|
---|
168 | { QRegExp("Net", Qt::CaseInsensitive), "Netware" },
|
---|
169 | { QRegExp("Rocki", Qt::CaseInsensitive), "JRockitVE" },
|
---|
170 | { QRegExp("bs[23]{0,1}-", Qt::CaseInsensitive), "VBoxBS_64" }, /* bootsector tests */
|
---|
171 | { QRegExp("Ot", Qt::CaseInsensitive), "Other" },
|
---|
172 | };
|
---|
173 |
|
---|
174 | UIWizardNewVMPage1::UIWizardNewVMPage1(const QString &strGroup)
|
---|
175 | : m_strGroup(strGroup)
|
---|
176 | {
|
---|
177 | CHost host = vboxGlobal().host();
|
---|
178 | m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
|
---|
179 | m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
|
---|
180 | }
|
---|
181 |
|
---|
182 | void UIWizardNewVMPage1::onNameChanged(QString strNewName)
|
---|
183 | {
|
---|
184 | /* Do not forget about achitecture bits, if not yet specified: */
|
---|
185 | if (!strNewName.contains("32") && !strNewName.contains("64"))
|
---|
186 | strNewName += ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode ? "64" : "32";
|
---|
187 |
|
---|
188 | /* Search for a matching OS type based on the string the user typed already. */
|
---|
189 | for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
|
---|
190 | if (strNewName.contains(gs_OSTypePattern[i].pattern))
|
---|
191 | {
|
---|
192 | m_pNameAndSystemEditor->blockSignals(true);
|
---|
193 | m_pNameAndSystemEditor->setType(vboxGlobal().vmGuestOSType(gs_OSTypePattern[i].pcstId));
|
---|
194 | m_pNameAndSystemEditor->blockSignals(false);
|
---|
195 | break;
|
---|
196 | }
|
---|
197 | }
|
---|
198 |
|
---|
199 | void UIWizardNewVMPage1::onOsTypeChanged()
|
---|
200 | {
|
---|
201 | /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore.
|
---|
202 | * So simply disconnect the text-edit signal. */
|
---|
203 | m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &)));
|
---|
204 | }
|
---|
205 |
|
---|
206 | bool UIWizardNewVMPage1::machineFolderCreated()
|
---|
207 | {
|
---|
208 | return !m_strMachineFolder.isEmpty();
|
---|
209 | }
|
---|
210 |
|
---|
211 | bool UIWizardNewVMPage1::createMachineFolder()
|
---|
212 | {
|
---|
213 | /* Cleanup previosly created folder if any: */
|
---|
214 | if (machineFolderCreated() && !cleanupMachineFolder())
|
---|
215 | {
|
---|
216 | msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
|
---|
217 | return false;
|
---|
218 | }
|
---|
219 |
|
---|
220 | /* Compose machine file-path, parse it to folder and base-name: */
|
---|
221 | const QString strMachineFilePath = composeMachineFilePath(m_pNameAndSystemEditor->name());
|
---|
222 | const QString strMachineFolder = QDir::toNativeSeparators(QFileInfo(strMachineFilePath).absolutePath());
|
---|
223 | const QString strMachineBaseName = QFileInfo(strMachineFilePath).completeBaseName();
|
---|
224 |
|
---|
225 | /* Make sure that folder doesn't exists: */
|
---|
226 | if (QDir(strMachineFolder).exists())
|
---|
227 | {
|
---|
228 | msgCenter().cannotRewriteMachineFolder(strMachineFolder, thisImp());
|
---|
229 | return false;
|
---|
230 | }
|
---|
231 |
|
---|
232 | /* Try to create new folder (and it's predecessors): */
|
---|
233 | bool fMachineFolderCreated = QDir().mkpath(strMachineFolder);
|
---|
234 | if (!fMachineFolderCreated)
|
---|
235 | {
|
---|
236 | msgCenter().cannotCreateMachineFolder(strMachineFolder, thisImp());
|
---|
237 | return false;
|
---|
238 | }
|
---|
239 |
|
---|
240 | /* Initialize fields: */
|
---|
241 | m_strMachineFolder = strMachineFolder;
|
---|
242 | m_strMachineBaseName = strMachineBaseName;
|
---|
243 | m_strMachineFilePath = strMachineFilePath;
|
---|
244 | return true;
|
---|
245 | }
|
---|
246 |
|
---|
247 | bool UIWizardNewVMPage1::cleanupMachineFolder()
|
---|
248 | {
|
---|
249 | /* Make sure folder was previosly created: */
|
---|
250 | if (m_strMachineFolder.isEmpty())
|
---|
251 | return false;
|
---|
252 | /* Try to cleanup folder (and it's predecessors): */
|
---|
253 | bool fMachineFolderRemoved = QDir().rmpath(m_strMachineFolder);
|
---|
254 | /* Reset machine folder value: */
|
---|
255 | if (fMachineFolderRemoved)
|
---|
256 | m_strMachineFolder = QString();
|
---|
257 | /* Return cleanup result: */
|
---|
258 | return fMachineFolderRemoved;
|
---|
259 | }
|
---|
260 |
|
---|
261 | QString UIWizardNewVMPage1::composeMachineFilePath(const QString &strUserMachineLocation)
|
---|
262 | {
|
---|
263 | /* Get VBox: */
|
---|
264 | CVirtualBox vbox = vboxGlobal().virtualBox();
|
---|
265 | /* Get default machine folder: */
|
---|
266 | const QString strDefaultMachineFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
|
---|
267 | /* Fetch user's machine location: */
|
---|
268 | const QString strUserMachineFolder = QFileInfo(strUserMachineLocation).absolutePath();
|
---|
269 | const QString strUserMachineBaseName = QFileInfo(strUserMachineLocation).fileName();
|
---|
270 | const bool fUseDefaultPath = strUserMachineLocation == strUserMachineBaseName;
|
---|
271 | /* Compose machine filename: */
|
---|
272 | return vbox.ComposeMachineFilename(strUserMachineBaseName,
|
---|
273 | fUseDefaultPath ? m_strGroup : QString() /* no group in that case */,
|
---|
274 | QString(),
|
---|
275 | fUseDefaultPath ? strDefaultMachineFolder : strUserMachineFolder);
|
---|
276 | }
|
---|
277 |
|
---|
278 | UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1(const QString &strGroup)
|
---|
279 | : UIWizardNewVMPage1(strGroup)
|
---|
280 | {
|
---|
281 | /* Create widgets: */
|
---|
282 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
283 | {
|
---|
284 | m_pLabel = new QIRichTextLabel(this);
|
---|
285 | m_pNameAndSystemEditor = new UINameAndSystemEditor(this, true);
|
---|
286 | pMainLayout->addWidget(m_pLabel);
|
---|
287 | pMainLayout->addWidget(m_pNameAndSystemEditor);
|
---|
288 | pMainLayout->addStretch();
|
---|
289 | }
|
---|
290 |
|
---|
291 | /* Setup connections: */
|
---|
292 | connect(m_pNameAndSystemEditor, SIGNAL(sigNameChanged(const QString &)), this, SLOT(sltNameChanged(const QString &)));
|
---|
293 | connect(m_pNameAndSystemEditor, SIGNAL(sigOsTypeChanged()), this, SLOT(sltOsTypeChanged()));
|
---|
294 |
|
---|
295 | /* Register fields: */
|
---|
296 | registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
|
---|
297 | registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
|
---|
298 | registerField("machineFolder", this, "machineFolder");
|
---|
299 | registerField("machineBaseName", this, "machineBaseName");
|
---|
300 | registerField("machineFilePath", this, "machineFilePath");
|
---|
301 | }
|
---|
302 |
|
---|
303 | void UIWizardNewVMPageBasic1::sltNameChanged(const QString &strNewName)
|
---|
304 | {
|
---|
305 | /* Call to base-class: */
|
---|
306 | onNameChanged(strNewName);
|
---|
307 | }
|
---|
308 |
|
---|
309 | void UIWizardNewVMPageBasic1::sltOsTypeChanged()
|
---|
310 | {
|
---|
311 | /* Call to base-class: */
|
---|
312 | onOsTypeChanged();
|
---|
313 | }
|
---|
314 |
|
---|
315 | void UIWizardNewVMPageBasic1::retranslateUi()
|
---|
316 | {
|
---|
317 | /* Translate page: */
|
---|
318 | setTitle(UIWizardNewVM::tr("Name and operating system"));
|
---|
319 |
|
---|
320 | /* Translate widgets: */
|
---|
321 | m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name for the new virtual machine "
|
---|
322 | "and select the type of operating system you intend to install on it. "
|
---|
323 | "The name you choose will be used throughout VirtualBox "
|
---|
324 | "to identify this machine."));
|
---|
325 | }
|
---|
326 |
|
---|
327 | void UIWizardNewVMPageBasic1::initializePage()
|
---|
328 | {
|
---|
329 | /* Translate page: */
|
---|
330 | retranslateUi();
|
---|
331 | }
|
---|
332 |
|
---|
333 | void UIWizardNewVMPageBasic1::cleanupPage()
|
---|
334 | {
|
---|
335 | /* Cleanup: */
|
---|
336 | cleanupMachineFolder();
|
---|
337 | /* Call to base-class: */
|
---|
338 | UIWizardPage::cleanupPage();
|
---|
339 | }
|
---|
340 |
|
---|
341 | bool UIWizardNewVMPageBasic1::validatePage()
|
---|
342 | {
|
---|
343 | /* Try to create machine folder: */
|
---|
344 | return createMachineFolder();
|
---|
345 | }
|
---|
346 |
|
---|