VirtualBox

Changeset 66809 in vbox for trunk/src


Ignore:
Timestamp:
May 5, 2017 12:59:38 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
115230
Message:

FE/Qt: bugref:8847: Host Network Manager: Validation, step 1.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkDetailsDialog.cpp

    r66781 r66809  
    3636/* Other VBox includes: */
    3737# include "iprt/assert.h"
     38# include "iprt/cidr.h"
    3839
    3940#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     
    4344    : QIWithRetranslateUI2<QWidget>(pParent)
    4445    , m_pTabWidget(0)
    45     , m_pButtonAutomatic(0), m_pButtonManual(0)
    46     , m_pLabelIPv4(0), m_pEditorIPv4(0), m_pLabelNMv4(0), m_pEditorNMv4(0)
    47     , m_pLabelIPv6(0), m_pEditorIPv6(0), m_pLabelNMv6(0), m_pEditorNMv6(0)
    48     , m_pCheckBoxDHCP(0) , m_pLabelDHCPAddress(0), m_pEditorDHCPAddress(0), m_pLabelDHCPMask(0), m_pEditorDHCPMask(0)
    49     , m_pLabelDHCPLowerAddress(0), m_pEditorDHCPLowerAddress(0), m_pLabelDHCPUpperAddress(0), m_pEditorDHCPUpperAddress(0)
     46    , m_pButtonAutomatic(0), m_pErrorPaneAutomatic(0)
     47    , m_pButtonManual(0)
     48    , m_pLabelIPv4(0), m_pEditorIPv4(0), m_pErrorPaneIPv4(0)
     49    , m_pLabelNMv4(0), m_pEditorNMv4(0), m_pErrorPaneNMv4(0)
     50    , m_pLabelIPv6(0), m_pEditorIPv6(0), m_pErrorPaneIPv6(0)
     51    , m_pLabelNMv6(0), m_pEditorNMv6(0), m_pErrorPaneNMv6(0)
     52    , m_pCheckBoxDHCP(0)
     53    , m_pLabelDHCPAddress(0), m_pEditorDHCPAddress(0), m_pErrorPaneDHCPAddress(0)
     54    , m_pLabelDHCPMask(0), m_pEditorDHCPMask(0), m_pErrorPaneDHCPMask(0)
     55    , m_pLabelDHCPLowerAddress(0), m_pEditorDHCPLowerAddress(0), m_pErrorPaneDHCPLowerAddress(0)
     56    , m_pLabelDHCPUpperAddress(0), m_pEditorDHCPUpperAddress(0), m_pErrorPaneDHCPUpperAddress(0)
    5057{
    5158    /* Prepare: */
     
    130137    m_pLabelDHCPUpperAddress->setText(tr("&Upper Address Bound:"));
    131138    m_pEditorDHCPUpperAddress->setToolTip(tr("Holds the upper address bound offered by the DHCP server servicing the network associated with this host-only adapter."));
     139
     140    /* Retranslate validation: */
     141    retranslateValidation();
     142}
     143
     144void UIHostNetworkDetailsDialog::sltToggledButtonAutomatic(bool fChecked)
     145{
     146    m_newData.m_interface.m_fDHCPEnabled = fChecked;
     147    loadDataForInterface();
     148    revalidate();
     149    notify();
     150}
     151
     152void UIHostNetworkDetailsDialog::sltToggledButtonManual(bool fChecked)
     153{
     154    m_newData.m_interface.m_fDHCPEnabled = !fChecked;
     155    loadDataForInterface();
     156    revalidate();
     157    notify();
     158}
     159
     160void UIHostNetworkDetailsDialog::sltTextChangedIPv4(const QString &strText)
     161{
     162    m_newData.m_interface.m_strAddress = strText;
     163    revalidate(m_pErrorPaneIPv4);
     164    notify();
     165}
     166
     167void UIHostNetworkDetailsDialog::sltTextChangedNMv4(const QString &strText)
     168{
     169    m_newData.m_interface.m_strMask = strText;
     170    revalidate(m_pErrorPaneNMv4);
     171    notify();
     172}
     173
     174void UIHostNetworkDetailsDialog::sltTextChangedIPv6(const QString &strText)
     175{
     176    m_newData.m_interface.m_strAddress6 = strText;
     177    revalidate(m_pErrorPaneIPv6);
     178    notify();
     179}
     180
     181void UIHostNetworkDetailsDialog::sltTextChangedNMv6(const QString &strText)
     182{
     183    m_newData.m_interface.m_strMaskLength6 = strText;
     184    revalidate(m_pErrorPaneNMv6);
     185    notify();
     186}
     187
     188void UIHostNetworkDetailsDialog::sltStatusChangedServer(int iChecked)
     189{
     190    m_newData.m_dhcpserver.m_fEnabled = (bool)iChecked;
     191    loadDataForDHCPServer();
     192    revalidate();
     193    notify();
     194}
     195
     196void UIHostNetworkDetailsDialog::sltTextChangedAddress(const QString &strText)
     197{
     198    m_newData.m_dhcpserver.m_strAddress = strText;
     199    revalidate(m_pErrorPaneDHCPAddress);
     200    notify();
     201}
     202
     203void UIHostNetworkDetailsDialog::sltTextChangedMask(const QString &strText)
     204{
     205    m_newData.m_dhcpserver.m_strMask = strText;
     206    revalidate(m_pErrorPaneDHCPMask);
     207    notify();
     208}
     209
     210void UIHostNetworkDetailsDialog::sltTextChangedLowerAddress(const QString &strText)
     211{
     212    m_newData.m_dhcpserver.m_strLowerAddress = strText;
     213    revalidate(m_pErrorPaneDHCPLowerAddress);
     214    notify();
     215}
     216
     217void UIHostNetworkDetailsDialog::sltTextChangedUpperAddress(const QString &strText)
     218{
     219    m_newData.m_dhcpserver.m_strUpperAddress = strText;
     220    revalidate(m_pErrorPaneDHCPUpperAddress);
     221    notify();
    132222}
    133223
     
    183273            pLayoutInterface->setContentsMargins(10, 10, 10, 10);
    184274#endif
    185             /* Create automatic interface configuration radio-button: */
    186             m_pButtonAutomatic = new QRadioButton;
    187             AssertPtrReturnVoid(m_pButtonAutomatic);
    188             {
    189                 /* Configure radio-button: */
    190                 connect(m_pButtonAutomatic, &QRadioButton::toggled,
    191                         this, &UIHostNetworkDetailsDialog::sltToggledButtonAutomatic);
    192                 /* Add into layout: */
    193                 pLayoutInterface->addWidget(m_pButtonAutomatic, 0, 0, 1, 3);
    194             }
     275
     276            /* Create automatic interface configuration layout: */
     277            QHBoxLayout *pLayoutAutomatic = new QHBoxLayout;
     278            AssertPtrReturnVoid(pLayoutAutomatic);
     279            {
     280                /* Configure layout: */
     281                pLayoutAutomatic->setContentsMargins(0, 0, 0, 0);
     282                /* Create automatic interface configuration radio-button: */
     283                m_pButtonAutomatic = new QRadioButton;
     284                AssertPtrReturnVoid(m_pButtonAutomatic);
     285                {
     286                    /* Configure radio-button: */
     287                    connect(m_pButtonAutomatic, &QRadioButton::toggled,
     288                            this, &UIHostNetworkDetailsDialog::sltToggledButtonAutomatic);
     289                    /* Add into layout: */
     290                    pLayoutAutomatic->addWidget(m_pButtonAutomatic);
     291                }
     292                /* Create automatic interface configuration error pane: */
     293                m_pErrorPaneAutomatic = new QLabel;
     294                AssertPtrReturnVoid(m_pErrorPaneAutomatic);
     295                {
     296                    /* Configure label: */
     297                    m_pErrorPaneAutomatic->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
     298                    m_pErrorPaneAutomatic->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
     299                    m_pErrorPaneAutomatic->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(16, 16)));
     300                    /* Add into layout: */
     301                    pLayoutAutomatic->addWidget(m_pErrorPaneAutomatic);
     302                }
     303                /* Add into layout: */
     304                pLayoutInterface->addLayout(pLayoutAutomatic, 0, 0, 1, 3);
     305            }
     306
    195307            /* Create manual interface configuration radio-button: */
    196308            m_pButtonManual = new QRadioButton;
     
    203315                pLayoutInterface->addWidget(m_pButtonManual, 1, 0, 1, 3);
    204316            }
     317
    205318            /* Create IPv4 address label: */
    206319            m_pLabelIPv4 = new QLabel;
     
    212325                pLayoutInterface->addWidget(m_pLabelIPv4, 2, 1);
    213326            }
    214             /* Create IPv4 address editor: */
    215             m_pEditorIPv4 = new QILineEdit;
    216             AssertPtrReturnVoid(m_pEditorIPv4);
    217             {
    218                 /* Configure editor: */
    219                 m_pLabelIPv4->setBuddy(m_pEditorIPv4);
    220                 connect(m_pEditorIPv4, &QLineEdit::textChanged,
    221                         this, &UIHostNetworkDetailsDialog::sltTextChangedIPv4);
    222                 /* Add into layout: */
    223                 pLayoutInterface->addWidget(m_pEditorIPv4, 2, 2);
    224             }
    225             /* Create IPv4 network mask label: */
     327            /* Create IPv4 layout: */
     328            QHBoxLayout *pLayoutIPv4 = new QHBoxLayout;
     329            AssertPtrReturnVoid(pLayoutIPv4);
     330            {
     331                /* Configure layout: */
     332                pLayoutIPv4->setContentsMargins(0, 0, 0, 0);
     333                /* Create IPv4 address editor: */
     334                m_pEditorIPv4 = new QILineEdit;
     335                AssertPtrReturnVoid(m_pEditorIPv4);
     336                {
     337                    /* Configure editor: */
     338                    m_pLabelIPv4->setBuddy(m_pEditorIPv4);
     339                    connect(m_pEditorIPv4, &QLineEdit::textChanged,
     340                            this, &UIHostNetworkDetailsDialog::sltTextChangedIPv4);
     341                    /* Add into layout: */
     342                    pLayoutIPv4->addWidget(m_pEditorIPv4);
     343                }
     344                /* Create IPv4 error pane: */
     345                m_pErrorPaneIPv4 = new QLabel;
     346                AssertPtrReturnVoid(m_pErrorPaneIPv4);
     347                {
     348                    /* Configure label: */
     349                    m_pErrorPaneIPv4->setAlignment(Qt::AlignCenter);
     350                    m_pErrorPaneIPv4->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(16, 16)));
     351                    /* Add into layout: */
     352                    pLayoutIPv4->addWidget(m_pErrorPaneIPv4);
     353                }
     354                /* Add into layout: */
     355                pLayoutInterface->addLayout(pLayoutIPv4, 2, 2);
     356            }
     357
     358            /* Create NMv4 network mask label: */
    226359            m_pLabelNMv4 = new QLabel;
    227360            AssertPtrReturnVoid(m_pLabelNMv4);
     
    232365                pLayoutInterface->addWidget(m_pLabelNMv4, 3, 1);
    233366            }
    234             /* Create IPv4 network mask editor: */
    235             m_pEditorNMv4 = new QILineEdit;
    236             AssertPtrReturnVoid(m_pEditorNMv4);
    237             {
    238                 /* Configure editor: */
    239                 m_pLabelNMv4->setBuddy(m_pEditorNMv4);
    240                 connect(m_pEditorNMv4, &QLineEdit::textChanged,
    241                         this, &UIHostNetworkDetailsDialog::sltTextChangedNMv4);
    242                 /* Add into layout: */
    243                 pLayoutInterface->addWidget(m_pEditorNMv4, 3, 2);
    244             }
     367            /* Create NMv4 layout: */
     368            QHBoxLayout *pLayoutNMv4 = new QHBoxLayout;
     369            AssertPtrReturnVoid(pLayoutNMv4);
     370            {
     371                /* Configure layout: */
     372                pLayoutNMv4->setContentsMargins(0, 0, 0, 0);
     373                /* Create NMv4 network mask editor: */
     374                m_pEditorNMv4 = new QILineEdit;
     375                AssertPtrReturnVoid(m_pEditorNMv4);
     376                {
     377                    /* Configure editor: */
     378                    m_pLabelNMv4->setBuddy(m_pEditorNMv4);
     379                    connect(m_pEditorNMv4, &QLineEdit::textChanged,
     380                            this, &UIHostNetworkDetailsDialog::sltTextChangedNMv4);
     381                    /* Add into layout: */
     382                    pLayoutNMv4->addWidget(m_pEditorNMv4);
     383                }
     384                /* Create NMv4 error pane: */
     385                m_pErrorPaneNMv4 = new QLabel;
     386                AssertPtrReturnVoid(m_pErrorPaneNMv4);
     387                {
     388                    /* Configure label: */
     389                    m_pErrorPaneNMv4->setAlignment(Qt::AlignCenter);
     390                    m_pErrorPaneNMv4->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(16, 16)));
     391                    /* Add into layout: */
     392                    pLayoutNMv4->addWidget(m_pErrorPaneNMv4);
     393                }
     394                /* Add into layout: */
     395                pLayoutInterface->addLayout(pLayoutNMv4, 3, 2);
     396            }
     397
    245398            /* Create IPv6 address label: */
    246399            m_pLabelIPv6 = new QLabel;
     
    252405                pLayoutInterface->addWidget(m_pLabelIPv6, 4, 1);
    253406            }
    254             /* Create IPv6 address editor: */
    255             m_pEditorIPv6 = new QILineEdit;
    256             AssertPtrReturnVoid(m_pEditorIPv6);
    257             {
    258                 /* Configure editor: */
    259                 m_pLabelIPv6->setBuddy(m_pEditorIPv6);
    260                 connect(m_pEditorIPv6, &QLineEdit::textChanged,
    261                         this, &UIHostNetworkDetailsDialog::sltTextChangedIPv6);
    262                 /* Add into layout: */
    263                 pLayoutInterface->addWidget(m_pEditorIPv6, 4, 2);
    264             }
    265             /* Create IPv6 network mask label: */
     407            /* Create IPv6 layout: */
     408            QHBoxLayout *pLayoutIPv6 = new QHBoxLayout;
     409            AssertPtrReturnVoid(pLayoutIPv6);
     410            {
     411                /* Configure layout: */
     412                pLayoutIPv6->setContentsMargins(0, 0, 0, 0);
     413                /* Create IPv6 address editor: */
     414                m_pEditorIPv6 = new QILineEdit;
     415                AssertPtrReturnVoid(m_pEditorIPv6);
     416                {
     417                    /* Configure editor: */
     418                    m_pLabelIPv6->setBuddy(m_pEditorIPv6);
     419                    connect(m_pEditorIPv6, &QLineEdit::textChanged,
     420                            this, &UIHostNetworkDetailsDialog::sltTextChangedIPv6);
     421                    /* Add into layout: */
     422                    pLayoutIPv6->addWidget(m_pEditorIPv6);
     423                }
     424                /* Create IPv4 error pane: */
     425                m_pErrorPaneIPv6 = new QLabel;
     426                AssertPtrReturnVoid(m_pErrorPaneIPv6);
     427                {
     428                    /* Configure label: */
     429                    m_pErrorPaneIPv6->setAlignment(Qt::AlignCenter);
     430                    m_pErrorPaneIPv6->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(16, 16)));
     431                    /* Add into layout: */
     432                    pLayoutIPv6->addWidget(m_pErrorPaneIPv6);
     433                }
     434                /* Add into layout: */
     435                pLayoutInterface->addLayout(pLayoutIPv6, 4, 2);
     436            }
     437
     438            /* Create NMv6 network mask label: */
    266439            m_pLabelNMv6 = new QLabel;
    267440            AssertPtrReturnVoid(m_pLabelNMv6);
     
    272445                pLayoutInterface->addWidget(m_pLabelNMv6, 5, 1);
    273446            }
    274             /* Create IPv6 network mask editor: */
    275             m_pEditorNMv6 = new QILineEdit;
    276             AssertPtrReturnVoid(m_pEditorNMv6);
    277             {
    278                 /* Configure editor: */
    279                 m_pLabelNMv6->setBuddy(m_pEditorNMv6);
    280                 connect(m_pEditorNMv6, &QLineEdit::textChanged,
    281                         this, &UIHostNetworkDetailsDialog::sltTextChangedNMv6);
    282                 /* Add into layout: */
    283                 pLayoutInterface->addWidget(m_pEditorNMv6, 5, 2);
    284             }
     447            /* Create NMv6 layout: */
     448            QHBoxLayout *pLayoutNMv6 = new QHBoxLayout;
     449            AssertPtrReturnVoid(pLayoutNMv6);
     450            {
     451                /* Configure layout: */
     452                pLayoutNMv6->setContentsMargins(0, 0, 0, 0);
     453                /* Create NMv6 network mask editor: */
     454                m_pEditorNMv6 = new QILineEdit;
     455                AssertPtrReturnVoid(m_pEditorNMv6);
     456                {
     457                    /* Configure editor: */
     458                    m_pLabelNMv6->setBuddy(m_pEditorNMv6);
     459                    connect(m_pEditorNMv6, &QLineEdit::textChanged,
     460                            this, &UIHostNetworkDetailsDialog::sltTextChangedNMv6);
     461                    /* Add into layout: */
     462                    pLayoutNMv6->addWidget(m_pEditorNMv6);
     463                }
     464                /* Create NMv6 error pane: */
     465                m_pErrorPaneNMv6 = new QLabel;
     466                AssertPtrReturnVoid(m_pErrorPaneNMv6);
     467                {
     468                    /* Configure label: */
     469                    m_pErrorPaneNMv6->setAlignment(Qt::AlignCenter);
     470                    m_pErrorPaneNMv6->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(16, 16)));
     471                    /* Add into layout: */
     472                    pLayoutNMv6->addWidget(m_pErrorPaneNMv6);
     473                }
     474                /* Add into layout: */
     475                pLayoutInterface->addLayout(pLayoutNMv6, 5, 2);
     476            }
     477
    285478            /* Create indent: */
    286479            QStyleOption options;
     
    322515            pLayoutDHCPServer->setContentsMargins(10, 10, 10, 10);
    323516#endif
     517
    324518            /* Create DHCP server status check-box: */
    325519            m_pCheckBoxDHCP = new QCheckBox;
     
    332526                pLayoutDHCPServer->addWidget(m_pCheckBoxDHCP, 0, 0, 1, 2);
    333527            }
     528
    334529            /* Create DHCP address label: */
    335530            m_pLabelDHCPAddress = new QLabel;
     
    341536                pLayoutDHCPServer->addWidget(m_pLabelDHCPAddress, 1, 1);
    342537            }
    343             /* Create DHCP address editor: */
    344             m_pEditorDHCPAddress = new QILineEdit;
    345             AssertPtrReturnVoid(m_pEditorDHCPAddress);
    346             {
    347                 /* Configure editor: */
    348                 m_pLabelDHCPAddress->setBuddy(m_pEditorDHCPAddress);
    349                 connect(m_pEditorDHCPAddress, &QLineEdit::textChanged,
    350                         this, &UIHostNetworkDetailsDialog::sltTextChangedAddress);
    351                 /* Add into layout: */
    352                 pLayoutDHCPServer->addWidget(m_pEditorDHCPAddress, 1, 2);
    353             }
     538            /* Create DHCP address layout: */
     539            QHBoxLayout *pLayoutDHCPAddress = new QHBoxLayout;
     540            AssertPtrReturnVoid(pLayoutDHCPAddress);
     541            {
     542                /* Configure layout: */
     543                pLayoutDHCPAddress->setContentsMargins(0, 0, 0, 0);
     544                /* Create DHCP address editor: */
     545                m_pEditorDHCPAddress = new QILineEdit;
     546                AssertPtrReturnVoid(m_pEditorDHCPAddress);
     547                {
     548                    /* Configure editor: */
     549                    m_pLabelDHCPAddress->setBuddy(m_pEditorDHCPAddress);
     550                    connect(m_pEditorDHCPAddress, &QLineEdit::textChanged,
     551                            this, &UIHostNetworkDetailsDialog::sltTextChangedAddress);
     552                    /* Add into layout: */
     553                    pLayoutDHCPAddress->addWidget(m_pEditorDHCPAddress);
     554                }
     555                /* Create DHCP address error pane: */
     556                m_pErrorPaneDHCPAddress = new QLabel;
     557                AssertPtrReturnVoid(m_pErrorPaneDHCPAddress);
     558                {
     559                    /* Configure label: */
     560                    m_pErrorPaneDHCPAddress->setAlignment(Qt::AlignCenter);
     561                    m_pErrorPaneDHCPAddress->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(16, 16)));
     562                    /* Add into layout: */
     563                    pLayoutDHCPAddress->addWidget(m_pErrorPaneDHCPAddress);
     564                }
     565                /* Add into layout: */
     566                pLayoutDHCPServer->addLayout(pLayoutDHCPAddress, 1, 2);
     567            }
     568
    354569            /* Create DHCP network mask label: */
    355570            m_pLabelDHCPMask = new QLabel;
     
    361576                pLayoutDHCPServer->addWidget(m_pLabelDHCPMask, 2, 1);
    362577            }
    363             /* Create DHCP network mask editor: */
    364             m_pEditorDHCPMask = new QILineEdit;
    365             AssertPtrReturnVoid(m_pEditorDHCPMask);
    366             {
    367                 /* Configure editor: */
    368                 m_pLabelDHCPMask->setBuddy(m_pEditorDHCPMask);
    369                 connect(m_pEditorDHCPMask, &QLineEdit::textChanged,
    370                         this, &UIHostNetworkDetailsDialog::sltTextChangedMask);
    371                 /* Add into layout: */
    372                 pLayoutDHCPServer->addWidget(m_pEditorDHCPMask, 2, 2);
    373             }
     578            /* Create DHCP mask layout: */
     579            QHBoxLayout *pLayoutDHCPMask = new QHBoxLayout;
     580            AssertPtrReturnVoid(pLayoutDHCPMask);
     581            {
     582                /* Configure layout: */
     583                pLayoutDHCPMask->setContentsMargins(0, 0, 0, 0);
     584                /* Create DHCP network mask editor: */
     585                m_pEditorDHCPMask = new QILineEdit;
     586                AssertPtrReturnVoid(m_pEditorDHCPMask);
     587                {
     588                    /* Configure editor: */
     589                    m_pLabelDHCPMask->setBuddy(m_pEditorDHCPMask);
     590                    connect(m_pEditorDHCPMask, &QLineEdit::textChanged,
     591                            this, &UIHostNetworkDetailsDialog::sltTextChangedMask);
     592                    /* Add into layout: */
     593                    pLayoutDHCPMask->addWidget(m_pEditorDHCPMask);
     594                }
     595                /* Create DHCP mask error pane: */
     596                m_pErrorPaneDHCPMask = new QLabel;
     597                AssertPtrReturnVoid(m_pErrorPaneDHCPMask);
     598                {
     599                    /* Configure label: */
     600                    m_pErrorPaneDHCPMask->setAlignment(Qt::AlignCenter);
     601                    m_pErrorPaneDHCPMask->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(16, 16)));
     602                    /* Add into layout: */
     603                    pLayoutDHCPMask->addWidget(m_pErrorPaneDHCPMask);
     604                }
     605                /* Add into layout: */
     606                pLayoutDHCPServer->addLayout(pLayoutDHCPMask, 2, 2);
     607            }
     608
    374609            /* Create DHCP lower address label: */
    375610            m_pLabelDHCPLowerAddress = new QLabel;
     
    381616                pLayoutDHCPServer->addWidget(m_pLabelDHCPLowerAddress, 3, 1);
    382617            }
    383             /* Create DHCP lower address editor: */
    384             m_pEditorDHCPLowerAddress = new QILineEdit;
    385             AssertPtrReturnVoid(m_pEditorDHCPLowerAddress);
    386             {
    387                 /* Configure editor: */
    388                 m_pLabelDHCPLowerAddress->setBuddy(m_pEditorDHCPLowerAddress);
    389                 connect(m_pEditorDHCPLowerAddress, &QLineEdit::textChanged,
    390                         this, &UIHostNetworkDetailsDialog::sltTextChangedLowerAddress);
    391                 /* Add into layout: */
    392                 pLayoutDHCPServer->addWidget(m_pEditorDHCPLowerAddress, 3, 2);
    393             }
     618            /* Create DHCP lower address layout: */
     619            QHBoxLayout *pLayoutDHCPLowerAddress = new QHBoxLayout;
     620            AssertPtrReturnVoid(pLayoutDHCPLowerAddress);
     621            {
     622                /* Configure layout: */
     623                pLayoutDHCPLowerAddress->setContentsMargins(0, 0, 0, 0);
     624                /* Create DHCP lower address editor: */
     625                m_pEditorDHCPLowerAddress = new QILineEdit;
     626                AssertPtrReturnVoid(m_pEditorDHCPLowerAddress);
     627                {
     628                    /* Configure editor: */
     629                    m_pLabelDHCPLowerAddress->setBuddy(m_pEditorDHCPLowerAddress);
     630                    connect(m_pEditorDHCPLowerAddress, &QLineEdit::textChanged,
     631                            this, &UIHostNetworkDetailsDialog::sltTextChangedLowerAddress);
     632                    /* Add into layout: */
     633                    pLayoutDHCPLowerAddress->addWidget(m_pEditorDHCPLowerAddress);
     634                }
     635                /* Create DHCP lower address error pane: */
     636                m_pErrorPaneDHCPLowerAddress = new QLabel;
     637                AssertPtrReturnVoid(m_pErrorPaneDHCPLowerAddress);
     638                {
     639                    /* Configure label: */
     640                    m_pErrorPaneDHCPLowerAddress->setAlignment(Qt::AlignCenter);
     641                    m_pErrorPaneDHCPLowerAddress->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(16, 16)));
     642                    /* Add into layout: */
     643                    pLayoutDHCPLowerAddress->addWidget(m_pErrorPaneDHCPLowerAddress);
     644                }
     645                /* Add into layout: */
     646                pLayoutDHCPServer->addLayout(pLayoutDHCPLowerAddress, 3, 2);
     647            }
     648
    394649            /* Create DHCP upper address label: */
    395650            m_pLabelDHCPUpperAddress = new QLabel;
     
    401656                pLayoutDHCPServer->addWidget(m_pLabelDHCPUpperAddress, 4, 1);
    402657            }
    403             /* Create DHCP upper address editor: */
    404             m_pEditorDHCPUpperAddress = new QILineEdit;
    405             AssertPtrReturnVoid(m_pEditorDHCPUpperAddress);
    406             {
    407                 /* Configure editor: */
    408                 m_pLabelDHCPUpperAddress->setBuddy(m_pEditorDHCPUpperAddress);
    409                 connect(m_pEditorDHCPUpperAddress, &QLineEdit::textChanged,
    410                         this, &UIHostNetworkDetailsDialog::sltTextChangedUpperAddress);
    411                 /* Add into layout: */
    412                 pLayoutDHCPServer->addWidget(m_pEditorDHCPUpperAddress, 4, 2);
    413             }
     658            /* Create DHCP upper address layout: */
     659            QHBoxLayout *pLayoutDHCPUpperAddress = new QHBoxLayout;
     660            AssertPtrReturnVoid(pLayoutDHCPUpperAddress);
     661            {
     662                /* Configure layout: */
     663                pLayoutDHCPUpperAddress->setContentsMargins(0, 0, 0, 0);
     664                /* Create DHCP upper address editor: */
     665                m_pEditorDHCPUpperAddress = new QILineEdit;
     666                AssertPtrReturnVoid(m_pEditorDHCPUpperAddress);
     667                {
     668                    /* Configure editor: */
     669                    m_pLabelDHCPUpperAddress->setBuddy(m_pEditorDHCPUpperAddress);
     670                    connect(m_pEditorDHCPUpperAddress, &QLineEdit::textChanged,
     671                            this, &UIHostNetworkDetailsDialog::sltTextChangedUpperAddress);
     672                    /* Add into layout: */
     673                    pLayoutDHCPUpperAddress->addWidget(m_pEditorDHCPUpperAddress);
     674                }
     675                /* Create DHCP upper address error pane: */
     676                m_pErrorPaneDHCPUpperAddress = new QLabel;
     677                AssertPtrReturnVoid(m_pErrorPaneDHCPUpperAddress);
     678                {
     679                    /* Configure label: */
     680                    m_pErrorPaneDHCPUpperAddress->setAlignment(Qt::AlignCenter);
     681                    m_pErrorPaneDHCPUpperAddress->setPixmap(UIIconPool::iconSet(":/status_error_16px.png").pixmap(QSize(16, 16)));
     682                    /* Add into layout: */
     683                    pLayoutDHCPUpperAddress->addWidget(m_pErrorPaneDHCPUpperAddress);
     684                }
     685                /* Add into layout: */
     686                pLayoutDHCPServer->addLayout(pLayoutDHCPUpperAddress, 4, 2);
     687            }
     688
    414689            /* Create indent: */
    415690            QStyleOption options;
     
    483758    m_pEditorDHCPLowerAddress->setText(m_newData.m_dhcpserver.m_strLowerAddress);
    484759    m_pEditorDHCPUpperAddress->setText(m_newData.m_dhcpserver.m_strUpperAddress);
     760}
     761
     762void UIHostNetworkDetailsDialog::revalidate(QWidget *pWidget /* = 0 */)
     763{
     764    /* Validate 'Interface' tab content: */
     765    if (!pWidget || pWidget == m_pErrorPaneAutomatic)
     766    {
     767        const bool fError =    m_newData.m_interface.m_fDHCPEnabled
     768                            && !m_newData.m_dhcpserver.m_fEnabled;
     769        m_pErrorPaneAutomatic->setVisible(fError);
     770    }
     771    if (!pWidget || pWidget == m_pErrorPaneIPv4)
     772    {
     773        const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
     774                            && !m_newData.m_interface.m_strAddress.trimmed().isEmpty()
     775                            && (   !RTNetIsIPv4AddrStr(m_newData.m_interface.m_strAddress.toUtf8().constData())
     776                                || RTNetStrIsIPv4AddrAny(m_newData.m_interface.m_strAddress.toUtf8().constData()));
     777        m_pErrorPaneIPv4->setVisible(fError);
     778    }
     779    if (!pWidget || pWidget == m_pErrorPaneNMv4)
     780    {
     781        const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
     782                            && !m_newData.m_interface.m_strMask.trimmed().isEmpty()
     783                            && (   !RTNetIsIPv4AddrStr(m_newData.m_interface.m_strMask.toUtf8().constData())
     784                                || RTNetStrIsIPv4AddrAny(m_newData.m_interface.m_strMask.toUtf8().constData()));
     785        m_pErrorPaneNMv4->setVisible(fError);
     786    }
     787    if (!pWidget || pWidget == m_pErrorPaneIPv6)
     788    {
     789        const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
     790                            && m_newData.m_interface.m_fSupportedIPv6
     791                            && !m_newData.m_interface.m_strAddress6.trimmed().isEmpty()
     792                            && (   !RTNetIsIPv6AddrStr(m_newData.m_interface.m_strAddress6.toUtf8().constData())
     793                                || RTNetStrIsIPv6AddrAny(m_newData.m_interface.m_strAddress6.toUtf8().constData()));
     794        m_pErrorPaneIPv6->setVisible(fError);
     795    }
     796    if (!pWidget || pWidget == m_pErrorPaneNMv6)
     797    {
     798        bool fIsMaskPrefixLengthNumber = false;
     799        const int iMaskPrefixLength = m_newData.m_interface.m_strMaskLength6.trimmed().toInt(&fIsMaskPrefixLengthNumber);
     800        const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
     801                            && m_newData.m_interface.m_fSupportedIPv6
     802                            && (   !fIsMaskPrefixLengthNumber
     803                                || iMaskPrefixLength < 0
     804                                || iMaskPrefixLength > 128);
     805        m_pErrorPaneNMv6->setVisible(fError);
     806    }
     807
     808    /* Validate 'DHCP server' tab content: */
     809    if (!pWidget || pWidget == m_pErrorPaneDHCPAddress)
     810    {
     811        const bool fError =    m_newData.m_dhcpserver.m_fEnabled
     812                            && (   !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strAddress.toUtf8().constData())
     813                                || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strAddress.toUtf8().constData()));
     814        m_pErrorPaneDHCPAddress->setVisible(fError);
     815    }
     816    if (!pWidget || pWidget == m_pErrorPaneDHCPMask)
     817    {
     818        const bool fError =    m_newData.m_dhcpserver.m_fEnabled
     819                            && (   !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strMask.toUtf8().constData())
     820                                || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strMask.toUtf8().constData()));
     821        m_pErrorPaneDHCPMask->setVisible(fError);
     822    }
     823    if (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress)
     824    {
     825        const bool fError =    m_newData.m_dhcpserver.m_fEnabled
     826                            && (   !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData())
     827                                || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strLowerAddress.toUtf8().constData()));
     828        m_pErrorPaneDHCPLowerAddress->setVisible(fError);
     829    }
     830    if (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress)
     831    {
     832        const bool fError =    m_newData.m_dhcpserver.m_fEnabled
     833                            && (   !RTNetIsIPv4AddrStr(m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData())
     834                                || RTNetStrIsIPv4AddrAny(m_newData.m_dhcpserver.m_strUpperAddress.toUtf8().constData()));
     835        m_pErrorPaneDHCPUpperAddress->setVisible(fError);
     836    }
     837
     838    /* Retranslate validation: */
     839    retranslateValidation(pWidget);
     840}
     841
     842void UIHostNetworkDetailsDialog::retranslateValidation(QWidget *pWidget /* = 0 */)
     843{
     844    /* Translate 'Interface' tab content: */
     845    if (!pWidget || pWidget == m_pErrorPaneAutomatic)
     846        m_pErrorPaneAutomatic->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> is set to obtain address automatically "
     847                                             "but its DHCP server is not enabled.").arg(m_newData.m_interface.m_strName));
     848    if (!pWidget || pWidget == m_pErrorPaneIPv4)
     849        m_pErrorPaneIPv4->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
     850                                        "IPv4 address.").arg(m_newData.m_interface.m_strName));
     851    if (!pWidget || pWidget == m_pErrorPaneNMv4)
     852        m_pErrorPaneNMv4->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
     853                                        "IPv4 network mask.").arg(m_newData.m_interface.m_strName));
     854    if (!pWidget || pWidget == m_pErrorPaneIPv6)
     855        m_pErrorPaneIPv6->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
     856                                        "IPv6 address.").arg(m_newData.m_interface.m_strName));
     857    if (!pWidget || pWidget == m_pErrorPaneNMv6)
     858        m_pErrorPaneNMv6->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
     859                                        "IPv6 network mask prefix length.").arg(m_newData.m_interface.m_strName));
     860
     861    /* Translate 'DHCP server' tab content: */
     862    if (!pWidget || pWidget == m_pErrorPaneDHCPAddress)
     863        m_pErrorPaneDHCPAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
     864                                               "DHCP server address.").arg(m_newData.m_interface.m_strName));
     865    if (!pWidget || pWidget == m_pErrorPaneDHCPMask)
     866        m_pErrorPaneDHCPMask->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
     867                                            "DHCP server mask.").arg(m_newData.m_interface.m_strName));
     868    if (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress)
     869        m_pErrorPaneDHCPLowerAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
     870                                                    "DHCP server lower address bound.").arg(m_newData.m_interface.m_strName));
     871    if (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress)
     872        m_pErrorPaneDHCPUpperAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
     873                                                    "DHCP server upper address bound.").arg(m_newData.m_interface.m_strName));
    485874}
    486875
  • trunk/src/VBox/Frontends/VirtualBox/src/hostnetwork/UIHostNetworkDetailsDialog.h

    r66781 r66809  
    187187     * @{ */
    188188        /** Handles interface automatic configuration choice change. */
    189         void sltToggledButtonAutomatic(bool fChecked) { m_newData.m_interface.m_fDHCPEnabled = fChecked; loadDataForInterface(); notify(); }
     189        void sltToggledButtonAutomatic(bool fChecked);
    190190        /** Handles interface manual configuration choice change. */
    191         void sltToggledButtonManual(bool fChecked) { m_newData.m_interface.m_fDHCPEnabled = !fChecked; loadDataForInterface(); notify(); }
     191        void sltToggledButtonManual(bool fChecked);
    192192        /** Handles interface IPv4 text change. */
    193         void sltTextChangedIPv4(const QString &strText) { m_newData.m_interface.m_strAddress = strText; notify(); }
     193        void sltTextChangedIPv4(const QString &strText);
    194194        /** Handles interface NMv4 text change. */
    195         void sltTextChangedNMv4(const QString &strText) { m_newData.m_interface.m_strMask = strText; notify(); }
     195        void sltTextChangedNMv4(const QString &strText);
    196196        /** Handles interface IPv6 text change. */
    197         void sltTextChangedIPv6(const QString &strText) { m_newData.m_interface.m_strAddress6 = strText; notify(); }
     197        void sltTextChangedIPv6(const QString &strText);
    198198        /** Handles interface NMv6 text change. */
    199         void sltTextChangedNMv6(const QString &strText) { m_newData.m_interface.m_strMaskLength6 = strText; notify(); }
     199        void sltTextChangedNMv6(const QString &strText);
    200200
    201201        /** Handles DHCP server status change. */
    202         void sltStatusChangedServer(int iChecked) { m_newData.m_dhcpserver.m_fEnabled = (bool)iChecked; loadDataForDHCPServer(); notify(); }
     202        void sltStatusChangedServer(int iChecked);
    203203        /** Handles DHCP server address text change. */
    204         void sltTextChangedAddress(const QString &strText) { m_newData.m_dhcpserver.m_strAddress = strText; notify(); }
     204        void sltTextChangedAddress(const QString &strText);
    205205        /** Handles DHCP server mask text change. */
    206         void sltTextChangedMask(const QString &strText)  { m_newData.m_dhcpserver.m_strMask = strText; notify(); }
     206        void sltTextChangedMask(const QString &strText);
    207207        /** Handles DHCP server lower address text change. */
    208         void sltTextChangedLowerAddress(const QString &strText)  { m_newData.m_dhcpserver.m_strLowerAddress = strText; notify(); }
     208        void sltTextChangedLowerAddress(const QString &strText);
    209209        /** Handles DHCP server upper address text change. */
    210         void sltTextChangedUpperAddress(const QString &strText)  { m_newData.m_dhcpserver.m_strUpperAddress = strText; notify(); }
     210        void sltTextChangedUpperAddress(const QString &strText);
    211211    /** @} */
    212212
     
    237237    /** @name Change handling stuff.
    238238     * @{ */
     239        /** Revalidates changes for passed @a pWidget. */
     240        void revalidate(QWidget *pWidget = 0);
     241        /** Retranslates validation for passed @a pWidget. */
     242        void retranslateValidation(QWidget *pWidget = 0);
    239243        /** Notifies listeners about data changed or not. */
    240244        void notify();
     
    263267        /** Holds the automatic interface configuration button. */
    264268        QRadioButton *m_pButtonAutomatic;
     269        /** Holds the automatic interface configuration error pane. */
     270        QLabel       *m_pErrorPaneAutomatic;
     271
    265272        /** Holds the manual interface configuration button. */
    266273        QRadioButton *m_pButtonManual;
     274
    267275        /** Holds the IPv4 address label. */
    268276        QLabel       *m_pLabelIPv4;
    269277        /** Holds the IPv4 address editor. */
    270278        QILineEdit   *m_pEditorIPv4;
     279        /** Holds the IPv4 address error pane. */
     280        QLabel       *m_pErrorPaneIPv4;
     281
    271282        /** Holds the IPv4 network mask label. */
    272283        QLabel       *m_pLabelNMv4;
    273284        /** Holds the IPv4 network mask editor. */
    274285        QILineEdit   *m_pEditorNMv4;
     286        /** Holds the IPv4 network mask error pane. */
     287        QLabel       *m_pErrorPaneNMv4;
     288
    275289        /** Holds the IPv6 address label. */
    276290        QLabel       *m_pLabelIPv6;
    277291        /** Holds the IPv6 address editor. */
    278292        QILineEdit   *m_pEditorIPv6;
     293        /** Holds the IPv6 address error pane. */
     294        QLabel       *m_pErrorPaneIPv6;
     295
    279296        /** Holds the IPv6 network mask label. */
    280297        QLabel       *m_pLabelNMv6;
    281298        /** Holds the IPv6 network mask editor. */
    282299        QILineEdit   *m_pEditorNMv6;
     300        /** Holds the IPv6 network mask error pane. */
     301        QLabel       *m_pErrorPaneNMv6;
    283302    /** @} */
    284303
     
    287306        /** Holds the DHCP server status chack-box. */
    288307        QCheckBox  *m_pCheckBoxDHCP;
     308
    289309        /** Holds the DHCP address label. */
    290310        QLabel     *m_pLabelDHCPAddress;
    291311        /** Holds the DHCP address editor. */
    292312        QILineEdit *m_pEditorDHCPAddress;
     313        /** Holds the DHCP address error pane. */
     314        QLabel     *m_pErrorPaneDHCPAddress;
     315
    293316        /** Holds the DHCP network mask label. */
    294317        QLabel     *m_pLabelDHCPMask;
    295318        /** Holds the DHCP network mask editor. */
    296319        QILineEdit *m_pEditorDHCPMask;
     320        /** Holds the DHCP network mask error pane. */
     321        QLabel     *m_pErrorPaneDHCPMask;
     322
    297323        /** Holds the DHCP lower address label. */
    298324        QLabel     *m_pLabelDHCPLowerAddress;
    299325        /** Holds the DHCP lower address editor. */
    300326        QILineEdit *m_pEditorDHCPLowerAddress;
     327        /** Holds the DHCP lower address error pane. */
     328        QLabel     *m_pErrorPaneDHCPLowerAddress;
     329
    301330        /** Holds the DHCP upper address label. */
    302331        QLabel     *m_pLabelDHCPUpperAddress;
    303332        /** Holds the DHCP upper address editor. */
    304333        QILineEdit *m_pEditorDHCPUpperAddress;
     334        /** Holds the DHCP upper address error pane. */
     335        QLabel     *m_pErrorPaneDHCPUpperAddress;
    305336    /** @} */
    306337};
Note: See TracChangeset for help on using the changeset viewer.

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