Changeset 72092 in vbox for trunk/src/VBox
- Timestamp:
- May 3, 2018 12:55:48 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r72059 r72092 520 520 src/selector/graphics/details/UIGDetailsElements.h \ 521 521 src/selector/graphics/details/UIGMachinePreview.h \ 522 src/settings/UISettingsDialogSpecific.h \523 522 src/settings/UISettingsPage.h \ 524 523 src/settings/UISettingsSelector.h \ … … 664 663 src/selector/UIVirtualBoxEventHandler.h \ 665 664 src/settings/UISettingsDialog.h \ 665 src/settings/UISettingsDialogSpecific.h \ 666 666 src/widgets/UIAddDiskEncryptionPasswordDialog.h \ 667 667 src/widgets/UIBootTable.h \ … … 778 778 src/selector/UIVirtualBoxEventHandler.h \ 779 779 src/settings/UISettingsDialog.h \ 780 src/settings/UISettingsDialogSpecific.h \ 780 781 src/widgets/UIAddDiskEncryptionPasswordDialog.h \ 781 782 src/widgets/UIBootTable.h \ … … 1035 1036 src/selector/graphics/details/UIGDetailsElements.cpp \ 1036 1037 src/selector/graphics/details/UIGMachinePreview.cpp \ 1037 src/settings/UISettingsDialogSpecific.cpp \1038 1038 src/settings/UISettingsPage.cpp \ 1039 1039 src/settings/UISettingsSelector.cpp \ … … 1220 1220 src/settings/UISettingsDefs.cpp \ 1221 1221 src/settings/UISettingsDialog.cpp \ 1222 src/settings/UISettingsDialogSpecific.cpp \ 1222 1223 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 1223 1224 src/widgets/UIBootTable.cpp \ … … 1361 1362 src/settings/UISettingsDefs.cpp \ 1362 1363 src/settings/UISettingsDialog.cpp \ 1364 src/settings/UISettingsDialogSpecific.cpp \ 1363 1365 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 1364 1366 src/widgets/UIBootTable.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp
r71027 r72092 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* GUI includes: */ 23 # include "QIWidgetValidator.h" 24 # include "VBoxGlobal.h" 25 # include "UIExtraDataManager.h" 26 # include "UIMessageCenter.h" 27 # include "UISettingsDefs.h" 23 28 # include "UISettingsDialogSpecific.h" 24 29 # include "UISettingsSerializer.h" 25 # include "UISettingsDefs.h"26 # include "VBoxGlobal.h"27 # include "UIMessageCenter.h"28 # include "UIExtraDataManager.h"29 # include "QIWidgetValidator.h"30 30 # include "UISettingsSelector.h" 31 31 # include "UIVirtualBoxEventHandler.h" 32 32 33 /* GUI includes: Global Preferences: */ 34 # include "UIGlobalSettingsDisplay.h" 35 # include "UIGlobalSettingsExtension.h" 33 36 # include "UIGlobalSettingsGeneral.h" 34 37 # include "UIGlobalSettingsInput.h" 35 # ifdef VBOX_GUI_WITH_NETWORK_MANAGER36 # include "UIGlobalSettingsUpdate.h"37 # endif /* VBOX_GUI_WITH_NETWORK_MANAGER */38 38 # include "UIGlobalSettingsLanguage.h" 39 # include "UIGlobalSettingsDisplay.h"40 39 # include "UIGlobalSettingsNetwork.h" 41 # include "UIGlobalSettingsExtension.h"42 40 # ifdef VBOX_GUI_WITH_NETWORK_MANAGER 43 41 # include "UIGlobalSettingsProxy.h" 44 # endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 45 42 # include "UIGlobalSettingsUpdate.h" 43 # endif 44 45 /* GUI includes: Machine Settings: */ 46 # include "UIMachineSettingsAudio.h" 47 # include "UIMachineSettingsDisplay.h" 46 48 # include "UIMachineSettingsGeneral.h" 47 # include "UIMachineSettingsSystem.h" 48 # include "UIMachineSettingsDisplay.h" 49 # include "UIMachineSettingsStorage.h" 50 # include "UIMachineSettingsAudio.h" 49 # include "UIMachineSettingsInterface.h" 51 50 # include "UIMachineSettingsNetwork.h" 52 51 # include "UIMachineSettingsSerial.h" 52 # include "UIMachineSettingsSF.h" 53 # include "UIMachineSettingsStorage.h" 54 # include "UIMachineSettingsSystem.h" 53 55 # include "UIMachineSettingsUSB.h" 54 # include "UIMachineSettingsSF.h"55 # include "UIMachineSettingsInterface.h"56 56 57 57 /* COM includes: */ … … 62 62 #ifdef VBOX_WS_MAC 63 63 # define VBOX_GUI_WITH_TOOLBAR_SETTINGS 64 #endif /* VBOX_WS_MAC */ 64 #endif 65 66 67 /********************************************************************************************************************************* 68 * Class UISettingsDialogGlobal implementation. * 69 *********************************************************************************************************************************/ 65 70 66 71 UISettingsDialogGlobal::UISettingsDialogGlobal(QWidget *pParent, … … 68 73 const QString &strControl /* = QString() */) 69 74 : UISettingsDialog(pParent) 75 , m_strCategory(strCategory) 76 , m_strControl(strControl) 77 { 78 /* Prepare: */ 79 prepare(); 80 } 81 82 void UISettingsDialogGlobal::retranslateUi() 83 { 84 /* Selector itself: */ 85 m_pSelector->widget()->setWhatsThis(tr("Allows to navigate through Global Property categories")); 86 87 /* General page: */ 88 m_pSelector->setItemText(GlobalSettingsPageType_General, tr("General")); 89 90 /* Input page: */ 91 m_pSelector->setItemText(GlobalSettingsPageType_Input, tr("Input")); 92 93 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 94 /* Update page: */ 95 m_pSelector->setItemText(GlobalSettingsPageType_Update, tr("Update")); 96 #endif 97 98 /* Language page: */ 99 m_pSelector->setItemText(GlobalSettingsPageType_Language, tr("Language")); 100 101 /* Display page: */ 102 m_pSelector->setItemText(GlobalSettingsPageType_Display, tr("Display")); 103 104 /* Network page: */ 105 m_pSelector->setItemText(GlobalSettingsPageType_Network, tr("Network")); 106 107 /* Extension page: */ 108 m_pSelector->setItemText(GlobalSettingsPageType_Extensions, tr("Extensions")); 109 110 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 111 /* Proxy page: */ 112 m_pSelector->setItemText(GlobalSettingsPageType_Proxy, tr("Proxy")); 113 #endif 114 115 /* Polish the selector: */ 116 m_pSelector->polish(); 117 118 /* Base-class UI translation: */ 119 UISettingsDialog::retranslateUi(); 120 121 /* Set dialog's name: */ 122 setWindowTitle(title()); 123 } 124 125 void UISettingsDialogGlobal::loadOwnData() 126 { 127 /* Get properties: */ 128 CSystemProperties comProperties = vboxGlobal().virtualBox().GetSystemProperties(); 129 /* Prepare global data: */ 130 qRegisterMetaType<UISettingsDataGlobal>(); 131 UISettingsDataGlobal data(comProperties); 132 QVariant varData = QVariant::fromValue(data); 133 134 /* Call to base-class: */ 135 UISettingsDialog::loadData(varData); 136 } 137 138 void UISettingsDialogGlobal::saveOwnData() 139 { 140 /* Get properties: */ 141 CSystemProperties comProperties = vboxGlobal().virtualBox().GetSystemProperties(); 142 /* Prepare global data: */ 143 qRegisterMetaType<UISettingsDataGlobal>(); 144 UISettingsDataGlobal data(comProperties); 145 QVariant varData = QVariant::fromValue(data); 146 147 /* Call to base-class: */ 148 UISettingsDialog::saveData(varData); 149 150 /* Get updated properties: */ 151 CSystemProperties comNewProperties = varData.value<UISettingsDataGlobal>().m_properties; 152 /* If properties are not OK => show the error: */ 153 if (!comNewProperties.isOk()) 154 msgCenter().cannotSetSystemProperties(comNewProperties, this); 155 156 /* Mark as saved: */ 157 sltMarkSaved(); 158 } 159 160 QString UISettingsDialogGlobal::titleExtension() const 161 { 162 #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS 163 return m_pSelector->itemText(m_pSelector->currentId()); 164 #else 165 return tr("Preferences"); 166 #endif 167 } 168 169 QString UISettingsDialogGlobal::title() const 170 { 171 return tr("VirtualBox - %1").arg(titleExtension()); 172 } 173 174 void UISettingsDialogGlobal::prepare() 70 175 { 71 176 /* Window icon: */ 72 177 #ifndef VBOX_WS_MAC 73 178 setWindowIcon(QIcon(":/global_settings_16px.png")); 74 #endif /* !VBOX_WS_MAC */179 #endif 75 180 76 181 /* Creating settings pages: */ … … 165 270 setConfigurationAccessLevel(ConfigurationAccessLevel_Full); 166 271 167 /* Retranslate UI: */272 /* Apply language settings: */ 168 273 retranslateUi(); 169 274 170 275 /* Setup settings window: */ 171 if (! strCategory.isNull())172 { 173 m_pSelector->selectByLink( strCategory);276 if (!m_strCategory.isNull()) 277 { 278 m_pSelector->selectByLink(m_strCategory); 174 279 /* Search for a widget with the given name: */ 175 if (! strControl.isNull())176 { 177 if (QWidget *pWidget = m_pStack->findChild<QWidget*>( strControl))280 if (!m_strControl.isNull()) 281 { 282 if (QWidget *pWidget = m_pStack->findChild<QWidget*>(m_strControl)) 178 283 { 179 284 QList<QWidget*> parents; … … 183 288 if (QTabWidget *pTabWidget = qobject_cast<QTabWidget*>(pParentWidget)) 184 289 { 185 /* The tab contents widget is two steps down 186 * (QTabWidget -> QStackedWidget -> QWidget): */ 290 // WORKAROUND: 291 // The tab contents widget is two steps down 292 // (QTabWidget -> QStackedWidget -> QWidget). 187 293 QWidget *pTabPage = parents[parents.count() - 1]; 188 294 if (pTabPage) … … 202 308 } 203 309 204 void UISettingsDialogGlobal::loadOwnData() 205 { 206 /* Get properties: */ 207 CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties(); 208 /* Prepare global data: */ 209 qRegisterMetaType<UISettingsDataGlobal>(); 210 UISettingsDataGlobal data(properties); 211 QVariant varData = QVariant::fromValue(data); 212 213 /* Call to base-class: */ 214 UISettingsDialog::loadData(varData); 215 } 216 217 void UISettingsDialogGlobal::saveOwnData() 218 { 219 /* Get properties: */ 220 CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties(); 221 /* Prepare global data: */ 222 qRegisterMetaType<UISettingsDataGlobal>(); 223 UISettingsDataGlobal data(properties); 224 QVariant varData = QVariant::fromValue(data); 225 226 /* Call to base-class: */ 227 UISettingsDialog::saveData(varData); 228 229 /* Get updated properties: */ 230 CSystemProperties newProperties = varData.value<UISettingsDataGlobal>().m_properties; 231 /* If properties are not OK => show the error: */ 232 if (!newProperties.isOk()) 233 msgCenter().cannotSetSystemProperties(newProperties, this); 234 235 /* Mark as saved: */ 236 sltMarkSaved(); 237 } 238 239 void UISettingsDialogGlobal::retranslateUi() 240 { 241 /* Selector itself: */ 242 m_pSelector->widget()->setWhatsThis(tr("Allows to navigate through Global Property categories")); 243 244 /* General page: */ 245 m_pSelector->setItemText(GlobalSettingsPageType_General, tr("General")); 246 247 /* Input page: */ 248 m_pSelector->setItemText(GlobalSettingsPageType_Input, tr("Input")); 249 250 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 251 /* Update page: */ 252 m_pSelector->setItemText(GlobalSettingsPageType_Update, tr("Update")); 253 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 254 255 /* Language page: */ 256 m_pSelector->setItemText(GlobalSettingsPageType_Language, tr("Language")); 257 258 /* Display page: */ 259 m_pSelector->setItemText(GlobalSettingsPageType_Display, tr("Display")); 260 261 /* Network page: */ 262 m_pSelector->setItemText(GlobalSettingsPageType_Network, tr("Network")); 263 264 /* Extension page: */ 265 m_pSelector->setItemText(GlobalSettingsPageType_Extensions, tr("Extensions")); 266 267 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 268 /* Proxy page: */ 269 m_pSelector->setItemText(GlobalSettingsPageType_Proxy, tr("Proxy")); 270 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 271 272 /* Polish the selector: */ 273 m_pSelector->polish(); 274 275 /* Base-class UI translation: */ 276 UISettingsDialog::retranslateUi(); 277 278 /* Set dialog's name: */ 279 setWindowTitle(title()); 280 } 281 282 QString UISettingsDialogGlobal::titleExtension() const 283 { 284 #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS 285 return m_pSelector->itemText(m_pSelector->currentId()); 286 #else /* VBOX_GUI_WITH_TOOLBAR_SETTINGS */ 287 return tr("Preferences"); 288 #endif /* !VBOX_GUI_WITH_TOOLBAR_SETTINGS */ 289 } 290 291 QString UISettingsDialogGlobal::title() const 292 { 293 return tr("VirtualBox - %1").arg(titleExtension()); 294 } 295 296 bool UISettingsDialogGlobal::isPageAvailable(int iPageId) 310 bool UISettingsDialogGlobal::isPageAvailable(int iPageId) const 297 311 { 298 312 switch (iPageId) … … 302 316 #ifndef VBOX_WITH_NETFLT 303 317 return false; 304 #endif /* !VBOX_WITH_NETFLT */318 #endif 305 319 break; 306 320 } … … 310 324 return true; 311 325 } 326 327 328 /********************************************************************************************************************************* 329 * Class UISettingsDialogMachine implementation. * 330 *********************************************************************************************************************************/ 312 331 313 332 UISettingsDialogMachine::UISettingsDialogMachine(QWidget *pParent, const QString &strMachineId, … … 315 334 : UISettingsDialog(pParent) 316 335 , m_strMachineId(strMachineId) 336 , m_strCategory(strCategory) 337 , m_strControl(strControl) 317 338 , m_fAllowResetFirstRunFlag(false) 318 339 , m_fResetFirstRunFlag(false) 319 340 { 320 /* Window icon: */ 321 #ifndef VBOX_WS_MAC 322 setWindowIcon(QIcon(":/vm_settings_16px.png")); 323 #endif /* VBOX_WS_MAC */ 324 325 /* Allow to reset first-run flag just when medium enumeration was finished: */ 326 connect(&vboxGlobal(), SIGNAL(sigMediumEnumerationFinished()), this, SLOT(sltAllowResetFirstRunFlag())); 327 328 /* Make sure settings window will be updated on session/machine state/data changes: */ 329 connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), 330 this, SLOT(sltSessionStateChanged(QString, KSessionState))); 331 connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), 332 this, SLOT(sltMachineStateChanged(QString, KMachineState))); 333 connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), 334 this, SLOT(sltMachineDataChanged(QString))); 335 336 /* Get corresponding machine (required to determine dialog type and page availability): */ 337 m_machine = vboxGlobal().virtualBox().FindMachine(m_strMachineId); 338 AssertMsg(!m_machine.isNull(), ("Can't find corresponding machine!\n")); 339 m_sessionState = m_machine.GetSessionState(); 340 m_machineState = m_machine.GetState(); 341 342 /* Creating settings pages: */ 343 QList<MachineSettingsPageType> restrictedMachineSettingsPages = gEDataManager->restrictedMachineSettingsPages(m_strMachineId); 344 for (int iPageIndex = MachineSettingsPageType_General; iPageIndex < MachineSettingsPageType_Max; ++iPageIndex) 345 { 346 /* Make sure page was not restricted: */ 347 if (restrictedMachineSettingsPages.contains(static_cast<MachineSettingsPageType>(iPageIndex))) 348 continue; 349 350 /* Make sure page is available: */ 351 if (isPageAvailable(iPageIndex)) 352 { 353 UISettingsPage *pSettingsPage = 0; 354 switch (iPageIndex) 355 { 356 /* General page: */ 357 case MachineSettingsPageType_General: 358 { 359 pSettingsPage = new UIMachineSettingsGeneral; 360 addItem(":/machine_32px.png", ":/machine_24px.png", ":/machine_16px.png", 361 iPageIndex, "#general", pSettingsPage); 362 break; 363 } 364 /* System page: */ 365 case MachineSettingsPageType_System: 366 { 367 pSettingsPage = new UIMachineSettingsSystem; 368 addItem(":/chipset_32px.png", ":/chipset_24px.png", ":/chipset_16px.png", 369 iPageIndex, "#system", pSettingsPage); 370 break; 371 } 372 /* Display page: */ 373 case MachineSettingsPageType_Display: 374 { 375 pSettingsPage = new UIMachineSettingsDisplay; 376 addItem(":/vrdp_32px.png", ":/vrdp_24px.png", ":/vrdp_16px.png", 377 iPageIndex, "#display", pSettingsPage); 378 break; 379 } 380 /* Storage page: */ 381 case MachineSettingsPageType_Storage: 382 { 383 pSettingsPage = new UIMachineSettingsStorage; 384 connect(pSettingsPage, SIGNAL(sigStorageChanged()), this, SLOT(sltResetFirstRunFlag())); 385 addItem(":/hd_32px.png", ":/hd_24px.png", ":/hd_16px.png", 386 iPageIndex, "#storage", pSettingsPage); 387 break; 388 } 389 /* Audio page: */ 390 case MachineSettingsPageType_Audio: 391 { 392 pSettingsPage = new UIMachineSettingsAudio; 393 addItem(":/sound_32px.png", ":/sound_24px.png", ":/sound_16px.png", 394 iPageIndex, "#audio", pSettingsPage); 395 break; 396 } 397 /* Network page: */ 398 case MachineSettingsPageType_Network: 399 { 400 pSettingsPage = new UIMachineSettingsNetworkPage; 401 addItem(":/nw_32px.png", ":/nw_24px.png", ":/nw_16px.png", 402 iPageIndex, "#network", pSettingsPage); 403 break; 404 } 405 /* Ports page: */ 406 case MachineSettingsPageType_Ports: 407 { 408 addItem(":/serial_port_32px.png", ":/serial_port_24px.png", ":/serial_port_16px.png", 409 iPageIndex, "#ports"); 410 break; 411 } 412 /* Serial page: */ 413 case MachineSettingsPageType_Serial: 414 { 415 pSettingsPage = new UIMachineSettingsSerialPage; 416 addItem(":/serial_port_32px.png", ":/serial_port_24px.png", ":/serial_port_16px.png", 417 iPageIndex, "#serialPorts", pSettingsPage, MachineSettingsPageType_Ports); 418 break; 419 } 420 /* USB page: */ 421 case MachineSettingsPageType_USB: 422 { 423 pSettingsPage = new UIMachineSettingsUSB; 424 addItem(":/usb_32px.png", ":/usb_24px.png", ":/usb_16px.png", 425 iPageIndex, "#usb", pSettingsPage, MachineSettingsPageType_Ports); 426 break; 427 } 428 /* Shared Folders page: */ 429 case MachineSettingsPageType_SF: 430 { 431 pSettingsPage = new UIMachineSettingsSF; 432 addItem(":/sf_32px.png", ":/sf_24px.png", ":/sf_16px.png", 433 iPageIndex, "#sharedFolders", pSettingsPage); 434 break; 435 } 436 /* Interface page: */ 437 case MachineSettingsPageType_Interface: 438 { 439 pSettingsPage = new UIMachineSettingsInterface(m_machine.GetId()); 440 addItem(":/interface_32px.png", ":/interface_24px.png", ":/interface_16px.png", 441 iPageIndex, "#userInterface", pSettingsPage); 442 break; 443 } 444 default: 445 break; 446 } 447 } 448 } 449 450 /* Calculate initial configuration access level: */ 451 setConfigurationAccessLevel(::configurationAccessLevel(m_sessionState, m_machineState)); 452 453 /* Retranslate UI: */ 454 retranslateUi(); 455 456 /* Setup settings window: */ 457 if (!strCategory.isNull()) 458 { 459 m_pSelector->selectByLink(strCategory); 460 /* Search for a widget with the given name: */ 461 if (!strControl.isNull()) 462 { 463 if (QWidget *pWidget = m_pStack->findChild<QWidget*>(strControl)) 464 { 465 QList<QWidget*> parents; 466 QWidget *pParentWidget = pWidget; 467 while ((pParentWidget = pParentWidget->parentWidget()) != 0) 468 { 469 if (QTabWidget *pTabWidget = qobject_cast<QTabWidget*>(pParentWidget)) 470 { 471 /* The tab contents widget is two steps down 472 * (QTabWidget -> QStackedWidget -> QWidget): */ 473 QWidget *pTabPage = parents[parents.count() - 1]; 474 if (pTabPage) 475 pTabPage = parents[parents.count() - 2]; 476 if (pTabPage) 477 pTabWidget->setCurrentWidget(pTabPage); 478 } 479 parents.append(pParentWidget); 480 } 481 pWidget->setFocus(); 482 } 483 } 484 } 485 /* First item as default: */ 486 else 487 m_pSelector->selectById(MachineSettingsPageType_General); 341 /* Prepare: */ 342 prepare(); 343 } 344 345 void UISettingsDialogMachine::retranslateUi() 346 { 347 /* Selector itself: */ 348 m_pSelector->widget()->setWhatsThis(tr("Allows to navigate through VM Settings categories")); 349 350 /* We have to make sure that the Network, Serial pages are retranslated 351 * before they are revalidated. Cause: They do string comparing within 352 * vboxGlobal which is retranslated at that point already: */ 353 QEvent event(QEvent::LanguageChange); 354 if (QWidget *pPage = m_pSelector->idToPage(MachineSettingsPageType_Network)) 355 qApp->sendEvent(pPage, &event); 356 if (QWidget *pPage = m_pSelector->idToPage(MachineSettingsPageType_Serial)) 357 qApp->sendEvent(pPage, &event); 358 359 /* General page: */ 360 m_pSelector->setItemText(MachineSettingsPageType_General, tr("General")); 361 362 /* System page: */ 363 m_pSelector->setItemText(MachineSettingsPageType_System, tr("System")); 364 365 /* Display page: */ 366 m_pSelector->setItemText(MachineSettingsPageType_Display, tr("Display")); 367 368 /* Storage page: */ 369 m_pSelector->setItemText(MachineSettingsPageType_Storage, tr("Storage")); 370 371 /* Audio page: */ 372 m_pSelector->setItemText(MachineSettingsPageType_Audio, tr("Audio")); 373 374 /* Network page: */ 375 m_pSelector->setItemText(MachineSettingsPageType_Network, tr("Network")); 376 377 /* Ports page: */ 378 m_pSelector->setItemText(MachineSettingsPageType_Ports, tr("Ports")); 379 380 /* Serial page: */ 381 m_pSelector->setItemText(MachineSettingsPageType_Serial, tr("Serial Ports")); 382 383 /* USB page: */ 384 m_pSelector->setItemText(MachineSettingsPageType_USB, tr("USB")); 385 386 /* SFolders page: */ 387 m_pSelector->setItemText(MachineSettingsPageType_SF, tr("Shared Folders")); 388 389 /* Interface page: */ 390 m_pSelector->setItemText(MachineSettingsPageType_Interface, tr("User Interface")); 391 392 /* Polish the selector: */ 393 m_pSelector->polish(); 394 395 /* Base-class UI translation: */ 396 UISettingsDialog::retranslateUi(); 397 398 /* Set dialog's name: */ 399 setWindowTitle(title()); 488 400 } 489 401 … … 584 496 } 585 497 586 void UISettingsDialogMachine::retranslateUi()587 {588 /* Selector itself: */589 m_pSelector->widget()->setWhatsThis(tr("Allows to navigate through VM Settings categories"));590 591 /* We have to make sure that the Network, Serial pages are retranslated592 * before they are revalidated. Cause: They do string comparing within593 * vboxGlobal which is retranslated at that point already: */594 QEvent event(QEvent::LanguageChange);595 if (QWidget *pPage = m_pSelector->idToPage(MachineSettingsPageType_Network))596 qApp->sendEvent(pPage, &event);597 if (QWidget *pPage = m_pSelector->idToPage(MachineSettingsPageType_Serial))598 qApp->sendEvent(pPage, &event);599 600 /* General page: */601 m_pSelector->setItemText(MachineSettingsPageType_General, tr("General"));602 603 /* System page: */604 m_pSelector->setItemText(MachineSettingsPageType_System, tr("System"));605 606 /* Display page: */607 m_pSelector->setItemText(MachineSettingsPageType_Display, tr("Display"));608 609 /* Storage page: */610 m_pSelector->setItemText(MachineSettingsPageType_Storage, tr("Storage"));611 612 /* Audio page: */613 m_pSelector->setItemText(MachineSettingsPageType_Audio, tr("Audio"));614 615 /* Network page: */616 m_pSelector->setItemText(MachineSettingsPageType_Network, tr("Network"));617 618 /* Ports page: */619 m_pSelector->setItemText(MachineSettingsPageType_Ports, tr("Ports"));620 621 /* Serial page: */622 m_pSelector->setItemText(MachineSettingsPageType_Serial, tr("Serial Ports"));623 624 /* USB page: */625 m_pSelector->setItemText(MachineSettingsPageType_USB, tr("USB"));626 627 /* SFolders page: */628 m_pSelector->setItemText(MachineSettingsPageType_SF, tr("Shared Folders"));629 630 /* Interface page: */631 m_pSelector->setItemText(MachineSettingsPageType_Interface, tr("User Interface"));632 633 /* Polish the selector: */634 m_pSelector->polish();635 636 /* Base-class UI translation: */637 UISettingsDialog::retranslateUi();638 639 /* Set dialog's name: */640 setWindowTitle(title());641 }642 643 498 QString UISettingsDialogMachine::titleExtension() const 644 499 { 645 500 #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS 646 501 return m_pSelector->itemText(m_pSelector->currentId()); 647 #else /* VBOX_GUI_WITH_TOOLBAR_SETTINGS */502 #else 648 503 return tr("Settings"); 649 #endif /* !VBOX_GUI_WITH_TOOLBAR_SETTINGS */504 #endif 650 505 } 651 506 … … 705 560 } 706 561 562 void UISettingsDialogMachine::sltCategoryChanged(int cId) 563 { 564 /* Raise priority of requested page: */ 565 if (serializeProcess()) 566 serializeProcess()->raisePriorityOfPage(cId); 567 568 /* Call to base-class: */ 569 UISettingsDialog::sltCategoryChanged(cId); 570 } 571 707 572 void UISettingsDialogMachine::sltMarkLoaded() 708 573 { … … 738 603 } 739 604 740 void UISettingsDialogMachine::sltSessionStateChanged(QString strMachineId, KSessionState sessionState)605 void UISettingsDialogMachine::sltSessionStateChanged(QString strMachineId, KSessionState enmSessionState) 741 606 { 742 607 /* Ignore if serialization is in progress: */ 743 608 if (isSerializationInProgress()) 744 609 return; 745 746 610 /* Ignore if thats NOT our VM: */ 747 611 if (strMachineId != m_strMachineId) … … 749 613 750 614 /* Ignore if state was NOT actually changed: */ 751 if (m_sessionState == sessionState) 752 return; 753 615 if (m_enmSessionState == enmSessionState) 616 return; 754 617 /* Update current session state: */ 755 m_ sessionState = sessionState;618 m_enmSessionState = enmSessionState; 756 619 757 620 /* Recalculate configuration access level: */ … … 759 622 } 760 623 761 void UISettingsDialogMachine::sltMachineStateChanged(QString strMachineId, KMachineState machineState)624 void UISettingsDialogMachine::sltMachineStateChanged(QString strMachineId, KMachineState enmMachineState) 762 625 { 763 626 /* Ignore if serialization is in progress: */ 764 627 if (isSerializationInProgress()) 765 628 return; 766 767 629 /* Ignore if thats NOT our VM: */ 768 630 if (strMachineId != m_strMachineId) … … 770 632 771 633 /* Ignore if state was NOT actually changed: */ 772 if (m_machineState == machineState) 773 return; 774 634 if (m_enmMachineState == enmMachineState) 635 return; 775 636 /* Update current machine state: */ 776 m_ machineState = machineState;637 m_enmMachineState = enmMachineState; 777 638 778 639 /* Recalculate configuration access level: */ … … 785 646 if (isSerializationInProgress()) 786 647 return; 787 788 648 /* Ignore if thats NOT our VM: */ 789 649 if (strMachineId != m_strMachineId) … … 798 658 } 799 659 800 void UISettingsDialogMachine::sltCategoryChanged(int cId)801 {802 if (serializeProcess())803 serializeProcess()->raisePriorityOfPage(cId);804 805 UISettingsDialog::sltCategoryChanged(cId);806 }807 808 660 void UISettingsDialogMachine::sltAllowResetFirstRunFlag() 809 661 { … … 817 669 } 818 670 819 bool UISettingsDialogMachine::isPageAvailable(int iPageId) 671 void UISettingsDialogMachine::prepare() 672 { 673 /* Window icon: */ 674 #ifndef VBOX_WS_MAC 675 setWindowIcon(QIcon(":/vm_settings_16px.png")); 676 #endif 677 678 /* Allow to reset first-run flag just when medium enumeration was finished: */ 679 connect(&vboxGlobal(), &VBoxGlobal::sigMediumEnumerationFinished, 680 this, &UISettingsDialogMachine::sltAllowResetFirstRunFlag); 681 682 /* Make sure settings window will be updated on session/machine state/data changes: */ 683 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange, 684 this, &UISettingsDialogMachine::sltSessionStateChanged); 685 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, 686 this, &UISettingsDialogMachine::sltMachineStateChanged); 687 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineDataChange, 688 this, &UISettingsDialogMachine::sltMachineDataChanged); 689 690 /* Get corresponding machine (required to determine dialog type and page availability): */ 691 m_machine = vboxGlobal().virtualBox().FindMachine(m_strMachineId); 692 AssertMsg(!m_machine.isNull(), ("Can't find corresponding machine!\n")); 693 m_enmSessionState = m_machine.GetSessionState(); 694 m_enmMachineState = m_machine.GetState(); 695 696 /* Creating settings pages: */ 697 QList<MachineSettingsPageType> restrictedMachineSettingsPages = gEDataManager->restrictedMachineSettingsPages(m_strMachineId); 698 for (int iPageIndex = MachineSettingsPageType_General; iPageIndex < MachineSettingsPageType_Max; ++iPageIndex) 699 { 700 /* Make sure page was not restricted: */ 701 if (restrictedMachineSettingsPages.contains(static_cast<MachineSettingsPageType>(iPageIndex))) 702 continue; 703 704 /* Make sure page is available: */ 705 if (isPageAvailable(iPageIndex)) 706 { 707 UISettingsPage *pSettingsPage = 0; 708 switch (iPageIndex) 709 { 710 /* General page: */ 711 case MachineSettingsPageType_General: 712 { 713 pSettingsPage = new UIMachineSettingsGeneral; 714 addItem(":/machine_32px.png", ":/machine_24px.png", ":/machine_16px.png", 715 iPageIndex, "#general", pSettingsPage); 716 break; 717 } 718 /* System page: */ 719 case MachineSettingsPageType_System: 720 { 721 pSettingsPage = new UIMachineSettingsSystem; 722 addItem(":/chipset_32px.png", ":/chipset_24px.png", ":/chipset_16px.png", 723 iPageIndex, "#system", pSettingsPage); 724 break; 725 } 726 /* Display page: */ 727 case MachineSettingsPageType_Display: 728 { 729 pSettingsPage = new UIMachineSettingsDisplay; 730 addItem(":/vrdp_32px.png", ":/vrdp_24px.png", ":/vrdp_16px.png", 731 iPageIndex, "#display", pSettingsPage); 732 break; 733 } 734 /* Storage page: */ 735 case MachineSettingsPageType_Storage: 736 { 737 pSettingsPage = new UIMachineSettingsStorage; 738 connect(static_cast<UIMachineSettingsStorage*>(pSettingsPage), &UIMachineSettingsStorage::sigStorageChanged, 739 this, &UISettingsDialogMachine::sltResetFirstRunFlag); 740 addItem(":/hd_32px.png", ":/hd_24px.png", ":/hd_16px.png", 741 iPageIndex, "#storage", pSettingsPage); 742 break; 743 } 744 /* Audio page: */ 745 case MachineSettingsPageType_Audio: 746 { 747 pSettingsPage = new UIMachineSettingsAudio; 748 addItem(":/sound_32px.png", ":/sound_24px.png", ":/sound_16px.png", 749 iPageIndex, "#audio", pSettingsPage); 750 break; 751 } 752 /* Network page: */ 753 case MachineSettingsPageType_Network: 754 { 755 pSettingsPage = new UIMachineSettingsNetworkPage; 756 addItem(":/nw_32px.png", ":/nw_24px.png", ":/nw_16px.png", 757 iPageIndex, "#network", pSettingsPage); 758 break; 759 } 760 /* Ports page: */ 761 case MachineSettingsPageType_Ports: 762 { 763 addItem(":/serial_port_32px.png", ":/serial_port_24px.png", ":/serial_port_16px.png", 764 iPageIndex, "#ports"); 765 break; 766 } 767 /* Serial page: */ 768 case MachineSettingsPageType_Serial: 769 { 770 pSettingsPage = new UIMachineSettingsSerialPage; 771 addItem(":/serial_port_32px.png", ":/serial_port_24px.png", ":/serial_port_16px.png", 772 iPageIndex, "#serialPorts", pSettingsPage, MachineSettingsPageType_Ports); 773 break; 774 } 775 /* USB page: */ 776 case MachineSettingsPageType_USB: 777 { 778 pSettingsPage = new UIMachineSettingsUSB; 779 addItem(":/usb_32px.png", ":/usb_24px.png", ":/usb_16px.png", 780 iPageIndex, "#usb", pSettingsPage, MachineSettingsPageType_Ports); 781 break; 782 } 783 /* Shared Folders page: */ 784 case MachineSettingsPageType_SF: 785 { 786 pSettingsPage = new UIMachineSettingsSF; 787 addItem(":/sf_32px.png", ":/sf_24px.png", ":/sf_16px.png", 788 iPageIndex, "#sharedFolders", pSettingsPage); 789 break; 790 } 791 /* Interface page: */ 792 case MachineSettingsPageType_Interface: 793 { 794 pSettingsPage = new UIMachineSettingsInterface(m_machine.GetId()); 795 addItem(":/interface_32px.png", ":/interface_24px.png", ":/interface_16px.png", 796 iPageIndex, "#userInterface", pSettingsPage); 797 break; 798 } 799 default: 800 break; 801 } 802 } 803 } 804 805 /* Calculate initial configuration access level: */ 806 setConfigurationAccessLevel(::configurationAccessLevel(m_enmSessionState, m_enmMachineState)); 807 808 /* Apply language settings: */ 809 retranslateUi(); 810 811 /* Setup settings window: */ 812 if (!m_strCategory.isNull()) 813 { 814 m_pSelector->selectByLink(m_strCategory); 815 /* Search for a widget with the given name: */ 816 if (!m_strControl.isNull()) 817 { 818 if (QWidget *pWidget = m_pStack->findChild<QWidget*>(m_strControl)) 819 { 820 QList<QWidget*> parents; 821 QWidget *pParentWidget = pWidget; 822 while ((pParentWidget = pParentWidget->parentWidget()) != 0) 823 { 824 if (QTabWidget *pTabWidget = qobject_cast<QTabWidget*>(pParentWidget)) 825 { 826 // WORKAROUND: 827 // The tab contents widget is two steps down 828 // (QTabWidget -> QStackedWidget -> QWidget). 829 QWidget *pTabPage = parents[parents.count() - 1]; 830 if (pTabPage) 831 pTabPage = parents[parents.count() - 2]; 832 if (pTabPage) 833 pTabWidget->setCurrentWidget(pTabPage); 834 } 835 parents.append(pParentWidget); 836 } 837 pWidget->setFocus(); 838 } 839 } 840 } 841 /* First item as default: */ 842 else 843 m_pSelector->selectById(MachineSettingsPageType_General); 844 } 845 846 bool UISettingsDialogMachine::isPageAvailable(int iPageId) const 820 847 { 821 848 if (m_machine.isNull()) … … 869 896 { 870 897 /* Determine new configuration access level: */ 871 ConfigurationAccessLevel newConfigurationAccessLevel = ::configurationAccessLevel(m_sessionState, m_machineState);898 const ConfigurationAccessLevel newConfigurationAccessLevel = ::configurationAccessLevel(m_enmSessionState, m_enmMachineState); 872 899 873 900 /* Make sure someting changed: */ … … 876 903 877 904 /* Should we warn a user about access level decrease? */ 878 bool fShouldWeWarn = configurationAccessLevel() == ConfigurationAccessLevel_Full;905 const bool fShouldWeWarn = configurationAccessLevel() == ConfigurationAccessLevel_Full; 879 906 880 907 /* Apply new configuration access level: */ … … 885 912 msgCenter().warnAboutStateChange(this); 886 913 } 887 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.h
r71027 r72092 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UISettingsDialogSpecific_h__19 #define __ UISettingsDialogSpecific_h__18 #ifndef ___UISettingsDialogSpecific_h___ 19 #define ___UISettingsDialogSpecific_h___ 20 20 21 21 /* GUI includes: */ … … 24 24 /* COM includes: */ 25 25 #include "COMEnums.h" 26 #include "CSession.h"27 26 #include "CConsole.h" 28 27 #include "CMachine.h" 28 #include "CSession.h" 29 29 30 /* Dialog which encapsulate all the specific functionalities of the Global Settings */ 31 class UISettingsDialogGlobal : public UISettingsDialog 30 31 /** UISettingsDialog extension encapsulating all the specific functionality of the Global Preferences. */ 32 class SHARED_LIBRARY_STUFF UISettingsDialogGlobal : public UISettingsDialog 32 33 { 33 34 Q_OBJECT; … … 35 36 public: 36 37 38 /** Constructs settings dialog passing @a pParent to the base-class. 39 * @param strCategory Brings the name of category to be opened. 40 * @param strControl Brings the name of control to be focused. */ 37 41 UISettingsDialogGlobal(QWidget *pParent, 38 42 const QString &strCategory = QString(), … … 41 45 protected: 42 46 47 /** Handles translation event. */ 48 virtual void retranslateUi() /* override */; 49 43 50 /** Loads the data from the corresponding source. */ 44 v oid loadOwnData();51 virtual void loadOwnData() /* override */; 45 52 /** Saves the data to the corresponding source. */ 46 void saveOwnData(); 47 48 void retranslateUi(); 53 virtual void saveOwnData() /* override */; 49 54 50 55 /** Returns the dialog title extension. */ 51 QString titleExtension() const;56 virtual QString titleExtension() const /* override */; 52 57 /** Returns the dialog title. */ 53 QString title() const;58 virtual QString title() const /* override */; 54 59 55 60 private: 56 61 57 bool isPageAvailable(int iPageId); 62 /** Prepares all. */ 63 void prepare(); 64 65 /** Returns whether page with certain @a iPageId is available. */ 66 bool isPageAvailable(int iPageId) const; 67 68 /** Holds the name of category to be opened. */ 69 QString m_strCategory; 70 /** Holds the name of control to be focused. */ 71 QString m_strControl; 58 72 }; 59 73 60 /* Dialog which encapsulate all the specific functionalities of the Virtual Machine Settings */ 61 class UISettingsDialogMachine : public UISettingsDialog 74 75 /** UISettingsDialog extension encapsulating all the specific functionality of the Machine Settings. */ 76 class SHARED_LIBRARY_STUFF UISettingsDialogMachine : public UISettingsDialog 62 77 { 63 78 Q_OBJECT; … … 65 80 public: 66 81 82 /** Constructs settings dialog passing @a pParent to the base-class. 83 * @param strMachineId Brings the machine ID. 84 * @param strCategory Brings the name of category to be opened. 85 * @param strControl Brings the name of control to be focused. */ 67 86 UISettingsDialogMachine(QWidget *pParent, const QString &strMachineId, 68 87 const QString &strCategory, const QString &strControl); … … 70 89 protected: 71 90 91 /** Handles translation event. */ 92 virtual void retranslateUi() /* override */; 93 72 94 /** Loads the data from the corresponding source. */ 73 v oid loadOwnData();95 virtual void loadOwnData() /* override */; 74 96 /** Saves the data to the corresponding source. */ 75 void saveOwnData(); 76 77 void retranslateUi(); 97 virtual void saveOwnData() /* override */; 78 98 79 99 /** Returns the dialog title extension. */ 80 QString titleExtension() const;100 virtual QString titleExtension() const /* override */; 81 101 /** Returns the dialog title. */ 82 QString title() const;102 virtual QString title() const /* override */; 83 103 84 void recorrelate(UISettingsPage *pSettingsPage); 104 /** Verifies data integrity between certain @a pSettingsPage and other pages. */ 105 virtual void recorrelate(UISettingsPage *pSettingsPage) /* override */; 106 107 protected slots: 108 109 /** Handles category change to @a cId. */ 110 virtual void sltCategoryChanged(int cId) /* override */; 111 112 /** Marks dialog loaded. */ 113 virtual void sltMarkLoaded() /* override */; 114 /** Marks dialog saved. */ 115 virtual void sltMarkSaved() /* override */; 85 116 86 117 private slots: 87 118 88 void sltMarkLoaded(); 89 void sltMarkSaved(); 90 void sltSessionStateChanged(QString strMachineId, KSessionState sessionState); 91 void sltMachineStateChanged(QString strMachineId, KMachineState machineState); 119 /** Handles session state change for machine with certain @a strMachineId to @a enmSessionState. */ 120 void sltSessionStateChanged(QString strMachineId, KSessionState enmSessionState); 121 /** Handles machine state change for machine with certain @a strMachineId to @a enmMachineState. */ 122 void sltMachineStateChanged(QString strMachineId, KMachineState enmMachineState); 123 /** Handles machine data change for machine with certain @a strMachineId. */ 92 124 void sltMachineDataChanged(QString strMachineId); 93 void sltCategoryChanged(int cId); 125 126 /** Handles request to allow to reset first run flag. */ 94 127 void sltAllowResetFirstRunFlag(); 128 /** Handles request to reset first run flag. */ 95 129 void sltResetFirstRunFlag(); 96 130 97 131 private: 98 132 99 bool isPageAvailable(int iPageId); 133 /** Prepares all. */ 134 void prepare(); 135 136 /** Returns whether page with certain @a iPageId is available. */ 137 bool isPageAvailable(int iPageId) const; 138 139 /** Returns whether settings were changed. */ 100 140 bool isSettingsChanged(); 101 141 102 /* Recalculates configuration access level. */142 /** Recalculates configuration access level. */ 103 143 void updateConfigurationAccessLevel(); 104 144 105 QString m_strMachineId; 106 KSessionState m_sessionState; 107 KMachineState m_machineState; 145 /** Holds the machine ID. */ 146 QString m_strMachineId; 147 /** Holds the name of category to be opened. */ 148 QString m_strCategory; 149 /** Holds the name of control to be focused. */ 150 QString m_strControl; 108 151 109 CSession m_session; 110 CMachine m_machine; 111 CConsole m_console; 152 /** Holds the session state. */ 153 KSessionState m_enmSessionState; 154 /** Holds the machine state. */ 155 KMachineState m_enmMachineState; 112 156 113 bool m_fAllowResetFirstRunFlag; 114 bool m_fResetFirstRunFlag; 157 /** Holds the session reference. */ 158 CSession m_session; 159 /** Holds the machine reference. */ 160 CMachine m_machine; 161 /** Holds the console reference. */ 162 CConsole m_console; 163 164 /** Holds whether we are allowed to reset first run flag. */ 165 bool m_fAllowResetFirstRunFlag : 1; 166 /** Holds whether we have request to reset first run flag. */ 167 bool m_fResetFirstRunFlag : 1; 115 168 }; 116 169 117 #endif // __UISettingsDialogSpecific_h__118 170 171 #endif /* !___UISettingsDialogSpecific_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.