VirtualBox

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

Last change on this file was 104358, checked in by vboxsync, 2 months ago

FE/Qt. bugref:10622. More refactoring around the retranslation functionality.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 32.4 KB
RevLine 
[26714]1/* $Id: UIAdvancedSettingsDialogSpecific.cpp 104358 2024-04-18 05:33:40Z vboxsync $ */
[25177]2/** @file
[102139]3 * VBox Qt GUI - UIAdvancedSettingsDialogSpecific class implementation.
[25177]4 */
5
6/*
[98103]7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
[25177]8 *
[96407]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
[25177]26 */
27
[85711]28/* Qt includes: */
[104358]29#include <QApplication>
[85711]30#include <QStackedWidget>
31
[41587]32/* GUI includes: */
[100979]33#include "UIAdvancedSettingsDialogSpecific.h"
[79365]34#include "UICommon.h"
[76606]35#include "UIExtraDataManager.h"
[103771]36#include "UIGlobalSession.h"
[100896]37#include "UIIconPool.h"
[76606]38#include "UIMessageCenter.h"
39#include "UISettingsDefs.h"
40#include "UISettingsSerializer.h"
41#include "UISettingsSelector.h"
42#include "UIVirtualBoxEventHandler.h"
[25177]43
[72092]44/* GUI includes: Global Preferences: */
[76606]45#include "UIGlobalSettingsDisplay.h"
46#include "UIGlobalSettingsGeneral.h"
47#include "UIGlobalSettingsInput.h"
48#include "UIGlobalSettingsLanguage.h"
[89324]49#ifdef VBOX_WS_WIN
50# include "UIGlobalSettingsInterface.h"
51#endif
[76606]52#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
53# include "UIGlobalSettingsProxy.h"
54# include "UIGlobalSettingsUpdate.h"
55#endif
[25177]56
[72092]57/* GUI includes: Machine Settings: */
[76606]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"
[25177]68
[41587]69/* COM includes: */
[87251]70#include "CExtPackManager.h"
[81964]71#include "CGraphicsAdapter.h"
[101757]72#include "CPlatform.h"
[76606]73#include "CUSBController.h"
[41587]74
[55515]75
[72092]76/*********************************************************************************************************************************
[100979]77* Class UIAdvancedSettingsDialogGlobal implementation. *
[72092]78*********************************************************************************************************************************/
79
[100979]80UIAdvancedSettingsDialogGlobal::UIAdvancedSettingsDialogGlobal(QWidget *pParent,
81 const QString &strCategory /* = QString() */,
82 const QString &strControl /* = QString() */)
[100985]83 : UIAdvancedSettingsDialog(pParent, strCategory, strControl)
[25177]84{
[72092]85 prepare();
86}
87
[104313]88void UIAdvancedSettingsDialogGlobal::sltRetranslateUI()
[72092]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
[89324]115#ifdef VBOX_WS_WIN
116 /* Interface page: */
117 m_pSelector->setItemText(GlobalSettingsPageType_Interface, tr("Interface"));
118#endif
119
[72092]120 /* Polish the selector: */
121 m_pSelector->polish();
122
123 /* Base-class UI translation: */
[104313]124 UIAdvancedSettingsDialog::sltRetranslateUI();
[72092]125
126 /* Set dialog's name: */
127 setWindowTitle(title());
128}
129
[102140]130bool UIAdvancedSettingsDialogGlobal::load()
[72092]131{
[94757]132 /* Get host & properties: */
[103771]133 CHost comHost = gpGlobalSession->host();
134 CSystemProperties comProperties = gpGlobalSession->virtualBox().GetSystemProperties();
[72092]135 /* Prepare global data: */
136 qRegisterMetaType<UISettingsDataGlobal>();
[94757]137 UISettingsDataGlobal data(comHost, comProperties);
[72092]138 QVariant varData = QVariant::fromValue(data);
139
140 /* Call to base-class: */
[100985]141 UIAdvancedSettingsDialog::loadData(varData);
[102140]142
143 /* True by default: */
144 return true;
[72092]145}
146
[100979]147void UIAdvancedSettingsDialogGlobal::save()
[72092]148{
[94757]149 /* Get host & properties: */
[103771]150 CHost comHost = gpGlobalSession->host();
151 CSystemProperties comProperties = gpGlobalSession->virtualBox().GetSystemProperties();
[72092]152 /* Prepare global data: */
153 qRegisterMetaType<UISettingsDataGlobal>();
[94757]154 UISettingsDataGlobal data(comHost, comProperties);
[72092]155 QVariant varData = QVariant::fromValue(data);
156
157 /* Call to base-class: */
[100985]158 UIAdvancedSettingsDialog::saveData(varData);
[72092]159
[94757]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
[72092]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
[100902]172 /* Handle serializartion finished: */
173 sltHandleSerializationFinished();
[72092]174}
175
[100979]176QString UIAdvancedSettingsDialogGlobal::titleExtension() const
[72092]177{
178 return tr("Preferences");
179}
180
[100979]181QString UIAdvancedSettingsDialogGlobal::title() const
[72092]182{
183 return tr("VirtualBox - %1").arg(titleExtension());
184}
185
[100979]186void UIAdvancedSettingsDialogGlobal::prepare()
[72092]187{
[60362]188#ifndef VBOX_WS_MAC
[100896]189 /* Assign window icon: */
190 setWindowIcon(UIIconPool::iconSetFull(":/global_settings_32px.png", ":/global_settings_16px.png"));
[72092]191#endif
[25177]192
[32667]193 /* Creating settings pages: */
[51054]194 QList<GlobalSettingsPageType> restrictedGlobalSettingsPages = gEDataManager->restrictedGlobalSettingsPages();
[46759]195 for (int iPageIndex = GlobalSettingsPageType_General; iPageIndex < GlobalSettingsPageType_Max; ++iPageIndex)
[25177]196 {
[46763]197 /* Make sure page was not restricted: */
198 if (restrictedGlobalSettingsPages.contains(static_cast<GlobalSettingsPageType>(iPageIndex)))
199 continue;
200
201 /* Make sure page is available: */
[36592]202 if (isPageAvailable(iPageIndex))
[32667]203 {
[36323]204 UISettingsPage *pSettingsPage = 0;
205 switch (iPageIndex)
[32667]206 {
207 /* General page: */
[46759]208 case GlobalSettingsPageType_General:
[32667]209 {
[36323]210 pSettingsPage = new UIGlobalSettingsGeneral;
[51287]211 addItem(":/machine_32px.png", ":/machine_24px.png", ":/machine_16px.png",
[36323]212 iPageIndex, "#general", pSettingsPage);
[96828]213 addPageHelpKeyword(iPageIndex, "preferences");
[32667]214 break;
215 }
216 /* Input page: */
[46759]217 case GlobalSettingsPageType_Input:
[32667]218 {
[36323]219 pSettingsPage = new UIGlobalSettingsInput;
[51470]220 addItem(":/keyboard_32px.png", ":/keyboard_24px.png", ":/keyboard_16px.png",
[36323]221 iPageIndex, "#input", pSettingsPage);
[96828]222 addPageHelpKeyword(iPageIndex, "preferences");
[32667]223 break;
224 }
[49596]225#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
[32667]226 /* Update page: */
[46759]227 case GlobalSettingsPageType_Update:
[32667]228 {
[36323]229 pSettingsPage = new UIGlobalSettingsUpdate;
[51287]230 addItem(":/refresh_32px.png", ":/refresh_24px.png", ":/refresh_16px.png",
[36323]231 iPageIndex, "#update", pSettingsPage);
[96828]232 addPageHelpKeyword(iPageIndex, "preferences");
[32667]233 break;
234 }
[49596]235#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
[32667]236 /* Language page: */
[46759]237 case GlobalSettingsPageType_Language:
[32667]238 {
[36323]239 pSettingsPage = new UIGlobalSettingsLanguage;
[51287]240 addItem(":/site_32px.png", ":/site_24px.png", ":/site_16px.png",
[36323]241 iPageIndex, "#language", pSettingsPage);
[96828]242 addPageHelpKeyword(iPageIndex, "preferences");
[32667]243 break;
244 }
[39779]245 /* Display page: */
[46759]246 case GlobalSettingsPageType_Display:
[39779]247 {
248 pSettingsPage = new UIGlobalSettingsDisplay;
[51287]249 addItem(":/vrdp_32px.png", ":/vrdp_24px.png", ":/vrdp_16px.png",
[39779]250 iPageIndex, "#display", pSettingsPage);
[96828]251 addPageHelpKeyword(iPageIndex, "preferences");
[39779]252 break;
253 }
[49596]254#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
[37544]255 /* Proxy page: */
[46759]256 case GlobalSettingsPageType_Proxy:
[37544]257 {
258 pSettingsPage = new UIGlobalSettingsProxy;
[51287]259 addItem(":/proxy_32px.png", ":/proxy_24px.png", ":/proxy_16px.png",
[37544]260 iPageIndex, "#proxy", pSettingsPage);
[96828]261 addPageHelpKeyword(iPageIndex, "preferences");
[37544]262 break;
263 }
[49596]264#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
[89324]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);
[96828]272 addPageHelpKeyword(iPageIndex, "preferences");
[89324]273 break;
274 }
275#endif /* VBOX_WS_WIN */
[32667]276 default:
277 break;
278 }
279 }
[25177]280 }
281
[50906]282 /* Assign default (full) configuration access level: */
283 setConfigurationAccessLevel(ConfigurationAccessLevel_Full);
284
[72092]285 /* Apply language settings: */
[104313]286 sltRetranslateUI();
[25177]287}
288
[100979]289bool UIAdvancedSettingsDialogGlobal::isPageAvailable(int) const
[25177]290{
[87418]291 /* Add restrictions here.. */
[25177]292 return true;
293}
294
[72092]295
296/*********************************************************************************************************************************
[100979]297* Class UIAdvancedSettingsDialogMachine implementation. *
[72092]298*********************************************************************************************************************************/
299
[100979]300UIAdvancedSettingsDialogMachine::UIAdvancedSettingsDialogMachine(QWidget *pParent,
301 const QUuid &uMachineId,
302 UIActionPool *pActionPool,
303 const QString &strCategory /* = QString() */,
304 const QString &strControl /* = QString() */)
[100985]305 : UIAdvancedSettingsDialog(pParent, strCategory, strControl)
[74942]306 , m_uMachineId(uMachineId)
[97427]307 , m_pActionPool(pActionPool)
[25177]308{
[72092]309 prepare();
310}
[25177]311
[100979]312void UIAdvancedSettingsDialogMachine::setNewMachineId(const QUuid &uMachineId,
313 const QString &strCategory /* = QString() */,
314 const QString &strControl /* = QString() */)
[97436]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): */
[103771]322 m_machine = gpGlobalSession->virtualBox().FindMachine(m_uMachineId.toString());
[97436]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: */
[104313]331 sltRetranslateUI();
[97436]332
333 /* Choose page/tab: */
334 choosePageAndTab(true /* keep previous by default */);
335
336 /* Load finally: */
337 load();
338}
339
[104313]340void UIAdvancedSettingsDialogMachine::sltRetranslateUI()
[72092]341{
342 /* Selector itself: */
343 m_pSelector->widget()->setWhatsThis(tr("Allows to navigate through VM Settings categories"));
[25177]344
[72092]345 /* We have to make sure that the Network, Serial pages are retranslated
346 * before they are revalidated. Cause: They do string comparing within
[79365]347 * UICommon which is retranslated at that point already: */
[72092]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);
[55742]353
[72092]354 /* General page: */
355 m_pSelector->setItemText(MachineSettingsPageType_General, tr("General"));
[37109]356
[72092]357 /* System page: */
358 m_pSelector->setItemText(MachineSettingsPageType_System, tr("System"));
[46763]359
[72092]360 /* Display page: */
361 m_pSelector->setItemText(MachineSettingsPageType_Display, tr("Display"));
[25177]362
[72092]363 /* Storage page: */
364 m_pSelector->setItemText(MachineSettingsPageType_Storage, tr("Storage"));
[50906]365
[72092]366 /* Audio page: */
367 m_pSelector->setItemText(MachineSettingsPageType_Audio, tr("Audio"));
[25177]368
[72092]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: */
[104313]391 UIAdvancedSettingsDialog::sltRetranslateUI();
[72092]392
393 /* Set dialog's name: */
394 setWindowTitle(title());
[25177]395}
396
[102140]397bool UIAdvancedSettingsDialogMachine::load()
[25177]398{
[37109]399 /* Check that session is NOT created: */
400 if (!m_session.isNull())
[102140]401 return false;
[37109]402
403 /* Prepare session: */
[54919]404 m_session = configurationAccessLevel() == ConfigurationAccessLevel_Null ? CSession() :
[79365]405 configurationAccessLevel() == ConfigurationAccessLevel_Full ? uiCommon().openSession(m_uMachineId) :
406 uiCommon().openExistingSession(m_uMachineId);
[37109]407 /* Check that session was created: */
408 if (m_session.isNull())
[102140]409 return false;
[37109]410
[54919]411 /* Get machine and console: */
[37109]412 m_machine = m_session.GetMachine();
[50906]413 m_console = configurationAccessLevel() == ConfigurationAccessLevel_Full ? CConsole() : m_session.GetConsole();
[33631]414 /* Prepare machine data: */
415 qRegisterMetaType<UISettingsDataMachine>();
[36357]416 UISettingsDataMachine data(m_machine, m_console);
[54921]417 QVariant varData = QVariant::fromValue(data);
418
419 /* Call to base-class: */
[100985]420 UIAdvancedSettingsDialog::loadData(varData);
[102140]421
422 /* True by default: */
423 return true;
[25177]424}
425
[100979]426void UIAdvancedSettingsDialogMachine::save()
[25177]427{
[37109]428 /* Check that session is NOT created: */
429 if (!m_session.isNull())
430 return;
431
432 /* Prepare session: */
[54919]433 m_session = configurationAccessLevel() == ConfigurationAccessLevel_Null ? CSession() :
[79365]434 configurationAccessLevel() == ConfigurationAccessLevel_Full ? uiCommon().openSession(m_uMachineId) :
435 uiCommon().openExistingSession(m_uMachineId);
[37109]436 /* Check that session was created: */
437 if (m_session.isNull())
438 return;
439
[54919]440 /* Get machine and console: */
[37109]441 m_machine = m_session.GetMachine();
[50906]442 m_console = configurationAccessLevel() == ConfigurationAccessLevel_Full ? CConsole() : m_session.GetConsole();
[33631]443 /* Prepare machine data: */
444 qRegisterMetaType<UISettingsDataMachine>();
[36357]445 UISettingsDataMachine data(m_machine, m_console);
[54921]446 QVariant varData = QVariant::fromValue(data);
[25177]447
[54921]448 /* Call to base-class: */
[100985]449 UIAdvancedSettingsDialog::saveData(varData);
[54921]450
[33631]451 /* Get updated machine: */
[54921]452 m_machine = varData.value<UISettingsDataMachine>().m_machine;
[54919]453 /* If machine is OK => perform final operations: */
[34735]454 if (m_machine.isOk())
455 {
456 UIMachineSettingsSystem *pSystemPage =
[46759]457 qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(MachineSettingsPageType_System));
[84790]458#ifdef VBOX_WITH_3D_ACCELERATION
[81457]459 UIMachineSettingsDisplay *pDisplayPage =
460 qobject_cast<UIMachineSettingsDisplay*>(m_pSelector->idToPage(MachineSettingsPageType_Display));
[84790]461#endif /* VBOX_WITH_3D_ACCELERATION */
[81457]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())
[81964]468 m_machine.GetGraphicsAdapter().SetGraphicsControllerType(pDisplayPage->graphicsControllerTypeRecommended());
[81457]469#endif /* VBOX_WITH_3D_ACCELERATION */
470
[51322]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);
[34735]474
[37109]475 /* Save settings finally: */
476 m_machine.SaveSettings();
[34735]477 }
[37109]478
[54919]479 /* If machine is NOT OK => show the error message: */
[37109]480 if (!m_machine.isOk())
[45274]481 msgCenter().cannotSaveMachineSettings(m_machine, this);
[54932]482
[100902]483 /* Handle serializartion finished: */
484 sltHandleSerializationFinished();
[25177]485}
486
[100979]487QString UIAdvancedSettingsDialogMachine::titleExtension() const
[55513]488{
489 return tr("Settings");
490}
491
[100979]492QString UIAdvancedSettingsDialogMachine::title() const
[25177]493{
[32667]494 QString strDialogTitle;
[37615]495 /* Get corresponding machine (required to compose dialog title): */
[103771]496 const CMachine &machine = gpGlobalSession->virtualBox().FindMachine(m_uMachineId.toString());
[37615]497 if (!machine.isNull())
498 strDialogTitle = tr("%1 - %2").arg(machine.GetName()).arg(titleExtension());
[32667]499 return strDialogTitle;
[25177]500}
501
[100979]502void UIAdvancedSettingsDialogMachine::recorrelate(UISettingsPage *pSettingsPage)
[25177]503{
[37168]504 switch (pSettingsPage->id())
[25177]505 {
[47559]506 /* General page correlations: */
[46759]507 case MachineSettingsPageType_General:
[25177]508 {
[47559]509 /* Make changes on 'general' page influent 'display' page: */
[37168]510 UIMachineSettingsGeneral *pGeneralPage = qobject_cast<UIMachineSettingsGeneral*>(pSettingsPage);
[47559]511 UIMachineSettingsDisplay *pDisplayPage = qobject_cast<UIMachineSettingsDisplay*>(m_pSelector->idToPage(MachineSettingsPageType_Display));
512 if (pGeneralPage && pDisplayPage)
[101265]513 pDisplayPage->setGuestOSTypeId(pGeneralPage->guestOSTypeId());
[47559]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));
[97310]522 if (pSystemPage && pStoragePage)
523 pStoragePage->setChipsetType(pSystemPage->chipsetType());
[47559]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);
[46759]531 UIMachineSettingsSystem *pSystemPage = qobject_cast<UIMachineSettingsSystem*>(m_pSelector->idToPage(MachineSettingsPageType_System));
[47559]532 if (pUsbPage && pSystemPage)
[51345]533 pSystemPage->setUSBEnabled(pUsbPage->isUSBEnabled());
[47559]534 break;
535 }
536 default:
537 break;
538 }
539}
540
[100979]541void UIAdvancedSettingsDialogMachine::sltCategoryChanged(int cId)
[72092]542{
543 /* Raise priority of requested page: */
544 if (serializeProcess())
545 serializeProcess()->raisePriorityOfPage(cId);
546
547 /* Call to base-class: */
[100985]548 UIAdvancedSettingsDialog::sltCategoryChanged(cId);
[72092]549}
550
[100979]551void UIAdvancedSettingsDialogMachine::sltHandleSerializationFinished()
[37109]552{
[100902]553 /* Call to base-class: */
[100985]554 UIAdvancedSettingsDialog::sltHandleSerializationFinished();
[37109]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
[100979]566void UIAdvancedSettingsDialogMachine::sltSessionStateChanged(const QUuid &uMachineId, const KSessionState enmSessionState)
[37109]567{
[55742]568 /* Ignore if serialization is in progress: */
569 if (isSerializationInProgress())
570 return;
[37109]571 /* Ignore if thats NOT our VM: */
[74942]572 if (uMachineId != m_uMachineId)
[37109]573 return;
574
575 /* Ignore if state was NOT actually changed: */
[72092]576 if (m_enmSessionState == enmSessionState)
[37109]577 return;
[45198]578 /* Update current session state: */
[72092]579 m_enmSessionState = enmSessionState;
[37109]580
[50906]581 /* Recalculate configuration access level: */
582 updateConfigurationAccessLevel();
[45198]583}
[37109]584
[100979]585void UIAdvancedSettingsDialogMachine::sltMachineStateChanged(const QUuid &uMachineId, const KMachineState enmMachineState)
[45198]586{
[55742]587 /* Ignore if serialization is in progress: */
588 if (isSerializationInProgress())
589 return;
[45198]590 /* Ignore if thats NOT our VM: */
[74942]591 if (uMachineId != m_uMachineId)
[37109]592 return;
593
[45198]594 /* Ignore if state was NOT actually changed: */
[72092]595 if (m_enmMachineState == enmMachineState)
[45198]596 return;
597 /* Update current machine state: */
[72092]598 m_enmMachineState = enmMachineState;
[37901]599
[50906]600 /* Recalculate configuration access level: */
601 updateConfigurationAccessLevel();
[37109]602}
603
[100979]604void UIAdvancedSettingsDialogMachine::sltMachineDataChanged(const QUuid &uMachineId)
[37109]605{
[55742]606 /* Ignore if serialization is in progress: */
607 if (isSerializationInProgress())
608 return;
[37109]609 /* Ignore if thats NOT our VM: */
[74942]610 if (uMachineId != m_uMachineId)
[37109]611 return;
612
[37143]613 /* Check if user had changed something and warn him about he will loose settings on reloading: */
[45233]614 if (isSettingsChanged() && !msgCenter().confirmSettingsReloading(this))
[37143]615 return;
616
[37109]617 /* Reload data: */
[97383]618 load();
[37109]619}
620
[100979]621void UIAdvancedSettingsDialogMachine::prepare()
[25177]622{
[72092]623#ifndef VBOX_WS_MAC
[100896]624 /* Assign window icon: */
625 setWindowIcon(UIIconPool::iconSetFull(":/vm_settings_32px.png", ":/vm_settings_16px.png"));
[72092]626#endif
627
628 /* Make sure settings window will be updated on session/machine state/data changes: */
629 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange,
[100979]630 this, &UIAdvancedSettingsDialogMachine::sltSessionStateChanged);
[72092]631 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange,
[100979]632 this, &UIAdvancedSettingsDialogMachine::sltMachineStateChanged);
[72092]633 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineDataChange,
[100979]634 this, &UIAdvancedSettingsDialogMachine::sltMachineDataChanged);
[72092]635
636 /* Get corresponding machine (required to determine dialog type and page availability): */
[103771]637 m_machine = gpGlobalSession->virtualBox().FindMachine(m_uMachineId.toString());
[72092]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: */
[74878]643 QList<MachineSettingsPageType> restrictedMachineSettingsPages = gEDataManager->restrictedMachineSettingsPages(m_uMachineId);
[72092]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 {
[101752]659 pSettingsPage = new UIMachineSettingsGeneral;
[72092]660 addItem(":/machine_32px.png", ":/machine_24px.png", ":/machine_16px.png",
[101752]661 iPageIndex, "#general", pSettingsPage);
[86986]662 addPageHelpKeyword(iPageIndex, "generalsettings");
[72092]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);
[86986]671 addPageHelpKeyword(iPageIndex, "settings-system");
[72092]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);
[86986]680 addPageHelpKeyword(iPageIndex, "settings-display");
[72092]681 break;
682 }
683 /* Storage page: */
684 case MachineSettingsPageType_Storage:
685 {
[92413]686 pSettingsPage = new UIMachineSettingsStorage(m_pActionPool);
[72092]687 addItem(":/hd_32px.png", ":/hd_24px.png", ":/hd_16px.png",
688 iPageIndex, "#storage", pSettingsPage);
[86986]689 addPageHelpKeyword(iPageIndex, "settings-storage");
[72092]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);
[86986]698 addPageHelpKeyword(iPageIndex, "settings-audio");
[72092]699 break;
700 }
701 /* Network page: */
702 case MachineSettingsPageType_Network:
703 {
[101596]704 pSettingsPage = new UIMachineSettingsNetwork;
[72092]705 addItem(":/nw_32px.png", ":/nw_24px.png", ":/nw_16px.png",
706 iPageIndex, "#network", pSettingsPage);
[86986]707 addPageHelpKeyword(iPageIndex, "settings-network");
[72092]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 {
[101607]720 pSettingsPage = new UIMachineSettingsSerial;
[72092]721 addItem(":/serial_port_32px.png", ":/serial_port_24px.png", ":/serial_port_16px.png",
722 iPageIndex, "#serialPorts", pSettingsPage, MachineSettingsPageType_Ports);
[86986]723 addPageHelpKeyword(iPageIndex, "serialports");
[72092]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);
[86986]732 addPageHelpKeyword(iPageIndex, "usb-support");
[72092]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);
[86986]741 addPageHelpKeyword(iPageIndex, "shared-folders");
[72092]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);
[86986]750 addPageHelpKeyword(iPageIndex, "user-interface");
[72092]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
[101757]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 {
[102160]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;
[101757]784 }
785 setOptionalFlags(optFlags);
786 }
787 }
788
[72092]789 /* Apply language settings: */
[104313]790 sltRetranslateUI();
[72092]791}
792
[100979]793bool UIAdvancedSettingsDialogMachine::isPageAvailable(int iPageId) const
[72092]794{
[32667]795 if (m_machine.isNull())
[25177]796 return false;
797
[36592]798 switch (iPageId)
[25177]799 {
[46759]800 case MachineSettingsPageType_Serial:
[25177]801 {
[32667]802 /* Depends on ports availability: */
[46759]803 if (!isPageAvailable(MachineSettingsPageType_Ports))
[32667]804 return false;
805 break;
806 }
[46759]807 case MachineSettingsPageType_USB:
[25177]808 {
[32667]809 /* Depends on ports availability: */
[46759]810 if (!isPageAvailable(MachineSettingsPageType_Ports))
[25177]811 return false;
[47401]812 /* Check if USB is implemented: */
813 if (!m_machine.GetUSBProxyAvailable())
814 return false;
[32667]815 /* Get the USB controller object: */
[47401]816 CUSBControllerVector controllerColl = m_machine.GetUSBControllers();
[32667]817 /* Show the machine error message if any: */
[47401]818 if ( !m_machine.isReallyOk()
819 && controllerColl.size() > 0
[51322]820 && !m_machine.GetUSBControllers().isEmpty())
[46519]821 msgCenter().warnAboutUnaccessibleUSB(m_machine, parentWidget());
[25177]822 break;
823 }
824 default:
825 break;
826 }
827 return true;
828}
829
[100979]830void UIAdvancedSettingsDialogMachine::updateConfigurationAccessLevel()
[45198]831{
[50906]832 /* Determine new configuration access level: */
[72092]833 const ConfigurationAccessLevel newConfigurationAccessLevel = ::configurationAccessLevel(m_enmSessionState, m_enmMachineState);
[45198]834
[50906]835 /* Make sure someting changed: */
836 if (configurationAccessLevel() == newConfigurationAccessLevel)
[45198]837 return;
838
[50906]839 /* Should we warn a user about access level decrease? */
[72092]840 const bool fShouldWeWarn = configurationAccessLevel() == ConfigurationAccessLevel_Full;
[45198]841
[50906]842 /* Apply new configuration access level: */
843 setConfigurationAccessLevel(newConfigurationAccessLevel);
[45198]844
[50906]845 /* Show a warning about access level decrease if we should: */
846 if (isSettingsChanged() && fShouldWeWarn)
[45198]847 msgCenter().warnAboutStateChange(this);
848}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use