Compléter NI

main
Alexis Drai 2 years ago
parent 5fe23ef097
commit 10eb212209

@ -2,7 +2,15 @@ import QtQuick 2.0
import Sailfish.Silica 1.0
ApplicationWindow {
Label {
text: networkInterface.name()
Column {
Label {
text: "Name: " + networkInterface.name()
}
Label {
text: "Physical Address: " + networkInterface.physicalAddress()
}
Label {
text: "IP Address: " + networkInterface.address()
}
}
}

@ -9,3 +9,17 @@ QString NetworkInterface::name() const
{
return m_networkInterface.name();
}
QString NetworkInterface::physicalAddress() const
{
return m_networkInterface.hardwareAddress();
}
QString NetworkInterface::address() const
{
QList<QNetworkAddressEntry> entries = m_networkInterface.addressEntries();
if (!entries.isEmpty())
return entries.first().ip().toString();
else
return QString();
}

@ -10,6 +10,8 @@ class NetworkInterface : public QObject
public:
explicit NetworkInterface(const QNetworkInterface& networkInterface, QObject *parent = nullptr);
Q_INVOKABLE QString name() const;
Q_INVOKABLE QString physicalAddress() const;
Q_INVOKABLE QString address() const;
private:
QNetworkInterface m_networkInterface;

Loading…
Cancel
Save