mirror of
https://github.com/Serial-Studio/Serial-Studio.git
synced 2025-01-31 17:42:55 +08:00
Perform DNS lookups automatically
This commit is contained in:
parent
e87648294f
commit
93482e8e82
2
.github/workflows/Build.yml
vendored
2
.github/workflows/Build.yml
vendored
@ -19,7 +19,7 @@ on:
|
|||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
|
|
||||||
env:
|
env:
|
||||||
VERSION: "1.0.20"
|
VERSION: "1.0.21"
|
||||||
EXECUTABLE: "SerialStudio"
|
EXECUTABLE: "SerialStudio"
|
||||||
APPLICATION: "Serial Studio"
|
APPLICATION: "Serial Studio"
|
||||||
QMAKE_PROJECT: "Serial-Studio.pro"
|
QMAKE_PROJECT: "Serial-Studio.pro"
|
||||||
|
@ -36,7 +36,6 @@ Control {
|
|||||||
property alias topic: _topic.text
|
property alias topic: _topic.text
|
||||||
property alias user: _user.text
|
property alias user: _user.text
|
||||||
property alias password: _password.text
|
property alias password: _password.text
|
||||||
property alias dnsAddress: _addrLookup.text
|
|
||||||
property alias version: _version.currentIndex
|
property alias version: _version.currentIndex
|
||||||
property alias mode: _mode.currentIndex
|
property alias mode: _mode.currentIndex
|
||||||
|
|
||||||
@ -237,46 +236,6 @@ Control {
|
|||||||
Layout.minimumHeight: app.spacing
|
Layout.minimumHeight: app.spacing
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Address lookup
|
|
||||||
//
|
|
||||||
Label {
|
|
||||||
text: qsTr("DNS lookup") + ": "
|
|
||||||
opacity: enabled ? 1 : 0.5
|
|
||||||
enabled: !Cpp_MQTT_Client.isConnectedToHost
|
|
||||||
Behavior on opacity {NumberAnimation{}}
|
|
||||||
} RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
spacing: app.spacing / 2
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: _addrLookup
|
|
||||||
Layout.fillWidth: true
|
|
||||||
opacity: enabled ? 1 : 0.5
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
onAccepted: Cpp_MQTT_Client.lookup(text)
|
|
||||||
placeholderText: qsTr("Enter address (e.g. google.com)")
|
|
||||||
enabled: !Cpp_MQTT_Client.isConnectedToHost &&
|
|
||||||
!Cpp_MQTT_Client.lookupActive
|
|
||||||
|
|
||||||
Behavior on opacity {NumberAnimation{}}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
icon.color: palette.text
|
|
||||||
opacity: enabled ? 1 : 0.5
|
|
||||||
Layout.maximumWidth: height
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
icon.source: "qrc:/icons/search.svg"
|
|
||||||
onClicked: Cpp_MQTT_Client.lookup(_addrLookup.text)
|
|
||||||
enabled: _addrLookup.text.length > 0 &&
|
|
||||||
!Cpp_MQTT_Client.isConnectedToHost &&
|
|
||||||
!Cpp_MQTT_Client.lookupActive
|
|
||||||
|
|
||||||
Behavior on opacity {NumberAnimation{}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Spacer
|
// Spacer
|
||||||
//
|
//
|
||||||
|
@ -32,8 +32,7 @@ Control {
|
|||||||
// Access to properties
|
// Access to properties
|
||||||
//
|
//
|
||||||
property alias port: _portText.text
|
property alias port: _portText.text
|
||||||
property alias address: _ipText.text
|
property alias address: _address.text
|
||||||
property alias addressLookup: _addrLookup.text
|
|
||||||
property alias socketType: _typeCombo.currentIndex
|
property alias socketType: _typeCombo.currentIndex
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -80,9 +79,9 @@ Control {
|
|||||||
opacity: enabled ? 1 : 0.5
|
opacity: enabled ? 1 : 0.5
|
||||||
enabled: !Cpp_IO_Manager.connected
|
enabled: !Cpp_IO_Manager.connected
|
||||||
Behavior on opacity {NumberAnimation{}}
|
Behavior on opacity {NumberAnimation{}}
|
||||||
text: qsTr("IP Address") + ":"
|
text: qsTr("Host") + ":"
|
||||||
} TextField {
|
} TextField {
|
||||||
id: _ipText
|
id: _address
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
placeholderText: Cpp_IO_Network.defaultHost
|
placeholderText: Cpp_IO_Network.defaultHost
|
||||||
text: Cpp_IO_Network.host
|
text: Cpp_IO_Network.host
|
||||||
@ -133,43 +132,6 @@ Control {
|
|||||||
Layout.minimumHeight: app.spacing
|
Layout.minimumHeight: app.spacing
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Address lookup
|
|
||||||
//
|
|
||||||
Label {
|
|
||||||
text: qsTr("DNS lookup") + ": "
|
|
||||||
opacity: enabled ? 1 : 0.5
|
|
||||||
enabled: !Cpp_IO_Manager.connected
|
|
||||||
Behavior on opacity {NumberAnimation{}}
|
|
||||||
} RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
spacing: app.spacing / 2
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: _addrLookup
|
|
||||||
Layout.fillWidth: true
|
|
||||||
opacity: enabled ? 1 : 0.5
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
enabled: !Cpp_IO_Manager.connected && !Cpp_IO_Network.lookupActive
|
|
||||||
onAccepted: Cpp_IO_Network.lookup(text)
|
|
||||||
placeholderText: qsTr("Enter address (e.g. google.com)")
|
|
||||||
|
|
||||||
Behavior on opacity {NumberAnimation{}}
|
|
||||||
}
|
|
||||||
|
|
||||||
Button {
|
|
||||||
icon.color: palette.text
|
|
||||||
opacity: enabled ? 1 : 0.5
|
|
||||||
Layout.maximumWidth: height
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
icon.source: "qrc:/icons/search.svg"
|
|
||||||
onClicked: Cpp_IO_Network.lookup(_addrLookup.text)
|
|
||||||
enabled: _addrLookup.text.length > 0 && !Cpp_IO_Manager.connected && !Cpp_IO_Network.lookupActive
|
|
||||||
|
|
||||||
Behavior on opacity {NumberAnimation{}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Spacer
|
// Spacer
|
||||||
//
|
//
|
||||||
|
@ -63,7 +63,6 @@ Control {
|
|||||||
property alias port: network.port
|
property alias port: network.port
|
||||||
property alias address: network.address
|
property alias address: network.address
|
||||||
property alias socketType: network.socketType
|
property alias socketType: network.socketType
|
||||||
property alias addressLookup: network.addressLookup
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// MQTT settings
|
// MQTT settings
|
||||||
@ -75,7 +74,6 @@ Control {
|
|||||||
property alias mqttTopic: mqtt.topic
|
property alias mqttTopic: mqtt.topic
|
||||||
property alias mqttVersion: mqtt.version
|
property alias mqttVersion: mqtt.version
|
||||||
property alias mqttPassword: mqtt.password
|
property alias mqttPassword: mqtt.password
|
||||||
property alias mqttDnsAddress: mqtt.dnsAddress
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// App settings
|
// App settings
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.20</string>
|
<string>1.0.21</string>
|
||||||
<key>LSHasLocalizedDisplayName</key>
|
<key>LSHasLocalizedDisplayName</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
|
@ -29,7 +29,7 @@ Unicode True
|
|||||||
!define DESCRIPTION "Dashboard software for serial port devices"
|
!define DESCRIPTION "Dashboard software for serial port devices"
|
||||||
!define VERSIONMAJOR 1
|
!define VERSIONMAJOR 1
|
||||||
!define VERSIONMINOR 0
|
!define VERSIONMINOR 0
|
||||||
!define VERSIONBUILD 20
|
!define VERSIONBUILD 21
|
||||||
!define MUI_ABORTWARNING
|
!define MUI_ABORTWARNING
|
||||||
!define INSTALL_DIR "$PROGRAMFILES64\${APPNAME}"
|
!define INSTALL_DIR "$PROGRAMFILES64\${APPNAME}"
|
||||||
!define MUI_FINISHPAGE_RUN
|
!define MUI_FINISHPAGE_RUN
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define APP_VERSION "1.0.20"
|
#define APP_VERSION "1.0.21"
|
||||||
#define APP_DEVELOPER "Alex Spataru"
|
#define APP_DEVELOPER "Alex Spataru"
|
||||||
#define APP_NAME "Serial Studio"
|
#define APP_NAME "Serial Studio"
|
||||||
#define APP_ICON ":/images/icon.png"
|
#define APP_ICON ":/images/icon.png"
|
||||||
|
@ -33,6 +33,7 @@ static Network *INSTANCE = nullptr;
|
|||||||
*/
|
*/
|
||||||
Network::Network()
|
Network::Network()
|
||||||
{
|
{
|
||||||
|
m_hostExists = false;
|
||||||
m_lookupActive = false;
|
m_lookupActive = false;
|
||||||
|
|
||||||
setHost("");
|
setHost("");
|
||||||
@ -110,7 +111,7 @@ int Network::socketTypeIndex() const
|
|||||||
*/
|
*/
|
||||||
bool Network::configurationOk() const
|
bool Network::configurationOk() const
|
||||||
{
|
{
|
||||||
return port() > 0 && !QHostAddress(host()).isNull();
|
return port() > 0 && m_hostExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -210,6 +211,17 @@ void Network::setPort(const quint16 port)
|
|||||||
*/
|
*/
|
||||||
void Network::setHost(const QString &host)
|
void Network::setHost(const QString &host)
|
||||||
{
|
{
|
||||||
|
// Check if host name exists
|
||||||
|
if (QHostAddress(host).isNull()) {
|
||||||
|
m_hostExists = false;
|
||||||
|
lookup(host);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Host is an IP address, host should exist
|
||||||
|
else
|
||||||
|
m_hostExists = true;
|
||||||
|
|
||||||
|
// Change host
|
||||||
m_host = host;
|
m_host = host;
|
||||||
emit hostChanged();
|
emit hostChanged();
|
||||||
}
|
}
|
||||||
@ -271,12 +283,11 @@ void Network::lookupFinished(const QHostInfo &info)
|
|||||||
auto addresses = info.addresses();
|
auto addresses = info.addresses();
|
||||||
if (addresses.count() >= 1)
|
if (addresses.count() >= 1)
|
||||||
{
|
{
|
||||||
setHost(addresses.first().toString());
|
m_hostExists = true;
|
||||||
|
emit hostChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Misc::Utilities::showMessageBox(tr("IP address lookup error"), info.errorString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,6 +111,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
QString m_host;
|
QString m_host;
|
||||||
quint16 m_port;
|
quint16 m_port;
|
||||||
|
bool m_hostExists;
|
||||||
bool m_lookupActive;
|
bool m_lookupActive;
|
||||||
QIODevice *m_device;
|
QIODevice *m_device;
|
||||||
QTcpSocket m_tcpSocket;
|
QTcpSocket m_tcpSocket;
|
||||||
|
@ -150,7 +150,7 @@ QString Client::password() const
|
|||||||
*/
|
*/
|
||||||
QString Client::host() const
|
QString Client::host() const
|
||||||
{
|
{
|
||||||
return m_client.host().toString();
|
return m_client.hostName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,7 +247,7 @@ void Client::setPort(const quint16 port)
|
|||||||
*/
|
*/
|
||||||
void Client::setHost(const QString &host)
|
void Client::setHost(const QString &host)
|
||||||
{
|
{
|
||||||
m_client.setHost(QHostAddress(host));
|
m_client.setHostName(host);
|
||||||
emit hostChanged();
|
emit hostChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user