Changeset 66502 in vbox
- Timestamp:
- Apr 10, 2017 3:27:38 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r66501 r66502 59 59 # include "CAudioAdapter.h" 60 60 # include "CParallelPort.h" 61 # include "CSerialPort.h" 61 62 # include "CConsole.h" 62 63 # include "CMachine.h" … … 1235 1236 error(pParent, MessageType_Error, 1236 1237 tr("Cannot save parallel port settings."), 1238 formatErrorInfo(comPort)); 1239 } 1240 1241 void UIMessageCenter::cannotSaveSerialSettings(const CMachine &comMachine, QWidget *pParent /* = 0 */) 1242 { 1243 error(pParent, MessageType_Error, 1244 tr("Cannot save serial ports settings."), 1245 formatErrorInfo(comMachine)); 1246 } 1247 1248 void UIMessageCenter::cannotSaveSerialPortSettings(const CSerialPort &comPort, QWidget *pParent /* = 0 */) 1249 { 1250 error(pParent, MessageType_Error, 1251 tr("Cannot save serial port settings."), 1237 1252 formatErrorInfo(comPort)); 1238 1253 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r66501 r66502 251 251 void cannotSaveParallelSettings(const CMachine &comMachine, QWidget *pParent = 0); 252 252 void cannotSaveParallelPortSettings(const CParallelPort &comPort, QWidget *pParent = 0); 253 void cannotSaveSerialSettings(const CMachine &comMachine, QWidget *pParent = 0); 254 void cannotSaveSerialPortSettings(const CSerialPort &comPort, QWidget *pParent = 0); 253 255 void cannotAttachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0); 254 256 bool warnAboutIncorrectPort(QWidget *pParent = 0) const; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp
r66460 r66502 28 28 # include "UIConverter.h" 29 29 # include "UIMachineSettingsSerial.h" 30 # include "UIMessageCenter.h" 30 31 # include "VBoxGlobal.h" 31 32 … … 459 460 UISettingsPageMachine::fetchData(data); 460 461 461 /* Make sure machine is offline & serial data was changed: */ 462 if (isMachineOffline() && m_pCache->wasChanged()) 463 { 464 /* For each serial port: */ 465 for (int iPort = 0; iPort < m_pTabWidget->count(); ++iPort) 466 { 467 /* Get old serial data from the cache: */ 468 const UIDataSettingsMachineSerialPort &oldPortData = m_pCache->base().m_ports.at(iPort); 469 /* Get new serial data from the cache: */ 470 const UIDataSettingsMachineSerialPort &newPortData = m_pCache->data().m_ports.at(iPort); 471 472 /* Make sure port data was changed: */ 473 if (newPortData != oldPortData) 474 { 475 /* Check if port still valid: */ 476 CSerialPort comPort = m_machine.GetSerialPort(iPort); 477 /* Store new adapter data: */ 478 if (!comPort.isNull()) 479 { 480 /* Whether the port is enabled: */ 481 if ( comPort.isOk() 482 && newPortData.m_fPortEnabled != oldPortData.m_fPortEnabled) 483 comPort.SetEnabled(newPortData.m_fPortEnabled); 484 /* Port IRQ: */ 485 if ( comPort.isOk() 486 && newPortData.m_uIRQ != oldPortData.m_uIRQ) 487 comPort.SetIRQ(newPortData.m_uIRQ); 488 /* Port IO base: */ 489 if ( comPort.isOk() 490 && newPortData.m_uIOBase != oldPortData.m_uIOBase) 491 comPort.SetIOBase(newPortData.m_uIOBase); 492 /* Whether the port is server: */ 493 if ( comPort.isOk() 494 && newPortData.m_fServer != oldPortData.m_fServer) 495 comPort.SetServer(newPortData.m_fServer); 496 /* Port path: */ 497 if ( comPort.isOk() 498 && newPortData.m_strPath != oldPortData.m_strPath) 499 comPort.SetPath(newPortData.m_strPath); 500 /* This *must* be last. The host mode will be changed to disconnected if 501 * some of the necessary settings above will not meet the requirements for 502 * the selected mode. */ 503 if ( comPort.isOk() 504 && newPortData.m_hostMode != oldPortData.m_hostMode) 505 comPort.SetHostMode(newPortData.m_hostMode); 506 } 507 } 508 } 509 } 462 /* Update serial data and failing state: */ 463 setFailed(!saveSerialData()); 510 464 511 465 /* Upload machine to data: */ … … 656 610 } 657 611 612 bool UIMachineSettingsSerialPage::saveSerialData() 613 { 614 /* Prepare result: */ 615 bool fSuccess = true; 616 /* Save serial settings from the cache: */ 617 if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged()) 618 { 619 /* For each port: */ 620 for (int iSlot = 0; fSuccess && iSlot < m_pTabWidget->count(); ++iSlot) 621 fSuccess = savePortData(iSlot); 622 } 623 /* Return result: */ 624 return fSuccess; 625 } 626 627 bool UIMachineSettingsSerialPage::savePortData(int iPort) 628 { 629 /* Prepare result: */ 630 bool fSuccess = true; 631 /* Save adapter settings from the cache: */ 632 if (fSuccess) 633 { 634 /* Get old serial data from the cache: */ 635 const UIDataSettingsMachineSerialPort &oldPortData = m_pCache->base().m_ports.at(iPort); 636 /* Get new serial data from the cache: */ 637 const UIDataSettingsMachineSerialPort &newPortData = m_pCache->data().m_ports.at(iPort); 638 639 /* Make sure port data was changed: */ 640 if (newPortData != oldPortData) 641 { 642 /* Get serial port for further activities: */ 643 CSerialPort comPort = m_machine.GetSerialPort(iPort); 644 fSuccess = m_machine.isOk() && comPort.isNotNull(); 645 /* Show error message if necessary: */ 646 if (!fSuccess) 647 msgCenter().cannotSaveSerialSettings(m_machine, this); 648 649 // This *must* be first. 650 // If the requested host mode is changed to disconnected we should do it first. 651 // That allows to automatically fulfill the requirements for some of the settings below. 652 /* Save port host mode: */ 653 if ( fSuccess && isMachineOffline() 654 && newPortData.m_hostMode != oldPortData.m_hostMode 655 && newPortData.m_hostMode == KPortMode_Disconnected) 656 { 657 comPort.SetHostMode(newPortData.m_hostMode); 658 fSuccess = comPort.isOk(); 659 } 660 /* Save whether the port is enabled: */ 661 if (fSuccess && isMachineOffline() && newPortData.m_fPortEnabled != oldPortData.m_fPortEnabled) 662 { 663 comPort.SetEnabled(newPortData.m_fPortEnabled); 664 fSuccess = comPort.isOk(); 665 } 666 /* Save port IRQ: */ 667 if (fSuccess && isMachineOffline() && newPortData.m_uIRQ != oldPortData.m_uIRQ) 668 { 669 comPort.SetIRQ(newPortData.m_uIRQ); 670 fSuccess = comPort.isOk(); 671 } 672 /* Save port IO base: */ 673 if (fSuccess && isMachineOffline() && newPortData.m_uIOBase != oldPortData.m_uIOBase) 674 { 675 comPort.SetIOBase(newPortData.m_uIOBase); 676 fSuccess = comPort.isOk(); 677 } 678 /* Save whether the port is server: */ 679 if (fSuccess && isMachineOffline() && newPortData.m_fServer != oldPortData.m_fServer) 680 { 681 comPort.SetServer(newPortData.m_fServer); 682 fSuccess = comPort.isOk(); 683 } 684 /* Save port path: */ 685 if (fSuccess && isMachineOffline() && newPortData.m_strPath != oldPortData.m_strPath) 686 { 687 comPort.SetPath(newPortData.m_strPath); 688 fSuccess = comPort.isOk(); 689 } 690 // This *must* be last. 691 // The host mode will be changed to disconnected if some of the necessary 692 // settings above will not meet the requirements for the selected mode. 693 /* Save port host mode: */ 694 if ( fSuccess && isMachineOffline() 695 && newPortData.m_hostMode != oldPortData.m_hostMode 696 && newPortData.m_hostMode != KPortMode_Disconnected) 697 { 698 comPort.SetHostMode(newPortData.m_hostMode); 699 fSuccess = comPort.isOk(); 700 } 701 /* Show error message if necessary: */ 702 if (!fSuccess) 703 msgCenter().cannotSaveSerialPortSettings(comPort, this); 704 } 705 } 706 /* Return result: */ 707 return fSuccess; 708 } 709 658 710 # include "UIMachineSettingsSerial.moc" 659 711 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.h
r66366 r66502 77 77 void cleanup(); 78 78 79 /** Saves existing serial data from the cache. */ 80 bool saveSerialData(); 81 /** Saves existing port data from the cache. */ 82 bool savePortData(int iPort); 83 79 84 /** Holds the tab-widget instance. */ 80 85 QITabWidget *m_pTabWidget;
Note:
See TracChangeset
for help on using the changeset viewer.