VirtualBox

Ignore:
Timestamp:
Apr 11, 2022 1:34:39 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt/Ds: bugref:6899: Machine settings: Network page accessibility improvements (part 4); A bit of sanity checks and page cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
Files:
2 edited

Legend:

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

    r94534 r94555  
    689689
    690690UIMachineSettingsNetworkPage::UIMachineSettingsNetworkPage()
    691     : m_pTabWidget(0)
    692     , m_pCache(0)
     691    : m_pCache(0)
     692    , m_pTabWidget(0)
    693693{
    694694    prepare();
     
    770770                                                                 forwardingData.at(4),
    771771                                                                 forwardingData.at(5).toUInt());
    772 
    773772                const QString &strForwardingKey = forwardingData.at(0);
    774773                /* Cache old forwarding data: */
     
    800799        /* Get adapter page: */
    801800        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iSlot));
     801        AssertPtrReturnVoid(pTab);
    802802
    803803        /* Load old adapter data from cache: */
     
    828828        /* Get adapter page: */
    829829        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iSlot));
     830        AssertPtrReturnVoid(pTab);
    830831
    831832        /* Gather new adapter data: */
     
    858859    {
    859860        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(i));
    860         AssertMsg(pTab, ("Can't get adapter tab!\n"));
     861        AssertPtrReturn(pTab, false);
    861862        if (!pTab->validate(messages))
    862863            fValid = false;
     
    869870void UIMachineSettingsNetworkPage::retranslateUi()
    870871{
    871     for (int i = 0; i < m_pTabWidget->count(); ++i)
    872     {
    873         UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(i));
    874         Assert(pTab);
    875         m_pTabWidget->setTabText(i, pTab->tabTitle());
     872    for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot)
     873    {
     874        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iSlot));
     875        AssertPtrReturnVoid(pTab);
     876        m_pTabWidget->setTabText(iSlot, pTab->tabTitle());
    876877    }
    877878}
     
    879880void UIMachineSettingsNetworkPage::polishPage()
    880881{
    881     /* Get the count of network adapter tabs: */
    882882    for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot)
    883883    {
     
    888888                                     m_pCache->child(iSlot).base().m_fAdapterEnabled));
    889889        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iSlot));
     890        AssertPtrReturnVoid(pTab);
    890891        pTab->polishTab();
    891892    }
     
    896897    /* Determine the sender: */
    897898    UIMachineSettingsNetwork *pSender = qobject_cast<UIMachineSettingsNetwork*>(sender());
    898     AssertMsg(pSender, ("This slot should be called only through signal<->slot mechanism from one of UIMachineSettingsNetwork tabs!\n"));
     899    AssertPtrReturnVoid(pSender);
    899900
    900901    /* Determine sender's attachment type: */
    901     const KNetworkAttachmentType enmSenderAttachmentType = pSender->attachmentType();
    902     switch (enmSenderAttachmentType)
    903     {
    904         case KNetworkAttachmentType_Internal:
    905         {
    906             refreshInternalNetworkList();
    907             break;
    908         }
    909         case KNetworkAttachmentType_Generic:
    910         {
    911             refreshGenericDriverList();
    912             break;
    913         }
    914         default:
    915             break;
     902    switch (pSender->attachmentType())
     903    {
     904        case KNetworkAttachmentType_Internal: refreshInternalNetworkList(); break;
     905        case KNetworkAttachmentType_Generic: refreshGenericDriverList(); break;
     906        default: break;
    916907    }
    917908
     
    921912        /* Get the iterated tab: */
    922913        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iSlot));
    923         AssertMsg(pTab, ("All the tabs of m_pTabWidget should be of the UIMachineSettingsNetwork type!\n"));
     914        AssertPtrReturnVoid(pTab);
    924915
    925916        /* Update all the tabs (except sender): */
     
    935926    {
    936927        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iSlot));
     928        AssertPtrReturnVoid(pTab);
    937929        pTab->setAdvancedButtonState(fExpanded);
    938930    }
     
    947939    /* Create main layout: */
    948940    QVBoxLayout *pLayoutMain = new QVBoxLayout(this);
    949     AssertPtrReturnVoid(pLayoutMain);
     941    if (pLayoutMain)
    950942    {
    951943        /* Creating tab-widget: */
    952944        m_pTabWidget = new QITabWidget;
    953         AssertPtrReturnVoid(m_pTabWidget);
     945        if (m_pTabWidget)
    954946        {
    955947            /* How many adapters to display: */
     
    965957                /* Create adapter tab: */
    966958                UIMachineSettingsNetwork *pTab = new UIMachineSettingsNetwork(this);
    967                 AssertPtrReturnVoid(pTab);
     959                if (pTab)
    968960                {
    969961                    /* Configure tab: */
     
    1004996    m_internalNetworkList << m_internalNetworkListSaved;
    1005997    /* Append internal network list with names from all the tabs: */
    1006     for (int iTab = 0; iTab < m_pTabWidget->count(); ++iTab)
    1007     {
    1008         UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iTab));
    1009         if (pTab)
    1010         {
    1011             const QString strName = pTab->alternativeName(KNetworkAttachmentType_Internal);
    1012             if (!strName.isEmpty() && !m_internalNetworkList.contains(strName))
    1013                 m_internalNetworkList << strName;
    1014         }
     998    for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot)
     999    {
     1000        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iSlot));
     1001        AssertPtrReturnVoid(pTab);
     1002        const QString strName = pTab->alternativeName(KNetworkAttachmentType_Internal);
     1003        if (!strName.isEmpty() && !m_internalNetworkList.contains(strName))
     1004            m_internalNetworkList << strName;
    10151005    }
    10161006}
     
    10471037    m_genericDriverList << m_genericDriverListSaved;
    10481038    /* Append generic driver list with names from all the tabs: */
    1049     for (int iTab = 0; iTab < m_pTabWidget->count(); ++iTab)
    1050     {
    1051         UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iTab));
    1052         if (pTab)
    1053         {
    1054             const QString strName = pTab->alternativeName(KNetworkAttachmentType_Generic);
    1055             if (!strName.isEmpty() && !m_genericDriverList.contains(strName))
    1056                 m_genericDriverList << strName;
    1057         }
     1039    for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot)
     1040    {
     1041        UIMachineSettingsNetwork *pTab = qobject_cast<UIMachineSettingsNetwork*>(m_pTabWidget->widget(iSlot));
     1042        AssertPtrReturnVoid(pTab);
     1043        const QString strName = pTab->alternativeName(KNetworkAttachmentType_Generic);
     1044        if (!strName.isEmpty() && !m_genericDriverList.contains(strName))
     1045            m_genericDriverList << strName;
    10581046    }
    10591047}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsNetwork.h

    r94333 r94555  
    139139    bool saveAdapterData(int iSlot);
    140140
    141     /** Holds the tab-widget instance. */
    142     QITabWidget *m_pTabWidget;
    143 
    144141    /** Holds the bridged adapter list. */
    145142    QStringList  m_bridgedAdapterList;
     
    167164    /** Holds the page data cache instance. */
    168165    UISettingsCacheMachineNetwork *m_pCache;
     166
     167    /** Holds the tab-widget instance. */
     168    QITabWidget *m_pTabWidget;
    169169};
    170170
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