Changeset 66501 in vbox
- Timestamp:
- Apr 10, 2017 3:23:15 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
r66497 r66501 58 58 /* COM includes: */ 59 59 # include "CAudioAdapter.h" 60 # include "CParallelPort.h" 60 61 # include "CConsole.h" 61 62 # include "CMachine.h" … … 1221 1222 tr("Cannot save network adapter settings."), 1222 1223 formatErrorInfo(comAdapter)); 1224 } 1225 1226 void UIMessageCenter::cannotSaveParallelSettings(const CMachine &comMachine, QWidget *pParent /* = 0 */) 1227 { 1228 error(pParent, MessageType_Error, 1229 tr("Cannot save parallel ports settings."), 1230 formatErrorInfo(comMachine)); 1231 } 1232 1233 void UIMessageCenter::cannotSaveParallelPortSettings(const CParallelPort &comPort, QWidget *pParent /* = 0 */) 1234 { 1235 error(pParent, MessageType_Error, 1236 tr("Cannot save parallel port settings."), 1237 formatErrorInfo(comPort)); 1223 1238 } 1224 1239 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r66497 r66501 249 249 void cannotSaveNetworkSettings(const CMachine &comMachine, QWidget *pParent = 0); 250 250 void cannotSaveNetworkAdapterSettings(const CNetworkAdapter &comAdapter, QWidget *pParent = 0); 251 void cannotSaveParallelSettings(const CMachine &comMachine, QWidget *pParent = 0); 252 void cannotSaveParallelPortSettings(const CParallelPort &comPort, QWidget *pParent = 0); 251 253 void cannotAttachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0); 252 254 bool warnAboutIncorrectPort(QWidget *pParent = 0) const; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.cpp
r66460 r66501 27 27 # include "QIWidgetValidator.h" 28 28 # include "UIMachineSettingsParallel.h" 29 # include "UIMessageCenter.h" 29 30 # include "VBoxGlobal.h" 30 31 … … 409 410 UISettingsPageMachine::fetchData(data); 410 411 411 /* Make sure machine is offline & parallel data was changed: */ 412 if (isMachineOffline() && m_pCache->wasChanged()) 413 { 414 /* For each parallel port: */ 415 for (int iPort = 0; iPort < m_pTabWidget->count(); ++iPort) 416 { 417 /* Get old parallel data from the cache: */ 418 const UIDataSettingsMachineParallelPort &oldPortData = m_pCache->base().m_ports.at(iPort); 419 /* Get new parallel data from the cache: */ 420 const UIDataSettingsMachineParallelPort &newPortData = m_pCache->data().m_ports.at(iPort); 421 422 /* Make sure port data was changed: */ 423 if (newPortData != oldPortData) 424 { 425 /* Check if port still valid: */ 426 CParallelPort comPort = m_machine.GetParallelPort(iPort); 427 /* Store new adapter data: */ 428 if (!comPort.isNull()) 429 { 430 /* Whether the port is enabled: */ 431 if ( comPort.isOk() 432 && newPortData.m_fPortEnabled != oldPortData.m_fPortEnabled) 433 comPort.SetEnabled(newPortData.m_fPortEnabled); 434 /* Port IRQ: */ 435 if ( comPort.isOk() 436 && newPortData.m_uIRQ != oldPortData.m_uIRQ) 437 comPort.SetIRQ(newPortData.m_uIRQ); 438 /* Port IO base: */ 439 if ( comPort.isOk() 440 && newPortData.m_uIOBase != oldPortData.m_uIOBase) 441 comPort.SetIOBase(newPortData.m_uIOBase); 442 /* Port path: */ 443 if ( comPort.isOk() 444 && newPortData.m_strPath != oldPortData.m_strPath) 445 comPort.SetPath(newPortData.m_strPath); 446 } 447 } 448 } 449 } 412 /* Update parallel data and failing state: */ 413 setFailed(!saveParallelData()); 450 414 451 415 /* Upload machine to data: */ … … 589 553 } 590 554 555 bool UIMachineSettingsParallelPage::saveParallelData() 556 { 557 /* Prepare result: */ 558 bool fSuccess = true; 559 /* Save parallel settings from the cache: */ 560 if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged()) 561 { 562 /* For each port: */ 563 for (int iSlot = 0; fSuccess && iSlot < m_pTabWidget->count(); ++iSlot) 564 fSuccess = savePortData(iSlot); 565 } 566 /* Return result: */ 567 return fSuccess; 568 } 569 570 bool UIMachineSettingsParallelPage::savePortData(int iPort) 571 { 572 /* Prepare result: */ 573 bool fSuccess = true; 574 /* Save adapter settings from the cache: */ 575 if (fSuccess) 576 { 577 /* Get old parallel data from the cache: */ 578 const UIDataSettingsMachineParallelPort &oldPortData = m_pCache->base().m_ports.at(iPort); 579 /* Get new parallel data from the cache: */ 580 const UIDataSettingsMachineParallelPort &newPortData = m_pCache->data().m_ports.at(iPort); 581 582 /* Make sure port data was changed: */ 583 if (newPortData != oldPortData) 584 { 585 /* Get parallel port for further activities: */ 586 CParallelPort comPort = m_machine.GetParallelPort(iPort); 587 fSuccess = m_machine.isOk() && comPort.isNotNull(); 588 /* Show error message if necessary: */ 589 if (!fSuccess) 590 msgCenter().cannotSaveParallelSettings(m_machine, this); 591 592 /* Save whether the port is enabled: */ 593 if (fSuccess && isMachineOffline() && newPortData.m_fPortEnabled != oldPortData.m_fPortEnabled) 594 { 595 comPort.SetEnabled(newPortData.m_fPortEnabled); 596 fSuccess = comPort.isOk(); 597 } 598 /* Save port IRQ: */ 599 if (fSuccess && isMachineOffline() && newPortData.m_uIRQ != oldPortData.m_uIRQ) 600 { 601 comPort.SetIRQ(newPortData.m_uIRQ); 602 fSuccess = comPort.isOk(); 603 } 604 /* Save port IO base: */ 605 if (fSuccess && isMachineOffline() && newPortData.m_uIOBase != oldPortData.m_uIOBase) 606 { 607 comPort.SetIOBase(newPortData.m_uIOBase); 608 fSuccess = comPort.isOk(); 609 } 610 /* Save port path: */ 611 if (fSuccess && isMachineOffline() && newPortData.m_strPath != oldPortData.m_strPath) 612 { 613 comPort.SetPath(newPortData.m_strPath); 614 fSuccess = comPort.isOk(); 615 } 616 /* Show error message if necessary: */ 617 if (!fSuccess) 618 msgCenter().cannotSaveParallelPortSettings(comPort, this); 619 } 620 } 621 /* Return result: */ 622 return fSuccess; 623 } 624 591 625 # include "UIMachineSettingsParallel.moc" 592 626 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsParallel.h
r66365 r66501 77 77 void cleanup(); 78 78 79 /** Saves existing parallel data from the cache. */ 80 bool saveParallelData(); 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.