1 | /* $Id: UIWizardNewVMHardwarePage.cpp 103957 2024-03-20 13:41:59Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIWizardNewVMHardwarePage 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 <QVBoxLayout>
|
---|
30 |
|
---|
31 | /* GUI includes: */
|
---|
32 | #include "QIRichTextLabel.h"
|
---|
33 | #include "UIBaseMemoryEditor.h"
|
---|
34 | #include "UIGlobalSession.h"
|
---|
35 | #include "UIGuestOSType.h"
|
---|
36 | #include "UIVirtualCPUEditor.h"
|
---|
37 | #include "UIWizardNewVM.h"
|
---|
38 | #include "UIWizardNewVMEditors.h"
|
---|
39 | #include "UIWizardNewVMHardwarePage.h"
|
---|
40 |
|
---|
41 |
|
---|
42 | UIWizardNewVMHardwarePage::UIWizardNewVMHardwarePage()
|
---|
43 | : m_pLabel(0)
|
---|
44 | , m_pHardwareWidgetContainer(0)
|
---|
45 | {
|
---|
46 | prepare();
|
---|
47 | qRegisterMetaType<CMedium>();
|
---|
48 | }
|
---|
49 |
|
---|
50 | void UIWizardNewVMHardwarePage::prepare()
|
---|
51 | {
|
---|
52 | QVBoxLayout *pMainLayout = new QVBoxLayout(this);
|
---|
53 |
|
---|
54 | m_pLabel = new QIRichTextLabel(this);
|
---|
55 | pMainLayout->addWidget(m_pLabel);
|
---|
56 | m_pHardwareWidgetContainer = new UINewVMHardwareContainer;
|
---|
57 | AssertReturnVoid(m_pHardwareWidgetContainer);
|
---|
58 | pMainLayout->addWidget(m_pHardwareWidgetContainer);
|
---|
59 |
|
---|
60 | pMainLayout->addStretch();
|
---|
61 | createConnections();
|
---|
62 | }
|
---|
63 |
|
---|
64 | void UIWizardNewVMHardwarePage::createConnections()
|
---|
65 | {
|
---|
66 | if (m_pHardwareWidgetContainer)
|
---|
67 | {
|
---|
68 | connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigMemorySizeChanged,
|
---|
69 | this, &UIWizardNewVMHardwarePage::sltMemorySizeChanged);
|
---|
70 | connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigCPUCountChanged,
|
---|
71 | this, &UIWizardNewVMHardwarePage::sltCPUCountChanged);
|
---|
72 | connect(m_pHardwareWidgetContainer, &UINewVMHardwareContainer::sigEFIEnabledChanged,
|
---|
73 | this, &UIWizardNewVMHardwarePage::sltEFIEnabledChanged);
|
---|
74 | }
|
---|
75 | }
|
---|
76 |
|
---|
77 | void UIWizardNewVMHardwarePage::sltRetranslateUI()
|
---|
78 | {
|
---|
79 | setTitle(UIWizardNewVM::tr("Hardware"));
|
---|
80 |
|
---|
81 | if (m_pLabel)
|
---|
82 | m_pLabel->setText(UIWizardNewVM::tr("You can modify virtual machine's hardware by changing amount of RAM and "
|
---|
83 | "virtual CPU count. Enabling EFI is also possible."));
|
---|
84 | }
|
---|
85 |
|
---|
86 | void UIWizardNewVMHardwarePage::initializePage()
|
---|
87 | {
|
---|
88 | sltRetranslateUI();
|
---|
89 |
|
---|
90 | UIWizardNewVM *pWizard = wizardWindow<UIWizardNewVM>();
|
---|
91 | if (pWizard && m_pHardwareWidgetContainer)
|
---|
92 | {
|
---|
93 | const QString &strTypeId = pWizard->guestOSTypeId();
|
---|
94 |
|
---|
95 | m_pHardwareWidgetContainer->blockSignals(true);
|
---|
96 | if (!m_userModifiedParameters.contains("MemorySize"))
|
---|
97 | {
|
---|
98 | ULONG recommendedRam = gpGlobalSession->guestOSTypeManager().getRecommendedRAM(strTypeId);
|
---|
99 | m_pHardwareWidgetContainer->setMemorySize(recommendedRam);
|
---|
100 | pWizard->setMemorySize(recommendedRam);
|
---|
101 | }
|
---|
102 | if (!m_userModifiedParameters.contains("CPUCount"))
|
---|
103 | {
|
---|
104 | ULONG recommendedCPUs = gpGlobalSession->guestOSTypeManager().getRecommendedCPUCount(strTypeId);
|
---|
105 | m_pHardwareWidgetContainer->setCPUCount(recommendedCPUs);
|
---|
106 | pWizard->setCPUCount(recommendedCPUs);
|
---|
107 | }
|
---|
108 | if (!m_userModifiedParameters.contains("EFIEnabled"))
|
---|
109 | {
|
---|
110 | KFirmwareType fwType = gpGlobalSession->guestOSTypeManager().getRecommendedFirmware(strTypeId);
|
---|
111 | m_pHardwareWidgetContainer->setEFIEnabled(fwType != KFirmwareType_BIOS);
|
---|
112 | pWizard->setEFIEnabled(fwType != KFirmwareType_BIOS);
|
---|
113 | }
|
---|
114 | m_pHardwareWidgetContainer->blockSignals(false);
|
---|
115 | }
|
---|
116 | }
|
---|
117 |
|
---|
118 | bool UIWizardNewVMHardwarePage::isComplete() const
|
---|
119 | {
|
---|
120 | return true;
|
---|
121 | }
|
---|
122 |
|
---|
123 | void UIWizardNewVMHardwarePage::sltMemorySizeChanged(int iValue)
|
---|
124 | {
|
---|
125 | AssertReturnVoid(wizardWindow<UIWizardNewVM>());
|
---|
126 | wizardWindow<UIWizardNewVM>()->setMemorySize(iValue);
|
---|
127 | m_userModifiedParameters << "MemorySize";
|
---|
128 | }
|
---|
129 |
|
---|
130 | void UIWizardNewVMHardwarePage::sltCPUCountChanged(int iCount)
|
---|
131 | {
|
---|
132 | AssertReturnVoid(wizardWindow<UIWizardNewVM>());
|
---|
133 | wizardWindow<UIWizardNewVM>()->setCPUCount(iCount);
|
---|
134 | m_userModifiedParameters << "CPUCount";
|
---|
135 | }
|
---|
136 |
|
---|
137 | void UIWizardNewVMHardwarePage::sltEFIEnabledChanged(bool fEnabled)
|
---|
138 | {
|
---|
139 | AssertReturnVoid(wizardWindow<UIWizardNewVM>());
|
---|
140 | wizardWindow<UIWizardNewVM>()->setEFIEnabled(fEnabled);
|
---|
141 | m_userModifiedParameters << "EFIEnabled";
|
---|
142 | }
|
---|