1 | /* $Id: UIAdvancedSettingsDialogSpecific.cpp 103771 2024-03-11 15:16:04Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIAdvancedSettingsDialogSpecific 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 <QStackedWidget>
|
---|
30 |
|
---|
31 | /* GUI includes: */
|
---|
32 | #include "UIAdvancedSettingsDialogSpecific.h"
|
---|
33 | #include "UICommon.h"
|
---|
34 | #include "UIExtraDataManager.h"
|
---|
35 | #include "UIGlobalSession.h"
|
---|
36 | #include "UIIconPool.h"
|
---|
37 | #include "UIMessageCenter.h"
|
---|
38 | #include "UISettingsDefs.h"
|
---|
39 | #include "UISettingsSerializer.h"
|
---|
40 | #include "UISettingsSelector.h"
|
---|
41 | #include "UIVirtualBoxEventHandler.h"
|
---|
42 |
|
---|
43 | /* GUI includes: Global Preferences: */
|
---|
44 | #include "UIGlobalSettingsDisplay.h"
|
---|
45 | #include "UIGlobalSettingsGeneral.h"
|
---|
46 | #include "UIGlobalSettingsInput.h"
|
---|
47 | #include "UIGlobalSettingsLanguage.h"
|
---|
48 | #ifdef VBOX_WS_WIN
|
---|
49 | # include "UIGlobalSettingsInterface.h"
|
---|
50 | #endif
|
---|
51 | #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
|
---|
52 | # include "UIGlobalSettingsProxy.h"
|
---|
53 | # include "UIGlobalSettingsUpdate.h"
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | /* GUI includes: Machine Settings: */
|
---|
57 | #include "UIMachineSettingsAudio.h"
|
---|
58 | #include "UIMachineSettingsDisplay.h"
|
---|
59 | #include "UIMachineSettingsGeneral.h"
|
---|
60 | #include "UIMachineSettingsInterface.h"
|
---|
61 | #include "UIMachineSettingsNetwork.h"
|
---|
62 | #include "UIMachineSettingsSerial.h"
|
---|
63 | #include "UIMachineSettingsSF.h"
|
---|
64 | #include "UIMachineSettingsStorage.h"
|
---|
65 | #include "UIMachineSettingsSystem.h"
|
---|
66 | #include "UIMachineSettingsUSB.h"
|
---|
67 |
|
---|
68 | /* COM includes: */
|
---|
69 | #include "CExtPackManager.h"
|
---|
70 | #include "CGraphicsAdapter.h"
|
---|
71 | #include "CPlatform.h"
|
---|
72 | #include "CUSBController.h"
|
---|
73 |
|
---|
74 |
|
---|
75 | /*********************************************************************************************************************************
|
---|
76 | * Class UIAdvancedSettingsDialogGlobal implementation. *
|
---|
77 | *********************************************************************************************************************************/
|
---|
78 |
|
---|
79 | UIAdvancedSettingsDialogGlobal::UIAdvancedSettingsDialogGlobal(QWidget *pParent,
|
---|
80 | const QString &strCategory /* = QString() */,
|
---|
81 | const QString &strControl /* = QString() */)
|
---|
82 | : UIAdvancedSettingsDialog(pParent, strCategory, strControl)
|
---|
83 | {
|
---|
84 | prepare();
|
---|
85 | }
|
---|
86 |
|
---|
87 | void UIAdvancedSettingsDialogGlobal::retranslateUi()
|
---|
88 | {
|
---|
89 | /* Selector itself: */
|
---|
90 | m_pSelector->widget()->setWhatsThis(tr("Allows to navigate through Global Property categories"));
|
---|
91 |
|
---|
92 | /* General page: */
|
---|
93 | m_pSelector->setItemText(GlobalSettingsPageType_General, tr("General"));
|
---|
94 |
|
---|
95 | /* Input page: */
|
---|
96 | m_pSelector->setItemText(GlobalSettingsPageType_Input, tr("Input"));
|
---|
97 |
|
---|
98 | #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
|
---|
99 | /* Update page: */
|
---|
100 | m_pSelector->setItemText(GlobalSettingsPageType_Update, tr("Update"));
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | /* Language page: */
|
---|
104 | m_pSelector->setItemText(GlobalSettingsPageType_Language, tr("Language"));
|
---|
105 |
|
---|
106 | /* Display page: */
|
---|
107 | m_pSelector->setItemText(GlobalSettingsPageType_Display, tr("Display"));
|
---|
108 |
|
---|
109 | #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
|
---|
110 | /* Proxy page: */
|
---|
111 | m_pSelector->setItemText(GlobalSettingsPageType_Proxy, tr("Proxy"));
|
---|
112 | #endif
|
---|
113 |
|
---|
114 | #ifdef VBOX_WS_WIN
|
---|
115 | /* Interface page: */
|
---|
116 | m_pSelector->setItemText(GlobalSettingsPageType_Interface, tr("Interface"));
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | /* Polish the selector: */
|
---|
120 | m_pSelector->polish();
|
---|
121 |
|
---|
122 | /* Base-class UI translation: */
|
---|
123 | UIAdvancedSettingsDialog::retranslateUi();
|
---|
124 |
|
---|
125 | /* Set dialog's name: */
|
---|
126 | setWindowTitle(title());
|
---|
127 | }
|
---|
128 |
|
---|
129 | bool UIAdvancedSettingsDialogGlobal::load()
|
---|
130 | {
|
---|
131 | /* Get host & properties: */
|
---|
132 | CHost comHost = gpGlobalSession->host();
|
---|
133 | CSystemProperties comProperties = gpGlobalSession->virtualBox().GetSystemProperties();
|
---|
134 | /* Prepare global data: */
|
---|
135 | qRegisterMetaType<UISettingsDataGlobal>();
|
---|
136 | UISettingsDataGlobal data(comHost, comProperties);
|
---|
137 | QVariant varData = QVariant::fromValue(data);
|
---|
138 |
|
---|
139 | /* Call to base-class: */
|
---|
140 | UIAdvancedSettingsDialog::loadData(varData);
|
---|
141 |
|
---|
142 | /* True by default: */
|
---|
143 | return true;
|
---|
144 | }
|
---|
145 |
|
---|
146 | void UIAdvancedSettingsDialogGlobal::save()
|
---|
147 | {
|
---|
148 | /* Get host & properties: */
|
---|
149 | CHost comHost = gpGlobalSession->host();
|
---|
150 | CSystemProperties comProperties = gpGlobalSession->virtualBox().GetSystemProperties();
|
---|
151 | /* Prepare global data: */
|
---|
152 | qRegisterMetaType<UISettingsDataGlobal>();
|
---|
153 | UISettingsDataGlobal data(comHost, comProperties);
|
---|
154 | QVariant varData = QVariant::fromValue(data);
|
---|
155 |
|
---|
156 | /* Call to base-class: */
|
---|
157 | UIAdvancedSettingsDialog::saveData(varData);
|
---|
158 |
|
---|
159 | /* Get updated host: */
|
---|
160 | CHost comNewHost = varData.value<UISettingsDataGlobal>().m_host;
|
---|
161 | /* If host is not OK => show the error: */
|
---|
162 | if (!comNewHost.isOk())
|
---|
163 | msgCenter().cannotSetHostSettings(comNewHost, this);
|
---|
164 |
|
---|
165 | /* Get updated properties: */
|
---|
166 | CSystemProperties comNewProperties = varData.value<UISettingsDataGlobal>().m_properties;
|
---|
167 | /* If properties are not OK => show the error: */
|
---|
168 | if (!comNewProperties.isOk())
|
---|
169 | msgCenter().cannotSetSystemProperties(comNewProperties, this);
|
---|
170 |
|
---|
171 | /* Handle serializartion finished: */
|
---|
172 | sltHandleSerializationFinished();
|
---|
173 | }
|
---|
174 |
|
---|
175 | QString UIAdvancedSettingsDialogGlobal::titleExtension() const
|
---|
176 | {
|
---|
177 | return tr("Preferences");
|
---|
178 | }
|
---|
179 |
|
---|
180 | QString UIAdvancedSettingsDialogGlobal::title() const
|
---|
181 | {
|
---|
182 | return tr("VirtualBox - %1").arg(titleExtension());
|
---|
183 | }
|
---|
184 |
|
---|
185 | void UIAdvancedSettingsDialogGlobal::prepare()
|
---|
186 | {
|
---|
187 | #ifndef VBOX_WS_MAC
|
---|
188 | /* Assign window icon: */
|
---|
189 | setWindowIcon(UIIconPool::iconSetFull(":/global_settings_32px.png", ":/global_settings_16px.png"));
|
---|
190 | #endif
|
---|
191 |
|
---|
192 | /* Creating settings pages: */
|
---|
193 | QList<GlobalSettingsPageType> restrictedGlobalSettingsPages = gEDataManager->restrictedGlobalSettingsPages();
|
---|
194 | for (int iPageIndex = GlobalSettingsPageType_General; iPageIndex < GlobalSettingsPageType_Max; ++iPageIndex)
|
---|
195 | {
|
---|
196 | /* Make sure page was not restricted: */
|
---|
197 | if (restrictedGlobalSettingsPages.contains(static_cast<GlobalSettingsPageType>(iPageIndex)))
|
---|
198 | continue;
|
---|
199 |
|
---|
200 | /* Make sure page is available: */
|
---|
201 | if (isPageAvailable(iPageIndex))
|
---|
202 | {
|
---|
203 | UISettingsPage *pSettingsPage = 0;
|
---|
204 | switch (iPageIndex)
|
---|
205 | {
|
---|
206 | /* General page: */
|
---|
207 | case GlobalSettingsPageType_General:
|
---|
208 | {
|
---|
209 | pSettingsPage = new UIGlobalSettingsGeneral;
|
---|
210 | addItem(":/machine_32px.png", ":/machine_24px.png", ":/machine_16px.png",
|
---|
211 | iPageIndex, "#general", pSettingsPage);
|
---|
212 | addPageHelpKeyword(iPageIndex, "preferences");
|
---|
213 | break;
|
---|
214 | }
|
---|
215 | /* Input page: */
|
---|
216 | case GlobalSettingsPageType_Input:
|
---|
217 | {
|
---|
218 | pSettingsPage = new UIGlobalSettingsInput;
|
---|
219 | addItem(":/keyboard_32px.png", ":/keyboard_24px.png", ":/keyboard_16px.png",
|
---|
220 | iPageIndex, "#input", pSettingsPage);
|
---|
221 | addPageHelpKeyword(iPageIndex, "preferences");
|
---|
222 | break;
|
---|
223 | }
|
---|
224 | #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
|
---|
225 | /* Update page: */
|
---|
226 | case GlobalSettingsPageType_Update:
|
---|
227 | {
|
---|
228 | pSettingsPage = new UIGlobalSettingsUpdate;
|
---|
229 | addItem(":/refresh_32px.png", ":/refresh_24px.png", ":/refresh_16px.png",
|
---|
230 | iPageIndex, "#update", pSettingsPage);
|
---|
231 | addPageHelpKeyword(iPageIndex, "preferences");
|
---|
232 | break;
|
---|
233 | }
|
---|
234 | #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
|
---|
235 | /* Language page: */
|
---|
236 | case GlobalSettingsPageType_Language:
|
---|
237 | {
|
---|
238 | pSettingsPage = new UIGlobalSettingsLanguage;
|
---|
239 | addItem(":/site_32px.png", ":/site_24px.png", ":/site_16px.png",
|
---|
240 | iPageIndex, "#language", pSettingsPage);
|
---|
241 | addPageHelpKeyword(iPageIndex, "preferences");
|
---|
242 | break;
|
---|
243 | }
|
---|
244 | /* Display page: */
|
---|
245 | case GlobalSettingsPageType_Display:
|
---|
246 | {
|
---|
247 | pSettingsPage = new UIGlobalSettingsDisplay;
|
---|
248 | addItem(":/vrdp_32px.png", ":/vrdp_24px.png", ":/vrdp_16px.png",
|
---|
249 | iPageIndex, "#display", pSettingsPage);
|
---|
250 | addPageHelpKeyword(iPageIndex, "preferences");
|
---|
251 | break;
|
---|
252 | }
|
---|
253 | #ifdef VBOX_GUI_WITH_NETWORK_MANAGER
|
---|
254 | /* Proxy page: */
|
---|
255 | case GlobalSettingsPageType_Proxy:
|
---|
256 | {
|
---|
257 | pSettingsPage = new UIGlobalSettingsProxy;
|
---|
258 | addItem(":/proxy_32px.png", ":/proxy_24px.png", ":/proxy_16px.png",
|
---|
259 | iPageIndex, "#proxy", pSettingsPage);
|
---|
260 | addPageHelpKeyword(iPageIndex, "preferences");
|
---|
261 | break;
|
---|
262 | }
|
---|
263 | #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
|
---|
264 | #ifdef VBOX_WS_WIN
|
---|
265 | /* Interface page: */
|
---|
266 | case GlobalSettingsPageType_Interface:
|
---|
267 | {
|
---|
268 | pSettingsPage = new UIGlobalSettingsInterface;
|
---|
269 | addItem(":/interface_32px.png", ":/interface_24px.png", ":/interface_16px.png",
|
---|
270 | iPageIndex, "#userInterface", pSettingsPage);
|
---|
271 | addPageHelpKeyword(iPageIndex, "preferences");
|
---|
272 | break;
|
---|
273 | }
|
---|
274 | #endif /* VBOX_WS_WIN */
|
---|
275 | default:
|
---|
276 | break;
|
---|
277 | }
|
---|
278 | }
|
---|
279 | }
|
---|
280 |
|
---|
281 | /* Assign default (full) configuration access level: */
|
---|
282 | setConfigurationAccessLevel(ConfigurationAccessLevel_Full);
|
---|
283 |
|
---|
284 | /* Apply language settings: */
|
---|
285 | retranslateUi();
|
---|
286 | }
|
---|
287 |
|
---|
288 | bool UIAdvancedSettingsDialogGlobal::isPageAvailable(int) const
|
---|
289 | {
|
---|
290 | /* Add restrictions here.. */
|
---|
291 | return true;
|
---|
292 | }
|
---|
293 |
|
---|
294 |
|
---|
295 | /*********************************************************************************************************************************
|
---|
296 | * Class UIAdvancedSettingsDialogMachine implementation. *
|
---|
297 | *********************************************************************************************************************************/
|
---|
298 |
|
---|
299 | UIAdvancedSettingsDialogMachine::UIAdvancedSettingsDialogMachine(QWidget *pParent,
|
---|
300 | const QUuid &uMachineId,
|
---|
301 | UIActionPool *pActionPool,
|
---|
302 | const QString &strCategory /* = QString() */,
|
---|
303 | const QString &strControl /* = QString() */)
|
---|
304 | : UIAdvancedSettingsDialog(pParent, strCategory, strControl)
|
---|
305 | , m_uMachineId(uMachineId)
|
---|
306 | , m_pActionPool(pActionPool)
|
---|
307 | {
|
---|
308 | prepare();
|
---|
309 | }
|
---|
310 |
|
---|
311 | void UIAdvancedSettingsDialogMachine::setNewMachineId(const QUuid &uMachineId,
|
---|
312 | const QString &strCategory /* = QString() */,
|
---|
313 | const QString &strControl /* = QString() */)
|
---|
314 | {
|
---|
315 | /* Cache new machine stuff: */
|
---|
316 | m_uMachineId = uMachineId;
|
---|
317 | m_strCategory = strCategory;
|
---|
318 | m_strControl = strControl;
|
---|
319 |
|
---|
320 | /* Get corresponding machine (required to determine dialog type and page availability): */
|
---|
321 | m_machine = gpGlobalSession->virtualBox().FindMachine(m_uMachineId.toString());
|
---|
322 | AssertReturnVoid(!m_machine.isNull());
|
---|
323 | m_enmSessionState = m_machine.GetSessionState();
|
---|
324 | m_enmMachineState = m_machine.GetState();
|
---|
325 |
|
---|
326 | /* Calculate initial configuration access level: */
|
---|
327 | setConfigurationAccessLevel(::configurationAccessLevel(m_enmSessionState, m_enmMachineState));
|
---|
328 |
|
---|
329 | /* Apply language settings: */
|
---|
330 | retranslateUi();
|
---|
331 |
|
---|
332 | /* Choose page/tab: */
|
---|
333 | choosePageAndTab(true /* keep previous by default */);
|
---|
334 |
|
---|
335 | /* Load finally: */
|
---|
336 | load();
|
---|
337 | }
|
---|
338 |
|
---|
339 | void UIAdvancedSettingsDialogMachine::retranslateUi()
|
---|
340 | {
|
---|
341 | /* Selector itself: */
|
---|
342 | m_pSelector->widget()->setWhatsThis(tr("Allows to navigate through VM Settings categories"));
|
---|
343 |
|
---|
344 | /* We have to make sure that the Network, Serial pages are retranslated
|
---|
345 | * before they are revalidated. Cause: They do string comparing within
|
---|
346 | * UICommon which is retranslated at that point already: */
|
---|
347 | QEvent event(QEvent::LanguageChange);
|
---|
348 | if (QWidget *pPage = m_pSelector->idToPage(MachineSettingsPageType_Network))
|
---|
349 | qApp->sendEvent(pPage, &event);
|
---|
350 | if (QWidget *pPage = m_pSelector->idToPage(MachineSettingsPageType_Serial))
|
---|
351 | qApp->sendEvent(pPage, &event);
|
---|
352 |
|
---|
353 | /* General page: */
|
---|
354 | m_pSelector->setItemText(MachineSettingsPageType_General, tr("General"));
|
---|
355 |
|
---|
356 | /* System page: */
|
---|
357 | m_pSelector->setItemText(MachineSettingsPageType_System, tr("System"));
|
---|
358 |
|
---|
359 | /* Display page: */
|
---|
360 | m_pSelector->setItemText(MachineSettingsPageType_Display, tr("Display"));
|
---|
361 |
|
---|
362 | /* Storage page: */
|
---|
363 | m_pSelector->setItemText(MachineSettingsPageType_Storage, tr("Storage"));
|
---|
364 |
|
---|
365 | /* Audio page: */
|
---|
366 | m_pSelector->setItemText(MachineSettingsPageType_Audio, tr("Audio"));
|
---|
367 |
|
---|
368 | /* Network page: */
|
---|
369 | m_pSelector->setItemText(MachineSettingsPageType_Network, tr("Network"));
|
---|
370 |
|
---|
371 | /* Ports page: */
|
---|
372 | m_pSelector->setItemText(MachineSettingsPageType_Ports, tr("Ports"));
|
---|
373 |
|
---|
374 | /* Serial page: */
|
---|
375 | m_pSelector->setItemText(MachineSettingsPageType_Serial, tr("Serial Ports"));
|
---|
376 |
|
---|
377 | /* USB page: */
|
---|
378 | m_pSelector->setItemText(MachineSettingsPageType_USB, tr("USB"));
|
---|
379 |
|
---|
380 | /* SFolders page: */
|
---|
381 | m_pSelector->setItemText(MachineSettingsPageType_SF, tr("Shared Folders"));
|
---|
382 |
|
---|
383 | /* Interface page: */
|
---|
384 | m_pSelector->setItemText(MachineSettingsPageType_Interface, tr("User Interface"));
|
---|
385 |
|
---|
386 | /* Polish the selector: */
|
---|
387 | m_pSelector->polish();
|
---|
388 |
|
---|
389 | /* Base-class UI translation: */
|
---|
390 | UIAdvancedSettingsDialog::retranslateUi();
|
---|
391 |
|
---|
392 | /* Set dialog's name: */
|
---|
393 | setWindowTitle(title());
|
---|
394 | }
|
---|
395 |
|
---|
396 | bool UIAdvancedSettingsDialogMachine::load()
|
---|
397 | {
|
---|
398 | /* Check that session is NOT created: */
|
---|
399 | if (!m_session.isNull())
|
---|
400 | return false;
|
---|
401 |
|
---|
402 | /* Prepare session: */
|
---|
403 | m_session = configurationAccessLevel() == ConfigurationAccessLevel_Null ? CSession() :
|
---|
404 | configurationAccessLevel() == ConfigurationAccessLevel_Full ? uiCommon().openSession(m_uMachineId) :
|
---|
405 | uiCommon().openExistingSession(m_uMachineId);
|
---|
406 | /* Check that session was created: */
|
---|
407 | if (m_session.isNull())
|
---|
408 | return false;
|
---|
409 |
|
---|
410 | /* Get machine and console: */
|
---|
411 | m_machine = m_session.GetMachine();
|
---|
412 | m_console = configurationAccessLevel() == ConfigurationAccessLevel_Full ? CConsole() : m_session.GetConsole();
|
---|
413 | /* Prepare machine data: */
|
---|
414 | qRegisterMetaType<UISettingsDataMachine>();
|
---|
415 | UISettingsDataMachine data(m_machine, m_console);
|
---|
416 | QVariant varData = QVariant::fromValue(data);
|
---|
417 |
|
---|
418 | /* Call to base-class: */
|
---|
419 | UIAdvancedSettingsDialog::loadData(varData);
|
---|
420 |
|
---|
421 | /* True by default: */
|
---|
422 | return true;
|
---|
423 | }
|
---|
424 |
|
---|
425 | void UIAdvancedSettingsDialogMachine::save()
|
---|
426 | {
|
---|
427 | /* Check that session is NOT created: */
|
---|
428 | if (!m_session.isNull())
|
---|
429 | return;
|
---|
430 |
|
---|
431 | /* Prepare session: */
|
---|
432 | m_session = configurationAccessLevel() == ConfigurationAccessLevel_Null ? CSession() :
|
---|
433 | configurationAccessLevel() == ConfigurationAccessLevel_Full ? uiCommon().openSession(m_uMachineId) :
|
---|
434 | uiCommon().openExistingSession(m_uMachineId);
|
---|
435 | /* Check that session was created: */
|
---|
436 | if (m_session.isNull())
|
---|
437 | return;
|
---|
438 |
|
---|
439 | /* Get machine and console: */
|
---|
440 | m_machine = m_session.GetMachine();
|
---|
441 | m_console = configurationAccessLevel() == ConfigurationAccessLevel_Full ? CConsole() : m_session.GetConsole();
|
---|
442 | /* Prepare machine data: */
|
---|
443 | qRegisterMetaType<UISettingsDataMachine>();
|
---|
444 | UISettingsDataMachine data(m_machine, m_console);
|
---|
445 | QVariant varData = QVariant::fromValue(data);
|
---|
446 |
|
---|
447 | /* Call to base-class: */
|
---|
448 | UIAdvancedSettingsDialog::saveData(varData);
|
---|
449 |
|
---|
450 | /* Get updated machine: */
|
---|
451 | m_machine = varData.value<UISettingsDataMachine>().m_machine;
|
---|
452 | /* If machine is OK => perform final operations: */
|
---|
453 | if (m_machine.isOk())
|
---|
454 | {
|
---|
455 | UIMachineSettingsSystem *pSystemPage =
|
---|
456 | qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(MachineSettingsPageType_System));
|
---|
457 | #ifdef VBOX_WITH_3D_ACCELERATION
|
---|
458 | UIMachineSettingsDisplay *pDisplayPage =
|
---|
459 | qobject_cast<UIMachineSettingsDisplay*>(m_pSelector->idToPage(MachineSettingsPageType_Display));
|
---|
460 | #endif /* VBOX_WITH_3D_ACCELERATION */
|
---|
461 |
|
---|
462 | #ifdef VBOX_WITH_3D_ACCELERATION
|
---|
463 | /* Adjust graphics controller type if necessary: */
|
---|
464 | if ( pDisplayPage
|
---|
465 | && pDisplayPage->isAcceleration3DSelected()
|
---|
466 | && pDisplayPage->graphicsControllerTypeCurrent() != pDisplayPage->graphicsControllerTypeRecommended())
|
---|
467 | m_machine.GetGraphicsAdapter().SetGraphicsControllerType(pDisplayPage->graphicsControllerTypeRecommended());
|
---|
468 | #endif /* VBOX_WITH_3D_ACCELERATION */
|
---|
469 |
|
---|
470 | /* Enable OHCI controller if HID is enabled but no USB controllers present: */
|
---|
471 | if (pSystemPage && pSystemPage->isHIDEnabled() && m_machine.GetUSBControllers().isEmpty())
|
---|
472 | m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);
|
---|
473 |
|
---|
474 | /* Save settings finally: */
|
---|
475 | m_machine.SaveSettings();
|
---|
476 | }
|
---|
477 |
|
---|
478 | /* If machine is NOT OK => show the error message: */
|
---|
479 | if (!m_machine.isOk())
|
---|
480 | msgCenter().cannotSaveMachineSettings(m_machine, this);
|
---|
481 |
|
---|
482 | /* Handle serializartion finished: */
|
---|
483 | sltHandleSerializationFinished();
|
---|
484 | }
|
---|
485 |
|
---|
486 | QString UIAdvancedSettingsDialogMachine::titleExtension() const
|
---|
487 | {
|
---|
488 | return tr("Settings");
|
---|
489 | }
|
---|
490 |
|
---|
491 | QString UIAdvancedSettingsDialogMachine::title() const
|
---|
492 | {
|
---|
493 | QString strDialogTitle;
|
---|
494 | /* Get corresponding machine (required to compose dialog title): */
|
---|
495 | const CMachine &machine = gpGlobalSession->virtualBox().FindMachine(m_uMachineId.toString());
|
---|
496 | if (!machine.isNull())
|
---|
497 | strDialogTitle = tr("%1 - %2").arg(machine.GetName()).arg(titleExtension());
|
---|
498 | return strDialogTitle;
|
---|
499 | }
|
---|
500 |
|
---|
501 | void UIAdvancedSettingsDialogMachine::recorrelate(UISettingsPage *pSettingsPage)
|
---|
502 | {
|
---|
503 | switch (pSettingsPage->id())
|
---|
504 | {
|
---|
505 | /* General page correlations: */
|
---|
506 | case MachineSettingsPageType_General:
|
---|
507 | {
|
---|
508 | /* Make changes on 'general' page influent 'display' page: */
|
---|
509 | UIMachineSettingsGeneral *pGeneralPage = qobject_cast<UIMachineSettingsGeneral*>(pSettingsPage);
|
---|
510 | UIMachineSettingsDisplay *pDisplayPage = qobject_cast<UIMachineSettingsDisplay*>(m_pSelector->idToPage(MachineSettingsPageType_Display));
|
---|
511 | if (pGeneralPage && pDisplayPage)
|
---|
512 | pDisplayPage->setGuestOSTypeId(pGeneralPage->guestOSTypeId());
|
---|
513 | break;
|
---|
514 | }
|
---|
515 | /* System page correlations: */
|
---|
516 | case MachineSettingsPageType_System:
|
---|
517 | {
|
---|
518 | /* Make changes on 'system' page influent 'general' and 'storage' page: */
|
---|
519 | UIMachineSettingsSystem *pSystemPage = qobject_cast<UIMachineSettingsSystem*>(pSettingsPage);
|
---|
520 | UIMachineSettingsStorage *pStoragePage = qobject_cast<UIMachineSettingsStorage*>(m_pSelector->idToPage(MachineSettingsPageType_Storage));
|
---|
521 | if (pSystemPage && pStoragePage)
|
---|
522 | pStoragePage->setChipsetType(pSystemPage->chipsetType());
|
---|
523 | break;
|
---|
524 | }
|
---|
525 | /* USB page correlations: */
|
---|
526 | case MachineSettingsPageType_USB:
|
---|
527 | {
|
---|
528 | /* Make changes on 'usb' page influent 'system' page: */
|
---|
529 | UIMachineSettingsUSB *pUsbPage = qobject_cast<UIMachineSettingsUSB*>(pSettingsPage);
|
---|
530 | UIMachineSettingsSystem *pSystemPage = qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(MachineSettingsPageType_System));
|
---|
531 | if (pUsbPage && pSystemPage)
|
---|
532 | pSystemPage->setUSBEnabled(pUsbPage->isUSBEnabled());
|
---|
533 | break;
|
---|
534 | }
|
---|
535 | default:
|
---|
536 | break;
|
---|
537 | }
|
---|
538 | }
|
---|
539 |
|
---|
540 | void UIAdvancedSettingsDialogMachine::sltCategoryChanged(int cId)
|
---|
541 | {
|
---|
542 | /* Raise priority of requested page: */
|
---|
543 | if (serializeProcess())
|
---|
544 | serializeProcess()->raisePriorityOfPage(cId);
|
---|
545 |
|
---|
546 | /* Call to base-class: */
|
---|
547 | UIAdvancedSettingsDialog::sltCategoryChanged(cId);
|
---|
548 | }
|
---|
549 |
|
---|
550 | void UIAdvancedSettingsDialogMachine::sltHandleSerializationFinished()
|
---|
551 | {
|
---|
552 | /* Call to base-class: */
|
---|
553 | UIAdvancedSettingsDialog::sltHandleSerializationFinished();
|
---|
554 |
|
---|
555 | /* Unlock the session if exists: */
|
---|
556 | if (!m_session.isNull())
|
---|
557 | {
|
---|
558 | m_session.UnlockMachine();
|
---|
559 | m_session = CSession();
|
---|
560 | m_machine = CMachine();
|
---|
561 | m_console = CConsole();
|
---|
562 | }
|
---|
563 | }
|
---|
564 |
|
---|
565 | void UIAdvancedSettingsDialogMachine::sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmSessionState)
|
---|
566 | {
|
---|
567 | /* Ignore if serialization is in progress: */
|
---|
568 | if (isSerializationInProgress())
|
---|
569 | return;
|
---|
570 | /* Ignore if thats NOT our VM: */
|
---|
571 | if (uMachineId != m_uMachineId)
|
---|
572 | return;
|
---|
573 |
|
---|
574 | /* Ignore if state was NOT actually changed: */
|
---|
575 | if (m_enmSessionState == enmSessionState)
|
---|
576 | return;
|
---|
577 | /* Update current session state: */
|
---|
578 | m_enmSessionState = enmSessionState;
|
---|
579 |
|
---|
580 | /* Recalculate configuration access level: */
|
---|
581 | updateConfigurationAccessLevel();
|
---|
582 | }
|
---|
583 |
|
---|
584 | void UIAdvancedSettingsDialogMachine::sltMachineStateChanged(const QUuid &uMachineId, const KMachineState enmMachineState)
|
---|
585 | {
|
---|
586 | /* Ignore if serialization is in progress: */
|
---|
587 | if (isSerializationInProgress())
|
---|
588 | return;
|
---|
589 | /* Ignore if thats NOT our VM: */
|
---|
590 | if (uMachineId != m_uMachineId)
|
---|
591 | return;
|
---|
592 |
|
---|
593 | /* Ignore if state was NOT actually changed: */
|
---|
594 | if (m_enmMachineState == enmMachineState)
|
---|
595 | return;
|
---|
596 | /* Update current machine state: */
|
---|
597 | m_enmMachineState = enmMachineState;
|
---|
598 |
|
---|
599 | /* Recalculate configuration access level: */
|
---|
600 | updateConfigurationAccessLevel();
|
---|
601 | }
|
---|
602 |
|
---|
603 | void UIAdvancedSettingsDialogMachine::sltMachineDataChanged(const QUuid &uMachineId)
|
---|
604 | {
|
---|
605 | /* Ignore if serialization is in progress: */
|
---|
606 | if (isSerializationInProgress())
|
---|
607 | return;
|
---|
608 | /* Ignore if thats NOT our VM: */
|
---|
609 | if (uMachineId != m_uMachineId)
|
---|
610 | return;
|
---|
611 |
|
---|
612 | /* Check if user had changed something and warn him about he will loose settings on reloading: */
|
---|
613 | if (isSettingsChanged() && !msgCenter().confirmSettingsReloading(this))
|
---|
614 | return;
|
---|
615 |
|
---|
616 | /* Reload data: */
|
---|
617 | load();
|
---|
618 | }
|
---|
619 |
|
---|
620 | void UIAdvancedSettingsDialogMachine::prepare()
|
---|
621 | {
|
---|
622 | #ifndef VBOX_WS_MAC
|
---|
623 | /* Assign window icon: */
|
---|
624 | setWindowIcon(UIIconPool::iconSetFull(":/vm_settings_32px.png", ":/vm_settings_16px.png"));
|
---|
625 | #endif
|
---|
626 |
|
---|
627 | /* Make sure settings window will be updated on session/machine state/data changes: */
|
---|
628 | connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange,
|
---|
629 | this, &UIAdvancedSettingsDialogMachine::sltSessionStateChanged);
|
---|
630 | connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange,
|
---|
631 | this, &UIAdvancedSettingsDialogMachine::sltMachineStateChanged);
|
---|
632 | connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineDataChange,
|
---|
633 | this, &UIAdvancedSettingsDialogMachine::sltMachineDataChanged);
|
---|
634 |
|
---|
635 | /* Get corresponding machine (required to determine dialog type and page availability): */
|
---|
636 | m_machine = gpGlobalSession->virtualBox().FindMachine(m_uMachineId.toString());
|
---|
637 | AssertMsg(!m_machine.isNull(), ("Can't find corresponding machine!\n"));
|
---|
638 | m_enmSessionState = m_machine.GetSessionState();
|
---|
639 | m_enmMachineState = m_machine.GetState();
|
---|
640 |
|
---|
641 | /* Creating settings pages: */
|
---|
642 | QList<MachineSettingsPageType> restrictedMachineSettingsPages = gEDataManager->restrictedMachineSettingsPages(m_uMachineId);
|
---|
643 | for (int iPageIndex = MachineSettingsPageType_General; iPageIndex < MachineSettingsPageType_Max; ++iPageIndex)
|
---|
644 | {
|
---|
645 | /* Make sure page was not restricted: */
|
---|
646 | if (restrictedMachineSettingsPages.contains(static_cast<MachineSettingsPageType>(iPageIndex)))
|
---|
647 | continue;
|
---|
648 |
|
---|
649 | /* Make sure page is available: */
|
---|
650 | if (isPageAvailable(iPageIndex))
|
---|
651 | {
|
---|
652 | UISettingsPage *pSettingsPage = 0;
|
---|
653 | switch (iPageIndex)
|
---|
654 | {
|
---|
655 | /* General page: */
|
---|
656 | case MachineSettingsPageType_General:
|
---|
657 | {
|
---|
658 | pSettingsPage = new UIMachineSettingsGeneral;
|
---|
659 | addItem(":/machine_32px.png", ":/machine_24px.png", ":/machine_16px.png",
|
---|
660 | iPageIndex, "#general", pSettingsPage);
|
---|
661 | addPageHelpKeyword(iPageIndex, "generalsettings");
|
---|
662 | break;
|
---|
663 | }
|
---|
664 | /* System page: */
|
---|
665 | case MachineSettingsPageType_System:
|
---|
666 | {
|
---|
667 | pSettingsPage = new UIMachineSettingsSystem;
|
---|
668 | addItem(":/chipset_32px.png", ":/chipset_24px.png", ":/chipset_16px.png",
|
---|
669 | iPageIndex, "#system", pSettingsPage);
|
---|
670 | addPageHelpKeyword(iPageIndex, "settings-system");
|
---|
671 | break;
|
---|
672 | }
|
---|
673 | /* Display page: */
|
---|
674 | case MachineSettingsPageType_Display:
|
---|
675 | {
|
---|
676 | pSettingsPage = new UIMachineSettingsDisplay;
|
---|
677 | addItem(":/vrdp_32px.png", ":/vrdp_24px.png", ":/vrdp_16px.png",
|
---|
678 | iPageIndex, "#display", pSettingsPage);
|
---|
679 | addPageHelpKeyword(iPageIndex, "settings-display");
|
---|
680 | break;
|
---|
681 | }
|
---|
682 | /* Storage page: */
|
---|
683 | case MachineSettingsPageType_Storage:
|
---|
684 | {
|
---|
685 | pSettingsPage = new UIMachineSettingsStorage(m_pActionPool);
|
---|
686 | addItem(":/hd_32px.png", ":/hd_24px.png", ":/hd_16px.png",
|
---|
687 | iPageIndex, "#storage", pSettingsPage);
|
---|
688 | addPageHelpKeyword(iPageIndex, "settings-storage");
|
---|
689 | break;
|
---|
690 | }
|
---|
691 | /* Audio page: */
|
---|
692 | case MachineSettingsPageType_Audio:
|
---|
693 | {
|
---|
694 | pSettingsPage = new UIMachineSettingsAudio;
|
---|
695 | addItem(":/sound_32px.png", ":/sound_24px.png", ":/sound_16px.png",
|
---|
696 | iPageIndex, "#audio", pSettingsPage);
|
---|
697 | addPageHelpKeyword(iPageIndex, "settings-audio");
|
---|
698 | break;
|
---|
699 | }
|
---|
700 | /* Network page: */
|
---|
701 | case MachineSettingsPageType_Network:
|
---|
702 | {
|
---|
703 | pSettingsPage = new UIMachineSettingsNetwork;
|
---|
704 | addItem(":/nw_32px.png", ":/nw_24px.png", ":/nw_16px.png",
|
---|
705 | iPageIndex, "#network", pSettingsPage);
|
---|
706 | addPageHelpKeyword(iPageIndex, "settings-network");
|
---|
707 | break;
|
---|
708 | }
|
---|
709 | /* Ports page: */
|
---|
710 | case MachineSettingsPageType_Ports:
|
---|
711 | {
|
---|
712 | addItem(":/serial_port_32px.png", ":/serial_port_24px.png", ":/serial_port_16px.png",
|
---|
713 | iPageIndex, "#ports");
|
---|
714 | break;
|
---|
715 | }
|
---|
716 | /* Serial page: */
|
---|
717 | case MachineSettingsPageType_Serial:
|
---|
718 | {
|
---|
719 | pSettingsPage = new UIMachineSettingsSerial;
|
---|
720 | addItem(":/serial_port_32px.png", ":/serial_port_24px.png", ":/serial_port_16px.png",
|
---|
721 | iPageIndex, "#serialPorts", pSettingsPage, MachineSettingsPageType_Ports);
|
---|
722 | addPageHelpKeyword(iPageIndex, "serialports");
|
---|
723 | break;
|
---|
724 | }
|
---|
725 | /* USB page: */
|
---|
726 | case MachineSettingsPageType_USB:
|
---|
727 | {
|
---|
728 | pSettingsPage = new UIMachineSettingsUSB;
|
---|
729 | addItem(":/usb_32px.png", ":/usb_24px.png", ":/usb_16px.png",
|
---|
730 | iPageIndex, "#usb", pSettingsPage, MachineSettingsPageType_Ports);
|
---|
731 | addPageHelpKeyword(iPageIndex, "usb-support");
|
---|
732 | break;
|
---|
733 | }
|
---|
734 | /* Shared Folders page: */
|
---|
735 | case MachineSettingsPageType_SF:
|
---|
736 | {
|
---|
737 | pSettingsPage = new UIMachineSettingsSF;
|
---|
738 | addItem(":/sf_32px.png", ":/sf_24px.png", ":/sf_16px.png",
|
---|
739 | iPageIndex, "#sharedFolders", pSettingsPage);
|
---|
740 | addPageHelpKeyword(iPageIndex, "shared-folders");
|
---|
741 | break;
|
---|
742 | }
|
---|
743 | /* Interface page: */
|
---|
744 | case MachineSettingsPageType_Interface:
|
---|
745 | {
|
---|
746 | pSettingsPage = new UIMachineSettingsInterface(m_machine.GetId());
|
---|
747 | addItem(":/interface_32px.png", ":/interface_24px.png", ":/interface_16px.png",
|
---|
748 | iPageIndex, "#userInterface", pSettingsPage);
|
---|
749 | addPageHelpKeyword(iPageIndex, "user-interface");
|
---|
750 | break;
|
---|
751 | }
|
---|
752 | default:
|
---|
753 | break;
|
---|
754 | }
|
---|
755 | }
|
---|
756 | }
|
---|
757 |
|
---|
758 | /* Calculate initial configuration access level: */
|
---|
759 | setConfigurationAccessLevel(::configurationAccessLevel(m_enmSessionState, m_enmMachineState));
|
---|
760 |
|
---|
761 | /* Define initial dialog platform, for now it's constant.
|
---|
762 | * Who knows, maybe we will be able to change it dynamically one day: */
|
---|
763 | const CPlatform comPlatform = m_machine.GetPlatform();
|
---|
764 | if (comPlatform.isNotNull())
|
---|
765 | {
|
---|
766 | const KPlatformArchitecture enmArch = comPlatform.GetArchitecture();
|
---|
767 | Assert(enmArch != KPlatformArchitecture_None);
|
---|
768 | if (enmArch != KPlatformArchitecture_None)
|
---|
769 | {
|
---|
770 | /* Push platform flag through whole UIEditor hierarchy: */
|
---|
771 | QMap<QString, QVariant> optFlags = optionalFlags();
|
---|
772 | switch (enmArch)
|
---|
773 | {
|
---|
774 | /* For x86/ARM we'll set the flag: */
|
---|
775 | case KPlatformArchitecture_x86:
|
---|
776 | case KPlatformArchitecture_ARM:
|
---|
777 | optFlags["arch"] = QVariant::fromValue(enmArch);
|
---|
778 | break;
|
---|
779 | /* For rest of platforms (+None) we'll remove it: */
|
---|
780 | default:
|
---|
781 | optFlags.remove("arch");
|
---|
782 | break;
|
---|
783 | }
|
---|
784 | setOptionalFlags(optFlags);
|
---|
785 | }
|
---|
786 | }
|
---|
787 |
|
---|
788 | /* Apply language settings: */
|
---|
789 | retranslateUi();
|
---|
790 | }
|
---|
791 |
|
---|
792 | bool UIAdvancedSettingsDialogMachine::isPageAvailable(int iPageId) const
|
---|
793 | {
|
---|
794 | if (m_machine.isNull())
|
---|
795 | return false;
|
---|
796 |
|
---|
797 | switch (iPageId)
|
---|
798 | {
|
---|
799 | case MachineSettingsPageType_Serial:
|
---|
800 | {
|
---|
801 | /* Depends on ports availability: */
|
---|
802 | if (!isPageAvailable(MachineSettingsPageType_Ports))
|
---|
803 | return false;
|
---|
804 | break;
|
---|
805 | }
|
---|
806 | case MachineSettingsPageType_USB:
|
---|
807 | {
|
---|
808 | /* Depends on ports availability: */
|
---|
809 | if (!isPageAvailable(MachineSettingsPageType_Ports))
|
---|
810 | return false;
|
---|
811 | /* Check if USB is implemented: */
|
---|
812 | if (!m_machine.GetUSBProxyAvailable())
|
---|
813 | return false;
|
---|
814 | /* Get the USB controller object: */
|
---|
815 | CUSBControllerVector controllerColl = m_machine.GetUSBControllers();
|
---|
816 | /* Show the machine error message if any: */
|
---|
817 | if ( !m_machine.isReallyOk()
|
---|
818 | && controllerColl.size() > 0
|
---|
819 | && !m_machine.GetUSBControllers().isEmpty())
|
---|
820 | msgCenter().warnAboutUnaccessibleUSB(m_machine, parentWidget());
|
---|
821 | break;
|
---|
822 | }
|
---|
823 | default:
|
---|
824 | break;
|
---|
825 | }
|
---|
826 | return true;
|
---|
827 | }
|
---|
828 |
|
---|
829 | void UIAdvancedSettingsDialogMachine::updateConfigurationAccessLevel()
|
---|
830 | {
|
---|
831 | /* Determine new configuration access level: */
|
---|
832 | const ConfigurationAccessLevel newConfigurationAccessLevel = ::configurationAccessLevel(m_enmSessionState, m_enmMachineState);
|
---|
833 |
|
---|
834 | /* Make sure someting changed: */
|
---|
835 | if (configurationAccessLevel() == newConfigurationAccessLevel)
|
---|
836 | return;
|
---|
837 |
|
---|
838 | /* Should we warn a user about access level decrease? */
|
---|
839 | const bool fShouldWeWarn = configurationAccessLevel() == ConfigurationAccessLevel_Full;
|
---|
840 |
|
---|
841 | /* Apply new configuration access level: */
|
---|
842 | setConfigurationAccessLevel(newConfigurationAccessLevel);
|
---|
843 |
|
---|
844 | /* Show a warning about access level decrease if we should: */
|
---|
845 | if (isSettingsChanged() && fShouldWeWarn)
|
---|
846 | msgCenter().warnAboutStateChange(this);
|
---|
847 | }
|
---|