VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialogSpecific.cpp

Last change on this file was 105887, checked in by vboxsync, 2 weeks ago

FE/Qt: bugref:10513: Wipe out a bit of remnants of previous VM Settings dialog; Will have to wipe corresponding NLS tags from .ts files as well.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette