qml: separate proxy and server controls from wizardcontainer, so we can reuse them in
network settings later
This commit is contained in:
85
electrum/gui/qml/components/controls/ProxyConfig.qml
Normal file
85
electrum/gui/qml/components/controls/ProxyConfig.qml
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import QtQuick 2.6
|
||||||
|
import QtQuick.Layouts 1.0
|
||||||
|
import QtQuick.Controls 2.1
|
||||||
|
|
||||||
|
Item {
|
||||||
|
property alias proxy_enabled: proxy_enabled_cb.checked
|
||||||
|
property alias proxy_type: proxytype.currentIndex
|
||||||
|
property alias proxy_address: address.text
|
||||||
|
property alias proxy_port: port.text
|
||||||
|
property alias username: username_tf.text
|
||||||
|
property alias password: password_tf.text
|
||||||
|
|
||||||
|
property var proxy_types: ['TOR', 'SOCKS5', 'SOCKS4']
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr('Proxy settings')
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: proxy_enabled_cb
|
||||||
|
text: qsTr('Enable Proxy')
|
||||||
|
}
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: proxytype
|
||||||
|
enabled: proxy_enabled_cb.checked
|
||||||
|
model: proxy_types
|
||||||
|
onCurrentIndexChanged: {
|
||||||
|
if (currentIndex == 0) {
|
||||||
|
address.text = "127.0.0.1"
|
||||||
|
port.text = "9050"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GridLayout {
|
||||||
|
columns: 4
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Address")
|
||||||
|
enabled: address.enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: address
|
||||||
|
enabled: proxytype.enabled && proxytype.currentIndex > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Port")
|
||||||
|
enabled: port.enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: port
|
||||||
|
enabled: proxytype.enabled && proxytype.currentIndex > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Username")
|
||||||
|
enabled: username_tf.enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: username_tf
|
||||||
|
enabled: proxytype.enabled && proxytype.currentIndex > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Password")
|
||||||
|
enabled: password_tf.enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: password_tf
|
||||||
|
enabled: proxytype.enabled && proxytype.currentIndex > 0
|
||||||
|
echoMode: TextInput.Password
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
37
electrum/gui/qml/components/controls/ServerConfig.qml
Normal file
37
electrum/gui/qml/components/controls/ServerConfig.qml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import QtQuick 2.6
|
||||||
|
import QtQuick.Layouts 1.0
|
||||||
|
import QtQuick.Controls 2.1
|
||||||
|
|
||||||
|
Item {
|
||||||
|
property alias auto_server: auto_server_cb.checked
|
||||||
|
property alias address: address_tf.text
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr('Server settings')
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: auto_server_cb
|
||||||
|
text: qsTr('Select server automatically')
|
||||||
|
checked: true
|
||||||
|
}
|
||||||
|
|
||||||
|
GridLayout {
|
||||||
|
columns: 2
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Server")
|
||||||
|
enabled: address_tf.enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: address_tf
|
||||||
|
enabled: !auto_server_cb.checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,94 +1,26 @@
|
|||||||
import QtQuick.Layouts 1.0
|
import "../controls"
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
WizardComponent {
|
WizardComponent {
|
||||||
valid: true
|
valid: true
|
||||||
|
|
||||||
onAccept: {
|
onAccept: {
|
||||||
var p = {}
|
var p = {}
|
||||||
p['enabled'] = proxy_enabled.checked
|
p['enabled'] = pc.proxy_enabled
|
||||||
if (proxy_enabled.checked) {
|
if (pc.proxy_enabled) {
|
||||||
var type = proxytype.currentValue.toLowerCase()
|
var type = pc.proxy_types[pc.proxy_type].toLowerCase()
|
||||||
if (type == 'tor')
|
if (type == 'tor')
|
||||||
type = 'socks5'
|
type = 'socks5'
|
||||||
p['mode'] = type
|
p['mode'] = type
|
||||||
p['host'] = address.text
|
p['host'] = pc.proxy_address
|
||||||
p['port'] = port.text
|
p['port'] = pc.proxy_port
|
||||||
p['user'] = username.text
|
p['user'] = pc.username
|
||||||
p['password'] = password.text
|
p['password'] = pc.password
|
||||||
}
|
}
|
||||||
wizard_data['proxy'] = p
|
wizard_data['proxy'] = p
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ProxyConfig {
|
||||||
|
id: pc
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr('Proxy settings')
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckBox {
|
|
||||||
id: proxy_enabled
|
|
||||||
text: qsTr('Enable Proxy')
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox {
|
|
||||||
id: proxytype
|
|
||||||
enabled: proxy_enabled.checked
|
|
||||||
model: ['TOR', 'SOCKS5', 'SOCKS4']
|
|
||||||
onCurrentIndexChanged: {
|
|
||||||
if (currentIndex == 0) {
|
|
||||||
address.text = "127.0.0.1"
|
|
||||||
port.text = "9050"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GridLayout {
|
|
||||||
columns: 4
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr("Address")
|
|
||||||
enabled: address.enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: address
|
|
||||||
enabled: proxytype.enabled && proxytype.currentIndex > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr("Port")
|
|
||||||
enabled: port.enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: port
|
|
||||||
enabled: proxytype.enabled && proxytype.currentIndex > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr("Username")
|
|
||||||
enabled: username.enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: username
|
|
||||||
enabled: proxytype.enabled && proxytype.currentIndex > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr("Password")
|
|
||||||
enabled: password.enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: password
|
|
||||||
enabled: proxytype.enabled && proxytype.currentIndex > 0
|
|
||||||
echoMode: TextInput.Password
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,16 @@
|
|||||||
import QtQuick.Layouts 1.0
|
import "../controls"
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
|
|
||||||
WizardComponent {
|
WizardComponent {
|
||||||
valid: true
|
valid: true
|
||||||
last: true
|
last: true
|
||||||
|
|
||||||
onAccept: {
|
onAccept: {
|
||||||
wizard_data['oneserver'] = !auto_server.checked
|
wizard_data['oneserver'] = !sc.auto_server
|
||||||
wizard_data['server'] = address.text
|
wizard_data['server'] = sc.address
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ServerConfig {
|
||||||
|
id: sc
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr('Server settings')
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckBox {
|
|
||||||
id: auto_server
|
|
||||||
text: qsTr('Select server automatically')
|
|
||||||
checked: true
|
|
||||||
}
|
|
||||||
|
|
||||||
GridLayout {
|
|
||||||
columns: 2
|
|
||||||
Layout.fillWidth: true
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: qsTr("Server")
|
|
||||||
enabled: address.enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: address
|
|
||||||
enabled: !auto_server.checked
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user