Skip to content
Snippets Groups Projects
Commit 304d6f90 authored by Burak Hançerli's avatar Burak Hançerli :headphones:
Browse files

QDS-13458 Show ip addresses on the home page

parent 98f060ef
No related branches found
No related tags found
1 merge request!58QDS-13458 Show ip addresses on the home page
Pipeline #76683 passed
......@@ -137,117 +137,27 @@ Flickable {
spacing: 10
Rectangle {
Label {
Layout.fillWidth: true
Layout.preferredHeight: optionLayout1.height
color: Constants.boxBackgroundColor
radius: Material.MediumScale
border {
width: 1
color: Constants.boxBorderColor
}
ColumnLayout {
id: optionLayout1
width: parent.width
spacing: 20
Label {
Layout.fillWidth: true
Layout.topMargin: 20
horizontalAlignment: Qt.AlignHCenter
text: qsTr("Option 1")
font.pixelSize: Constants.lgTextSize
font.bold: true
wrapMode: Text.WordWrap
}
Label {
Layout.fillWidth: true
Layout.leftMargin: 20
Layout.rightMargin: 20
horizontalAlignment: Qt.AlignHCenter
text: qsTr("Click to scan the QR code in Qt Design Studio")
font.pixelSize: Constants.mdTextSize
wrapMode: Text.WordWrap
}
QrButton {
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: 20
onClicked: backend.scanQrCode()
}
}
text: qsTr("This device can be reached at the following IP addresses:")
font.pixelSize: Constants.lgTextSize
font.bold: true
wrapMode: Text.WordWrap
}
Rectangle {
Label {
id: ipAddress
Layout.fillWidth: true
Layout.preferredHeight: optionLayout2.height
color: Constants.boxBackgroundColor
radius: Material.MediumScale
border {
width: 1
color: Constants.boxBorderColor
}
ColumnLayout {
id: optionLayout2
width: parent.width
spacing: 20
Label {
Layout.fillWidth: true
Layout.topMargin: 20
horizontalAlignment: Qt.AlignHCenter
text: qsTr("Option 2")
font.pixelSize: Constants.lgTextSize
font.bold: true
wrapMode: Text.WordWrap
}
TextField {
id: ipAddress
Layout.fillWidth: true
Layout.leftMargin: 20
Layout.rightMargin: 20
Layout.alignment: Qt.AlignHCenter
placeholderText: qsTr("IP Address")
text: backend.lastDesignStudioIp()
validator: RegularExpressionValidator {
regularExpression: /^(\d{1,3}\.){3}\d{1,3}$/
}
Connections {
target: backend
function onConnectedChanged(isConnected, ip) {
ipAddress.text = ip;
}
}
}
Button {
id: downloadUserProject
Layout.fillWidth: true
Layout.leftMargin: 20
Layout.rightMargin: 20
Layout.bottomMargin: 20
Layout.alignment: Qt.AlignHCenter
text: qsTr("Connect Design Studio")
enabled: true
text: qsTr("xxx.xxx.xxx.xxx")
font.pixelSize: Constants.lgTextSize
font.bold: true
wrapMode: Text.WordWrap
onClicked: backend.connectDesignStudio(ipAddress.text)
Component.onCompleted: {
ipAddress.text = '';
var val = backend.getIpAddresses();
for(var i = 0; i < val.length; i++) {
ipAddress.text += val[i].interface + ': ' + val[i].ip + '\n';
}
}
}
......
......@@ -26,6 +26,7 @@
#include "backend.h"
#include <QDesktopServices>
#include <QNetworkInterface>
#include "logger.h"
......@@ -253,3 +254,21 @@ QString Backend::lastDesignStudioIp() const
{
return m_dsManager ? m_dsManager->getDesignStudioIp({}) : QString();
}
QJsonArray Backend::getIpAddresses() const
{
QNetworkInterface networkInterface;
QJsonArray ipAddresses;
for (const auto &interface : networkInterface.allInterfaces()) {
for (const auto &entry : interface.addressEntries()) {
if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol && !entry.ip().isLoopback()) {
qDebug() << "Interface:" << interface.name() << "IP:" << entry.ip().toString();
ipAddresses.append(
QJsonObject{{"interface", interface.name()}, {"ip", entry.ip().toString()}});
}
}
}
return ipAddresses;
}
......@@ -26,6 +26,7 @@
#ifndef DV_ANDROID_H
#define DV_ANDROID_H
#include <QJsonArray>
#include <QThread>
#include "dsconnector/dsmanager.h"
......@@ -81,6 +82,7 @@ public slots:
void connectDesignStudio(const QString &ipAddr);
void parseDesignViewerUrl(const QUrl &url);
void popupInterrupted();
QJsonArray getIpAddresses() const;
bool autoScaleProject() const;
void setAutoScaleProject(bool autoScaleProject);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment