VirtualBox

Ignore:
Timestamp:
Aug 25, 2020 8:58:40 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9812: VM settings: Prepare cascade cleanup for Network page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r85791 r85886  
    207207private:
    208208
    209     /* Helper: Prepare stuff: */
    210     void prepareValidation();
    211 
    212     /* Prepares widgets: */
     209    /** Prepares all. */
     210    void prepare();
     211    /** Prepares widgets. */
    213212    void prepareWidgets();
     213    /** Prepares connections. */
     214    void prepareConnections();
    214215
    215216    /* Helping stuff: */
     
    233234    /** @name Widgets
    234235     * @{ */
    235        QLabel *m_pAttachmentTypeLabel;
    236        QLabel *m_pAdapterNameLabel;
    237        QLabel *m_pAdapterTypeLabel;
    238        QLabel *m_pPromiscuousModeLabel;
    239        QLabel *m_pMACLabel;
    240        QLabel *m_pGenericPropertiesLabel;
    241        UINetworkAttachmentEditor *m_pAttachmentTypeEditor;
    242        QILineEdit *m_pMACEditor;
    243        QIToolButton *m_pMACButton;
    244        QIArrowButtonSwitch *m_pAdvancedArrow;
    245        QCheckBox *m_pEnableAdapterCheckBox;
    246        QCheckBox *m_pCableConnectedCheckBox;
    247        QPushButton *m_pPortForwardingButton;
    248        QComboBox *m_pPromiscuousModeCombo;
    249        QComboBox *m_pAdapterTypeCombo;
    250        QTextEdit *m_pGenericPropertiesTextEdit;
    251        QWidget *m_pAdapterOptionsContainer;
     236        /** Holds the adapter check-box instance. */
     237        QCheckBox                 *m_pCheckBoxAdapter;
     238        /** Holds the adapter settings widget instance. */
     239        QWidget                   *m_pWidgetAdapterSettings;
     240        /** Holds the attachment type label instance. */
     241        QLabel                    *m_pLabelAttachmentType;
     242        /** Holds the adapter name label instance. */
     243        QLabel                    *m_pLabelAdapterName;
     244        /** Holds the attachment type editor instance. */
     245        UINetworkAttachmentEditor *m_pEditorAttachmentType;
     246        /** Holds the advanced button instance. */
     247        QIArrowButtonSwitch       *m_pButtonAdvanced;
     248        /** Holds the adapter type label instance. */
     249        QLabel                    *m_pLabelAdapterType;
     250        /** Holds the adapter type editor instance. */
     251        QComboBox                 *m_pComboAdapterType;
     252        /** Holds the promiscuous mode label instance. */
     253        QLabel                    *m_pLabelPromiscuousMode;
     254        /** Holds the promiscuous mode combo instance. */
     255        QComboBox                 *m_pComboPromiscuousMode;
     256        /** Holds the MAC label instance. */
     257        QLabel                    *m_pLabelMAC;
     258        /** Holds the MAC editor instance. */
     259        QILineEdit                *m_pEditorMAC;
     260        /** Holds the MAC button instance. */
     261        QIToolButton              *m_pButtonMAC;
     262        /** Holds the generic properties label instance. */
     263        QLabel                    *m_pLabelGenericProperties;
     264        /** Holds the generic properties editor instance. */
     265        QTextEdit                 *m_pEditorGenericProperties;
     266        /** Holds the cable connected check-box instance. */
     267        QCheckBox                 *m_pCheckBoxCableConnected;
     268        /** Holds the port forwarding button instance. */
     269        QPushButton               *m_pButtonPortForwarding;
    252270    /** @} */
    253271};
     
    263281    , m_iSlot(-1)
    264282    , m_enmAdapterType(KNetworkAdapterType_Null)
    265     , m_pAttachmentTypeLabel(0)
    266     , m_pAdapterNameLabel(0)
    267     , m_pAdapterTypeLabel(0)
    268     , m_pPromiscuousModeLabel(0)
    269     , m_pMACLabel(0)
    270     , m_pGenericPropertiesLabel(0)
    271     , m_pAttachmentTypeEditor(0)
    272     , m_pMACEditor(0)
    273     , m_pMACButton(0)
    274     , m_pAdvancedArrow(0)
    275     , m_pEnableAdapterCheckBox(0)
    276     , m_pCableConnectedCheckBox(0)
    277     , m_pPortForwardingButton(0)
    278     , m_pPromiscuousModeCombo(0)
    279     , m_pAdapterTypeCombo(0)
    280     , m_pGenericPropertiesTextEdit(0)
    281     , m_pAdapterOptionsContainer(0)
    282 {
    283     prepareWidgets();
    284 
    285     /* Determine icon metric: */
    286     const QStyle *pStyle = QApplication::style();
    287     const int iIconMetric = (int)(pStyle->pixelMetric(QStyle::PM_SmallIconSize) * .625);
    288 
    289     /* Setup widgets: */
    290     m_pAttachmentTypeLabel->setBuddy(m_pAttachmentTypeEditor->focusProxy1());
    291     m_pAdapterNameLabel->setBuddy(m_pAttachmentTypeEditor->focusProxy2());
    292     m_pMACEditor->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this));
    293     m_pMACEditor->setMinimumWidthByText(QString().fill('0', 12));
    294     m_pMACButton->setIcon(UIIconPool::iconSet(":/refresh_16px.png"));
    295     m_pAdvancedArrow->setIconSize(QSize(iIconMetric, iIconMetric));
    296     m_pAdvancedArrow->setIcons(UIIconPool::iconSet(":/arrow_right_10px.png"),
    297                                UIIconPool::iconSet(":/arrow_down_10px.png"));
    298 
    299     /* Setup connections: */
    300     connect(m_pEnableAdapterCheckBox, &QCheckBox::toggled, this, &UIMachineSettingsNetwork::sltHandleAdapterActivityChange);
    301     connect(m_pAttachmentTypeEditor, &UINetworkAttachmentEditor::sigValueTypeChanged,
    302             this, &UIMachineSettingsNetwork::sltHandleAttachmentTypeChange);
    303     connect(m_pAttachmentTypeEditor, &UINetworkAttachmentEditor::sigValueNameChanged,
    304             this, &UIMachineSettingsNetwork::sltHandleAlternativeNameChange);
    305     connect(m_pAdvancedArrow, &QIArrowButtonSwitch::sigClicked, this, &UIMachineSettingsNetwork::sltHandleAdvancedButtonStateChange);
    306     connect(m_pMACButton, &QIToolButton::clicked, this, &UIMachineSettingsNetwork::sltGenerateMac);
    307     connect(m_pPortForwardingButton, &QPushButton::clicked, this, &UIMachineSettingsNetwork::sltOpenPortForwardingDlg);
    308     connect(this, &UIMachineSettingsNetwork::sigTabUpdated, m_pParent, &UIMachineSettingsNetworkPage::sltHandleTabUpdate);
    309 
    310     /* Prepare validation: */
    311     prepareValidation();
    312 
    313     /* Apply language settings: */
    314     retranslateUi();
     283    , m_pCheckBoxAdapter(0)
     284    , m_pWidgetAdapterSettings(0)
     285    , m_pLabelAttachmentType(0)
     286    , m_pLabelAdapterName(0)
     287    , m_pEditorAttachmentType(0)
     288    , m_pButtonAdvanced(0)
     289    , m_pLabelAdapterType(0)
     290    , m_pComboAdapterType(0)
     291    , m_pLabelPromiscuousMode(0)
     292    , m_pComboPromiscuousMode(0)
     293    , m_pLabelMAC(0)
     294    , m_pEditorMAC(0)
     295    , m_pButtonMAC(0)
     296    , m_pLabelGenericProperties(0)
     297    , m_pEditorGenericProperties(0)
     298    , m_pCheckBoxCableConnected(0)
     299    , m_pButtonPortForwarding(0)
     300{
     301    prepare();
    315302}
    316303
     
    324311
    325312    /* Load adapter activity state: */
    326     m_pEnableAdapterCheckBox->setChecked(oldAdapterData.m_fAdapterEnabled);
     313    m_pCheckBoxAdapter->setChecked(oldAdapterData.m_fAdapterEnabled);
    327314    /* Handle adapter activity change: */
    328315    sltHandleAdapterActivityChange();
    329316
    330317    /* Load attachment type: */
    331     m_pAttachmentTypeEditor->setValueType(oldAdapterData.m_attachmentType);
     318    m_pEditorAttachmentType->setValueType(oldAdapterData.m_attachmentType);
    332319    /* Load alternative names: */
    333     m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_Bridged, wipedOutString(oldAdapterData.m_strBridgedAdapterName));
    334     m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_Internal, wipedOutString(oldAdapterData.m_strInternalNetworkName));
    335     m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_HostOnly, wipedOutString(oldAdapterData.m_strHostInterfaceName));
    336     m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_Generic, wipedOutString(oldAdapterData.m_strGenericDriverName));
    337     m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_NATNetwork, wipedOutString(oldAdapterData.m_strNATNetworkName));
     320    m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_Bridged, wipedOutString(oldAdapterData.m_strBridgedAdapterName));
     321    m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_Internal, wipedOutString(oldAdapterData.m_strInternalNetworkName));
     322    m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_HostOnly, wipedOutString(oldAdapterData.m_strHostInterfaceName));
     323    m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_Generic, wipedOutString(oldAdapterData.m_strGenericDriverName));
     324    m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_NATNetwork, wipedOutString(oldAdapterData.m_strNATNetworkName));
    338325#ifdef VBOX_WITH_CLOUD_NET
    339     m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_Cloud, wipedOutString(oldAdapterData.m_strCloudNetworkName));
     326    m_pEditorAttachmentType->setValueName(KNetworkAttachmentType_Cloud, wipedOutString(oldAdapterData.m_strCloudNetworkName));
    340327#endif /* VBOX_WITH_CLOUD_NET */
    341328    /* Handle attachment type change: */
     
    346333
    347334    /* Load promiscuous mode type: */
    348     m_pPromiscuousModeCombo->setCurrentIndex(position(m_pPromiscuousModeCombo, oldAdapterData.m_promiscuousMode));
     335    m_pComboPromiscuousMode->setCurrentIndex(position(m_pComboPromiscuousMode, oldAdapterData.m_promiscuousMode));
    349336
    350337    /* Other options: */
    351     m_pMACEditor->setText(oldAdapterData.m_strMACAddress);
    352     m_pGenericPropertiesTextEdit->setText(oldAdapterData.m_strGenericProperties);
    353     m_pCableConnectedCheckBox->setChecked(oldAdapterData.m_fCableConnected);
     338    m_pEditorMAC->setText(oldAdapterData.m_strMACAddress);
     339    m_pEditorGenericProperties->setText(oldAdapterData.m_strGenericProperties);
     340    m_pCheckBoxCableConnected->setChecked(oldAdapterData.m_fCableConnected);
    354341
    355342    /* Load port forwarding rules: */
     
    370357
    371358    /* Save adapter activity state: */
    372     newAdapterData.m_fAdapterEnabled = m_pEnableAdapterCheckBox->isChecked();
     359    newAdapterData.m_fAdapterEnabled = m_pCheckBoxAdapter->isChecked();
    373360
    374361    /* Save attachment type & alternative name: */
     
    384371            break;
    385372        case KNetworkAttachmentType_Internal:
    386             newAdapterData.m_strInternalNetworkName = m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_Internal);
     373            newAdapterData.m_strInternalNetworkName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Internal);
    387374            break;
    388375        case KNetworkAttachmentType_HostOnly:
    389             newAdapterData.m_strHostInterfaceName = m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_HostOnly);
     376            newAdapterData.m_strHostInterfaceName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_HostOnly);
    390377            break;
    391378        case KNetworkAttachmentType_Generic:
    392             newAdapterData.m_strGenericDriverName = m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_Generic);
    393             newAdapterData.m_strGenericProperties = m_pGenericPropertiesTextEdit->toPlainText();
     379            newAdapterData.m_strGenericDriverName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Generic);
     380            newAdapterData.m_strGenericProperties = m_pEditorGenericProperties->toPlainText();
    394381            break;
    395382        case KNetworkAttachmentType_NATNetwork:
    396             newAdapterData.m_strNATNetworkName = m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_NATNetwork);
     383            newAdapterData.m_strNATNetworkName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_NATNetwork);
    397384            break;
    398385#ifdef VBOX_WITH_CLOUD_NET
    399386        case KNetworkAttachmentType_Cloud:
    400             newAdapterData.m_strCloudNetworkName = m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_Cloud);
     387            newAdapterData.m_strCloudNetworkName = m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Cloud);
    401388            break;
    402389#endif /* VBOX_WITH_CLOUD_NET */
     
    406393
    407394    /* Save adapter type: */
    408     newAdapterData.m_adapterType = m_pAdapterTypeCombo->currentData().value<KNetworkAdapterType>();
     395    newAdapterData.m_adapterType = m_pComboAdapterType->currentData().value<KNetworkAdapterType>();
    409396
    410397    /* Save promiscuous mode type: */
    411     newAdapterData.m_promiscuousMode = (KNetworkAdapterPromiscModePolicy)m_pPromiscuousModeCombo->itemData(m_pPromiscuousModeCombo->currentIndex()).toInt();
     398    newAdapterData.m_promiscuousMode = (KNetworkAdapterPromiscModePolicy)m_pComboPromiscuousMode->itemData(m_pComboPromiscuousMode->currentIndex()).toInt();
    412399
    413400    /* Other options: */
    414     newAdapterData.m_strMACAddress = m_pMACEditor->text().isEmpty() ? QString() : m_pMACEditor->text();
    415     newAdapterData.m_fCableConnected = m_pCableConnectedCheckBox->isChecked();
     401    newAdapterData.m_strMACAddress = m_pEditorMAC->text().isEmpty() ? QString() : m_pEditorMAC->text();
     402    newAdapterData.m_fCableConnected = m_pCheckBoxCableConnected->isChecked();
    416403
    417404    /* Save port forwarding rules: */
     
    426413{
    427414    /* Pass if adapter is disabled: */
    428     if (!m_pEnableAdapterCheckBox->isChecked())
     415    if (!m_pCheckBoxAdapter->isChecked())
    429416        return true;
    430417
     
    500487
    501488    /* Validate MAC-address length: */
    502     if (m_pMACEditor->text().size() < 12)
     489    if (m_pEditorMAC->text().size() < 12)
    503490    {
    504491        message.second << tr("The MAC address must be 12 hexadecimal digits long.");
     
    507494
    508495    /* Make sure MAC-address is unicast: */
    509     if (m_pMACEditor->text().size() >= 2)
     496    if (m_pEditorMAC->text().size() >= 2)
    510497    {
    511498        QRegExp validator("^[0-9A-Fa-f][02468ACEace]");
    512         if (validator.indexIn(m_pMACEditor->text()) != 0)
     499        if (validator.indexIn(m_pEditorMAC->text()) != 0)
    513500        {
    514501            message.second << tr("The second digit in the MAC address may not be odd as only unicast addresses are allowed.");
     
    527514QWidget *UIMachineSettingsNetwork::setOrderAfter(QWidget *pAfter)
    528515{
    529     setTabOrder(pAfter, m_pEnableAdapterCheckBox);
    530     setTabOrder(m_pEnableAdapterCheckBox, m_pAttachmentTypeEditor);
    531     setTabOrder(m_pAttachmentTypeEditor, m_pAdvancedArrow);
    532     setTabOrder(m_pAdvancedArrow, m_pAdapterTypeCombo);
    533     setTabOrder(m_pAdapterTypeCombo, m_pPromiscuousModeCombo);
    534     setTabOrder(m_pPromiscuousModeCombo, m_pMACEditor);
    535     setTabOrder(m_pMACEditor, m_pMACButton);
    536     setTabOrder(m_pMACButton, m_pGenericPropertiesTextEdit);
    537     setTabOrder(m_pGenericPropertiesTextEdit, m_pCableConnectedCheckBox);
    538     setTabOrder(m_pCableConnectedCheckBox, m_pPortForwardingButton);
    539     return m_pPortForwardingButton;
     516    setTabOrder(pAfter, m_pCheckBoxAdapter);
     517    setTabOrder(m_pCheckBoxAdapter, m_pEditorAttachmentType);
     518    setTabOrder(m_pEditorAttachmentType, m_pButtonAdvanced);
     519    setTabOrder(m_pButtonAdvanced, m_pComboAdapterType);
     520    setTabOrder(m_pComboAdapterType, m_pComboPromiscuousMode);
     521    setTabOrder(m_pComboPromiscuousMode, m_pEditorMAC);
     522    setTabOrder(m_pEditorMAC, m_pButtonMAC);
     523    setTabOrder(m_pButtonMAC, m_pEditorGenericProperties);
     524    setTabOrder(m_pEditorGenericProperties, m_pCheckBoxCableConnected);
     525    setTabOrder(m_pCheckBoxCableConnected, m_pButtonPortForwarding);
     526    return m_pButtonPortForwarding;
    540527}
    541528
     
    547534KNetworkAttachmentType UIMachineSettingsNetwork::attachmentType() const
    548535{
    549     return m_pAttachmentTypeEditor->valueType();
     536    return m_pEditorAttachmentType->valueType();
    550537}
    551538
     
    554541    if (enmType == KNetworkAttachmentType_Null)
    555542        enmType = attachmentType();
    556     return m_pAttachmentTypeEditor->valueName(enmType);
     543    return m_pEditorAttachmentType->valueName(enmType);
    557544}
    558545
     
    560547{
    561548    /* Basic attributes: */
    562     m_pEnableAdapterCheckBox->setEnabled(m_pParent->isMachineOffline());
    563     m_pAttachmentTypeLabel->setEnabled(m_pParent->isMachineInValidMode());
    564     m_pAttachmentTypeEditor->setEnabled(m_pParent->isMachineInValidMode());
    565     m_pAdapterNameLabel->setEnabled(m_pParent->isMachineInValidMode() &&
     549    m_pCheckBoxAdapter->setEnabled(m_pParent->isMachineOffline());
     550    m_pLabelAttachmentType->setEnabled(m_pParent->isMachineInValidMode());
     551    m_pEditorAttachmentType->setEnabled(m_pParent->isMachineInValidMode());
     552    m_pLabelAdapterName->setEnabled(m_pParent->isMachineInValidMode() &&
    566553                                    attachmentType() != KNetworkAttachmentType_Null &&
    567554                                    attachmentType() != KNetworkAttachmentType_NAT);
    568     m_pAdvancedArrow->setEnabled(m_pParent->isMachineInValidMode());
     555    m_pButtonAdvanced->setEnabled(m_pParent->isMachineInValidMode());
    569556
    570557    /* Advanced attributes: */
    571     m_pAdapterTypeLabel->setEnabled(m_pParent->isMachineOffline());
    572     m_pAdapterTypeCombo->setEnabled(m_pParent->isMachineOffline());
    573     m_pPromiscuousModeLabel->setEnabled(m_pParent->isMachineInValidMode() &&
     558    m_pLabelAdapterType->setEnabled(m_pParent->isMachineOffline());
     559    m_pComboAdapterType->setEnabled(m_pParent->isMachineOffline());
     560    m_pLabelPromiscuousMode->setEnabled(m_pParent->isMachineInValidMode() &&
    574561                                        attachmentType() != KNetworkAttachmentType_Null &&
    575562                                        attachmentType() != KNetworkAttachmentType_Generic &&
    576563                                        attachmentType() != KNetworkAttachmentType_NAT);
    577     m_pPromiscuousModeCombo->setEnabled(m_pParent->isMachineInValidMode() &&
     564    m_pComboPromiscuousMode->setEnabled(m_pParent->isMachineInValidMode() &&
    578565                                        attachmentType() != KNetworkAttachmentType_Null &&
    579566                                        attachmentType() != KNetworkAttachmentType_Generic &&
    580567                                        attachmentType() != KNetworkAttachmentType_NAT);
    581     m_pMACLabel->setEnabled(m_pParent->isMachineOffline());
    582     m_pMACEditor->setEnabled(m_pParent->isMachineOffline());
    583     m_pMACButton->setEnabled(m_pParent->isMachineOffline());
    584     m_pGenericPropertiesLabel->setEnabled(m_pParent->isMachineInValidMode());
    585     m_pGenericPropertiesTextEdit->setEnabled(m_pParent->isMachineInValidMode());
    586     m_pCableConnectedCheckBox->setEnabled(m_pParent->isMachineInValidMode());
    587     m_pPortForwardingButton->setEnabled(m_pParent->isMachineInValidMode() &&
     568    m_pLabelMAC->setEnabled(m_pParent->isMachineOffline());
     569    m_pEditorMAC->setEnabled(m_pParent->isMachineOffline());
     570    m_pButtonMAC->setEnabled(m_pParent->isMachineOffline());
     571    m_pLabelGenericProperties->setEnabled(m_pParent->isMachineInValidMode());
     572    m_pEditorGenericProperties->setEnabled(m_pParent->isMachineInValidMode());
     573    m_pCheckBoxCableConnected->setEnabled(m_pParent->isMachineInValidMode());
     574    m_pButtonPortForwarding->setEnabled(m_pParent->isMachineInValidMode() &&
    588575                                        attachmentType() == KNetworkAttachmentType_NAT);
    589576
     
    594581void UIMachineSettingsNetwork::reloadAlternatives()
    595582{
    596     m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Bridged, m_pParent->bridgedAdapterList());
    597     m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Internal, m_pParent->internalNetworkList());
    598     m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_HostOnly, m_pParent->hostInterfaceList());
    599     m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Generic, m_pParent->genericDriverList());
    600     m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_NATNetwork, m_pParent->natNetworkList());
     583    m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_Bridged, m_pParent->bridgedAdapterList());
     584    m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_Internal, m_pParent->internalNetworkList());
     585    m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_HostOnly, m_pParent->hostInterfaceList());
     586    m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_Generic, m_pParent->genericDriverList());
     587    m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_NATNetwork, m_pParent->natNetworkList());
    601588#ifdef VBOX_WITH_CLOUD_NET
    602     m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Cloud, m_pParent->cloudNetworkList());
     589    m_pEditorAttachmentType->setValueNames(KNetworkAttachmentType_Cloud, m_pParent->cloudNetworkList());
    603590#endif /* VBOX_WITH_CLOUD_NET */
    604591}
     
    607594{
    608595    /* Check whether the button state really changed: */
    609     if (m_pAdvancedArrow->isExpanded() == fExpanded)
     596    if (m_pButtonAdvanced->isExpanded() == fExpanded)
    610597        return;
    611598
    612599    /* Push the state to button and handle the state change: */
    613     m_pAdvancedArrow->setExpanded(fExpanded);
     600    m_pButtonAdvanced->setExpanded(fExpanded);
    614601    handleAdvancedButtonStateChange();
    615602}
     
    617604void UIMachineSettingsNetwork::retranslateUi()
    618605{
    619     m_pEnableAdapterCheckBox->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, plugs this virtual "
     606    m_pCheckBoxAdapter->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, plugs this virtual "
    620607                                                                   "network adapter into the virtual machine."));
    621     m_pEnableAdapterCheckBox->setText(QApplication::translate("UIMachineSettingsNetwork", "&Enable Network Adapter"));
    622     m_pAttachmentTypeLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "&Attached to:"));
    623     m_pAttachmentTypeEditor->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects how this virtual adapter "
     608    m_pCheckBoxAdapter->setText(QApplication::translate("UIMachineSettingsNetwork", "&Enable Network Adapter"));
     609    m_pLabelAttachmentType->setText(QApplication::translate("UIMachineSettingsNetwork", "&Attached to:"));
     610    m_pEditorAttachmentType->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects how this virtual adapter "
    624611                                                                  "is attached to the real network of the Host OS."));
    625     m_pAdapterNameLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "&Name:"));
    626     m_pAdvancedArrow->setText(QApplication::translate("UIMachineSettingsNetwork", "A&dvanced"));
    627     m_pAdvancedArrow->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Shows additional network adapter options."));
    628     m_pAdapterTypeLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "Adapter &Type:"));
    629     m_pAdapterTypeCombo->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the type of the virtual network "
     612    m_pLabelAdapterName->setText(QApplication::translate("UIMachineSettingsNetwork", "&Name:"));
     613    m_pButtonAdvanced->setText(QApplication::translate("UIMachineSettingsNetwork", "A&dvanced"));
     614    m_pButtonAdvanced->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Shows additional network adapter options."));
     615    m_pLabelAdapterType->setText(QApplication::translate("UIMachineSettingsNetwork", "Adapter &Type:"));
     616    m_pComboAdapterType->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the type of the virtual network "
    630617                                                              "adapter. Depending on this value, VirtualBox will provide different "
    631618                                                              "network hardware to the virtual machine."));
    632     m_pPromiscuousModeLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "&Promiscuous Mode:"));
    633     m_pPromiscuousModeCombo->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the promiscuous mode policy "
     619    m_pLabelPromiscuousMode->setText(QApplication::translate("UIMachineSettingsNetwork", "&Promiscuous Mode:"));
     620    m_pComboPromiscuousMode->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Selects the promiscuous mode policy "
    634621                                                                  "of the network adapter when attached to an internal network, "
    635622                                                                  "host only network or a bridge."));
    636     m_pMACLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "&MAC Address:"));
    637     m_pMACEditor->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the MAC address of this adapter. It contains "
     623    m_pLabelMAC->setText(QApplication::translate("UIMachineSettingsNetwork", "&MAC Address:"));
     624    m_pEditorMAC->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the MAC address of this adapter. It contains "
    638625                                                       "exactly 12 characters chosen from {0-9,A-F}. Note that the second character "
    639626                                                       "must be an even digit."));
    640     m_pMACButton->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Generates a new random MAC address."));
    641     m_pGenericPropertiesLabel->setText(QApplication::translate("UIMachineSettingsNetwork", "Generic Properties:"));
    642     m_pGenericPropertiesTextEdit->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the configuration settings "
     627    m_pButtonMAC->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Generates a new random MAC address."));
     628    m_pLabelGenericProperties->setText(QApplication::translate("UIMachineSettingsNetwork", "Generic Properties:"));
     629    m_pEditorGenericProperties->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Holds the configuration settings "
    643630                                                                       "for the network attachment driver. The settings should be of "
    644631                                                                       "the form <b>name=value</b> and will depend on the driver. "
    645632                                                                       "Use <b>shift-enter</b> to add a new entry."));
    646     m_pCableConnectedCheckBox->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, the virtual network "
     633    m_pCheckBoxCableConnected->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "When checked, the virtual network "
    647634                                                                    "cable is plugged in."));
    648     m_pCableConnectedCheckBox->setText(QApplication::translate("UIMachineSettingsNetwork", "&Cable Connected"));
    649     m_pPortForwardingButton->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Displays a window to configure port "
     635    m_pCheckBoxCableConnected->setText(QApplication::translate("UIMachineSettingsNetwork", "&Cable Connected"));
     636    m_pButtonPortForwarding->setWhatsThis(QApplication::translate("UIMachineSettingsNetwork", "Displays a window to configure port "
    650637                                                                  "forwarding rules."));
    651     m_pPortForwardingButton->setText(QApplication::translate("UIMachineSettingsNetwork", "&Port Forwarding"));
     638    m_pButtonPortForwarding->setText(QApplication::translate("UIMachineSettingsNetwork", "&Port Forwarding"));
    652639
    653640    /* Translate combo-boxes content: */
     
    661648{
    662649    /* Update availability: */
    663     m_pAdapterOptionsContainer->setEnabled(m_pEnableAdapterCheckBox->isChecked());
     650    m_pWidgetAdapterSettings->setEnabled(m_pCheckBoxAdapter->isChecked());
    664651
    665652    /* Generate a new MAC address in case this adapter was never enabled before: */
    666     if (   m_pEnableAdapterCheckBox->isChecked()
    667         && m_pMACEditor->text().isEmpty())
     653    if (   m_pCheckBoxAdapter->isChecked()
     654        && m_pEditorMAC->text().isEmpty())
    668655        sltGenerateMac();
    669656
     
    675662{
    676663    /* Update alternative-name combo-box availability: */
    677     m_pAdapterNameLabel->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
     664    m_pLabelAdapterName->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
    678665                                    attachmentType() != KNetworkAttachmentType_NAT);
    679666    /* Update promiscuous-mode combo-box availability: */
    680     m_pPromiscuousModeLabel->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
     667    m_pLabelPromiscuousMode->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
    681668                                        attachmentType() != KNetworkAttachmentType_Generic &&
    682669                                        attachmentType() != KNetworkAttachmentType_NAT);
    683     m_pPromiscuousModeCombo->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
     670    m_pComboPromiscuousMode->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
    684671                                        attachmentType() != KNetworkAttachmentType_Generic &&
    685672                                        attachmentType() != KNetworkAttachmentType_NAT);
    686673    /* Update generic-properties editor visibility: */
    687     m_pGenericPropertiesLabel->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
    688                                           m_pAdvancedArrow->isExpanded());
    689     m_pGenericPropertiesTextEdit->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
    690                                              m_pAdvancedArrow->isExpanded());
     674    m_pLabelGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
     675                                          m_pButtonAdvanced->isExpanded());
     676    m_pEditorGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
     677                                             m_pButtonAdvanced->isExpanded());
    691678    /* Update forwarding rules button availability: */
    692     m_pPortForwardingButton->setEnabled(attachmentType() == KNetworkAttachmentType_NAT);
     679    m_pButtonPortForwarding->setEnabled(attachmentType() == KNetworkAttachmentType_NAT);
    693680
    694681    /* Revalidate: */
     
    704691        case KNetworkAttachmentType_Internal:
    705692        {
    706             if (!m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_Internal).isNull())
     693            if (!m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Internal).isNull())
    707694                emit sigTabUpdated();
    708695            break;
     
    710697        case KNetworkAttachmentType_Generic:
    711698        {
    712             if (!m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_Generic).isNull())
     699            if (!m_pEditorAttachmentType->valueName(KNetworkAttachmentType_Generic).isNull())
    713700                emit sigTabUpdated();
    714701            break;
     
    728715
    729716    /* Notify listeners about the button state change: */
    730     emit sigNotifyAdvancedButtonStateChange(m_pAdvancedArrow->isExpanded());
     717    emit sigNotifyAdvancedButtonStateChange(m_pButtonAdvanced->isExpanded());
    731718}
    732719
    733720void UIMachineSettingsNetwork::sltGenerateMac()
    734721{
    735     m_pMACEditor->setText(uiCommon().host().GenerateMACAddress());
     722    m_pEditorMAC->setText(uiCommon().host().GenerateMACAddress());
    736723}
    737724
     
    743730}
    744731
    745 void UIMachineSettingsNetwork::prepareValidation()
    746 {
    747     /* Configure validation: */
    748     connect(m_pMACEditor, &QILineEdit::textChanged, m_pParent, &UIMachineSettingsNetworkPage::revalidate);
     732void UIMachineSettingsNetwork::prepare()
     733{
     734    /* Prepare everything: */
     735    prepareWidgets();
     736    prepareConnections();
     737
     738    /* Apply language settings: */
     739    retranslateUi();
    749740}
    750741
    751742void UIMachineSettingsNetwork::prepareWidgets()
    752743{
    753     if (objectName().isEmpty())
    754         setObjectName(QStringLiteral("UIMachineSettingsNetwork"));
    755     resize(430, 250);
     744    /* Prepare main layout: */
    756745    QGridLayout *pMainLayout = new QGridLayout(this);
    757     pMainLayout->setObjectName(QStringLiteral("pMainLayout"));
    758     m_pEnableAdapterCheckBox = new QCheckBox(this);
    759     m_pEnableAdapterCheckBox->setObjectName(QStringLiteral("m_pEnableAdapterCheckBox"));
    760 
    761     pMainLayout->addWidget(m_pEnableAdapterCheckBox, 0, 0, 1, 2);
    762     QSpacerItem *pHorizontalSpacer1 = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
    763     pMainLayout->addItem(pHorizontalSpacer1, 1, 0, 1, 1);
    764 
    765     m_pAdapterOptionsContainer = new QWidget();
    766     m_pAdapterOptionsContainer->setObjectName(QStringLiteral("m_pAdapterOptionsContainer"));
    767     QGridLayout *pAdapterOptionsLayout = new QGridLayout(m_pAdapterOptionsContainer);
    768     pAdapterOptionsLayout->setContentsMargins(0, 0, 0, 0);
    769     pAdapterOptionsLayout->setObjectName(QStringLiteral("pAdapterOptionsLayout"));
    770     m_pAttachmentTypeLabel = new QLabel(m_pAdapterOptionsContainer);
    771     m_pAttachmentTypeLabel->setObjectName(QStringLiteral("m_pAttachmentTypeLabel"));
    772     m_pAttachmentTypeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    773     pAdapterOptionsLayout->addWidget(m_pAttachmentTypeLabel, 0, 0, 1, 1);
    774 
    775     m_pAttachmentTypeEditor = new UINetworkAttachmentEditor(m_pAdapterOptionsContainer);
    776     m_pAttachmentTypeEditor->setObjectName(QStringLiteral("m_pAttachmentTypeEditor"));
    777     pAdapterOptionsLayout->addWidget(m_pAttachmentTypeEditor, 0, 1, 2, 3);
    778 
    779     m_pAdapterNameLabel = new QLabel(m_pAdapterOptionsContainer);
    780     m_pAdapterNameLabel->setObjectName(QStringLiteral("m_pAdapterNameLabel"));
    781     m_pAdapterNameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    782     pAdapterOptionsLayout->addWidget(m_pAdapterNameLabel, 1, 0, 1, 1);
    783 
    784     QHBoxLayout *pAdvancedButtonLayout = new QHBoxLayout();
    785     pAdvancedButtonLayout->setContentsMargins(0, 0, 0, 0);
    786     pAdvancedButtonLayout->setObjectName(QStringLiteral("pAdvancedButtonLayout"));
    787     QSpacerItem *pHorizontalSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
    788     pAdvancedButtonLayout->addItem(pHorizontalSpacer2);
    789 
    790     m_pAdvancedArrow = new QIArrowButtonSwitch(m_pAdapterOptionsContainer);
    791     m_pAdvancedArrow->setObjectName(QStringLiteral("m_pAdvancedArrow"));
    792     pAdvancedButtonLayout->addWidget(m_pAdvancedArrow);
    793     pAdapterOptionsLayout->addLayout(pAdvancedButtonLayout, 2, 0, 1, 1);
    794 
    795     m_pAdapterTypeLabel = new QLabel(m_pAdapterOptionsContainer);
    796     m_pAdapterTypeLabel->setObjectName(QStringLiteral("m_pAdapterTypeLabel"));
    797     m_pAdapterTypeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    798     pAdapterOptionsLayout->addWidget(m_pAdapterTypeLabel, 3, 0, 1, 1);
    799 
    800     m_pAdapterTypeCombo = new QComboBox(m_pAdapterOptionsContainer);
    801     m_pAdapterTypeCombo->setObjectName(QStringLiteral("m_pAdapterTypeCombo"));
    802     QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    803     sizePolicy.setHorizontalStretch(1);
    804     sizePolicy.setVerticalStretch(0);
    805     sizePolicy.setHeightForWidth(m_pAdapterTypeCombo->sizePolicy().hasHeightForWidth());
    806     m_pAdapterTypeCombo->setSizePolicy(sizePolicy);
    807     pAdapterOptionsLayout->addWidget(m_pAdapterTypeCombo, 3, 1, 1, 3);
    808 
    809     m_pPromiscuousModeLabel = new QLabel(m_pAdapterOptionsContainer);
    810     m_pPromiscuousModeLabel->setObjectName(QStringLiteral("m_pPromiscuousModeLabel"));
    811     m_pPromiscuousModeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    812     pAdapterOptionsLayout->addWidget(m_pPromiscuousModeLabel, 4, 0, 1, 1);
    813 
    814     m_pPromiscuousModeCombo = new QComboBox(m_pAdapterOptionsContainer);
    815     m_pPromiscuousModeCombo->setObjectName(QStringLiteral("m_pPromiscuousModeCombo"));
    816     sizePolicy.setHeightForWidth(m_pPromiscuousModeCombo->sizePolicy().hasHeightForWidth());
    817     m_pPromiscuousModeCombo->setSizePolicy(sizePolicy);
    818     pAdapterOptionsLayout->addWidget(m_pPromiscuousModeCombo, 4, 1, 1, 3);
    819 
    820     m_pMACLabel = new QLabel(m_pAdapterOptionsContainer);
    821     m_pMACLabel->setObjectName(QStringLiteral("m_pMACLabel"));
    822     m_pMACLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    823     pAdapterOptionsLayout->addWidget(m_pMACLabel, 5, 0, 1, 1);
    824 
    825     m_pMACEditor = new QILineEdit(m_pAdapterOptionsContainer);
    826     m_pMACEditor->setObjectName(QStringLiteral("m_pMACEditor"));
    827     sizePolicy.setHeightForWidth(m_pMACEditor->sizePolicy().hasHeightForWidth());
    828     m_pMACEditor->setSizePolicy(sizePolicy);
    829     pAdapterOptionsLayout->addWidget(m_pMACEditor, 5, 1, 1, 2);
    830 
    831     m_pMACButton = new QIToolButton(m_pAdapterOptionsContainer);
    832     m_pMACButton->setObjectName(QStringLiteral("m_pMACButton"));
    833     pAdapterOptionsLayout->addWidget(m_pMACButton, 5, 3, 1, 1);
    834 
    835     m_pGenericPropertiesLabel = new QLabel(m_pAdapterOptionsContainer);
    836     m_pGenericPropertiesLabel->setObjectName(QStringLiteral("m_pGenericPropertiesLabel"));
    837     m_pGenericPropertiesLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignTop);
    838     pAdapterOptionsLayout->addWidget(m_pGenericPropertiesLabel, 6, 0, 1, 1);
    839 
    840     m_pGenericPropertiesTextEdit = new QTextEdit(m_pAdapterOptionsContainer);
    841     m_pGenericPropertiesTextEdit->setObjectName(QStringLiteral("m_pGenericPropertiesTextEdit"));
    842     pAdapterOptionsLayout->addWidget(m_pGenericPropertiesTextEdit, 6, 1, 1, 3);
    843 
    844     m_pCableConnectedCheckBox = new QCheckBox(m_pAdapterOptionsContainer);
    845     m_pCableConnectedCheckBox->setObjectName(QStringLiteral("m_pCableConnectedCheckBox"));
    846     pAdapterOptionsLayout->addWidget(m_pCableConnectedCheckBox, 7, 1, 1, 3);
    847 
    848     m_pPortForwardingButton = new QPushButton(m_pAdapterOptionsContainer);
    849     m_pPortForwardingButton->setObjectName(QStringLiteral("m_pPortForwardingButton"));
    850     pAdapterOptionsLayout->addWidget(m_pPortForwardingButton, 8, 1, 1, 1);
    851 
    852     QSpacerItem *pVerticalSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    853     pAdapterOptionsLayout->addItem(pVerticalSpacer, 9, 0, 1, 4);
    854     pMainLayout->addWidget(m_pAdapterOptionsContainer, 1, 1, 1, 1);
    855 
    856     m_pAdapterTypeLabel->setBuddy(m_pAdapterTypeCombo);
    857     m_pPromiscuousModeLabel->setBuddy(m_pPromiscuousModeCombo);
    858     m_pMACLabel->setBuddy(m_pMACEditor);
     746    if (pMainLayout)
     747    {
     748        pMainLayout->setRowStretch(2, 1);
     749
     750        /* Prepare adapter check-box: */
     751        m_pCheckBoxAdapter = new QCheckBox(this);
     752        if (m_pCheckBoxAdapter)
     753            pMainLayout->addWidget(m_pCheckBoxAdapter, 0, 0, 1, 2);
     754
     755        /* Prepare 20-px shifting spacer: */
     756        QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum);
     757        if (pSpacerItem)
     758            pMainLayout->addItem(pSpacerItem, 1, 0);
     759
     760        /* Prepare adapter settings widget: */
     761        m_pWidgetAdapterSettings = new QWidget(this);
     762        if (m_pWidgetAdapterSettings)
     763        {
     764            /* Prepare adapter settings widget layout: */
     765            QGridLayout *pLayoutAdapterSettings = new QGridLayout(m_pWidgetAdapterSettings);
     766            if (pLayoutAdapterSettings)
     767            {
     768                pLayoutAdapterSettings->setContentsMargins(0, 0, 0, 0);
     769                pLayoutAdapterSettings->setColumnStretch(2, 1);
     770
     771                /* Prepare attachment type label: */
     772                m_pLabelAttachmentType = new QLabel(m_pWidgetAdapterSettings);
     773                if (m_pLabelAttachmentType)
     774                {
     775                    m_pLabelAttachmentType->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     776                    pLayoutAdapterSettings->addWidget(m_pLabelAttachmentType, 0, 0);
     777                }
     778                /* Prepare adapter name label: */
     779                m_pLabelAdapterName = new QLabel(m_pWidgetAdapterSettings);
     780                if (m_pLabelAdapterName)
     781                {
     782                    m_pLabelAdapterName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     783                    pLayoutAdapterSettings->addWidget(m_pLabelAdapterName, 1, 0);
     784                }
     785                /* Prepare attachment type editor: */
     786                m_pEditorAttachmentType = new UINetworkAttachmentEditor(m_pWidgetAdapterSettings);
     787                if (m_pEditorAttachmentType)
     788                {
     789                    m_pLabelAttachmentType->setBuddy(m_pEditorAttachmentType->focusProxy1());
     790                    m_pLabelAdapterName->setBuddy(m_pEditorAttachmentType->focusProxy2());
     791                    pLayoutAdapterSettings->addWidget(m_pEditorAttachmentType, 0, 1, 2, 3);
     792                }
     793
     794                /* Prepare advanced arraow button: */
     795                m_pButtonAdvanced = new QIArrowButtonSwitch(m_pWidgetAdapterSettings);
     796                if (m_pButtonAdvanced)
     797                {
     798                    const QStyle *pStyle = QApplication::style();
     799                    const int iIconMetric = (int)(pStyle->pixelMetric(QStyle::PM_SmallIconSize) * .625);
     800                    m_pButtonAdvanced->setIconSize(QSize(iIconMetric, iIconMetric));
     801                    m_pButtonAdvanced->setIcons(UIIconPool::iconSet(":/arrow_right_10px.png"),
     802                                               UIIconPool::iconSet(":/arrow_down_10px.png"));
     803
     804                    pLayoutAdapterSettings->addWidget(m_pButtonAdvanced, 2, 0);
     805                }
     806
     807                /* Prepare adapter type label: */
     808                m_pLabelAdapterType = new QLabel(m_pWidgetAdapterSettings);
     809                if (m_pLabelAdapterType)
     810                {
     811                    m_pLabelAdapterType->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     812                    pLayoutAdapterSettings->addWidget(m_pLabelAdapterType, 3, 0);
     813                }
     814                /* Prepare adapter type combo: */
     815                m_pComboAdapterType = new QComboBox(m_pWidgetAdapterSettings);
     816                if (m_pComboAdapterType)
     817                {
     818                    m_pLabelAdapterType->setBuddy(m_pComboAdapterType);
     819                    pLayoutAdapterSettings->addWidget(m_pComboAdapterType, 3, 1, 1, 3);
     820                }
     821
     822                /* Prepare promiscuous mode label: */
     823                m_pLabelPromiscuousMode = new QLabel(m_pWidgetAdapterSettings);
     824                if (m_pLabelPromiscuousMode)
     825                {
     826                    m_pLabelPromiscuousMode->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     827                    pLayoutAdapterSettings->addWidget(m_pLabelPromiscuousMode, 4, 0);
     828                }
     829                /* Prepare promiscuous mode combo: */
     830                m_pComboPromiscuousMode = new QComboBox(m_pWidgetAdapterSettings);
     831                if (m_pComboPromiscuousMode)
     832                {
     833                    m_pLabelPromiscuousMode->setBuddy(m_pComboPromiscuousMode);
     834                    pLayoutAdapterSettings->addWidget(m_pComboPromiscuousMode, 4, 1, 1, 3);
     835                }
     836
     837                /* Prepare MAC label: */
     838                m_pLabelMAC = new QLabel(m_pWidgetAdapterSettings);
     839                if (m_pLabelMAC)
     840                {
     841                    m_pLabelMAC->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     842                    pLayoutAdapterSettings->addWidget(m_pLabelMAC, 5, 0);
     843                }
     844                /* Prepare MAC editor: */
     845                m_pEditorMAC = new QILineEdit(m_pWidgetAdapterSettings);
     846                if (m_pEditorMAC)
     847                {
     848                    m_pLabelMAC->setBuddy(m_pEditorMAC);
     849                    m_pEditorMAC->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this));
     850                    m_pEditorMAC->setMinimumWidthByText(QString().fill('0', 12));
     851
     852                    pLayoutAdapterSettings->addWidget(m_pEditorMAC, 5, 1, 1, 2);
     853                }
     854                /* Prepare MAC button: */
     855                m_pButtonMAC = new QIToolButton(m_pWidgetAdapterSettings);
     856                if (m_pButtonMAC)
     857                {
     858                    m_pButtonMAC->setIcon(UIIconPool::iconSet(":/refresh_16px.png"));
     859                    pLayoutAdapterSettings->addWidget(m_pButtonMAC, 5, 3);
     860                }
     861
     862                /* Prepare MAC label: */
     863                m_pLabelGenericProperties = new QLabel(m_pWidgetAdapterSettings);
     864                if (m_pLabelGenericProperties)
     865                {
     866                    m_pLabelGenericProperties->setAlignment(Qt::AlignRight | Qt::AlignTop);
     867                    pLayoutAdapterSettings->addWidget(m_pLabelGenericProperties, 6, 0);
     868                }
     869                /* Prepare MAC editor: */
     870                m_pEditorGenericProperties = new QTextEdit(m_pWidgetAdapterSettings);
     871                if (m_pEditorGenericProperties)
     872                    pLayoutAdapterSettings->addWidget(m_pEditorGenericProperties, 6, 1, 1, 3);
     873
     874                /* Prepare cable connected check-box: */
     875                m_pCheckBoxCableConnected = new QCheckBox(m_pWidgetAdapterSettings);
     876                if (m_pCheckBoxCableConnected)
     877                    pLayoutAdapterSettings->addWidget(m_pCheckBoxCableConnected, 7, 1, 1, 3);
     878
     879                /* Prepare port forwarding button: */
     880                m_pButtonPortForwarding = new QPushButton(m_pWidgetAdapterSettings);
     881                if (m_pButtonPortForwarding)
     882                    pLayoutAdapterSettings->addWidget(m_pButtonPortForwarding, 8, 1);
     883            }
     884
     885            pMainLayout->addWidget(m_pWidgetAdapterSettings, 1, 1);
     886        }
     887    }
     888}
     889
     890void UIMachineSettingsNetwork::prepareConnections()
     891{
     892    connect(m_pCheckBoxAdapter, &QCheckBox::toggled, this, &UIMachineSettingsNetwork::sltHandleAdapterActivityChange);
     893    connect(m_pEditorAttachmentType, &UINetworkAttachmentEditor::sigValueTypeChanged,
     894            this, &UIMachineSettingsNetwork::sltHandleAttachmentTypeChange);
     895    connect(m_pEditorAttachmentType, &UINetworkAttachmentEditor::sigValueNameChanged,
     896            this, &UIMachineSettingsNetwork::sltHandleAlternativeNameChange);
     897    connect(m_pButtonAdvanced, &QIArrowButtonSwitch::sigClicked, this, &UIMachineSettingsNetwork::sltHandleAdvancedButtonStateChange);
     898    connect(m_pEditorMAC, &QILineEdit::textChanged, m_pParent, &UIMachineSettingsNetworkPage::revalidate);
     899    connect(m_pButtonMAC, &QIToolButton::clicked, this, &UIMachineSettingsNetwork::sltGenerateMac);
     900    connect(m_pButtonPortForwarding, &QPushButton::clicked, this, &UIMachineSettingsNetwork::sltOpenPortForwardingDlg);
     901    connect(this, &UIMachineSettingsNetwork::sigTabUpdated, m_pParent, &UIMachineSettingsNetworkPage::sltHandleTabUpdate);
    859902}
    860903
     
    869912    {
    870913        /* Clear the adapter type combo-box: */
    871         m_pAdapterTypeCombo->clear();
     914        m_pComboAdapterType->clear();
    872915
    873916        /* Load currently supported network adapter types: */
     
    882925        foreach (const KNetworkAdapterType &enmType, supportedTypes)
    883926        {
    884             m_pAdapterTypeCombo->insertItem(iAdapterTypeIndex, gpConverter->toString(enmType));
    885             m_pAdapterTypeCombo->setItemData(iAdapterTypeIndex, QVariant::fromValue(enmType));
    886             m_pAdapterTypeCombo->setItemData(iAdapterTypeIndex, m_pAdapterTypeCombo->itemText(iAdapterTypeIndex), Qt::ToolTipRole);
     927            m_pComboAdapterType->insertItem(iAdapterTypeIndex, gpConverter->toString(enmType));
     928            m_pComboAdapterType->setItemData(iAdapterTypeIndex, QVariant::fromValue(enmType));
     929            m_pComboAdapterType->setItemData(iAdapterTypeIndex, m_pComboAdapterType->itemText(iAdapterTypeIndex), Qt::ToolTipRole);
    887930            ++iAdapterTypeIndex;
    888931        }
    889932
    890933        /* Choose requested adapter type: */
    891         const int iIndex = m_pAdapterTypeCombo->findData(m_enmAdapterType);
    892         m_pAdapterTypeCombo->setCurrentIndex(iIndex != -1 ? iIndex : 0);
     934        const int iIndex = m_pComboAdapterType->findData(m_enmAdapterType);
     935        m_pComboAdapterType->setCurrentIndex(iIndex != -1 ? iIndex : 0);
    893936    }
    894937
     
    896939    {
    897940        /* Remember the currently selected promiscuous mode type: */
    898         int iCurrentPromiscuousMode = m_pPromiscuousModeCombo->currentIndex();
     941        int iCurrentPromiscuousMode = m_pComboPromiscuousMode->currentIndex();
    899942
    900943        /* Clear the promiscuous mode combo-box: */
    901         m_pPromiscuousModeCombo->clear();
     944        m_pComboPromiscuousMode->clear();
    902945
    903946        /* Populate promiscuous modes: */
    904947        int iPromiscuousModeIndex = 0;
    905         m_pPromiscuousModeCombo->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_Deny));
    906         m_pPromiscuousModeCombo->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_Deny);
    907         m_pPromiscuousModeCombo->setItemData(iPromiscuousModeIndex, m_pPromiscuousModeCombo->itemText(iPromiscuousModeIndex), Qt::ToolTipRole);
     948        m_pComboPromiscuousMode->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_Deny));
     949        m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_Deny);
     950        m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, m_pComboPromiscuousMode->itemText(iPromiscuousModeIndex), Qt::ToolTipRole);
    908951        ++iPromiscuousModeIndex;
    909         m_pPromiscuousModeCombo->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_AllowNetwork));
    910         m_pPromiscuousModeCombo->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_AllowNetwork);
    911         m_pPromiscuousModeCombo->setItemData(iPromiscuousModeIndex, m_pPromiscuousModeCombo->itemText(iPromiscuousModeIndex), Qt::ToolTipRole);
     952        m_pComboPromiscuousMode->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_AllowNetwork));
     953        m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_AllowNetwork);
     954        m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, m_pComboPromiscuousMode->itemText(iPromiscuousModeIndex), Qt::ToolTipRole);
    912955        ++iPromiscuousModeIndex;
    913         m_pPromiscuousModeCombo->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_AllowAll));
    914         m_pPromiscuousModeCombo->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_AllowAll);
    915         m_pPromiscuousModeCombo->setItemData(iPromiscuousModeIndex, m_pPromiscuousModeCombo->itemText(iPromiscuousModeIndex), Qt::ToolTipRole);
     956        m_pComboPromiscuousMode->insertItem(iPromiscuousModeIndex, gpConverter->toString(KNetworkAdapterPromiscModePolicy_AllowAll));
     957        m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, KNetworkAdapterPromiscModePolicy_AllowAll);
     958        m_pComboPromiscuousMode->setItemData(iPromiscuousModeIndex, m_pComboPromiscuousMode->itemText(iPromiscuousModeIndex), Qt::ToolTipRole);
    916959        ++iPromiscuousModeIndex;
    917960
    918961        /* Restore the previously selected promiscuous mode type: */
    919         m_pPromiscuousModeCombo->setCurrentIndex(iCurrentPromiscuousMode == -1 ? 0 : iCurrentPromiscuousMode);
     962        m_pComboPromiscuousMode->setCurrentIndex(iCurrentPromiscuousMode == -1 ? 0 : iCurrentPromiscuousMode);
    920963    }
    921964}
     
    924967{
    925968    /* Update visibility of advanced options: */
    926     m_pAdapterTypeLabel->setVisible(m_pAdvancedArrow->isExpanded());
    927     m_pAdapterTypeCombo->setVisible(m_pAdvancedArrow->isExpanded());
    928     m_pPromiscuousModeLabel->setVisible(m_pAdvancedArrow->isExpanded());
    929     m_pPromiscuousModeCombo->setVisible(m_pAdvancedArrow->isExpanded());
    930     m_pGenericPropertiesLabel->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
    931                                           m_pAdvancedArrow->isExpanded());
    932     m_pGenericPropertiesTextEdit->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
    933                                              m_pAdvancedArrow->isExpanded());
    934     m_pMACLabel->setVisible(m_pAdvancedArrow->isExpanded());
    935     m_pMACEditor->setVisible(m_pAdvancedArrow->isExpanded());
    936     m_pMACButton->setVisible(m_pAdvancedArrow->isExpanded());
    937     m_pCableConnectedCheckBox->setVisible(m_pAdvancedArrow->isExpanded());
    938     m_pPortForwardingButton->setVisible(m_pAdvancedArrow->isExpanded());
     969    m_pLabelAdapterType->setVisible(m_pButtonAdvanced->isExpanded());
     970    m_pComboAdapterType->setVisible(m_pButtonAdvanced->isExpanded());
     971    m_pLabelPromiscuousMode->setVisible(m_pButtonAdvanced->isExpanded());
     972    m_pComboPromiscuousMode->setVisible(m_pButtonAdvanced->isExpanded());
     973    m_pLabelGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
     974                                          m_pButtonAdvanced->isExpanded());
     975    m_pEditorGenericProperties->setVisible(attachmentType() == KNetworkAttachmentType_Generic &&
     976                                             m_pButtonAdvanced->isExpanded());
     977    m_pLabelMAC->setVisible(m_pButtonAdvanced->isExpanded());
     978    m_pEditorMAC->setVisible(m_pButtonAdvanced->isExpanded());
     979    m_pButtonMAC->setVisible(m_pButtonAdvanced->isExpanded());
     980    m_pCheckBoxCableConnected->setVisible(m_pButtonAdvanced->isExpanded());
     981    m_pButtonPortForwarding->setVisible(m_pButtonAdvanced->isExpanded());
    939982}
    940983
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette