- Timestamp:
- Oct 4, 2021 3:13:38 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp
r91437 r91545 224 224 /** Prepares connections. */ 225 225 void prepareConnections(); 226 /** Prepares advanced settings widgets. */ 227 void prepareAdvancedSettingsWidgets(QGridLayout *pLayout); 226 228 227 229 /* Helping stuff: */ … … 249 251 /** Holds the adapter settings widget instance. */ 250 252 QWidget *m_pWidgetAdapterSettings; 253 /** Holds the adapter settings layout instance. */ 254 QGridLayout *m_pLayoutAdapterSettings; 255 /** Holds the advanced settings container widget instance. */ 256 QWidget *m_pWidgetAdvancedSettings; 251 257 /** Holds the attachment type label instance. */ 252 258 QLabel *m_pLabelAttachmentType; … … 294 300 , m_pCheckBoxAdapter(0) 295 301 , m_pWidgetAdapterSettings(0) 302 , m_pLayoutAdapterSettings(0) 303 , m_pWidgetAdvancedSettings(0) 296 304 , m_pLabelAttachmentType(0) 297 305 , m_pLabelAdapterName(0) … … 646 654 void UIMachineSettingsNetwork::retranslateUi() 647 655 { 656 int iFirstColumnWidth = 0; 648 657 m_pCheckBoxAdapter->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, plugs this virtual " 649 658 "network adapter into the virtual machine.")); 650 659 m_pCheckBoxAdapter->setText(QApplication::translate("UIMachineSettingsNetwork", "&Enable Network Adapter")); 651 660 m_pLabelAttachmentType->setText(QApplication::translate("UIMachineSettingsNetwork", "&Attached to:")); 661 iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelAttachmentType->minimumSizeHint().width()); 652 662 m_pEditorAttachmentType->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects how this virtual adapter " 653 663 "is attached to the real network of the Host OS.")); 654 664 m_pLabelAdapterName->setText(QApplication::translate("UIMachineSettingsNetwork", "&Name:")); 665 iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelAdapterName->minimumSizeHint().width()); 655 666 m_pButtonAdvanced->setText(QApplication::translate("UIMachineSettingsNetwork", "A&dvanced")); 656 667 m_pButtonAdvanced->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Shows additional network adapter options.")); 657 668 m_pLabelAdapterType->setText(QApplication::translate("UIMachineSettingsNetwork", "Adapter &Type:")); 669 iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelAdapterType->minimumSizeHint().width()); 658 670 m_pComboAdapterType->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the type of the virtual network " 659 671 "adapter. Depending on this value, VirtualBox will provide different " 660 672 "network hardware to the virtual machine.")); 661 673 m_pLabelPromiscuousMode->setText(QApplication::translate("UIMachineSettingsNetwork", "&Promiscuous Mode:")); 674 iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelPromiscuousMode->minimumSizeHint().width()); 662 675 m_pComboPromiscuousMode->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the promiscuous mode policy " 663 676 "of the network adapter when attached to an internal network, " 664 677 "host only network or a bridge.")); 665 678 m_pLabelMAC->setText(QApplication::translate("UIMachineSettingsNetwork", "&MAC Address:")); 679 iFirstColumnWidth = qMax(iFirstColumnWidth, m_pLabelMAC->minimumSizeHint().width()); 666 680 m_pEditorMAC->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the MAC address of this adapter. It contains " 667 681 "exactly 12 characters chosen from {0-9,A-F}. Note that the second character " … … 685 699 /* Translate attachment info: */ 686 700 sltHandleAttachmentTypeChange(); 701 /* Set the minimum width of the 1st column to size longest label to align all labels: */ 702 m_pLayoutAdapterSettings->setColumnMinimumWidth(0, iFirstColumnWidth); 687 703 } 688 704 … … 805 821 { 806 822 /* Prepare adapter settings widget layout: */ 807 QGridLayout *pLayoutAdapterSettings = new QGridLayout(m_pWidgetAdapterSettings);808 if ( pLayoutAdapterSettings)809 { 810 pLayoutAdapterSettings->setContentsMargins(0, 0, 0, 0);811 pLayoutAdapterSettings->setColumnStretch(2, 1);823 m_pLayoutAdapterSettings = new QGridLayout(m_pWidgetAdapterSettings); 824 if (m_pLayoutAdapterSettings) 825 { 826 m_pLayoutAdapterSettings->setContentsMargins(0, 0, 0, 0); 827 m_pLayoutAdapterSettings->setColumnStretch(2, 1); 812 828 813 829 /* Prepare attachment type label: */ … … 816 832 { 817 833 m_pLabelAttachmentType->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 818 pLayoutAdapterSettings->addWidget(m_pLabelAttachmentType, 0, 0);834 m_pLayoutAdapterSettings->addWidget(m_pLabelAttachmentType, 0, 0); 819 835 } 820 836 /* Prepare adapter name label: */ … … 823 839 { 824 840 m_pLabelAdapterName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 825 pLayoutAdapterSettings->addWidget(m_pLabelAdapterName, 1, 0);841 m_pLayoutAdapterSettings->addWidget(m_pLabelAdapterName, 1, 0); 826 842 } 827 843 /* Prepare attachment type editor: */ … … 834 850 m_pLabelAdapterName->setBuddy(m_pEditorAttachmentType->focusProxy2()); 835 851 836 pLayoutAdapterSettings->addWidget(m_pEditorAttachmentType, 0, 1, 2, 3);852 m_pLayoutAdapterSettings->addWidget(m_pEditorAttachmentType, 0, 1, 2, 3); 837 853 } 838 854 … … 847 863 UIIconPool::iconSet(":/arrow_down_10px.png")); 848 864 849 pLayoutAdapterSettings->addWidget(m_pButtonAdvanced, 2, 0);865 m_pLayoutAdapterSettings->addWidget(m_pButtonAdvanced, 2, 0); 850 866 } 851 867 852 /* Prepare adapter type label: */ 853 m_pLabelAdapterType = new QLabel(m_pWidgetAdapterSettings); 854 if (m_pLabelAdapterType) 855 { 856 m_pLabelAdapterType->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 857 pLayoutAdapterSettings->addWidget(m_pLabelAdapterType, 3, 0); 858 } 859 /* Prepare adapter type combo: */ 860 m_pComboAdapterType = new QComboBox(m_pWidgetAdapterSettings); 861 if (m_pComboAdapterType) 862 { 863 if (m_pLabelAdapterType) 864 m_pLabelAdapterType->setBuddy(m_pComboAdapterType); 865 pLayoutAdapterSettings->addWidget(m_pComboAdapterType, 3, 1, 1, 3); 866 } 867 868 /* Prepare promiscuous mode label: */ 869 m_pLabelPromiscuousMode = new QLabel(m_pWidgetAdapterSettings); 870 if (m_pLabelPromiscuousMode) 871 { 872 m_pLabelPromiscuousMode->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 873 pLayoutAdapterSettings->addWidget(m_pLabelPromiscuousMode, 4, 0); 874 } 875 /* Prepare promiscuous mode combo: */ 876 m_pComboPromiscuousMode = new QComboBox(m_pWidgetAdapterSettings); 877 if (m_pComboPromiscuousMode) 878 { 879 if (m_pLabelPromiscuousMode) 880 m_pLabelPromiscuousMode->setBuddy(m_pComboPromiscuousMode); 881 pLayoutAdapterSettings->addWidget(m_pComboPromiscuousMode, 4, 1, 1, 3); 882 } 883 884 /* Prepare MAC label: */ 885 m_pLabelMAC = new QLabel(m_pWidgetAdapterSettings); 886 if (m_pLabelMAC) 887 { 888 m_pLabelMAC->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 889 pLayoutAdapterSettings->addWidget(m_pLabelMAC, 5, 0); 890 } 891 /* Prepare MAC editor: */ 892 m_pEditorMAC = new QILineEdit(m_pWidgetAdapterSettings); 893 if (m_pEditorMAC) 894 { 895 if (m_pLabelMAC) 896 m_pLabelMAC->setBuddy(m_pEditorMAC); 897 m_pEditorMAC->setAllowToCopyContentsWhenDisabled(true); 898 m_pEditorMAC->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this)); 899 m_pEditorMAC->setMinimumWidthByText(QString().fill('0', 12)); 900 901 pLayoutAdapterSettings->addWidget(m_pEditorMAC, 5, 1, 1, 2); 902 } 903 /* Prepare MAC button: */ 904 m_pButtonMAC = new QIToolButton(m_pWidgetAdapterSettings); 905 if (m_pButtonMAC) 906 { 907 m_pButtonMAC->setIcon(UIIconPool::iconSet(":/refresh_16px.png")); 908 pLayoutAdapterSettings->addWidget(m_pButtonMAC, 5, 3); 909 } 910 911 /* Prepare MAC label: */ 912 m_pLabelGenericProperties = new QLabel(m_pWidgetAdapterSettings); 913 if (m_pLabelGenericProperties) 914 { 915 m_pLabelGenericProperties->setAlignment(Qt::AlignRight | Qt::AlignTop); 916 pLayoutAdapterSettings->addWidget(m_pLabelGenericProperties, 6, 0); 917 } 918 /* Prepare MAC editor: */ 919 m_pEditorGenericProperties = new QTextEdit(m_pWidgetAdapterSettings); 920 if (m_pEditorGenericProperties) 921 pLayoutAdapterSettings->addWidget(m_pEditorGenericProperties, 6, 1, 1, 3); 922 923 /* Prepare cable connected check-box: */ 924 m_pCheckBoxCableConnected = new QCheckBox(m_pWidgetAdapterSettings); 925 if (m_pCheckBoxCableConnected) 926 pLayoutAdapterSettings->addWidget(m_pCheckBoxCableConnected, 7, 1, 1, 2); 927 928 /* Prepare port forwarding button: */ 929 m_pButtonPortForwarding = new QPushButton(m_pWidgetAdapterSettings); 930 if (m_pButtonPortForwarding) 931 pLayoutAdapterSettings->addWidget(m_pButtonPortForwarding, 8, 1); 932 } 868 /* Create the container widget for advanced settings related widgets: */ 869 m_pWidgetAdvancedSettings = new QWidget; 870 m_pLayoutAdapterSettings->addWidget(m_pWidgetAdvancedSettings, 3, 0, 4, 3, Qt::AlignLeft); 871 QGridLayout *pLayoutAdvancedSettings = new QGridLayout(m_pWidgetAdvancedSettings); 872 pLayoutAdvancedSettings->setContentsMargins(0, 0, 0, 0); 873 prepareAdvancedSettingsWidgets(pLayoutAdvancedSettings); 874 } 933 875 934 876 pLayoutMain->addWidget(m_pWidgetAdapterSettings, 1, 1); … … 949 891 connect(m_pButtonPortForwarding, &QPushButton::clicked, this, &UIMachineSettingsNetwork::sltOpenPortForwardingDlg); 950 892 connect(this, &UIMachineSettingsNetwork::sigTabUpdated, m_pParent, &UIMachineSettingsNetworkPage::sltHandleTabUpdate); 893 } 894 895 void UIMachineSettingsNetwork::prepareAdvancedSettingsWidgets(QGridLayout *pLayout) 896 { 897 AssertPtrReturnVoid(pLayout); 898 899 /* Prepare adapter type label: */ 900 m_pLabelAdapterType = new QLabel(m_pWidgetAdapterSettings); 901 if (m_pLabelAdapterType) 902 { 903 m_pLabelAdapterType->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 904 pLayout->addWidget(m_pLabelAdapterType, 0, 0); 905 } 906 /* Prepare adapter type combo: */ 907 m_pComboAdapterType = new QComboBox(m_pWidgetAdapterSettings); 908 if (m_pComboAdapterType) 909 { 910 if (m_pLabelAdapterType) 911 m_pLabelAdapterType->setBuddy(m_pComboAdapterType); 912 pLayout->addWidget(m_pComboAdapterType, 0, 1, 1, 3); 913 } 914 915 /* Prepare promiscuous mode label: */ 916 m_pLabelPromiscuousMode = new QLabel(m_pWidgetAdapterSettings); 917 if (m_pLabelPromiscuousMode) 918 { 919 m_pLabelPromiscuousMode->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 920 pLayout->addWidget(m_pLabelPromiscuousMode, 1, 0); 921 } 922 /* Prepare promiscuous mode combo: */ 923 m_pComboPromiscuousMode = new QComboBox(m_pWidgetAdapterSettings); 924 if (m_pComboPromiscuousMode) 925 { 926 if (m_pLabelPromiscuousMode) 927 m_pLabelPromiscuousMode->setBuddy(m_pComboPromiscuousMode); 928 pLayout->addWidget(m_pComboPromiscuousMode, 1, 1, 1, 3); 929 } 930 931 /* Prepare MAC label: */ 932 m_pLabelMAC = new QLabel(m_pWidgetAdapterSettings); 933 if (m_pLabelMAC) 934 { 935 m_pLabelMAC->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 936 pLayout->addWidget(m_pLabelMAC, 2, 0); 937 } 938 /* Prepare MAC editor: */ 939 m_pEditorMAC = new QILineEdit(m_pWidgetAdapterSettings); 940 if (m_pEditorMAC) 941 { 942 if (m_pLabelMAC) 943 m_pLabelMAC->setBuddy(m_pEditorMAC); 944 m_pEditorMAC->setAllowToCopyContentsWhenDisabled(true); 945 m_pEditorMAC->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this)); 946 m_pEditorMAC->setMinimumWidthByText(QString().fill('0', 12)); 947 948 pLayout->addWidget(m_pEditorMAC, 2, 1, 1, 2); 949 } 950 /* Prepare MAC button: */ 951 m_pButtonMAC = new QIToolButton(m_pWidgetAdapterSettings); 952 if (m_pButtonMAC) 953 { 954 m_pButtonMAC->setIcon(UIIconPool::iconSet(":/refresh_16px.png")); 955 pLayout->addWidget(m_pButtonMAC, 2, 3); 956 } 957 958 /* Prepare MAC label: */ 959 m_pLabelGenericProperties = new QLabel(m_pWidgetAdapterSettings); 960 if (m_pLabelGenericProperties) 961 { 962 m_pLabelGenericProperties->setAlignment(Qt::AlignRight | Qt::AlignTop); 963 pLayout->addWidget(m_pLabelGenericProperties, 3, 0); 964 } 965 /* Prepare MAC editor: */ 966 m_pEditorGenericProperties = new QTextEdit(m_pWidgetAdapterSettings); 967 if (m_pEditorGenericProperties) 968 pLayout->addWidget(m_pEditorGenericProperties, 3, 1, 1, 3); 969 970 /* Prepare cable connected check-box: */ 971 m_pCheckBoxCableConnected = new QCheckBox(m_pWidgetAdapterSettings); 972 if (m_pCheckBoxCableConnected) 973 pLayout->addWidget(m_pCheckBoxCableConnected, 4, 1, 1, 2); 974 975 /* Prepare port forwarding button: */ 976 m_pButtonPortForwarding = new QPushButton(m_pWidgetAdapterSettings); 977 if (m_pButtonPortForwarding) 978 pLayout->addWidget(m_pButtonPortForwarding, 5, 1); 951 979 } 952 980 … … 1016 1044 { 1017 1045 /* Update visibility of advanced options: */ 1018 m_pLabelAdapterType->setVisible(m_pButtonAdvanced->isExpanded()); 1019 m_pComboAdapterType->setVisible(m_pButtonAdvanced->isExpanded()); 1020 m_pLabelPromiscuousMode->setVisible(m_pButtonAdvanced->isExpanded()); 1021 m_pComboPromiscuousMode->setVisible(m_pButtonAdvanced->isExpanded()); 1022 m_pLabelGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic && 1023 m_pButtonAdvanced->isExpanded()); 1024 m_pEditorGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic && 1025 m_pButtonAdvanced->isExpanded()); 1026 m_pLabelMAC->setVisible(m_pButtonAdvanced->isExpanded()); 1027 m_pEditorMAC->setVisible(m_pButtonAdvanced->isExpanded()); 1028 m_pButtonMAC->setVisible(m_pButtonAdvanced->isExpanded()); 1029 m_pCheckBoxCableConnected->setVisible(m_pButtonAdvanced->isExpanded()); 1030 m_pButtonPortForwarding->setVisible(m_pButtonAdvanced->isExpanded()); 1046 m_pWidgetAdvancedSettings->setVisible(m_pButtonAdvanced->isExpanded()); 1031 1047 } 1032 1048
Note:
See TracChangeset
for help on using the changeset viewer.