summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--startupscreen/MainView.qml11
-rw-r--r--startupscreen/settingsmanager.cpp27
-rw-r--r--startupscreen/settingsmanager.h3
3 files changed, 39 insertions, 2 deletions
diff --git a/startupscreen/MainView.qml b/startupscreen/MainView.qml
index 4e0a234..fb79df3 100644
--- a/startupscreen/MainView.qml
+++ b/startupscreen/MainView.qml
@@ -200,7 +200,7 @@ Item {
Text {
id: ipLabel
color: "grey"
- text: "Network"
+ text: "Networks:"
anchors.bottom: ipAddress.top
anchors.horizontalCenter: ipAddress.horizontalCenter
font.pixelSize: textNormal
@@ -209,13 +209,20 @@ Item {
Text {
id: ipAddress
color: "grey"
- text: "eth0: 255.255.255.255\nusb0: 0:0.0.0.0"
+ text: SettingsManager.networks
anchors.bottom: root.bottom
anchors.right: root.right
anchors.rightMargin: 5
font.pixelSize: textNormal
font.bold: true
font.family: "Titillium Web"
+
+ Timer {
+ interval: 3000
+ onTriggered: ipAddress.text = SettingsManager.networks
+ running: true
+ repeat: true
+ }
}
UsbModeDialog {
diff --git a/startupscreen/settingsmanager.cpp b/startupscreen/settingsmanager.cpp
index 4f5f217..0608f86 100644
--- a/startupscreen/settingsmanager.cpp
+++ b/startupscreen/settingsmanager.cpp
@@ -54,6 +54,7 @@
#include <QDir>
#include <QFile>
#include <QTemporaryFile>
+#include <QNetworkInterface>
#include <sys/reboot.h>
#include <unistd.h>
@@ -124,3 +125,29 @@ void SettingsManager::reboot()
::reboot(RB_AUTOBOOT);
qWarning("reboot failed");
}
+
+QString SettingsManager::networks()
+{
+ QString networks;
+ networks.reserve(100);
+
+ const auto interfaceList = QNetworkInterface::allInterfaces();
+ for (const auto &interface : interfaceList) {
+ if (interface.name() == QLatin1String("lo"))
+ continue;
+
+ if (interface.flags().testFlag(QNetworkInterface::IsUp)) {
+ for (QNetworkAddressEntry &entry : interface.addressEntries()) {
+ if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) {
+ if (!networks.isEmpty())
+ networks += QLatin1String("\n");
+
+ networks += interface.name();
+ networks += QLatin1String(": ");
+ networks += entry.ip().toString();
+ }
+ }
+ }
+ }
+ return networks;
+}
diff --git a/startupscreen/settingsmanager.h b/startupscreen/settingsmanager.h
index 1801812..fa6c066 100644
--- a/startupscreen/settingsmanager.h
+++ b/startupscreen/settingsmanager.h
@@ -60,6 +60,7 @@ class SettingsManager : public QObject
Q_PROPERTY(QString usbMode READ usbMode WRITE setUsbMode)
Q_PROPERTY(bool hasQdb READ hasQdb CONSTANT)
+ Q_PROPERTY(QString networks READ networks CONSTANT)
public:
explicit SettingsManager(QObject *parent = nullptr);
@@ -69,6 +70,8 @@ public:
bool hasQdb();
Q_INVOKABLE void reboot();
+ QString networks();
+
private:
QString m_usbMode;
};