VirtualBox

Changeset 80200 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 8, 2019 4:09:02 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:7720: VM settings / Network page: Replace heavily distributed across network page widgets related to network attachment type & adapter name functionality with single UINetworkAttachmentEditor.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r80132 r80200  
    904904        src/widgets/UIMenuBarEditorWindow.h \
    905905        src/widgets/UINameAndSystemEditor.h \
     906        src/widgets/UINetworkAttachmentEditor.h \
    906907        src/widgets/UIPopupBox.h \
    907908        src/widgets/UIPopupPane.h \
     
    14021403        src/widgets/UIMenuBarEditorWindow.cpp \
    14031404        src/widgets/UINameAndSystemEditor.cpp \
     1405        src/widgets/UINetworkAttachmentEditor.cpp \
    14041406        src/widgets/UIPopupBox.cpp \
    14051407        src/widgets/UIPopupPane.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r79365 r80200  
    4141#endif
    4242
    43 
    44 /* Empty item extra-code: */
    45 const char *pEmptyItemCode = "#empty#";
    4643
    4744QString wipedOutString(const QString &strInputString)
     
    165162    QString tabTitle() const;
    166163    KNetworkAttachmentType attachmentType() const;
    167     QString alternativeName(int iType = -1) const;
     164    QString alternativeName(KNetworkAttachmentType enmType = KNetworkAttachmentType_Null) const;
    168165    void polishTab();
    169     void reloadAlternative();
     166    void reloadAlternatives();
    170167
    171168    /** Defines whether the advanced button is @a fExpanded. */
     
    202199    /* Helping stuff: */
    203200    void populateComboboxes();
    204     void updateAlternativeList();
    205     void updateAlternativeName();
    206201
    207202    /** Handles advanced button state change. */
     
    217212    /* Other variables: */
    218213    int m_iSlot;
    219     QString m_strBridgedAdapterName;
    220     QString m_strInternalNetworkName;
    221     QString m_strHostInterfaceName;
    222     QString m_strGenericDriverName;
    223     QString m_strNATNetworkName;
    224214    UIPortForwardingDataList m_portForwardingRules;
    225215    /** Holds the list of restricted network attachment types. */
     
    246236
    247237    /* Setup widgets: */
    248     m_pAdapterNameCombo->setInsertPolicy(QComboBox::NoInsert);
     238    m_pAttachmentTypeLabel->setBuddy(m_pAttachmentTypeEditor->focusProxy1());
     239    m_pAdapterNameLabel->setBuddy(m_pAttachmentTypeEditor->focusProxy2());
    249240    m_pMACEditor->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this));
    250241    m_pMACEditor->setMinimumWidthByText(QString().fill('0', 12));
     
    256247    /* Setup connections: */
    257248    connect(m_pEnableAdapterCheckBox, SIGNAL(toggled(bool)), this, SLOT(sltHandleAdapterActivityChange()));
    258     connect(m_pAttachmentTypeComboBox, SIGNAL(activated(int)), this, SLOT(sltHandleAttachmentTypeChange()));
    259     connect(m_pAdapterNameCombo, SIGNAL(activated(int)), this, SLOT(sltHandleAlternativeNameChange()));
    260     connect(m_pAdapterNameCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(sltHandleAlternativeNameChange()));
     249    connect(m_pAttachmentTypeEditor, &UINetworkAttachmentEditor::sigValueTypeChanged,
     250            this, &UIMachineSettingsNetwork::sltHandleAttachmentTypeChange);
     251    connect(m_pAttachmentTypeEditor, &UINetworkAttachmentEditor::sigValueNameChanged,
     252            this, &UIMachineSettingsNetwork::sltHandleAlternativeNameChange);
    261253    connect(m_pAdvancedArrow, SIGNAL(sigClicked()), this, SLOT(sltHandleAdvancedButtonStateChange()));
    262254    connect(m_pMACButton, SIGNAL(clicked()), this, SLOT(sltGenerateMac()));
     
    285277
    286278    /* Load attachment type: */
    287     m_pAttachmentTypeComboBox->setCurrentIndex(position(m_pAttachmentTypeComboBox, oldAdapterData.m_attachmentType));
    288     /* Load alternative name: */
    289     m_strBridgedAdapterName = wipedOutString(oldAdapterData.m_strBridgedAdapterName);
    290     m_strInternalNetworkName = wipedOutString(oldAdapterData.m_strInternalNetworkName);
    291     m_strHostInterfaceName = wipedOutString(oldAdapterData.m_strHostInterfaceName);
    292     m_strGenericDriverName = wipedOutString(oldAdapterData.m_strGenericDriverName);
    293     m_strNATNetworkName = wipedOutString(oldAdapterData.m_strNATNetworkName);
     279    m_pAttachmentTypeEditor->setValueType(oldAdapterData.m_attachmentType);
     280    /* Load alternative names: */
     281    m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_Bridged, wipedOutString(oldAdapterData.m_strBridgedAdapterName));
     282    m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_Internal, wipedOutString(oldAdapterData.m_strInternalNetworkName));
     283    m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_HostOnly, wipedOutString(oldAdapterData.m_strHostInterfaceName));
     284    m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_Generic, wipedOutString(oldAdapterData.m_strGenericDriverName));
     285    m_pAttachmentTypeEditor->setValueName(KNetworkAttachmentType_NATNetwork, wipedOutString(oldAdapterData.m_strNATNetworkName));
    294286    /* Handle attachment type change: */
    295287    sltHandleAttachmentTypeChange();
     
    339331            break;
    340332        case KNetworkAttachmentType_Internal:
    341             newAdapterData.m_strInternalNetworkName = alternativeName();
     333            newAdapterData.m_strInternalNetworkName = m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_Internal);
    342334            break;
    343335        case KNetworkAttachmentType_HostOnly:
    344             newAdapterData.m_strHostInterfaceName = alternativeName();
     336            newAdapterData.m_strHostInterfaceName = m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_HostOnly);
    345337            break;
    346338        case KNetworkAttachmentType_Generic:
    347             newAdapterData.m_strGenericDriverName = alternativeName();
     339            newAdapterData.m_strGenericDriverName = m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_Generic);
    348340            newAdapterData.m_strGenericProperties = m_pGenericPropertiesTextEdit->toPlainText();
    349341            break;
    350342        case KNetworkAttachmentType_NATNetwork:
    351             newAdapterData.m_strNATNetworkName = alternativeName();
     343            newAdapterData.m_strNATNetworkName = m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_NATNetwork);
    352344            break;
    353345        default:
     
    467459{
    468460    setTabOrder(pAfter, m_pEnableAdapterCheckBox);
    469     setTabOrder(m_pEnableAdapterCheckBox, m_pAttachmentTypeComboBox);
    470     setTabOrder(m_pAttachmentTypeComboBox, m_pAdapterNameCombo);
    471     setTabOrder(m_pAdapterNameCombo, m_pAdvancedArrow);
     461    setTabOrder(m_pEnableAdapterCheckBox, m_pAttachmentTypeEditor);
     462    setTabOrder(m_pAttachmentTypeEditor, m_pAdvancedArrow);
    472463    setTabOrder(m_pAdvancedArrow, m_pAdapterTypeCombo);
    473464    setTabOrder(m_pAdapterTypeCombo, m_pPromiscuousModeCombo);
     
    487478KNetworkAttachmentType UIMachineSettingsNetwork::attachmentType() const
    488479{
    489     return (KNetworkAttachmentType)m_pAttachmentTypeComboBox->itemData(m_pAttachmentTypeComboBox->currentIndex()).toInt();
    490 }
    491 
    492 QString UIMachineSettingsNetwork::alternativeName(int iType) const
    493 {
    494     if (iType == -1)
    495         iType = attachmentType();
    496     QString strResult;
    497     switch (iType)
    498     {
    499         case KNetworkAttachmentType_Bridged:
    500             strResult = m_strBridgedAdapterName;
    501             break;
    502         case KNetworkAttachmentType_Internal:
    503             strResult = m_strInternalNetworkName;
    504             break;
    505         case KNetworkAttachmentType_HostOnly:
    506             strResult = m_strHostInterfaceName;
    507             break;
    508         case KNetworkAttachmentType_Generic:
    509             strResult = m_strGenericDriverName;
    510             break;
    511         case KNetworkAttachmentType_NATNetwork:
    512             strResult = m_strNATNetworkName;
    513             break;
    514         default:
    515             break;
    516     }
    517     Assert(strResult.isNull() || !strResult.isEmpty());
    518     return strResult;
     480    return m_pAttachmentTypeEditor->valueType();
     481}
     482
     483QString UIMachineSettingsNetwork::alternativeName(KNetworkAttachmentType enmType /* = KNetworkAttachmentType_Null */) const
     484{
     485    if (enmType == KNetworkAttachmentType_Null)
     486        enmType = attachmentType();
     487    return m_pAttachmentTypeEditor->valueName(enmType);
    519488}
    520489
     
    524493    m_pEnableAdapterCheckBox->setEnabled(m_pParent->isMachineOffline());
    525494    m_pAttachmentTypeLabel->setEnabled(m_pParent->isMachineInValidMode());
    526     m_pAttachmentTypeComboBox->setEnabled(m_pParent->isMachineInValidMode());
     495    m_pAttachmentTypeEditor->setEnabled(m_pParent->isMachineInValidMode());
    527496    m_pAdapterNameLabel->setEnabled(m_pParent->isMachineInValidMode() &&
    528                                     attachmentType() != KNetworkAttachmentType_Null &&
    529                                     attachmentType() != KNetworkAttachmentType_NAT);
    530     m_pAdapterNameCombo->setEnabled(m_pParent->isMachineInValidMode() &&
    531497                                    attachmentType() != KNetworkAttachmentType_Null &&
    532498                                    attachmentType() != KNetworkAttachmentType_NAT);
     
    557523}
    558524
    559 void UIMachineSettingsNetwork::reloadAlternative()
    560 {
    561     /* Repopulate alternative-name combo-box content: */
    562     updateAlternativeList();
    563     /* Select previous or default alternative-name combo-box item: */
    564     updateAlternativeName();
     525void UIMachineSettingsNetwork::reloadAlternatives()
     526{
     527    m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Bridged, m_pParent->bridgedAdapterList());
     528    m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Internal, m_pParent->internalNetworkList());
     529    m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_HostOnly, m_pParent->hostInterfaceList());
     530    m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_Generic, m_pParent->genericDriverList());
     531    m_pAttachmentTypeEditor->setValueNames(KNetworkAttachmentType_NATNetwork, m_pParent->natNetworkList());
    565532}
    566533
     
    606573    /* Update alternative-name combo-box availability: */
    607574    m_pAdapterNameLabel->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
    608                                     attachmentType() != KNetworkAttachmentType_NAT);
    609     m_pAdapterNameCombo->setEnabled(attachmentType() != KNetworkAttachmentType_Null &&
    610575                                    attachmentType() != KNetworkAttachmentType_NAT);
    611576    /* Update promiscuous-mode combo-box availability: */
     
    623588    /* Update forwarding rules button availability: */
    624589    m_pPortForwardingButton->setEnabled(attachmentType() == KNetworkAttachmentType_NAT);
    625     /* Update alternative-name combo-box whats-this and editable state: */
    626     switch (attachmentType())
    627     {
    628         case KNetworkAttachmentType_Bridged:
    629         {
    630             m_pAdapterNameCombo->setWhatsThis(tr("Selects the network adapter on the host system that traffic "
    631                                                  "to and from this network card will go through."));
    632             m_pAdapterNameCombo->setEditable(false);
    633             break;
    634         }
    635         case KNetworkAttachmentType_Internal:
    636         {
    637             m_pAdapterNameCombo->setWhatsThis(tr("Holds the name of the internal network that this network card "
    638                                                  "will be connected to. You can create a new internal network by "
    639                                                  "choosing a name which is not used by any other network cards "
    640                                                  "in this virtual machine or others."));
    641             m_pAdapterNameCombo->setEditable(true);
    642             break;
    643         }
    644         case KNetworkAttachmentType_HostOnly:
    645         {
    646             m_pAdapterNameCombo->setWhatsThis(tr("Selects the virtual network adapter on the host system that traffic "
    647                                                  "to and from this network card will go through. "
    648                                                  "You can create and remove adapters using the global network "
    649                                                  "settings in the virtual machine manager window."));
    650             m_pAdapterNameCombo->setEditable(false);
    651             break;
    652         }
    653         case KNetworkAttachmentType_Generic:
    654         {
    655             m_pAdapterNameCombo->setWhatsThis(tr("Selects the driver to be used with this network card."));
    656             m_pAdapterNameCombo->setEditable(true);
    657             break;
    658         }
    659         case KNetworkAttachmentType_NATNetwork:
    660         {
    661             m_pAdapterNameCombo->setWhatsThis(tr("Holds the name of the NAT network that this network card "
    662                                                  "will be connected to. You can create and remove networks "
    663                                                  "using the global network settings in the virtual machine "
    664                                                  "manager window."));
    665             m_pAdapterNameCombo->setEditable(false);
    666             break;
    667         }
    668         default:
    669         {
    670             m_pAdapterNameCombo->setWhatsThis(QString());
    671             break;
    672         }
    673     }
    674 
    675     /* Update alternative combo: */
    676     reloadAlternative();
    677 
    678     /* Handle alternative-name cange: */
    679     sltHandleAlternativeNameChange();
     590
     591    /* Revalidate: */
     592    m_pParent->revalidate();
    680593}
    681594
     
    686599    switch (attachmentType())
    687600    {
    688         case KNetworkAttachmentType_Bridged:
    689         {
    690             QString newName(m_pAdapterNameCombo->itemData(m_pAdapterNameCombo->currentIndex()).toString() == QString(pEmptyItemCode) ||
    691                             m_pAdapterNameCombo->currentText().isEmpty() ? QString() : m_pAdapterNameCombo->currentText());
    692             if (m_strBridgedAdapterName != newName)
    693                 m_strBridgedAdapterName = newName;
    694             break;
    695         }
    696601        case KNetworkAttachmentType_Internal:
    697602        {
    698             QString newName((m_pAdapterNameCombo->itemData(m_pAdapterNameCombo->currentIndex()).toString() == QString(pEmptyItemCode) &&
    699                              m_pAdapterNameCombo->currentText() == m_pAdapterNameCombo->itemText(m_pAdapterNameCombo->currentIndex())) ||
    700                              m_pAdapterNameCombo->currentText().isEmpty() ? QString() : m_pAdapterNameCombo->currentText());
    701             if (m_strInternalNetworkName != newName)
    702             {
    703                 m_strInternalNetworkName = newName;
    704                 if (!m_strInternalNetworkName.isNull())
    705                     emit sigTabUpdated();
    706             }
    707             break;
    708         }
    709         case KNetworkAttachmentType_HostOnly:
    710         {
    711             QString newName(m_pAdapterNameCombo->itemData(m_pAdapterNameCombo->currentIndex()).toString() == QString(pEmptyItemCode) ||
    712                             m_pAdapterNameCombo->currentText().isEmpty() ? QString() : m_pAdapterNameCombo->currentText());
    713             if (m_strHostInterfaceName != newName)
    714                 m_strHostInterfaceName = newName;
     603            if (!m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_Internal).isNull())
     604                emit sigTabUpdated();
    715605            break;
    716606        }
    717607        case KNetworkAttachmentType_Generic:
    718608        {
    719             QString newName((m_pAdapterNameCombo->itemData(m_pAdapterNameCombo->currentIndex()).toString() == QString(pEmptyItemCode) &&
    720                              m_pAdapterNameCombo->currentText() == m_pAdapterNameCombo->itemText(m_pAdapterNameCombo->currentIndex())) ||
    721                              m_pAdapterNameCombo->currentText().isEmpty() ? QString() : m_pAdapterNameCombo->currentText());
    722             if (m_strGenericDriverName != newName)
    723             {
    724                 m_strGenericDriverName = newName;
    725                 if (!m_strGenericDriverName.isNull())
    726                     emit sigTabUpdated();
    727             }
    728             break;
    729         }
    730         case KNetworkAttachmentType_NATNetwork:
    731         {
    732             QString newName(m_pAdapterNameCombo->itemData(m_pAdapterNameCombo->currentIndex()).toString() == QString(pEmptyItemCode) ||
    733                             m_pAdapterNameCombo->currentText().isEmpty() ? QString() : m_pAdapterNameCombo->currentText());
    734             if (m_strNATNetworkName != newName)
    735                 m_strNATNetworkName = newName;
     609            if (!m_pAttachmentTypeEditor->valueName(KNetworkAttachmentType_Generic).isNull())
     610                emit sigTabUpdated();
    736611            break;
    737612        }
     
    771646}
    772647
    773 UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork toInternalNetworkAdapterEnum(KNetworkAttachmentType comEnum)
    774 {
    775     switch (comEnum)
    776     {
    777         case KNetworkAttachmentType_NAT:        return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NAT;
    778         case KNetworkAttachmentType_Bridged:    return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_BridgetAdapter;
    779         case KNetworkAttachmentType_Internal:   return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_InternalNetwork;
    780         case KNetworkAttachmentType_HostOnly:   return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_HostOnlyAdapter;
    781         case KNetworkAttachmentType_Generic:    return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_GenericDriver;
    782         case KNetworkAttachmentType_NATNetwork: return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NATNetwork;
    783         default:                                return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid;
    784     }
    785 }
    786 
    787648void UIMachineSettingsNetwork::populateComboboxes()
    788649{
    789     /* Attachment type: */
    790     {
    791         /* Remember the currently selected attachment type: */
    792         int iCurrentAttachment = m_pAttachmentTypeComboBox->currentIndex();
    793 
    794         /* Clear the attachments combo-box: */
    795         m_pAttachmentTypeComboBox->clear();
    796 
    797         /* Populate attachments: */
    798         int iAttachmentTypeIndex = 0;
    799         /* We want some hardcoded order, so prepare a list of enum values: */
    800         QList<KNetworkAttachmentType> attachmentTypes  = QList<KNetworkAttachmentType>() << KNetworkAttachmentType_Null
    801                                                       << KNetworkAttachmentType_NAT << KNetworkAttachmentType_NATNetwork
    802                                                       << KNetworkAttachmentType_Bridged << KNetworkAttachmentType_Internal
    803                                                       << KNetworkAttachmentType_HostOnly << KNetworkAttachmentType_Generic;
    804         for (int i = 0; i < attachmentTypes.size(); ++i)
    805         {
    806             const KNetworkAttachmentType enmType = attachmentTypes.at(i);
    807             if (m_enmRestrictedNetworkAttachmentTypes & toInternalNetworkAdapterEnum(enmType))
    808                 continue;
    809             m_pAttachmentTypeComboBox->insertItem(iAttachmentTypeIndex, gpConverter->toString(enmType));
    810             m_pAttachmentTypeComboBox->setItemData(iAttachmentTypeIndex, enmType);
    811             m_pAttachmentTypeComboBox->setItemData(iAttachmentTypeIndex, m_pAttachmentTypeComboBox->itemText(iAttachmentTypeIndex), Qt::ToolTipRole);
    812             ++iAttachmentTypeIndex;
    813         }
    814 
    815         /* Restore the previously selected attachment type: */
    816         m_pAttachmentTypeComboBox->setCurrentIndex(iCurrentAttachment == -1 ? 0 : iCurrentAttachment);
     650    /* Adapter names: */
     651    {
     652        reloadAlternatives();
    817653    }
    818654
     
    888724}
    889725
    890 void UIMachineSettingsNetwork::updateAlternativeList()
    891 {
    892     /* Block signals initially: */
    893     m_pAdapterNameCombo->blockSignals(true);
    894 
    895     /* Repopulate alternative-name combo: */
    896     m_pAdapterNameCombo->clear();
    897     switch (attachmentType())
    898     {
    899         case KNetworkAttachmentType_Bridged:
    900             m_pAdapterNameCombo->insertItems(0, m_pParent->bridgedAdapterList());
    901             break;
    902         case KNetworkAttachmentType_Internal:
    903             m_pAdapterNameCombo->insertItems(0, m_pParent->internalNetworkList());
    904             break;
    905         case KNetworkAttachmentType_HostOnly:
    906             m_pAdapterNameCombo->insertItems(0, m_pParent->hostInterfaceList());
    907             break;
    908         case KNetworkAttachmentType_Generic:
    909             m_pAdapterNameCombo->insertItems(0, m_pParent->genericDriverList());
    910             break;
    911         case KNetworkAttachmentType_NATNetwork:
    912             m_pAdapterNameCombo->insertItems(0, m_pParent->natNetworkList());
    913             break;
    914         default:
    915             break;
    916     }
    917 
    918     /* Prepend 'empty' or 'default' item to alternative-name combo: */
    919     if (m_pAdapterNameCombo->count() == 0)
    920     {
    921         switch (attachmentType())
    922         {
    923             case KNetworkAttachmentType_Bridged:
    924             case KNetworkAttachmentType_HostOnly:
    925             case KNetworkAttachmentType_NATNetwork:
    926             {
    927                 /* If adapter list is empty => add 'Not selected' item: */
    928                 int pos = m_pAdapterNameCombo->findData(pEmptyItemCode);
    929                 if (pos == -1)
    930                     m_pAdapterNameCombo->insertItem(0, tr("Not selected", "network adapter name"), pEmptyItemCode);
    931                 else
    932                     m_pAdapterNameCombo->setItemText(pos, tr("Not selected", "network adapter name"));
    933                 break;
    934             }
    935             case KNetworkAttachmentType_Internal:
    936             {
    937                 /* Internal network list should have a default item: */
    938                 if (m_pAdapterNameCombo->findText("intnet") == -1)
    939                     m_pAdapterNameCombo->insertItem(0, "intnet");
    940                 break;
    941             }
    942             default:
    943                 break;
    944         }
    945     }
    946 
    947     /* Unblock signals finally: */
    948     m_pAdapterNameCombo->blockSignals(false);
    949 }
    950 
    951 void UIMachineSettingsNetwork::updateAlternativeName()
    952 {
    953     /* Block signals initially: */
    954     m_pAdapterNameCombo->blockSignals(true);
    955 
    956     switch (attachmentType())
    957     {
    958         case KNetworkAttachmentType_Bridged:
    959         case KNetworkAttachmentType_Internal:
    960         case KNetworkAttachmentType_HostOnly:
    961         case KNetworkAttachmentType_Generic:
    962         case KNetworkAttachmentType_NATNetwork:
    963         {
    964             m_pAdapterNameCombo->setCurrentIndex(position(m_pAdapterNameCombo, alternativeName()));
    965             break;
    966         }
    967         default:
    968             break;
    969     }
    970 
    971     /* Unblock signals finally: */
    972     m_pAdapterNameCombo->blockSignals(false);
    973 }
    974 
    975726void UIMachineSettingsNetwork::handleAdvancedButtonStateChange()
    976727{
     
    1239990        AssertMsg(pTab, ("All the tabs of m_pTabWidget should be of the UIMachineSettingsNetwork type!\n"));
    1240991
    1241         /* Update all the tabs (except sender) with the same attachment type as sender have: */
    1242         if (pTab != pSender && pTab->attachmentType() == enmSenderAttachmentType)
    1243             pTab->reloadAlternative();
     992        /* Update all the tabs (except sender): */
     993        if (pTab != pSender)
     994            pTab->reloadAlternatives();
    1244995    }
    1245996}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.ui

    r67067 r80200  
    6464         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    6565        </property>
    66         <property name="buddy">
    67          <cstring>m_pAttachmentTypeComboBox</cstring>
    68         </property>
    69        </widget>
    70       </item>
    71       <item row="0" column="1">
    72        <widget class="QComboBox" name="m_pAttachmentTypeComboBox">
    73         <property name="sizePolicy">
    74          <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
    75           <horstretch>0</horstretch>
    76           <verstretch>0</verstretch>
    77          </sizepolicy>
    78         </property>
     66       </widget>
     67      </item>
     68      <item row="0" column="1" rowspan="2" colspan="3">
     69       <widget class="UINetworkAttachmentEditor" name="m_pAttachmentTypeEditor">
    7970        <property name="whatsThis">
    8071         <string>Selects how this virtual adapter is attached to the real network of the Host OS.</string>
     
    8980        <property name="alignment">
    9081         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    91         </property>
    92         <property name="buddy">
    93          <cstring>m_pAdapterNameCombo</cstring>
    94         </property>
    95        </widget>
    96       </item>
    97       <item row="1" column="1" colspan="3">
    98        <widget class="QComboBox" name="m_pAdapterNameCombo">
    99         <property name="sizePolicy">
    100          <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
    101           <horstretch>1</horstretch>
    102           <verstretch>0</verstretch>
    103          </sizepolicy>
    10482        </property>
    10583       </widget>
     
    292270   <header>QIToolButton.h</header>
    293271  </customwidget>
     272  <customwidget>
     273   <class>UINetworkAttachmentEditor</class>
     274   <extends>QWidget</extends>
     275   <header>UINetworkAttachmentEditor.h</header>
     276  </customwidget>
    294277 </customwidgets>
    295278 <resources>
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINetworkAttachmentEditor.cpp

    r80154 r80200  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIAudioHostDriverEditor class implementation.
     3 * VBox Qt GUI - UINetworkAttachmentEditor class implementation.
    44 */
    55
     
    2424#include "QIComboBox.h"
    2525#include "UIConverter.h"
    26 #include "UIAudioHostDriverEditor.h"
    27 
    28 
    29 UIAudioHostDriverEditor::UIAudioHostDriverEditor(QWidget *pParent /* = 0 */, bool fWithLabel /* = false */)
     26#include "UIExtraDataManager.h"
     27#include "UINetworkAttachmentEditor.h"
     28
     29
     30/* static */
     31QString UINetworkAttachmentEditor::s_strEmptyItemId = QString("#empty#");
     32
     33UINetworkAttachmentEditor::UINetworkAttachmentEditor(QWidget *pParent /* = 0 */, bool fWithLabels /* = false */)
    3034    : QIWithRetranslateUI<QWidget>(pParent)
    31     , m_fWithLabel(fWithLabel)
    32     , m_pLabel(0)
    33     , m_pCombo(0)
     35    , m_fWithLabels(fWithLabels)
     36    , m_enmRestrictedNetworkAttachmentTypes(UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid)
     37    , m_pLabelType(0)
     38    , m_pComboType(0)
     39    , m_pLabelName(0)
     40    , m_pComboName(0)
    3441{
    3542    prepare();
    3643}
    3744
    38 void UIAudioHostDriverEditor::setValue(KAudioDriverType enmValue)
    39 {
    40     if (m_pCombo)
    41     {
    42         int iIndex = m_pCombo->findData(QVariant::fromValue(enmValue));
     45QWidget *UINetworkAttachmentEditor::focusProxy1() const
     46{
     47    return m_pComboType->focusProxy();
     48}
     49
     50QWidget *UINetworkAttachmentEditor::focusProxy2() const
     51{
     52    return m_pComboName->focusProxy();
     53}
     54
     55void UINetworkAttachmentEditor::setValueType(KNetworkAttachmentType enmType)
     56{
     57    /* Make sure combo is there: */
     58    if (!m_pComboType)
     59        return;
     60
     61    /* Search for an item with required data value, choose item to be current if found: */
     62    const int iIndex = m_pComboType->findData(QVariant::fromValue(enmType));
     63    if (iIndex != -1)
     64        m_pComboType->setCurrentIndex(iIndex);
     65}
     66
     67KNetworkAttachmentType UINetworkAttachmentEditor::valueType() const
     68{
     69    /* Make sure combo is there: */
     70    if (!m_pComboType)
     71        return KNetworkAttachmentType_Null;
     72
     73    /* Return current item data: */
     74    return m_pComboType->currentData().value<KNetworkAttachmentType>();
     75}
     76
     77void UINetworkAttachmentEditor::setValueNames(KNetworkAttachmentType enmType, const QStringList &names)
     78{
     79    /* Save possible names for passed type: */
     80    m_names[enmType] = names;
     81
     82    /* If value type is the same, update the combo as well: */
     83    if (valueType() == enmType)
     84        populateNameCombo();
     85}
     86
     87void UINetworkAttachmentEditor::setValueName(KNetworkAttachmentType enmType, const QString &strName)
     88{
     89    /* Save current name for passed type: */
     90    m_name[enmType] = strName;
     91
     92    /* Make sure combo is there: */
     93    if (!m_pComboName)
     94        return;
     95
     96    /* If value type is the same, update the combo as well: */
     97    if (valueType() == enmType)
     98    {
     99        const int iIndex = m_pComboName->findText(strName);
    43100        if (iIndex != -1)
    44             m_pCombo->setCurrentIndex(iIndex);
    45     }
    46 }
    47 
    48 KAudioDriverType UIAudioHostDriverEditor::value() const
    49 {
    50     return m_pCombo ? m_pCombo->itemData(m_pCombo->currentIndex()).value<KAudioDriverType>() : KAudioDriverType_Null;
    51 }
    52 
    53 void UIAudioHostDriverEditor::retranslateUi()
    54 {
    55     if (m_pLabel)
    56         m_pLabel->setText(tr("Host Audio &Driver:"));
    57     if (m_pCombo)
    58     {
    59         for (int i = 0; i < m_pCombo->count(); ++i)
     101            m_pComboName->setCurrentIndex(iIndex);
     102    }
     103}
     104
     105QString UINetworkAttachmentEditor::valueName(KNetworkAttachmentType enmType) const
     106{
     107    return m_name.value(enmType);
     108}
     109
     110void UINetworkAttachmentEditor::retranslateUi()
     111{
     112    /* Translate type label: */
     113    if (m_pLabelType)
     114        m_pLabelType->setText(tr("&Attached to:"));
     115
     116    /* Translate name label: */
     117    if (m_pLabelName)
     118        m_pLabelName->setText(tr("&Name:"));
     119
     120    /* Translate type combo: */
     121    if (m_pComboType)
     122    {
     123        for (int i = 0; i < m_pComboType->count(); ++i)
    60124        {
    61             const KAudioDriverType enmType = m_pCombo->itemData(i).value<KAudioDriverType>();
    62             m_pCombo->setItemText(i, gpConverter->toString(enmType));
     125            const KNetworkAttachmentType enmType = m_pComboType->itemData(i).value<KNetworkAttachmentType>();
     126            m_pComboType->setItemText(i, gpConverter->toString(enmType));
    63127        }
    64128    }
    65 }
    66 
    67 void UIAudioHostDriverEditor::sltHandleCurrentIndexChanged()
    68 {
    69     if (m_pCombo)
    70         emit sigValueChanged(m_pCombo->itemData(m_pCombo->currentIndex()).value<KAudioDriverType>());
    71 }
    72 
    73 void UIAudioHostDriverEditor::prepare()
    74 {
     129
     130    /* Translate name combo: */
     131    retranslateNameDescription();
     132}
     133
     134void UINetworkAttachmentEditor::sltHandleCurrentTypeChanged()
     135{
     136    /* Update name label & combo: */
     137    if (m_pLabelName)
     138        m_pLabelName->setEnabled(   valueType() != KNetworkAttachmentType_Null
     139                                 && valueType() != KNetworkAttachmentType_NAT);
     140    if (m_pComboName)
     141    {
     142        m_pComboName->setEnabled(   valueType() != KNetworkAttachmentType_Null
     143                                 && valueType() != KNetworkAttachmentType_NAT);
     144        m_pComboName->setEditable(   valueType() == KNetworkAttachmentType_Internal
     145                                  || valueType() == KNetworkAttachmentType_Generic);
     146    }
     147
     148    /* Update name combo description: */
     149    retranslateNameDescription();
     150
     151    /* Notify listeners: */
     152    emit sigValueTypeChanged();
     153
     154    /* Update name combo: */
     155    populateNameCombo();
     156
     157    /* Revalidate: */
     158    revalidate();
     159}
     160
     161void UINetworkAttachmentEditor::sltHandleCurrentNameChanged()
     162{
     163    if (m_pComboName)
     164    {
     165        /* Acquire new value name: */
     166        QString strNewName;
     167        /* Make sure that's not a name of 'empty' item: */
     168        if (m_pComboName->currentData().toString() != s_strEmptyItemId)
     169            strNewName = m_pComboName->currentText().simplified();
     170        /* Make sure that's not an empty name itself: */
     171        if (strNewName.isEmpty())
     172            strNewName = QString();
     173        /* If name is really changed: */
     174        if (m_name[valueType()] != strNewName)
     175        {
     176            /* Store it: */
     177            m_name[valueType()] = strNewName;
     178            /* Notify listeners: */
     179            emit sigValueNameChanged();
     180        }
     181    }
     182
     183    /* Revalidate: */
     184    revalidate();
     185}
     186
     187void UINetworkAttachmentEditor::prepare()
     188{
     189    /* Read current limitations: */
     190    m_enmRestrictedNetworkAttachmentTypes = gEDataManager->restrictedNetworkAttachmentTypes();
     191
    75192    /* Create main layout: */
    76193    QGridLayout *pMainLayout = new QGridLayout(this);
     
    78195    {
    79196        pMainLayout->setContentsMargins(0, 0, 0, 0);
    80         int iRow = 0;
    81 
    82         /* Create label: */
    83         if (m_fWithLabel)
    84             m_pLabel = new QLabel(this);
    85         if (m_pLabel)
    86             pMainLayout->addWidget(m_pLabel, 0, iRow++, 1, 1);
    87 
    88         /* Create combo layout: */
     197
     198        int iColumn = 0;
     199
     200        /* Create type label: */
     201        if (m_fWithLabels)
     202            m_pLabelType = new QLabel(this);
     203        if (m_pLabelType)
     204            pMainLayout->addWidget(m_pLabelType, 0, iColumn++);
     205
     206        /* Create type combo layout: */
    89207        QHBoxLayout *pComboLayout = new QHBoxLayout;
    90208        if (pComboLayout)
    91209        {
    92             /* Create combo: */
    93             m_pCombo = new QIComboBox(this);
    94             if (m_pCombo)
     210            /* Create type combo: */
     211            m_pComboType = new QIComboBox(this);
     212            if (m_pComboType)
    95213            {
    96                 setFocusProxy(m_pCombo->focusProxy());
    97                 if (m_pLabel)
    98                     m_pLabel->setBuddy(m_pCombo->focusProxy());
    99                 connect(m_pCombo, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged),
    100                         this, &UIAudioHostDriverEditor::sltHandleCurrentIndexChanged);
    101                 pComboLayout->addWidget(m_pCombo);
     214                setFocusProxy(m_pComboType->focusProxy());
     215                if (m_pLabelType)
     216                    m_pLabelType->setBuddy(m_pComboType->focusProxy());
     217                connect(m_pComboType, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged),
     218                        this, &UINetworkAttachmentEditor::sltHandleCurrentTypeChanged);
     219                pComboLayout->addWidget(m_pComboType);
    102220            }
    103221
     
    106224
    107225            /* Add combo-layout into main-layout: */
    108             pMainLayout->addLayout(pComboLayout, 0, iRow++, 1, 1);
     226            pMainLayout->addLayout(pComboLayout, 0, iColumn++);
    109227        }
    110     }
    111 
    112     /* Populate combo: */
    113     populateCombo();
     228
     229        iColumn = 0;
     230
     231        /* Create name label: */
     232        if (m_fWithLabels)
     233            m_pLabelName = new QLabel(this);
     234        if (m_pLabelName)
     235            pMainLayout->addWidget(m_pLabelName, 1, iColumn++);
     236
     237        /* Create name combo: */
     238        m_pComboName = new QIComboBox(this);
     239        if (m_pComboName)
     240        {
     241            if (m_pLabelName)
     242                m_pLabelName->setBuddy(m_pComboName->focusProxy());
     243            m_pComboName->setInsertPolicy(QComboBox::NoInsert);
     244            connect(m_pComboName, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged),
     245                    this, &UINetworkAttachmentEditor::sltHandleCurrentNameChanged);
     246            connect(m_pComboName, &QIComboBox::editTextChanged,
     247                    this, &UINetworkAttachmentEditor::sltHandleCurrentNameChanged);
     248            pMainLayout->addWidget(m_pComboName, 1, iColumn++);
     249        }
     250    }
     251
     252    /* Populate type combo: */
     253    populateTypeCombo();
    114254
    115255    /* Apply language settings: */
     
    117257}
    118258
    119 void UIAudioHostDriverEditor::populateCombo()
    120 {
    121     /* Fill combo manually: */
    122     m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_Null));
    123 #ifdef Q_OS_WIN
    124     m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_DirectSound));
    125 # ifdef VBOX_WITH_WINMM
    126     m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_WinMM));
    127 # endif
    128 #endif
    129 #ifdef VBOX_WITH_AUDIO_OSS
    130     m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_OSS));
    131 #endif
    132 #ifdef VBOX_WITH_AUDIO_ALSA
    133     m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_ALSA));
    134 #endif
    135 #ifdef VBOX_WITH_AUDIO_PULSE
    136     m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_Pulse));
    137 #endif
    138 #ifdef Q_OS_MACX
    139     m_pCombo->addItem(QString(), QVariant::fromValue(KAudioDriverType_CoreAudio));
    140 #endif
    141 }
     259void UINetworkAttachmentEditor::populateTypeCombo()
     260{
     261    /* Make sure combo is there: */
     262    if (!m_pComboType)
     263        return;
     264
     265    /* Block signals initially: */
     266    m_pComboType->blockSignals(true);
     267
     268    /* Remember currently selected type index: */
     269    int iCurrentAttachment = m_pComboType->currentIndex();
     270
     271    /* Clear the type combo-box: */
     272    m_pComboType->clear();
     273
     274    /* Populate attachments: */
     275    int iAttachmentTypeIndex = 0;
     276    // WORKAROUND:
     277    // We want some hardcoded order, so prepare a list of enum values.
     278    QList<KNetworkAttachmentType> attachmentTypes  = QList<KNetworkAttachmentType>() << KNetworkAttachmentType_Null
     279                                                  << KNetworkAttachmentType_NAT << KNetworkAttachmentType_NATNetwork
     280                                                  << KNetworkAttachmentType_Bridged << KNetworkAttachmentType_Internal
     281                                                  << KNetworkAttachmentType_HostOnly << KNetworkAttachmentType_Generic;
     282    for (int i = 0; i < attachmentTypes.size(); ++i)
     283    {
     284        const KNetworkAttachmentType enmType = attachmentTypes.at(i);
     285        if (m_enmRestrictedNetworkAttachmentTypes & toUiNetworkAdapterEnum(enmType))
     286            continue;
     287        m_pComboType->insertItem(iAttachmentTypeIndex, gpConverter->toString(enmType));
     288        m_pComboType->setItemData(iAttachmentTypeIndex, enmType);
     289        m_pComboType->setItemData(iAttachmentTypeIndex, m_pComboType->itemText(iAttachmentTypeIndex), Qt::ToolTipRole);
     290        ++iAttachmentTypeIndex;
     291    }
     292
     293    /* Restore previously selected type index: */
     294    m_pComboType->setCurrentIndex(iCurrentAttachment == -1 ? 0 : iCurrentAttachment);
     295
     296    /* Handle combo item change: */
     297    sltHandleCurrentTypeChanged();
     298
     299    /* Unblock signals finally: */
     300    m_pComboType->blockSignals(false);
     301}
     302
     303void UINetworkAttachmentEditor::populateNameCombo()
     304{
     305    /* Make sure combo is there: */
     306    if (!m_pComboName)
     307        return;
     308
     309    /* Block signals initially: */
     310    m_pComboName->blockSignals(true);
     311
     312    /* Clear the name combo: */
     313    m_pComboName->clear();
     314
     315    /* Add corresponding names to combo: */
     316    m_pComboName->addItems(m_names.value(valueType()));
     317
     318    /* Prepend 'empty' or 'default' item to combo: */
     319    if (m_pComboName->count() == 0)
     320    {
     321        switch (valueType())
     322        {
     323            case KNetworkAttachmentType_Bridged:
     324            case KNetworkAttachmentType_HostOnly:
     325            case KNetworkAttachmentType_NATNetwork:
     326            {
     327                /* If adapter list is empty => add 'Not selected' item: */
     328                const int iIndex = m_pComboName->findData(s_strEmptyItemId);
     329                if (iIndex == -1)
     330                    m_pComboName->insertItem(0, tr("Not selected", "network adapter name"), s_strEmptyItemId);
     331                else
     332                    m_pComboName->setItemText(iIndex, tr("Not selected", "network adapter name"));
     333                break;
     334            }
     335            case KNetworkAttachmentType_Internal:
     336            {
     337                /* Internal network list should have a default item: */
     338                if (m_pComboName->findText("intnet") == -1)
     339                    m_pComboName->insertItem(0, "intnet");
     340                break;
     341            }
     342            default:
     343                break;
     344        }
     345    }
     346
     347    /* Restore previously selected name: */
     348    const int iIndex = m_pComboName->findText(m_name.value(valueType()));
     349    if (iIndex != -1)
     350        m_pComboName->setCurrentIndex(iIndex);
     351
     352    /* Handle combo item change: */
     353    sltHandleCurrentNameChanged();
     354
     355    /* Unblock signals finally: */
     356    m_pComboName->blockSignals(false);
     357}
     358
     359void UINetworkAttachmentEditor::retranslateNameDescription()
     360{
     361    /* Update name combo description: */
     362    switch (valueType())
     363    {
     364        case KNetworkAttachmentType_Bridged:
     365            m_pComboName->setWhatsThis(tr("Selects the network adapter on the host system that traffic "
     366                                          "to and from this network card will go through."));
     367            break;
     368        case KNetworkAttachmentType_Internal:
     369            m_pComboName->setWhatsThis(tr("Holds the name of the internal network that this network card "
     370                                          "will be connected to. You can create a new internal network by "
     371                                          "choosing a name which is not used by any other network cards "
     372                                          "in this virtual machine or others."));
     373            break;
     374        case KNetworkAttachmentType_HostOnly:
     375            m_pComboName->setWhatsThis(tr("Selects the virtual network adapter on the host system that traffic "
     376                                          "to and from this network card will go through. "
     377                                          "You can create and remove adapters using the global network "
     378                                          "settings in the virtual machine manager window."));
     379            break;
     380        case KNetworkAttachmentType_Generic:
     381            m_pComboName->setWhatsThis(tr("Selects the driver to be used with this network card."));
     382            break;
     383        case KNetworkAttachmentType_NATNetwork:
     384            m_pComboName->setWhatsThis(tr("Holds the name of the NAT network that this network card "
     385                                          "will be connected to. You can create and remove networks "
     386                                          "using the global network settings in the virtual machine "
     387                                          "manager window."));
     388            break;
     389        default:
     390            m_pComboName->setWhatsThis(QString());
     391            break;
     392    }
     393}
     394
     395void UINetworkAttachmentEditor::revalidate()
     396{
     397    /// @todo Implement validation!
     398    emit sigValidChanged(true);
     399}
     400
     401/* static */
     402UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork UINetworkAttachmentEditor::toUiNetworkAdapterEnum(KNetworkAttachmentType comEnum)
     403{
     404    switch (comEnum)
     405    {
     406        case KNetworkAttachmentType_NAT:        return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NAT;
     407        case KNetworkAttachmentType_Bridged:    return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_BridgetAdapter;
     408        case KNetworkAttachmentType_Internal:   return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_InternalNetwork;
     409        case KNetworkAttachmentType_HostOnly:   return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_HostOnlyAdapter;
     410        case KNetworkAttachmentType_Generic:    return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_GenericDriver;
     411        case KNetworkAttachmentType_NATNetwork: return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_NATNetwork;
     412        default:                                return UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid;
     413    }
     414}
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UINetworkAttachmentEditor.h

    r80154 r80200  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIAudioHostDriverEditor class declaration.
     3 * VBox Qt GUI - UINetworkAttachmentEditor class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_widgets_UIAudioHostDriverEditor_h
    19 #define FEQT_INCLUDED_SRC_widgets_UIAudioHostDriverEditor_h
     18#ifndef FEQT_INCLUDED_SRC_widgets_UINetworkAttachmentEditor_h
     19#define FEQT_INCLUDED_SRC_widgets_UINetworkAttachmentEditor_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2727/* GUI includes: */
    2828#include "QIWithRetranslateUI.h"
     29#include "UIExtraDataDefs.h"
    2930#include "UILibraryDefs.h"
    3031
     
    3637class QIComboBox;
    3738
    38 /** QWidget subclass used as an audio host driver editor. */
    39 class SHARED_LIBRARY_STUFF UIAudioHostDriverEditor : public QIWithRetranslateUI<QWidget>
     39/** QWidget subclass used as a network attachment editor. */
     40class SHARED_LIBRARY_STUFF UINetworkAttachmentEditor : public QIWithRetranslateUI<QWidget>
    4041{
    4142    Q_OBJECT;
     
    4344signals:
    4445
    45     /** Notifies listeners about @a enmValue change. */
    46     void sigValueChanged(KAudioDriverType enmValue);
     46    /** Notifies listeners about value type has changed. */
     47    void sigValueTypeChanged();
     48    /** Notifies listeners about value name has changed. */
     49    void sigValueNameChanged();
     50
     51    /** Notifies listeners about value has became @a fValid. */
     52    void sigValidChanged(bool fValid);
    4753
    4854public:
    4955
    50     /** Constructs audio host driver editor passing @a pParent to the base-class.
    51       * @param  fWithLabel  Brings whether we should add label ourselves. */
    52     UIAudioHostDriverEditor(QWidget *pParent = 0, bool fWithLabel = false);
     56    /** Constructs network attachment editor passing @a pParent to the base-class.
     57      * @param  fWithLabels  Brings whether we should add labels ourselves. */
     58    UINetworkAttachmentEditor(QWidget *pParent = 0, bool fWithLabels = false);
    5359
    54     /** Defines editor @a enmValue. */
    55     void setValue(KAudioDriverType enmValue);
    56     /** Returns editor value. */
    57     KAudioDriverType value() const;
     60    /** Returns focus proxy 1. */
     61    QWidget *focusProxy1() const;
     62    /** Returns focus proxy 2. */
     63    QWidget *focusProxy2() const;
     64
     65    /** Defines value @a enmType. */
     66    void setValueType(KNetworkAttachmentType enmType);
     67    /** Returns value type. */
     68    KNetworkAttachmentType valueType() const;
     69
     70    /** Defines value @a names for specified @a enmType. */
     71    void setValueNames(KNetworkAttachmentType enmType, const QStringList &names);
     72    /** Defines value @a strName for specified @a enmType. */
     73    void setValueName(KNetworkAttachmentType enmType, const QString &strName);
     74    /** Returns current name for specified @a enmType. */
     75    QString valueName(KNetworkAttachmentType enmType) const;
    5876
    5977protected:
     
    6482private slots:
    6583
    66     /** Handles current index change. */
    67     void sltHandleCurrentIndexChanged();
     84    /** Handles current type change. */
     85    void sltHandleCurrentTypeChanged();
     86    /** Handles current name change. */
     87    void sltHandleCurrentNameChanged();
    6888
    6989private:
     
    7191    /** Prepares all. */
    7292    void prepare();
    73     /** Populates combo. */
    74     void populateCombo();
     93    /** Populates type combo. */
     94    void populateTypeCombo();
     95    /** Populates name combo. */
     96    void populateNameCombo();
    7597
    76     /** Holds whether descriptive label should be created. */
    77     bool  m_fWithLabel;
     98    /** Retranslates name description. */
     99    void retranslateNameDescription();
    78100
    79     /** Holds the label instance. */
    80     QLabel     *m_pLabel;
    81     /** Holds the combo instance. */
    82     QIComboBox *m_pCombo;
     101    /** Validates editor values. */
     102    void revalidate();
     103
     104    /** Returns UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork corresponding to passed KNetworkAttachmentType. */
     105    static UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork toUiNetworkAdapterEnum(KNetworkAttachmentType comEnum);
     106
     107    /** Holds the empty item data id. */
     108    static QString s_strEmptyItemId;
     109
     110    /** Holds whether descriptive labels should be created. */
     111    bool  m_fWithLabels;
     112
     113    /** Holds the attachment type restrictions. */
     114    UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork  m_enmRestrictedNetworkAttachmentTypes;
     115
     116    /** Holds the map of possible names. */
     117    QMap<KNetworkAttachmentType, QStringList>  m_names;
     118    /** Holds the map of current names. */
     119    QMap<KNetworkAttachmentType, QString>      m_name;
     120
     121    /** Holds the type label instance. */
     122    QLabel     *m_pLabelType;
     123    /** Holds the type combo instance. */
     124    QIComboBox *m_pComboType;
     125    /** Holds the name label instance. */
     126    QLabel     *m_pLabelName;
     127    /** Holds the name combo instance. */
     128    QIComboBox *m_pComboName;
    83129};
    84130
    85 #endif /* !FEQT_INCLUDED_SRC_widgets_UIAudioHostDriverEditor_h */
     131#endif /* !FEQT_INCLUDED_SRC_widgets_UINetworkAttachmentEditor_h */
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