VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardNewVMEditors.cpp@ 103551

Last change on this file since 103551 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.8 KB
Line 
1/* $Id: UIWizardNewVMEditors.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIUserNamePasswordEditor class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QCheckBox>
30#include <QLabel>
31#include <QVBoxLayout>
32
33/* GUI includes: */
34#include "QILineEdit.h"
35#include "UIBaseMemoryEditor.h"
36#include "UICommon.h"
37#include "UIHostnameDomainNameEditor.h"
38#include "UIFilePathSelector.h"
39#include "UIUserNamePasswordEditor.h"
40#include "UIVirtualCPUEditor.h"
41#include "UIWizardNewVM.h"
42#include "UIWizardNewVMEditors.h"
43#include "UIWizardNewVMUnattendedPage.h"
44
45/* Other VBox includes: */
46#include "iprt/assert.h"
47
48
49/*********************************************************************************************************************************
50* UIUserNamePasswordGroupBox implementation. *
51*********************************************************************************************************************************/
52
53UIUserNamePasswordGroupBox::UIUserNamePasswordGroupBox(QWidget *pParent /* = 0 */)
54 : QIWithRetranslateUI<QGroupBox>(pParent)
55 , m_pUserNamePasswordEditor(0)
56{
57 prepare();
58}
59
60void UIUserNamePasswordGroupBox::prepare()
61{
62 QVBoxLayout *pUserNameContainerLayout = new QVBoxLayout(this);
63 m_pUserNamePasswordEditor = new UIUserNamePasswordEditor;
64 AssertReturnVoid(m_pUserNamePasswordEditor);
65 m_pUserNamePasswordEditor->setLabelsVisible(true);
66 m_pUserNamePasswordEditor->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
67 pUserNameContainerLayout->addWidget(m_pUserNamePasswordEditor);
68
69 connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigPasswordChanged,
70 this, &UIUserNamePasswordGroupBox::sigPasswordChanged);
71 connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigUserNameChanged,
72 this, &UIUserNamePasswordGroupBox::sigUserNameChanged);
73 retranslateUi();
74}
75
76void UIUserNamePasswordGroupBox::retranslateUi()
77{
78 setTitle(UIWizardNewVM::tr("Username and Password"));
79}
80
81QString UIUserNamePasswordGroupBox::userName() const
82{
83 if (m_pUserNamePasswordEditor)
84 return m_pUserNamePasswordEditor->userName();
85 return QString();
86}
87
88void UIUserNamePasswordGroupBox::setUserName(const QString &strUserName)
89{
90 if (m_pUserNamePasswordEditor)
91 m_pUserNamePasswordEditor->setUserName(strUserName);
92}
93
94QString UIUserNamePasswordGroupBox::password() const
95{
96 if (m_pUserNamePasswordEditor)
97 return m_pUserNamePasswordEditor->password();
98 return QString();
99}
100
101void UIUserNamePasswordGroupBox::setPassword(const QString &strPassword)
102{
103 if (m_pUserNamePasswordEditor)
104 m_pUserNamePasswordEditor->setPassword(strPassword);
105}
106
107bool UIUserNamePasswordGroupBox::isComplete()
108{
109 if (m_pUserNamePasswordEditor)
110 return m_pUserNamePasswordEditor->isComplete();
111 return false;
112}
113
114void UIUserNamePasswordGroupBox::setLabelsVisible(bool fVisible)
115{
116 if (m_pUserNamePasswordEditor)
117 m_pUserNamePasswordEditor->setLabelsVisible(fVisible);
118}
119
120
121/*********************************************************************************************************************************
122* UIGAInstallationGroupBox implementation. *
123*********************************************************************************************************************************/
124
125UIGAInstallationGroupBox::UIGAInstallationGroupBox(QWidget *pParent /* = 0 */)
126 : QIWithRetranslateUI<QGroupBox>(pParent)
127 , m_pGAISOPathLabel(0)
128 , m_pGAISOFilePathSelector(0)
129
130{
131 prepare();
132}
133
134void UIGAInstallationGroupBox::prepare()
135{
136 setCheckable(true);
137
138 QHBoxLayout *pGAInstallationISOLayout = new QHBoxLayout(this);
139 AssertReturnVoid(pGAInstallationISOLayout);
140 m_pGAISOPathLabel = new QLabel;
141 AssertReturnVoid(m_pGAISOPathLabel);
142 m_pGAISOPathLabel->setAlignment(Qt::AlignRight);
143 m_pGAISOPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
144
145 pGAInstallationISOLayout->addWidget(m_pGAISOPathLabel);
146
147 m_pGAISOFilePathSelector = new UIFilePathSelector;
148 AssertReturnVoid(m_pGAISOFilePathSelector);
149
150 m_pGAISOFilePathSelector->setResetEnabled(false);
151 m_pGAISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
152 m_pGAISOFilePathSelector->setFileDialogFilters("ISO Images(*.iso *.ISO)");
153 m_pGAISOFilePathSelector->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
154 m_pGAISOFilePathSelector->setInitialPath(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD));
155 m_pGAISOFilePathSelector->setRecentMediaListType(UIMediumDeviceType_DVD);
156 if (m_pGAISOPathLabel)
157 m_pGAISOPathLabel->setBuddy(m_pGAISOFilePathSelector);
158
159 pGAInstallationISOLayout->addWidget(m_pGAISOFilePathSelector);
160
161 connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
162 this, &UIGAInstallationGroupBox::sigPathChanged);
163 connect(this, &UIGAInstallationGroupBox::toggled,
164 this, &UIGAInstallationGroupBox::sltToggleWidgetsEnabled);
165 retranslateUi();
166}
167
168void UIGAInstallationGroupBox::retranslateUi()
169{
170 if (m_pGAISOFilePathSelector)
171 m_pGAISOFilePathSelector->setToolTip(UIWizardNewVM::tr("Selects an installation medium (ISO file) for the Guest Additions."));
172 if (m_pGAISOPathLabel)
173 m_pGAISOPathLabel->setText(UIWizardNewVM::tr("Guest &Additions ISO:"));
174 setTitle(UIWizardNewVM::tr("Gu&est Additions"));
175 setToolTip(UIWizardNewVM::tr("When checked, the guest additions will be installed after the guest OS install."));
176}
177
178QString UIGAInstallationGroupBox::path() const
179{
180 if (m_pGAISOFilePathSelector)
181 return m_pGAISOFilePathSelector->path();
182 return QString();
183}
184
185void UIGAInstallationGroupBox::setPath(const QString &strPath, bool fRefreshText /* = true */)
186{
187 if (m_pGAISOFilePathSelector)
188 m_pGAISOFilePathSelector->setPath(strPath, fRefreshText);
189}
190
191void UIGAInstallationGroupBox::mark()
192{
193 bool fError = !UIWizardNewVMUnattendedCommon::checkGAISOFile(path());
194 if (m_pGAISOFilePathSelector)
195 m_pGAISOFilePathSelector->mark(fError, UIWizardNewVM::tr("Invalid Guest Additions installation media"));
196}
197
198bool UIGAInstallationGroupBox::isComplete() const
199{
200 if (!isChecked())
201 return true;
202 return UIWizardNewVMUnattendedCommon::checkGAISOFile(path());
203}
204
205void UIGAInstallationGroupBox::sltToggleWidgetsEnabled(bool fEnabled)
206{
207 if (m_pGAISOPathLabel)
208 m_pGAISOPathLabel->setEnabled(fEnabled);
209
210 if (m_pGAISOFilePathSelector)
211 m_pGAISOFilePathSelector->setEnabled(fEnabled);
212}
213
214
215/*********************************************************************************************************************************
216* UIAdditionalUnattendedOptions implementation. *
217*********************************************************************************************************************************/
218
219UIAdditionalUnattendedOptions::UIAdditionalUnattendedOptions(QWidget *pParent /* = 0 */)
220 :QIWithRetranslateUI<QGroupBox>(pParent)
221 , m_pProductKeyLabel(0)
222 , m_pProductKeyLineEdit(0)
223 , m_pHostnameDomainNameEditor(0)
224 , m_pStartHeadlessCheckBox(0)
225{
226 prepare();
227}
228
229void UIAdditionalUnattendedOptions::prepare()
230{
231 m_pMainLayout = new QGridLayout(this);
232 m_pMainLayout->setColumnStretch(0, 0);
233 m_pMainLayout->setColumnStretch(1, 1);
234 m_pProductKeyLabel = new QLabel;
235 if (m_pProductKeyLabel)
236 {
237 m_pProductKeyLabel->setAlignment(Qt::AlignRight);
238 m_pProductKeyLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
239 m_pMainLayout->addWidget(m_pProductKeyLabel, 0, 0);
240 }
241 m_pProductKeyLineEdit = new QILineEdit;
242 if (m_pProductKeyLineEdit)
243 {
244 m_pProductKeyLineEdit->setInputMask(">NNNNN-NNNNN-NNNNN-NNNNN-NNNNN;#");
245 if (m_pProductKeyLabel)
246 m_pProductKeyLabel->setBuddy(m_pProductKeyLineEdit);
247 m_pMainLayout->addWidget(m_pProductKeyLineEdit, 0, 1, 1, 2);
248 }
249
250 m_pHostnameDomainNameEditor = new UIHostnameDomainNameEditor;
251 if (m_pHostnameDomainNameEditor)
252 m_pMainLayout->addWidget(m_pHostnameDomainNameEditor, 1, 0, 2, 3);
253
254 m_pStartHeadlessCheckBox = new QCheckBox;
255 if (m_pStartHeadlessCheckBox)
256 m_pMainLayout->addWidget(m_pStartHeadlessCheckBox, 3, 1);
257
258 if (m_pHostnameDomainNameEditor)
259 connect(m_pHostnameDomainNameEditor, &UIHostnameDomainNameEditor::sigHostnameDomainNameChanged,
260 this, &UIAdditionalUnattendedOptions::sigHostnameDomainNameChanged);
261 if (m_pProductKeyLineEdit)
262 connect(m_pProductKeyLineEdit, &QILineEdit::textChanged,
263 this, &UIAdditionalUnattendedOptions::sigProductKeyChanged);
264 if (m_pStartHeadlessCheckBox)
265 connect(m_pStartHeadlessCheckBox, &QCheckBox::toggled,
266 this, &UIAdditionalUnattendedOptions::sigStartHeadlessChanged);
267
268 retranslateUi();
269}
270
271void UIAdditionalUnattendedOptions::retranslateUi()
272{
273 setTitle(UIWizardNewVM::tr("Additional Options"));
274
275 if (m_pProductKeyLabel)
276 m_pProductKeyLabel->setText(UIWizardNewVM::tr("&Product Key:"));
277
278 if (m_pStartHeadlessCheckBox)
279 {
280 m_pStartHeadlessCheckBox->setText(UIWizardNewVM::tr("&Install in Background"));
281 m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("When checked, headless boot (with no GUI) will be enabled for "
282 "unattended guest OS installation of newly created virtual machine."));
283 }
284
285 int iMaxWidth = 0;
286 if (m_pProductKeyLabel)
287 iMaxWidth = qMax(m_pProductKeyLabel->minimumSizeHint().width(), iMaxWidth);
288 if (m_pHostnameDomainNameEditor)
289 iMaxWidth = qMax(m_pHostnameDomainNameEditor->firstColumnWidth(), iMaxWidth);
290 if (iMaxWidth > 0)
291 {
292 m_pMainLayout->setColumnMinimumWidth(0, iMaxWidth);
293 m_pHostnameDomainNameEditor->setFirstColumnWidth(iMaxWidth);
294 }
295 if (m_pProductKeyLineEdit)
296 m_pProductKeyLineEdit->setToolTip(UIWizardNewVM::tr("Holds the product key."));
297}
298
299QString UIAdditionalUnattendedOptions::hostname() const
300{
301 if (m_pHostnameDomainNameEditor)
302 return m_pHostnameDomainNameEditor->hostname();
303 return QString();
304}
305
306void UIAdditionalUnattendedOptions::setHostname(const QString &strHostname)
307{
308 if (m_pHostnameDomainNameEditor)
309 return m_pHostnameDomainNameEditor->setHostname(strHostname);
310}
311
312QString UIAdditionalUnattendedOptions::domainName() const
313{
314 if (m_pHostnameDomainNameEditor)
315 return m_pHostnameDomainNameEditor->domainName();
316 return QString();
317}
318
319void UIAdditionalUnattendedOptions::setDomainName(const QString &strDomainName)
320{
321 if (m_pHostnameDomainNameEditor)
322 return m_pHostnameDomainNameEditor->setDomainName(strDomainName);
323}
324
325QString UIAdditionalUnattendedOptions::hostnameDomainName() const
326{
327 if (m_pHostnameDomainNameEditor)
328 return m_pHostnameDomainNameEditor->hostnameDomainName();
329 return QString();
330}
331
332bool UIAdditionalUnattendedOptions::isComplete() const
333{
334 return isHostnameComplete();
335}
336
337bool UIAdditionalUnattendedOptions::isHostnameComplete() const
338{
339 if (m_pHostnameDomainNameEditor)
340 return m_pHostnameDomainNameEditor->isComplete();
341 return false;
342}
343
344
345void UIAdditionalUnattendedOptions::mark()
346{
347 if (m_pHostnameDomainNameEditor)
348 m_pHostnameDomainNameEditor->mark();
349}
350
351void UIAdditionalUnattendedOptions::disableEnableProductKeyWidgets(bool fEnabled)
352{
353 if (m_pProductKeyLabel)
354 m_pProductKeyLabel->setEnabled(fEnabled);
355 if (m_pProductKeyLineEdit)
356 m_pProductKeyLineEdit->setEnabled(fEnabled);
357}
358
359/*********************************************************************************************************************************
360* UINewVMHardwareContainer implementation. *
361*********************************************************************************************************************************/
362
363UINewVMHardwareContainer::UINewVMHardwareContainer(QWidget *pParent /* = 0 */)
364 : QIWithRetranslateUI<QWidget>(pParent)
365 , m_pBaseMemoryEditor(0)
366 , m_pVirtualCPUEditor(0)
367 , m_pEFICheckBox(0)
368{
369 prepare();
370}
371
372void UINewVMHardwareContainer::setMemorySize(int iSize)
373{
374 if (m_pBaseMemoryEditor)
375 m_pBaseMemoryEditor->setValue(iSize);
376}
377
378void UINewVMHardwareContainer::setCPUCount(int iCount)
379{
380 if (m_pVirtualCPUEditor)
381 m_pVirtualCPUEditor->setValue(iCount);
382}
383
384void UINewVMHardwareContainer::setEFIEnabled(bool fEnabled)
385{
386 if (m_pEFICheckBox)
387 m_pEFICheckBox->setChecked(fEnabled);
388}
389
390void UINewVMHardwareContainer::prepare()
391{
392 QGridLayout *pHardwareLayout = new QGridLayout(this);
393 pHardwareLayout->setContentsMargins(0, 0, 0, 0);
394
395 m_pBaseMemoryEditor = new UIBaseMemoryEditor;
396 m_pVirtualCPUEditor = new UIVirtualCPUEditor;
397 m_pEFICheckBox = new QCheckBox;
398 pHardwareLayout->addWidget(m_pBaseMemoryEditor, 0, 0, 1, 4);
399 pHardwareLayout->addWidget(m_pVirtualCPUEditor, 1, 0, 1, 4);
400 pHardwareLayout->addWidget(m_pEFICheckBox, 2, 0, 1, 1);
401
402
403 if (m_pBaseMemoryEditor)
404 connect(m_pBaseMemoryEditor, &UIBaseMemoryEditor::sigValueChanged,
405 this, &UINewVMHardwareContainer::sigMemorySizeChanged);
406 if (m_pVirtualCPUEditor)
407 connect(m_pVirtualCPUEditor, &UIVirtualCPUEditor::sigValueChanged,
408 this, &UINewVMHardwareContainer::sigCPUCountChanged);
409 if (m_pEFICheckBox)
410 connect(m_pEFICheckBox, &QCheckBox::toggled,
411 this, &UINewVMHardwareContainer::sigEFIEnabledChanged);
412
413
414 retranslateUi();
415}
416
417void UINewVMHardwareContainer::retranslateUi()
418{
419 if (m_pEFICheckBox)
420 {
421 m_pEFICheckBox->setText(UIWizardNewVM::tr("&Enable EFI (special OSes only)"));
422 m_pEFICheckBox->setToolTip(UIWizardNewVM::tr("When checked, the guest will support the Extended Firmware Interface (EFI), "
423 "which is required to boot certain guest OSes. Non-EFI aware OSes will not "
424 "be able to boot if this option is activated."));
425 }
426}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette