Changeset 80215 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 9, 2019 5:08:08 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 132660
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDetailsGenerator.cpp
r80139 r80215 563 563 for (ulong uSlot = 0; uSlot < uCount; ++uSlot) 564 564 { 565 const QString strAnchorType = QString("network_attachment_type"); 565 566 const CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot); 566 567 … … 570 571 571 572 /* Gather adapter information: */ 572 const KNetworkAttachmentType enm Type = comAdapter.GetAttachmentType();573 const QString strAttachmentTemplate = gpConverter->toString(comAdapter.GetAdapterType()).replace(QRegExp("\\s\\(.+\\)"), " ( %1)");573 const KNetworkAttachmentType enmAttachmentType = comAdapter.GetAttachmentType(); 574 const QString strAttachmentTemplate = gpConverter->toString(comAdapter.GetAdapterType()).replace(QRegExp("\\s\\(.+\\)"), " (<a href=#%1,%2;%3;%4>%5</a>)"); 574 575 QString strAttachmentType; 575 switch (enm Type)576 switch (enmAttachmentType) 576 577 { 577 578 case KNetworkAttachmentType_NAT: 578 579 { 579 580 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NAT) 580 strAttachmentType = strAttachmentTemplate.arg(gpConverter->toString(enmType)); 581 strAttachmentType = strAttachmentTemplate 582 .arg(strAnchorType) 583 .arg(uSlot) 584 .arg((int)KNetworkAttachmentType_NAT) 585 .arg(QString()) 586 .arg(gpConverter->toString(KNetworkAttachmentType_NAT)); 581 587 break; 582 588 } … … 584 590 { 585 591 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_BridgetAdapter) 586 strAttachmentType = strAttachmentTemplate.arg(QApplication::translate("UIDetails", "Bridged Adapter, %1", "details (network)") 587 .arg(comAdapter.GetBridgedInterface())); 592 { 593 const QString strName = comAdapter.GetBridgedInterface(); 594 strAttachmentType = strAttachmentTemplate 595 .arg(strAnchorType) 596 .arg(uSlot) 597 .arg((int)KNetworkAttachmentType_Bridged) 598 .arg(strName) 599 .arg(QApplication::translate("UIDetails", "Bridged Adapter, %1", "details (network)") 600 .arg(strName)); 601 } 588 602 break; 589 603 } … … 591 605 { 592 606 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_InternalNetwork) 593 strAttachmentType = strAttachmentTemplate.arg(QApplication::translate("UIDetails", "Internal Network, '%1'", "details (network)") 594 .arg(comAdapter.GetInternalNetwork())); 607 { 608 const QString strName = comAdapter.GetInternalNetwork(); 609 strAttachmentType = strAttachmentTemplate 610 .arg(strAnchorType) 611 .arg(uSlot) 612 .arg((int)KNetworkAttachmentType_Internal) 613 .arg(strName) 614 .arg(QApplication::translate("UIDetails", "Internal Network, '%1'", "details (network)") 615 .arg(strName)); 616 } 595 617 break; 596 618 } … … 598 620 { 599 621 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_HostOnlyAdapter) 600 strAttachmentType = strAttachmentTemplate.arg(QApplication::translate("UIDetails", "Host-only Adapter, '%1'", "details (network)") 601 .arg(comAdapter.GetHostOnlyInterface())); 622 { 623 const QString strName = comAdapter.GetHostOnlyInterface(); 624 strAttachmentType = strAttachmentTemplate 625 .arg(strAnchorType) 626 .arg(uSlot) 627 .arg((int)KNetworkAttachmentType_HostOnly) 628 .arg(strName) 629 .arg(QApplication::translate("UIDetails", "Host-only Adapter, '%1'", "details (network)") 630 .arg(strName)); 631 } 602 632 break; 603 633 } … … 606 636 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_GenericDriver) 607 637 { 638 const QString strName = comAdapter.GetGenericDriver(); 608 639 const QString strGenericDriverProperties(summarizeGenericProperties(comAdapter)); 609 strAttachmentType = strGenericDriverProperties.isNull() ? 610 strAttachmentTemplate.arg(QApplication::translate("UIDetails", "Generic Driver, '%1'", "details (network)") 611 .arg(comAdapter.GetGenericDriver())) : 612 strAttachmentTemplate.arg(QApplication::translate("UIDetails", "Generic Driver, '%1' { %2 }", "details (network)") 613 .arg(comAdapter.GetGenericDriver(), strGenericDriverProperties)); 640 strAttachmentType = strGenericDriverProperties.isNull() 641 ? strAttachmentTemplate 642 .arg(strAnchorType) 643 .arg(uSlot) 644 .arg((int)KNetworkAttachmentType_Generic) 645 .arg(strName) 646 .arg(QApplication::translate("UIDetails", "Generic Driver, '%1'", "details (network)") 647 .arg(strName)) 648 : strAttachmentTemplate 649 .arg(strAnchorType) 650 .arg(uSlot) 651 .arg((int)KNetworkAttachmentType_Generic) 652 .arg(strName) 653 .arg(QApplication::translate("UIDetails", "Generic Driver, '%1' { %2 }", "details (network)") 654 .arg(strName, strGenericDriverProperties)); 614 655 } 615 656 break; … … 618 659 { 619 660 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NATNetwork) 620 strAttachmentType = strAttachmentTemplate.arg(QApplication::translate("UIDetails", "NAT Network, '%1'", "details (network)") 621 .arg(comAdapter.GetNATNetwork())); 661 { 662 const QString strName = comAdapter.GetNATNetwork(); 663 strAttachmentType = strAttachmentTemplate 664 .arg(strAnchorType) 665 .arg(uSlot) 666 .arg((int)KNetworkAttachmentType_NATNetwork) 667 .arg(strName) 668 .arg(QApplication::translate("UIDetails", "NAT Network, '%1'", "details (network)") 669 .arg(strName)); 670 } 622 671 break; 623 672 } … … 625 674 { 626 675 if (fOptions & UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NotAttached) 627 strAttachmentType = strAttachmentTemplate.arg(gpConverter->toString(enmType)); 676 strAttachmentType = strAttachmentTemplate 677 .arg(strAnchorType) 678 .arg(uSlot) 679 .arg((int)enmAttachmentType) 680 .arg(QString()) 681 .arg(gpConverter->toString(enmAttachmentType)); 628 682 break; 629 683 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMachineAttributeSetter.cpp
r80139 r80215 27 27 /* COM includes: */ 28 28 #include "CAudioAdapter.h" 29 #include "CNetworkAdapter.h" 29 30 #include "CUSBController.h" 30 31 … … 215 216 break; 216 217 } 218 case MachineAttribute_NetworkAttachmentType: 219 { 220 /* Acquire value itself: */ 221 const UINetworkAdapterDescriptor nad = guiAttribute.value<UINetworkAdapterDescriptor>(); 222 /* Acquire network adapter: */ 223 CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(nad.m_iSlot); 224 if (!comMachine.isOk()) 225 { 226 msgCenter().cannotAcquireMachineParameter(comMachine); 227 fErrorHappened = true; 228 break; 229 } 230 /* Change network adapter attachment type: */ 231 comAdapter.SetAttachmentType(nad.m_enmType); 232 if (!comAdapter.isOk()) 233 { 234 msgCenter().cannotChangeNetworkAdapterAttribute(comAdapter); 235 fErrorHappened = true; 236 break; 237 } 238 /* Change network adapter name: */ 239 switch (nad.m_enmType) 240 { 241 case KNetworkAttachmentType_Bridged: comAdapter.SetBridgedInterface(nad.m_strName); break; 242 case KNetworkAttachmentType_Internal: comAdapter.SetInternalNetwork(nad.m_strName); break; 243 case KNetworkAttachmentType_HostOnly: comAdapter.SetHostOnlyInterface(nad.m_strName); break; 244 case KNetworkAttachmentType_Generic: comAdapter.SetGenericDriver(nad.m_strName); break; 245 case KNetworkAttachmentType_NATNetwork: comAdapter.SetNATNetwork(nad.m_strName); break; 246 default: break; 247 } 248 if (!comAdapter.isOk()) 249 { 250 msgCenter().cannotChangeNetworkAdapterAttribute(comAdapter); 251 fErrorHappened = true; 252 } 253 break; 254 } 217 255 case MachineAttribute_USBControllerType: 218 256 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMachineAttributeSetter.h
r80139 r80215 39 39 MachineAttribute_AudioHostDriverType, 40 40 MachineAttribute_AudioControllerType, 41 MachineAttribute_NetworkAttachmentType, 41 42 MachineAttribute_USBControllerType, 42 43 }; 44 45 /** Contains short network adapter description. */ 46 struct UINetworkAdapterDescriptor 47 { 48 /** Composes network adapter descriptor for certain @a iSlot, @a enmType and @a strName. */ 49 UINetworkAdapterDescriptor(int iSlot = -1, 50 KNetworkAttachmentType enmType = KNetworkAttachmentType_Null, 51 const QString &strName = QString()) 52 : m_iSlot(iSlot), m_enmType(enmType), m_strName(strName) 53 {} 54 55 /** Holds the slot of described network adapter. */ 56 int m_iSlot; 57 /** Holds the attachment type of described network adapter. */ 58 KNetworkAttachmentType m_enmType; 59 /** Holds the adapter name of described network adapter. */ 60 QString m_strName; 61 }; 62 Q_DECLARE_METATYPE(UINetworkAdapterDescriptor); 43 63 44 64 /** A set of USB controller types. */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r80083 r80215 63 63 #include "CNATEngine.h" 64 64 #include "CNATNetwork.h" 65 #include "CNetworkAdapter.h" 65 66 #include "CRangedIntegerFormValue.h" 66 67 #include "CSerialPort.h" … … 1247 1248 error(pParent, MessageType_Error, 1248 1249 tr("Failed to change audio adapter attribute."), 1250 UIErrorString::formatErrorInfo(comAdapter)); 1251 } 1252 1253 void UIMessageCenter::cannotChangeNetworkAdapterAttribute(const CNetworkAdapter &comAdapter, QWidget *pParent /* = 0 */) const 1254 { 1255 error(pParent, MessageType_Error, 1256 tr("Failed to change network adapter attribute."), 1249 1257 UIErrorString::formatErrorInfo(comAdapter)); 1250 1258 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r80083 r80215 332 332 void cannotSaveMachineSettings(const CMachine &machine, QWidget *pParent = 0) const; 333 333 void cannotChangeAudioAdapterAttribute(const CAudioAdapter &comAdapter, QWidget *pParent = 0) const; 334 void cannotChangeNetworkAdapterAttribute(const CNetworkAdapter &comAdapter, QWidget *pParent = 0) const; 334 335 335 336 /* API: Virtual Medium Manager warnings: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp
r80139 r80215 44 44 #include "UIMachineAttributeSetter.h" 45 45 #include "UINameAndSystemEditor.h" 46 #include "UINetworkAttachmentEditor.h" 46 47 #include "UIVideoMemoryEditor.h" 47 48 #include "UIVirtualBoxManager.h" … … 62 63 AnchorRole_AudioHostDriverType, 63 64 AnchorRole_AudioControllerType, 65 AnchorRole_NetworkAttachmentType, 64 66 AnchorRole_USBControllerType, 65 67 #ifndef VBOX_WS_MAC … … 179 181 m_pTextPane->setAnchorRoleRestricted("#audio_host_driver_type", cal != ConfigurationAccessLevel_Full); 180 182 m_pTextPane->setAnchorRoleRestricted("#audio_controller_type", cal != ConfigurationAccessLevel_Full); 183 m_pTextPane->setAnchorRoleRestricted("#network_attachment_type", cal != ConfigurationAccessLevel_Full); 181 184 m_pTextPane->setAnchorRoleRestricted("#usb_controller_type", cal != ConfigurationAccessLevel_Full); 182 185 #ifndef VBOX_WS_MAC … … 475 478 roles["#audio_host_driver_type"] = AnchorRole_AudioHostDriverType; 476 479 roles["#audio_controller_type"] = AnchorRole_AudioControllerType; 480 roles["#network_attachment_type"] = AnchorRole_NetworkAttachmentType; 477 481 roles["#usb_controller_type"] = AnchorRole_USBControllerType; 478 482 #ifndef VBOX_WS_MAC … … 755 759 if (pPopup->exec() == QDialog::Accepted) 756 760 setMachineAttribute(machine(), MachineAttribute_AudioControllerType, QVariant::fromValue(pEditor->value())); 761 762 /* Delete popup: */ 763 delete pPopup; 764 } 765 break; 766 } 767 case AnchorRole_NetworkAttachmentType: 768 { 769 /* Prepare popup: */ 770 QPointer<QIDialogContainer> pPopup = new QIDialogContainer(0, Qt::Tool); 771 if (pPopup) 772 { 773 /* Prepare editor: */ 774 UINetworkAttachmentEditor *pEditor = new UINetworkAttachmentEditor(pPopup, true /* with label */); 775 if (pEditor) 776 { 777 pEditor->setValueNames(KNetworkAttachmentType_Bridged, UINetworkAttachmentEditor::bridgedAdapters()); 778 pEditor->setValueNames(KNetworkAttachmentType_Internal, UINetworkAttachmentEditor::internalNetworks()); 779 pEditor->setValueNames(KNetworkAttachmentType_HostOnly, UINetworkAttachmentEditor::hostInterfaces()); 780 pEditor->setValueNames(KNetworkAttachmentType_Generic, UINetworkAttachmentEditor::genericDrivers()); 781 pEditor->setValueNames(KNetworkAttachmentType_NATNetwork, UINetworkAttachmentEditor::natNetworks()); 782 pEditor->setValueType(static_cast<KNetworkAttachmentType>(strData.section(',', 0, 0).section(';', 1, 1).toInt())); 783 pEditor->setValueName(pEditor->valueType(), strData.section(',', 0, 0).section(';', 2, 2)); 784 connect(pEditor, &UINetworkAttachmentEditor::sigValidChanged, 785 pPopup.data(), &QIDialogContainer::setOkButtonEnabled); 786 pPopup->setWidget(pEditor); 787 } 788 789 /* Adjust popup geometry: */ 790 pPopup->move(QCursor::pos()); 791 pPopup->adjustSize(); 792 793 // WORKAROUND: 794 // On Windows, Tool dialogs aren't activated by default by some reason. 795 // So we have created sltActivateWindow wrapping actual activateWindow 796 // to fix that annoying issue. 797 QMetaObject::invokeMethod(pPopup, "sltActivateWindow", Qt::QueuedConnection); 798 /* Execute popup, change machine name if confirmed: */ 799 if (pPopup->exec() == QDialog::Accepted) 800 { 801 UINetworkAdapterDescriptor nad(strData.section(',', 0, 0).section(';', 0, 0).toInt(), 802 pEditor->valueType(), pEditor->valueName(pEditor->valueType())); 803 setMachineAttribute(machine(), MachineAttribute_NetworkAttachmentType, QVariant::fromValue(nad)); 804 } 757 805 758 806 /* Delete popup: */
Note:
See TracChangeset
for help on using the changeset viewer.