From 466be3df9894ca9f2b4a075902f2b16f42d4ca62 Mon Sep 17 00:00:00 2001 From: Albrecht Lohofener Date: Wed, 9 Oct 2024 13:49:52 +0200 Subject: [PATCH] Rework rtltcp settings. Remove tumbler for port and IP address. --- .../QML/settingpages/RTLTCPSettings.qml | 104 +++++++----------- 1 file changed, 38 insertions(+), 66 deletions(-) diff --git a/src/welle-gui/QML/settingpages/RTLTCPSettings.qml b/src/welle-gui/QML/settingpages/RTLTCPSettings.qml index b4c6bf38..43c0eeb8 100644 --- a/src/welle-gui/QML/settingpages/RTLTCPSettings.qml +++ b/src/welle-gui/QML/settingpages/RTLTCPSettings.qml @@ -34,84 +34,46 @@ import "../components" SettingSection { text: qsTr("rtl-tcp settings") + id: rtltcpsettings property bool isLoaded : false Settings { - property alias ipByte1: ipAddress1.currentIndex - property alias ipByte2: ipAddress2.currentIndex - property alias ipByte3: ipAddress3.currentIndex - property alias ipByte4: ipAddress4.currentIndex - property alias ipPort: ipPort.currentIndex - property alias rtlTcpEnableHostName: enableHostName.checked - property alias rtlTcpHostName: hostName.text - } + id: settings - WSwitch { - id: enableHostName - text: qsTr("Use host name") - Layout.fillWidth: true - checked: false + // Deprecated: Necessary for migration from version <=2.5, can be removed in future versions + property int ipByte1 + property int ipByte2 + property int ipByte3 + property int ipByte4 + + property alias ipPort: hostPort.text + property alias rtlTcpHostName: hostName.text } RowLayout { - spacing: Units.dp(20) - - ColumnLayout { - TextStandart { - text: qsTr("IP address") - Layout.alignment: Qt.AlignHCenter - } - - RowLayout { - id:layout - height: Units.dp(120) - spacing: Units.dp(5) - enabled: !enableHostName.checked - - WTumbler { - id: ipAddress1 - currentIndex: 192 - } - WTumbler { - id: ipAddress2 - currentIndex: 168 - } - WTumbler { - id: ipAddress3 - currentIndex: 1 - } - WTumbler { - id: ipAddress4 - currentIndex: 10 - } - } + TextField { + id: hostName + placeholderText: qsTr("Enter host name or IP address") + implicitWidth: 200 } - ColumnLayout { - TextStandart { - text: qsTr("IP port") - } - - WTumbler { - id: ipPort - model: 65536 - currentIndex: 1234 - } + TextStandart { + text: qsTr("Host name or IP-address") + Layout.fillWidth: true } } RowLayout { - enabled: enableHostName.checked - TextField { - id: hostName - placeholderText: qsTr("Enter host name") + id: hostPort + placeholderText: qsTr("Enter IP-port") implicitWidth: 200 + text: "1234" } TextStandart { - text: qsTr("Host name") + text: qsTr("IP-Port") Layout.fillWidth: true } } @@ -131,16 +93,26 @@ SettingSection { function __openDevice() { var serverAddress = ""; - if(!enableHostName.checked) + if(settings.ipByte1) { + // Deprecated: Necessary for migration from version <=2.5, can be removed in future versions serverAddress = - ipAddress1.currentIndex + "." - + ipAddress2.currentIndex + "." - + ipAddress3.currentIndex + "." - + ipAddress4.currentIndex - else + settings.ipByte1 + "." + + settings.ipByte2 + "." + + settings.ipByte3 + "." + + settings.ipByte4 + hostName.text = serverAddress + + // Clear IP address to avoid further usage + settings.ipByte1 = 0 + settings.ipByte2 = 0 + settings.ipByte3 = 0 + settings.ipByte4 = 0 + } + else { serverAddress = hostName.text + } - guiHelper.openRtlTcp(serverAddress, ipPort.currentIndex, true) + guiHelper.openRtlTcp(serverAddress, hostPort.text, true) } }