diff --git a/qt3.pro b/qt3.pro index 2fdfc56..7f24b6f 100644 --- a/qt3.pro +++ b/qt3.pro @@ -14,7 +14,8 @@ TARGET = qt3 CONFIG += sailfishapp -SOURCES += src/qt3.cpp +SOURCES += src/qt3.cpp \ + src/networkinterface.cpp DISTFILES += qml/qt3.qml \ qml/cover/CoverPage.qml \ @@ -37,3 +38,6 @@ CONFIG += sailfishapp_i18n # following TRANSLATIONS line. And also do not forget to # modify the localized app name in the the .desktop file. TRANSLATIONS += translations/qt3-de.ts + +HEADERS += \ + src/networkinterface.h diff --git a/src/networkinterface.cpp b/src/networkinterface.cpp new file mode 100644 index 0000000..e53d18f --- /dev/null +++ b/src/networkinterface.cpp @@ -0,0 +1,11 @@ +#include "networkinterface.h" + +NetworkInterface::NetworkInterface(const QNetworkInterface& networkInterface, QObject *parent) + : QObject(parent), m_networkInterface(networkInterface) +{ +} + +QString NetworkInterface::name() const +{ + return m_networkInterface.name(); +} diff --git a/src/networkinterface.h b/src/networkinterface.h new file mode 100644 index 0000000..a6a2173 --- /dev/null +++ b/src/networkinterface.h @@ -0,0 +1,22 @@ +#ifndef NETWORKINTERFACE_H +#define NETWORKINTERFACE_H + +#include +#include + +class NetworkInterface : public QObject +{ + Q_OBJECT +public: + explicit NetworkInterface(const QNetworkInterface& networkInterface, QObject *parent = nullptr); + Q_INVOKABLE QString name() const; + +private: + QNetworkInterface m_networkInterface; + +signals: + +public slots: +}; + +#endif // NETWORKINTERFACE_H diff --git a/src/qt3.cpp b/src/qt3.cpp index 631af3b..421fe47 100644 --- a/src/qt3.cpp +++ b/src/qt3.cpp @@ -1,5 +1,6 @@ #ifdef QT_QML_DEBUG #include +#include "networkinterface.h" #endif #include @@ -15,6 +16,8 @@ int main(int argc, char *argv[]) // - SailfishApp::pathToMainQml() to get a QUrl to the main QML file // // To display the view, call "show()" (will show fullscreen on device). + NetworkInterface ni(QNetworkInterface::interfaceFromName("lo")); + qDebug() << ni.name(); return SailfishApp::main(argc, argv); }