diff --git a/components/RemoteNodeEdit.qml b/components/RemoteNodeEdit.qml index e6076823..6dcd617b 100644 --- a/components/RemoteNodeEdit.qml +++ b/components/RemoteNodeEdit.qml @@ -43,6 +43,9 @@ GridLayout { property alias daemonAddrLabelText: daemonAddr.labelText property alias daemonPortLabelText: daemonPort.labelText + property string initialAddress: "" + property var initialHostPort: initialAddress.match(/^(.*?)(?:\:?(\d*))$/) + // TODO: LEGACY; remove these placeHolder variables when // the wizards get redesigned to the black-theme property string placeholderFontFamily: MoneroComponents.Style.fontRegular.name @@ -58,6 +61,9 @@ GridLayout { property bool lineEditFontBold: false property int lineEditFontSize: 15 + // Author: David M. Syzdek https://github.com/syzdek https://gist.github.com/syzdek/6086792 + readonly property var ipv6Regex: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe08:(:[0-9a-fA-F]{1,4}){2,2}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/ + signal editingFinished() signal textChanged() @@ -91,8 +97,12 @@ GridLayout { fontColor: lineEditFontColor fontBold: lineEditFontBold fontSize: lineEditFontSize - onEditingFinished: root.editingFinished() + onEditingFinished: { + text = text.replace(ipv6Regex, "[$1]"); + root.editingFinished(); + } onTextChanged: root.textChanged() + text: initialHostPort[1] } LineEdit { @@ -114,5 +124,6 @@ GridLayout { onEditingFinished: root.editingFinished() onTextChanged: root.textChanged() + text: initialHostPort[2] } } diff --git a/pages/settings/SettingsNode.qml b/pages/settings/SettingsNode.qml index 960e7a35..a7c1f45c 100644 --- a/pages/settings/SettingsNode.qml +++ b/pages/settings/SettingsNode.qml @@ -268,9 +268,7 @@ Rectangle{ daemonAddrLabelText: qsTr("Address") + translationManager.emptyString daemonPortLabelText: qsTr("Port") + translationManager.emptyString - property var rna: persistentSettings.remoteNodeAddress - daemonAddrText: rna.search(":") != -1 ? rna.split(":")[0].trim() : "" - daemonPortText: rna.search(":") != -1 ? (rna.split(":")[1].trim() == "") ? appWindow.getDefaultDaemonRpcPort(persistentSettings.nettype) : rna.split(":")[1] : "" + initialAddress: persistentSettings.remoteNodeAddress onEditingFinished: { persistentSettings.remoteNodeAddress = remoteNodeEdit.getAddress(); console.log("setting remote node to " + persistentSettings.remoteNodeAddress); @@ -419,15 +417,7 @@ Rectangle{ daemonAddrLabelText: qsTr("Bootstrap Address") + translationManager.emptyString daemonPortLabelText: qsTr("Bootstrap Port") + translationManager.emptyString - daemonAddrText: persistentSettings.bootstrapNodeAddress.split(":")[0].trim() - daemonPortText: { - var node_split = persistentSettings.bootstrapNodeAddress.split(":"); - if(node_split.length == 2){ - (node_split[1].trim() == "") ? appWindow.getDefaultDaemonRpcPort(persistentSettings.nettype) : node_split[1]; - } else { - return "" - } - } + initialAddress: persistentSettings.bootstrapNodeAddress onEditingFinished: { if (daemonAddrText == "auto") { persistentSettings.bootstrapNodeAddress = daemonAddrText; diff --git a/wizard/WizardDaemonSettings.qml b/wizard/WizardDaemonSettings.qml index 1a5ebd72..7155db10 100644 --- a/wizard/WizardDaemonSettings.qml +++ b/wizard/WizardDaemonSettings.qml @@ -147,15 +147,7 @@ ColumnLayout { Layout.minimumWidth: 300 //labelText: qsTr("Bootstrap node (leave blank if not wanted)") + translationManager.emptyString - daemonAddrText: persistentSettings.bootstrapNodeAddress.split(":")[0].trim() - daemonPortText: { - var node_split = persistentSettings.bootstrapNodeAddress.split(":"); - if(node_split.length == 2){ - (node_split[1].trim() == "") ? appWindow.getDefaultDaemonRpcPort(persistentSettings.nettype) : node_split[1]; - } else { - return "" - } - } + initialAddress: persistentSettings.bootstrapNodeAddress } } } @@ -184,9 +176,7 @@ ColumnLayout { id: remoteNodeEdit Layout.fillWidth: true - property var rna: persistentSettings.remoteNodeAddress - daemonAddrText: rna.search(":") != -1 ? rna.split(":")[0].trim() : "" - daemonPortText: rna.search(":") != -1 ? (rna.split(":")[1].trim() == "") ? appWindow.getDefaultDaemonRpcPort(persistentSettings.nettype) : persistentSettings.remoteNodeAddress.split(":")[1] : "" + initialAddress: persistentSettings.remoteNodeAddress } } }