Skip to content
Snippets Groups Projects

QDS-13458 Show ip addresses on the home page

Merged Burak Hançerli requested to merge QDS-13458/show-ip-addresses into master
3 files
+ 9
12
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 4
7
@@ -26,9 +26,6 @@
@@ -26,9 +26,6 @@
#include "backend.h"
#include "backend.h"
#include <QDesktopServices>
#include <QDesktopServices>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkInterface>
#include <QNetworkInterface>
#include "logger.h"
#include "logger.h"
@@ -258,20 +255,20 @@ QString Backend::lastDesignStudioIp() const
@@ -258,20 +255,20 @@ QString Backend::lastDesignStudioIp() const
return m_dsManager ? m_dsManager->getDesignStudioIp({}) : QString();
return m_dsManager ? m_dsManager->getDesignStudioIp({}) : QString();
}
}
QString Backend::getIpAddresses() const
QJsonArray Backend::getIpAddresses() const
{
{
QNetworkInterface networkInterface;
QNetworkInterface networkInterface;
QJsonArray ipAddresses;
QJsonArray ipAddresses;
for (const auto &interface : networkInterface.allInterfaces()) {
for (const auto &interface : networkInterface.allInterfaces()) {
for (const auto &entry : interface.addressEntries()) {
for (const auto &entry : interface.addressEntries()) {
if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol && !entry.ip().isLoopback()
if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol && !entry.ip().isLoopback()) {
&& !entry.ip().isMulticast() && !entry.ip().isBroadcast()) {
qDebug() << "Interface:" << interface.name() << "IP:" << entry.ip().toString();
ipAddresses.append(
ipAddresses.append(
QJsonObject{{"interface", interface.name()}, {"ip", entry.ip().toString()}});
QJsonObject{{"interface", interface.name()}, {"ip", entry.ip().toString()}});
}
}
}
}
}
}
return QJsonDocument(ipAddresses).toJson(QJsonDocument::Compact);
return ipAddresses;
}
}
Loading