2018-01-07 05:20:45 +00:00
|
|
|
// Copyright (c) 2014-2018, The Monero Project
|
2017-08-07 10:32:51 +00:00
|
|
|
//
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
// permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
// conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
// of conditions and the following disclaimer in the documentation and/or other
|
|
|
|
// materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
|
|
// used to endorse or promote products derived from this software without specific
|
|
|
|
// prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
import QtQuick.Controls 1.2
|
|
|
|
import QtQuick.Controls.Styles 1.2
|
2019-04-11 01:17:29 +00:00
|
|
|
import QtQuick 2.9
|
2017-08-07 10:32:51 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
2019-01-14 00:02:44 +00:00
|
|
|
import "../js/Utils.js" as Utils
|
2018-03-31 01:25:20 +00:00
|
|
|
import "../components" as MoneroComponents
|
|
|
|
|
2017-08-07 10:32:51 +00:00
|
|
|
GridLayout {
|
2019-09-05 22:11:12 +00:00
|
|
|
columns: 2
|
2017-12-09 16:46:03 +00:00
|
|
|
columnSpacing: 32
|
2017-08-07 10:32:51 +00:00
|
|
|
id: root
|
|
|
|
property alias daemonAddrText: daemonAddr.text
|
|
|
|
property alias daemonPortText: daemonPort.text
|
2017-12-09 16:46:03 +00:00
|
|
|
property alias daemonAddrLabelText: daemonAddr.labelText
|
|
|
|
property alias daemonPortLabelText: daemonPort.labelText
|
2017-08-07 10:32:51 +00:00
|
|
|
|
2020-07-02 13:29:27 +00:00
|
|
|
property string initialAddress: ""
|
|
|
|
property var initialHostPort: initialAddress.match(/^(.*?)(?:\:?(\d*))$/)
|
|
|
|
|
2018-03-27 20:04:18 +00:00
|
|
|
// TODO: LEGACY; remove these placeHolder variables when
|
|
|
|
// the wizards get redesigned to the black-theme
|
2018-03-31 01:25:20 +00:00
|
|
|
property string placeholderFontFamily: MoneroComponents.Style.fontRegular.name
|
2018-03-27 20:04:18 +00:00
|
|
|
property bool placeholderFontBold: false
|
2019-04-25 19:09:23 +00:00
|
|
|
property int placeholderFontSize: 15
|
2018-03-31 01:25:20 +00:00
|
|
|
property string placeholderColor: MoneroComponents.Style.defaultFontColor
|
2018-04-29 22:52:48 +00:00
|
|
|
property real placeholderOpacity: 0.35
|
2019-04-25 19:09:23 +00:00
|
|
|
property int labelFontSize: 14
|
2018-03-27 20:04:18 +00:00
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
property string lineEditBackgroundColor: "transparent"
|
|
|
|
property string lineEditFontColor: MoneroComponents.Style.defaultFontColor
|
|
|
|
property bool lineEditFontBold: false
|
2019-04-25 19:09:23 +00:00
|
|
|
property int lineEditFontSize: 15
|
2018-01-21 18:14:34 +00:00
|
|
|
|
2020-07-02 13:29:27 +00:00
|
|
|
// 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]))$/
|
|
|
|
|
2017-08-07 10:32:51 +00:00
|
|
|
signal editingFinished()
|
2018-11-10 23:43:50 +00:00
|
|
|
signal textChanged()
|
|
|
|
|
2021-04-02 16:42:52 +00:00
|
|
|
onActiveFocusChanged: activeFocus && daemonAddr.forceActiveFocus()
|
|
|
|
|
2018-11-10 23:43:50 +00:00
|
|
|
function isValid() {
|
|
|
|
return daemonAddr.text.trim().length > 0 && daemonPort.acceptableInput
|
|
|
|
}
|
2017-08-07 10:32:51 +00:00
|
|
|
|
|
|
|
function getAddress() {
|
2019-01-14 00:02:44 +00:00
|
|
|
var addr = daemonAddr.text.trim();
|
|
|
|
var port = daemonPort.text.trim();
|
|
|
|
|
|
|
|
// validation
|
|
|
|
if(addr === "" || addr.length < 2) return "";
|
|
|
|
if(!Utils.isNumeric(port)) return "";
|
|
|
|
|
|
|
|
return addr + ":" + port;
|
2017-08-07 10:32:51 +00:00
|
|
|
}
|
|
|
|
|
2018-10-21 13:14:17 +00:00
|
|
|
LineEdit {
|
2017-08-07 10:32:51 +00:00
|
|
|
id: daemonAddr
|
|
|
|
Layout.fillWidth: true
|
|
|
|
placeholderText: qsTr("Remote Node Hostname / IP") + translationManager.emptyString
|
2018-03-27 20:04:18 +00:00
|
|
|
placeholderFontFamily: root.placeholderFontFamily
|
|
|
|
placeholderFontBold: root.placeholderFontBold
|
|
|
|
placeholderFontSize: root.placeholderFontSize
|
|
|
|
placeholderColor: root.placeholderColor
|
|
|
|
placeholderOpacity: root.placeholderOpacity
|
2018-07-18 13:00:53 +00:00
|
|
|
labelFontSize: root.labelFontSize
|
2018-01-21 18:14:34 +00:00
|
|
|
backgroundColor: lineEditBackgroundColor
|
|
|
|
fontColor: lineEditFontColor
|
|
|
|
fontBold: lineEditFontBold
|
2018-07-18 13:00:53 +00:00
|
|
|
fontSize: lineEditFontSize
|
2020-07-02 13:29:27 +00:00
|
|
|
onEditingFinished: {
|
|
|
|
text = text.replace(ipv6Regex, "[$1]");
|
|
|
|
root.editingFinished();
|
|
|
|
}
|
2018-11-10 23:43:50 +00:00
|
|
|
onTextChanged: root.textChanged()
|
2020-07-02 13:29:27 +00:00
|
|
|
text: initialHostPort[1]
|
2017-08-07 10:32:51 +00:00
|
|
|
}
|
|
|
|
|
2018-10-21 13:14:17 +00:00
|
|
|
LineEdit {
|
2017-08-07 10:32:51 +00:00
|
|
|
id: daemonPort
|
|
|
|
Layout.fillWidth: true
|
|
|
|
placeholderText: qsTr("Port") + translationManager.emptyString
|
2018-03-27 20:04:18 +00:00
|
|
|
placeholderFontFamily: root.placeholderFontFamily
|
|
|
|
placeholderFontBold: root.placeholderFontBold
|
|
|
|
placeholderFontSize: root.placeholderFontSize
|
|
|
|
placeholderColor: root.placeholderColor
|
|
|
|
placeholderOpacity: root.placeholderOpacity
|
2018-07-18 13:00:53 +00:00
|
|
|
labelFontSize: root.labelFontSize
|
2018-01-21 18:14:34 +00:00
|
|
|
backgroundColor: lineEditBackgroundColor
|
|
|
|
fontColor: lineEditFontColor
|
|
|
|
fontBold: lineEditFontBold
|
2018-07-18 13:00:53 +00:00
|
|
|
fontSize: lineEditFontSize
|
2018-11-10 23:16:27 +00:00
|
|
|
validator: IntValidator{bottom: 1; top: 65535;}
|
2018-07-18 13:00:53 +00:00
|
|
|
|
|
|
|
onEditingFinished: root.editingFinished()
|
2018-11-10 23:43:50 +00:00
|
|
|
onTextChanged: root.textChanged()
|
2020-07-02 13:29:27 +00:00
|
|
|
text: initialHostPort[2]
|
2017-08-07 10:32:51 +00:00
|
|
|
}
|
|
|
|
}
|