VirtualBox

Ignore:
Timestamp:
Apr 8, 2022 12:20:59 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt/Ds: bugref:6899: Machine settings: Network page accessibility improvements (part 2); A bit of cleanup for attachment type editor.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp

    r94358 r94530  
    11451145    {
    11461146        /* Prepare editor: */
    1147         UINetworkAttachmentEditor *pEditor = new UINetworkAttachmentEditor(pPopup, true /* with label */);
     1147        UINetworkAttachmentEditor *pEditor = new UINetworkAttachmentEditor(pPopup);
    11481148        if (pEditor)
    11491149        {
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINetworkAttachmentEditor.cpp

    r94058 r94530  
    4343QString UINetworkAttachmentEditor::s_strEmptyItemId = QString("#empty#");
    4444
    45 UINetworkAttachmentEditor::UINetworkAttachmentEditor(QWidget *pParent /* = 0 */, bool fWithLabels /* = false */)
     45UINetworkAttachmentEditor::UINetworkAttachmentEditor(QWidget *pParent /* = 0 */)
    4646    : QIWithRetranslateUI<QWidget>(pParent)
    47     , m_fWithLabels(fWithLabels)
    4847    , m_enmRestrictedNetworkAttachmentTypes(UIExtraDataMetaDefs::DetailsElementOptionTypeNetwork_Invalid)
    4948    , m_enmType(KNetworkAttachmentType_Max)
     
    5857void UINetworkAttachmentEditor::setValueType(KNetworkAttachmentType enmType)
    5958{
    60     /* Make sure combo is there: */
    61     if (!m_pComboType)
    62         return;
    63     /* Make sure type is changed: */
    64     if (m_enmType == enmType)
    65         return;
    66 
    67     /* Remember requested type: */
    68     m_enmType = enmType;
    69     /* Repopulate finally, supported values might change: */
    70     populateTypeCombo();
     59    if (m_enmType != enmType)
     60    {
     61        m_enmType = enmType;
     62        populateTypeCombo();
     63    }
    7164}
    7265
     
    9184    m_name[enmType] = strName;
    9285
    93     /* Make sure combo is there: */
    94     if (!m_pComboName)
    95         return;
    96 
    9786    /* If value type is the same, update the combo as well: */
    9887    if (valueType() == enmType)
    9988    {
    100         const int iIndex = m_pComboName->findText(strName);
    101         if (iIndex != -1)
    102             m_pComboName->setCurrentIndex(iIndex);
     89        /* Make sure combo is there: */
     90        if (m_pComboName)
     91        {
     92            const int iIndex = m_pComboName->findText(strName);
     93            if (iIndex != -1)
     94                m_pComboName->setCurrentIndex(iIndex);
     95        }
    10396    }
    10497}
     
    194187        {
    195188            const KNetworkAttachmentType enmType = m_pComboType->itemData(i).value<KNetworkAttachmentType>();
    196             const QString strName = gpConverter->toString(enmType);
    197             m_pComboType->setItemData(i, strName, Qt::ToolTipRole);
    198             m_pComboType->setItemText(i, strName);
    199         }
    200         m_pComboType->setToolTip(tr("Selects how this virtual adapter is attached to the real network of the Host OS."));
    201     }
    202 
    203     /* Translate name combo: */
    204     if (m_pComboName)
    205         m_pComboName->setToolTip(tr("Selects the network or adapter name associated with this virtual adapter."));
     189            m_pComboType->setItemText(i, gpConverter->toString(enmType));
     190        }
     191        m_pComboType->setToolTip(tr("Holds how this virtual adapter is attached to the real network of the Host OS."));
     192    }
    206193
    207194    /* Translate name combo: */
     
    273260        pMainLayout->setContentsMargins(0, 0, 0, 0);
    274261
    275         int iColumn = 0;
    276 
    277262        /* Create type label: */
    278         if (m_fWithLabels)
    279         {
    280             m_pLabelType = new QLabel(this);
     263        m_pLabelType = new QLabel(this);
     264        if (m_pLabelType)
     265        {
    281266            m_pLabelType->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
    282         }
    283         if (m_pLabelType)
    284             pMainLayout->addWidget(m_pLabelType, 0, iColumn++);
    285 
     267            pMainLayout->addWidget(m_pLabelType, 0, 0);
     268        }
    286269        /* Create type combo layout: */
    287270        QHBoxLayout *pComboLayout = new QHBoxLayout;
     
    303286
    304287            /* Add combo-layout into main-layout: */
    305             pMainLayout->addLayout(pComboLayout, 0, iColumn++);
    306         }
    307 
    308         iColumn = 0;
     288            pMainLayout->addLayout(pComboLayout, 0, 1);
     289        }
    309290
    310291        /* Create name label: */
    311         if (m_fWithLabels)
    312         {
    313             m_pLabelName = new QLabel(this);
    314             m_pLabelName->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
    315         }
     292        m_pLabelName = new QLabel(this);
     293        m_pLabelName->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
    316294        if (m_pLabelName)
    317             pMainLayout->addWidget(m_pLabelName, 1, iColumn++);
    318 
     295            pMainLayout->addWidget(m_pLabelName, 1, 0);
    319296        /* Create name combo: */
    320297        m_pComboName = new QComboBox(this);
     
    328305            connect(m_pComboName, &QComboBox::editTextChanged,
    329306                    this, &UINetworkAttachmentEditor::sltHandleCurrentNameChanged);
    330             pMainLayout->addWidget(m_pComboName, 1, iColumn++);
     307            pMainLayout->addWidget(m_pComboName, 1, 1);
    331308        }
    332309    }
     
    354331    CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
    355332    QVector<KNetworkAttachmentType> supportedTypes = comProperties.GetSupportedNetworkAttachmentTypes();
    356     /* Take currently requested type into account if it's sane: */
     333    /* Take currently requested type into account if it's different from initial one: */
    357334    if (!supportedTypes.contains(m_enmType) && m_enmType != KNetworkAttachmentType_Max)
    358335        supportedTypes.prepend(m_enmType);
     
    367344        m_pComboType->insertItem(iAttachmentTypeIndex, gpConverter->toString(enmType));
    368345        m_pComboType->setItemData(iAttachmentTypeIndex, QVariant::fromValue(enmType));
    369         m_pComboType->setItemData(iAttachmentTypeIndex, m_pComboType->itemText(iAttachmentTypeIndex), Qt::ToolTipRole);
    370346        ++iAttachmentTypeIndex;
    371347    }
     
    450426    {
    451427        case KNetworkAttachmentType_Bridged:
    452             m_pComboName->setWhatsThis(tr("Selects the network adapter on the host system that traffic "
    453                                           "to and from this network card will go through."));
     428            m_pComboName->setToolTip(tr("Holds the network adapter on the host system that traffic "
     429                                        "to and from this network card will go through."));
    454430            break;
    455431        case KNetworkAttachmentType_Internal:
    456             m_pComboName->setWhatsThis(tr("Holds the name of the internal network that this network card "
    457                                           "will be connected to. You can create a new internal network by "
    458                                           "choosing a name which is not used by any other network cards "
    459                                           "in this virtual machine or others."));
     432            m_pComboName->setToolTip(tr("Holds the name of the internal network that this network card "
     433                                        "will be connected to. You can create a new internal network by "
     434                                        "choosing a name which is not used by any other network cards "
     435                                        "in this virtual machine or others."));
    460436            break;
    461437        case KNetworkAttachmentType_HostOnly:
    462             m_pComboName->setWhatsThis(tr("Selects the virtual network adapter on the host system that traffic "
    463                                           "to and from this network card will go through. "
    464                                           "You can create and remove adapters using the global network "
    465                                           "settings in the virtual machine manager window."));
     438            m_pComboName->setToolTip(tr("Holds the virtual network adapter on the host system that traffic "
     439                                        "to and from this network card will go through. "
     440                                        "You can create and remove adapters using the global network "
     441                                        "settings in the virtual machine manager window."));
    466442            break;
    467443        case KNetworkAttachmentType_Generic:
    468             m_pComboName->setWhatsThis(tr("Selects the driver to be used with this network card."));
     444            m_pComboName->setToolTip(tr("Holds the driver to be used with this network card."));
    469445            break;
    470446        case KNetworkAttachmentType_NATNetwork:
    471             m_pComboName->setWhatsThis(tr("Holds the name of the NAT network that this network card "
    472                                           "will be connected to. You can create and remove networks "
    473                                           "using the Network Manager tool in the virtual machine "
    474                                           "manager window."));
     447            m_pComboName->setToolTip(tr("Holds the name of the NAT network that this network card "
     448                                        "will be connected to. You can create and remove networks "
     449                                        "using the Network Manager tool in the virtual machine "
     450                                        "manager window."));
    475451            break;
    476452#ifdef VBOX_WITH_CLOUD_NET
    477453        case KNetworkAttachmentType_Cloud:
    478             m_pComboName->setWhatsThis(tr("(experimental) Holds the name of the cloud network that this network card "
    479                                           "will be connected to. You can add and remove networks "
    480                                           "using the Cloud Profile Manager tool in the virtual machine "
    481                                           "manager window."));
     454            m_pComboName->setToolTip(tr("(experimental) Holds the name of the cloud network that this network card "
     455                                        "will be connected to. You can add and remove networks "
     456                                        "using the Cloud Profile Manager tool in the virtual machine "
     457                                        "manager window."));
    482458            break;
    483459#endif /* VBOX_WITH_CLOUD_NET */
    484460#ifdef VBOX_WITH_VMNET
    485461        case KNetworkAttachmentType_HostOnlyNetwork:
    486             m_pComboName->setWhatsThis(tr("Holds the name of the host-only network that this network card "
    487                                           "will be connected to. You can add and remove networks "
    488                                           "using the Network Manager tool in the virtual machine "
    489                                           "manager window."));
     462            m_pComboName->setToolTip(tr("Holds the name of the host-only network that this network card "
     463                                        "will be connected to. You can add and remove networks "
     464                                        "using the Network Manager tool in the virtual machine "
     465                                        "manager window."));
    490466            break;
    491467#endif /* VBOX_WITH_VMNET */
    492468        default:
    493             m_pComboName->setWhatsThis(QString());
     469            m_pComboName->setToolTip(QString());
    494470            break;
    495471    }
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINetworkAttachmentEditor.h

    r94395 r94530  
    5454public:
    5555
    56     /** Constructs 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);
     56    /** Constructs editor passing @a pParent to the base-class. */
     57    UINetworkAttachmentEditor(QWidget *pParent = 0);
    5958
    6059    /** Defines value @a enmType. */
     
    120119
    121120    /** Holds the empty item data id. */
    122     static QString s_strEmptyItemId;
    123 
    124     /** Holds whether descriptive labels should be created. */
    125     bool  m_fWithLabels;
     121    static QString  s_strEmptyItemId;
    126122
    127123    /** Holds the attachment type restrictions. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.cpp

    r94527 r94530  
    643643
    644644                /* Prepare attachment type editor: */
    645                 m_pEditorAttachmentType = new UINetworkAttachmentEditor(m_pWidgetAdapterSettings, true);
     645                m_pEditorAttachmentType = new UINetworkAttachmentEditor(m_pWidgetAdapterSettings);
    646646                if (m_pEditorAttachmentType)
    647647                    pLayoutAdapterSettings->addWidget(m_pEditorAttachmentType);
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