1 | /* $Id: UIWizardNewVMPageBasicInstallSetup.cpp 84889 2020-06-22 07:33:39Z 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 <QIntValidator>
|
---|
20 | #include <QVBoxLayout>
|
---|
21 | #include <QGridLayout>
|
---|
22 | #include <QSpacerItem>
|
---|
23 | #include <QLabel>
|
---|
24 | #include <QLineEdit>
|
---|
25 | #include <QSpinBox>
|
---|
26 |
|
---|
27 | /* GUI includes: */
|
---|
28 | #include "QIRichTextLabel.h"
|
---|
29 | #include "UIBaseMemoryEditor.h"
|
---|
30 | #include "UIBaseMemorySlider.h"
|
---|
31 | #include "UICommon.h"
|
---|
32 | #include "UIVirtualCPUEditor.h"
|
---|
33 | #include "UIWizardNewVMPageBasicInstallSetup.h"
|
---|
34 | #include "UIWizardNewVM.h"
|
---|
35 |
|
---|
36 |
|
---|
37 | UIUserNamePasswordEditor::UIUserNamePasswordEditor(QWidget *pParent /* = 0 */)
|
---|
38 | : QIWithRetranslateUI<QWidget>(pParent)
|
---|
39 | , m_pUserNameField(0)
|
---|
40 | , m_pPasswordField(0)
|
---|
41 | , m_pPasswordRepeatField(0)
|
---|
42 | , m_pUserNameFieldLabel(0)
|
---|
43 | , m_pPasswordFieldLabel(0)
|
---|
44 | , m_pPasswordRepeatFieldLabel(0)
|
---|
45 | {
|
---|
46 | prepare();
|
---|
47 | }
|
---|
48 |
|
---|
49 | void UIUserNamePasswordEditor::retranslateUi()
|
---|
50 | {
|
---|
51 | if (m_pUserNameFieldLabel)
|
---|
52 | {
|
---|
53 | m_pUserNameFieldLabel->setText(UIWizardNewVM::tr("User Name:"));
|
---|
54 | m_pUserNameFieldLabel->setToolTip(UIWizardNewVM::tr("Type the user name which will be used in attended install:"));
|
---|
55 |
|
---|
56 | }
|
---|
57 | if (m_pPasswordFieldLabel)
|
---|
58 | {
|
---|
59 | m_pPasswordFieldLabel->setText(UIWizardNewVM::tr("Password:"));
|
---|
60 | m_pPasswordFieldLabel->setToolTip(UIWizardNewVM::tr("Type the password for the user name"));
|
---|
61 |
|
---|
62 | }
|
---|
63 | if (m_pPasswordRepeatFieldLabel)
|
---|
64 | {
|
---|
65 | m_pPasswordRepeatFieldLabel->setText(UIWizardNewVM::tr("Repeat Password:"));
|
---|
66 | m_pPasswordRepeatFieldLabel->setToolTip(UIWizardNewVM::tr("Retype the password:"));
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | void UIUserNamePasswordEditor::addField(QLabel *&pLabel, QLineEdit *&pLineEdit, QGridLayout *pLayout, bool fIsPasswordField /* = false */)
|
---|
71 | {
|
---|
72 | static int iRow = 0;
|
---|
73 | if (!pLayout || pLabel || pLineEdit)
|
---|
74 | return;
|
---|
75 | pLabel = new QLabel;
|
---|
76 | if (!pLabel)
|
---|
77 | return;
|
---|
78 | pLayout->addWidget(pLabel, iRow, 0, 1, 1, Qt::AlignRight);
|
---|
79 |
|
---|
80 | pLineEdit = new QLineEdit;
|
---|
81 | if (!pLineEdit)
|
---|
82 | return;
|
---|
83 | pLayout->addWidget(pLineEdit, iRow, 1, 1, 1);
|
---|
84 |
|
---|
85 | pLabel->setBuddy(pLineEdit);
|
---|
86 | if (fIsPasswordField)
|
---|
87 | pLineEdit->setEchoMode(QLineEdit::Password);
|
---|
88 | ++iRow;
|
---|
89 | return;
|
---|
90 | }
|
---|
91 |
|
---|
92 | void UIUserNamePasswordEditor::prepare()
|
---|
93 | {
|
---|
94 | QGridLayout *pMainLayout = new QGridLayout;
|
---|
95 | if (!pMainLayout)
|
---|
96 | return;
|
---|
97 | setLayout(pMainLayout);
|
---|
98 |
|
---|
99 | addField(m_pUserNameFieldLabel, m_pUserNameField, pMainLayout);
|
---|
100 | addField(m_pPasswordFieldLabel, m_pPasswordField, pMainLayout, true);
|
---|
101 | addField(m_pPasswordRepeatFieldLabel, m_pPasswordRepeatField, pMainLayout, true);
|
---|
102 | retranslateUi();
|
---|
103 | }
|
---|
104 |
|
---|
105 | UIWizardNewVMPageInstallSetup::UIWizardNewVMPageInstallSetup()
|
---|
106 | : m_pUserNamePasswordEditor(0)
|
---|
107 | {
|
---|
108 | }
|
---|
109 |
|
---|
110 | UIWizardNewVMPageBasicInstallSetup::UIWizardNewVMPageBasicInstallSetup()
|
---|
111 | : m_pLabel(0)
|
---|
112 | {
|
---|
113 | /* Create widget: */
|
---|
114 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
115 | {
|
---|
116 | m_pLabel = new QIRichTextLabel(this);
|
---|
117 | QGridLayout *pMemoryLayout = new QGridLayout;
|
---|
118 | {
|
---|
119 | m_pUserNamePasswordEditor = new UIUserNamePasswordEditor;
|
---|
120 | pMemoryLayout->addWidget(m_pUserNamePasswordEditor, 0, 0);
|
---|
121 | }
|
---|
122 | if (m_pLabel)
|
---|
123 | pMainLayout->addWidget(m_pLabel);
|
---|
124 | pMainLayout->addLayout(pMemoryLayout);
|
---|
125 | pMainLayout->addStretch();
|
---|
126 | }
|
---|
127 |
|
---|
128 |
|
---|
129 | /* Register fields: */
|
---|
130 | registerField("baseMemory", this, "baseMemory");
|
---|
131 | registerField("VCPUCount", this, "VCPUCount");
|
---|
132 | }
|
---|
133 |
|
---|
134 | void UIWizardNewVMPageBasicInstallSetup::retranslateUi()
|
---|
135 | {
|
---|
136 | /* Translate page: */
|
---|
137 | setTitle(UIWizardNewVM::tr("User Name/Password and Time Zone Selection"));
|
---|
138 |
|
---|
139 | /* Translate widgets: */
|
---|
140 | if (m_pLabel)
|
---|
141 | m_pLabel->setText(UIWizardNewVM::tr("<p>Here you can specify the user name/password and time zone. "
|
---|
142 | "The values you enter here will be used during the unattended install.</p>"));
|
---|
143 |
|
---|
144 | }
|
---|
145 |
|
---|
146 | void UIWizardNewVMPageBasicInstallSetup::initializePage()
|
---|
147 | {
|
---|
148 | /* Translate page: */
|
---|
149 | retranslateUi();
|
---|
150 |
|
---|
151 | /* Get recommended 'ram' field value: */
|
---|
152 | // CGuestOSType type = field("type").value<CGuestOSType>();
|
---|
153 | // m_pBaseMemoryEditor->setValue(type.GetRecommendedRAM());
|
---|
154 | // m_pVirtualCPUEditor->setValue(1);
|
---|
155 |
|
---|
156 | // /* 'Ram' field should have focus initially: */
|
---|
157 | // m_pBaseMemoryEditor->setFocus();
|
---|
158 | }
|
---|
159 |
|
---|
160 | bool UIWizardNewVMPageBasicInstallSetup::isComplete() const
|
---|
161 | {
|
---|
162 | return UIWizardPage::isComplete();
|
---|
163 | }
|
---|