VirtualBox

Changeset 42253 in vbox


Ignore:
Timestamp:
Jul 20, 2012 11:33:08 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings / Network page: Better validation message for MAC address field.

File:
1 edited

Legend:

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

    r41819 r42253  
    5656    /* Setup widgets: */
    5757    m_pAdapterNameCombo->setInsertPolicy(QComboBox::NoInsert);
    58     m_pMACEditor->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f][02468ACEace][0-9A-Fa-f]{10}"), this));
     58    m_pMACEditor->setValidator(new QRegExpValidator(QRegExp("[0-9A-Fa-f]{12}"), this));
    5959    m_pMACEditor->setMinimumWidthByText(QString().fill('0', 12));
    6060
     
    164164{
    165165    m_pValidator = pValidator;
     166    connect(m_pMACEditor, SIGNAL(textEdited(const QString &)), m_pValidator, SLOT(revalidate()));
    166167}
    167168
     
    215216            break;
    216217    }
     218
     219    /* Validate MAC-address: */
     220    if (m_pMACEditor->text().size() < 12)
     221    {
     222        strWarning = tr("the value of the Mac address field in not complete.");
     223        fValid = false;
     224    }
     225    else
     226    {
     227        QRegExp validator("[0-9A-Fa-f][02468ACEace][0-9A-Fa-f]{10}");
     228        if (!validator.exactMatch(m_pMACEditor->text()))
     229        {
     230            strWarning = tr("the second digit cannot be odd, as only unicast Mac addresses allowed.");
     231            fValid = false;
     232        }
     233    }
     234
    217235    if (!fValid)
    218236        strTitle += ": " + vboxGlobal().removeAccelMark(tabTitle());
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