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