1 | /* $Id: UIWizardNewVMPageBasicInstallSetup.cpp 84969 2020-06-26 13:56:07Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardNewVMPageBasicInstallSetup 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 <QGridLayout>
|
---|
20 | #include <QLabel>
|
---|
21 | #include <QVBoxLayout>
|
---|
22 |
|
---|
23 | /* GUI includes: */
|
---|
24 | #include "QIRichTextLabel.h"
|
---|
25 | #include "UIUserNamePasswordEditor.h"
|
---|
26 | #include "UIWizardNewVMPageBasicInstallSetup.h"
|
---|
27 | #include "UIWizardNewVM.h"
|
---|
28 |
|
---|
29 |
|
---|
30 | UIWizardNewVMPageInstallSetup::UIWizardNewVMPageInstallSetup()
|
---|
31 | : m_pUserNamePasswordEditor(0)
|
---|
32 | , m_pHostnameLineEdit(0)
|
---|
33 | , m_pHostnameLabel(0)
|
---|
34 | {
|
---|
35 | }
|
---|
36 |
|
---|
37 | QString UIWizardNewVMPageInstallSetup::userName() const
|
---|
38 | {
|
---|
39 | if (m_pUserNamePasswordEditor)
|
---|
40 | return m_pUserNamePasswordEditor->userName();
|
---|
41 | return QString();
|
---|
42 | }
|
---|
43 |
|
---|
44 | QString UIWizardNewVMPageInstallSetup::password() const
|
---|
45 | {
|
---|
46 | if (m_pUserNamePasswordEditor)
|
---|
47 | return m_pUserNamePasswordEditor->password();
|
---|
48 | return QString();
|
---|
49 | }
|
---|
50 |
|
---|
51 | QString UIWizardNewVMPageInstallSetup::hostname() const
|
---|
52 | {
|
---|
53 | if (m_pHostnameLineEdit)
|
---|
54 | return m_pHostnameLineEdit->text();
|
---|
55 | return QString();
|
---|
56 | }
|
---|
57 |
|
---|
58 | UIWizardNewVMPageBasicInstallSetup::UIWizardNewVMPageBasicInstallSetup()
|
---|
59 | : m_pLabel(0)
|
---|
60 | {
|
---|
61 | /* Create widget: */
|
---|
62 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
63 | {
|
---|
64 | m_pLabel = new QIRichTextLabel(this);
|
---|
65 | QGridLayout *pGridLayout = new QGridLayout;
|
---|
66 | {
|
---|
67 | m_pUserNamePasswordEditor = new UIUserNamePasswordEditor;
|
---|
68 | pGridLayout->addWidget(m_pUserNamePasswordEditor, 0, 0, 3, 4);
|
---|
69 | connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigSomeTextChanged,
|
---|
70 | this, &UIWizardNewVMPageBasicInstallSetup::completeChanged);
|
---|
71 | m_pHostnameLabel = new QLabel;
|
---|
72 | m_pHostnameLineEdit = new QLineEdit;
|
---|
73 | pGridLayout->addWidget(m_pHostnameLabel, 3, 0, 1, 1, Qt::AlignRight);
|
---|
74 | pGridLayout->addWidget(m_pHostnameLineEdit, 3, 1, 1, 3);
|
---|
75 | }
|
---|
76 | if (m_pLabel)
|
---|
77 | pMainLayout->addWidget(m_pLabel);
|
---|
78 | pMainLayout->addLayout(pGridLayout);
|
---|
79 | pMainLayout->addStretch();
|
---|
80 | }
|
---|
81 |
|
---|
82 | /* Register fields: */
|
---|
83 | registerField("userName", this, "userName");
|
---|
84 | registerField("password", this, "password");
|
---|
85 | registerField("hostname", this, "hostname");
|
---|
86 | }
|
---|
87 |
|
---|
88 | void UIWizardNewVMPageBasicInstallSetup::setDefaultUnattendedInstallData(const UIUnattendedInstallData &unattendedInstallData)
|
---|
89 | {
|
---|
90 | /* Initialize the widget data: */
|
---|
91 | if (m_pUserNamePasswordEditor)
|
---|
92 | {
|
---|
93 | m_pUserNamePasswordEditor->setUserName(unattendedInstallData.m_strUserName);
|
---|
94 | m_pUserNamePasswordEditor->setPassword(unattendedInstallData.m_strPassword);
|
---|
95 | }
|
---|
96 | if (m_pHostnameLineEdit)
|
---|
97 | m_pHostnameLineEdit->setText(unattendedInstallData.m_strHostname);
|
---|
98 | }
|
---|
99 |
|
---|
100 | void UIWizardNewVMPageBasicInstallSetup::retranslateUi()
|
---|
101 | {
|
---|
102 | /* Translate page: */
|
---|
103 | setTitle(UIWizardNewVM::tr("User Name/Password and Hostname Settings"));
|
---|
104 |
|
---|
105 | /* Translate widgets: */
|
---|
106 | if (m_pLabel)
|
---|
107 | m_pLabel->setText(UIWizardNewVM::tr("<p>Here you can specify the user name/password and hostname. "
|
---|
108 | "The values you enter here will be used during the unattended install.</p>"));
|
---|
109 | if (m_pHostnameLabel)
|
---|
110 | m_pHostnameLabel->setText(UIWizardNewVM::tr("Hostname:"));
|
---|
111 | }
|
---|
112 |
|
---|
113 | void UIWizardNewVMPageBasicInstallSetup::initializePage()
|
---|
114 | {
|
---|
115 | /* Translate page: */
|
---|
116 | retranslateUi();
|
---|
117 | }
|
---|
118 |
|
---|
119 | bool UIWizardNewVMPageBasicInstallSetup::isComplete() const
|
---|
120 | {
|
---|
121 | if (m_pUserNamePasswordEditor)
|
---|
122 | return m_pUserNamePasswordEditor->isComplete();
|
---|
123 | return true;
|
---|
124 | }
|
---|
125 |
|
---|
126 | int UIWizardNewVMPageBasicInstallSetup::nextId() const
|
---|
127 | {
|
---|
128 | UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
|
---|
129 | if (!pWizard || !pWizard->isUnattendedInstallEnabled() || !pWizard->isGuestOSTypeWindows())
|
---|
130 | return UIWizardNewVM::PageHardware;
|
---|
131 | return UIWizardNewVM::PageProductKey;
|
---|
132 | }
|
---|