qml: add server and proxy config dialogs
This commit is contained in:
@@ -1,13 +1,58 @@
|
||||
import QtQuick 2.6
|
||||
import QtQuick.Layouts 1.0
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Controls.Material 2.0
|
||||
import QtQml 2.6
|
||||
|
||||
import "controls"
|
||||
|
||||
Pane {
|
||||
id: root
|
||||
|
||||
property string title: qsTr('Network')
|
||||
|
||||
property QtObject menu: Menu {
|
||||
id: menu
|
||||
MenuItem {
|
||||
icon.color: 'transparent'
|
||||
action: Action {
|
||||
text: qsTr('Server Settings');
|
||||
onTriggered: menu.openPage(sc_comp);
|
||||
enabled: Daemon.currentWallet
|
||||
icon.source: '../../icons/network.png'
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
icon.color: 'transparent'
|
||||
action: Action {
|
||||
text: qsTr('Proxy Settings');
|
||||
onTriggered: menu.openPage(pc_comp);
|
||||
enabled: Daemon.currentWallet
|
||||
icon.source: '../../icons/status_connected_proxy.png'
|
||||
}
|
||||
}
|
||||
|
||||
function openPage(comp) {
|
||||
var dialog = comp.createObject(root)
|
||||
dialog.open()
|
||||
currentIndex = -1
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: sc_comp
|
||||
ServerConfigDialog {
|
||||
onClosed: destroy()
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: pc_comp
|
||||
ProxyConfigDialog {
|
||||
onClosed: destroy()
|
||||
}
|
||||
}
|
||||
|
||||
GridLayout {
|
||||
columns: 2
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Image {
|
||||
property bool lagging: connected && Network.isLagging
|
||||
property bool fork: connected && Network.chaintips > 1
|
||||
property bool syncing: connected && Daemon.currentWallet && Daemon.currentWallet.synchronizing
|
||||
property bool proxy: connected && Network.proxy.mode
|
||||
property bool proxy: connected && 'mode' in Network.proxy && Network.proxy.mode
|
||||
|
||||
// ?: in order to keep this a binding..
|
||||
source: !connected
|
||||
|
||||
@@ -3,6 +3,8 @@ import QtQuick.Layouts 1.0
|
||||
import QtQuick.Controls 2.1
|
||||
|
||||
Item {
|
||||
id: pc
|
||||
|
||||
property alias proxy_enabled: proxy_enabled_cb.checked
|
||||
property alias proxy_type: proxytype.currentIndex
|
||||
property alias proxy_address: address.text
|
||||
@@ -12,8 +14,29 @@ Item {
|
||||
|
||||
property var proxy_types: ['TOR', 'SOCKS5', 'SOCKS4']
|
||||
|
||||
height: rootLayout.height
|
||||
|
||||
function toProxyDict() {
|
||||
var p = {}
|
||||
p['enabled'] = pc.proxy_enabled
|
||||
if (pc.proxy_enabled) {
|
||||
var type = pc.proxy_types[pc.proxy_type].toLowerCase()
|
||||
if (type == 'tor')
|
||||
type = 'socks5'
|
||||
p['mode'] = type
|
||||
p['host'] = pc.proxy_address
|
||||
p['port'] = pc.proxy_port
|
||||
p['user'] = pc.username
|
||||
p['password'] = pc.password
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: rootLayout
|
||||
|
||||
width: parent.width
|
||||
spacing: constants.paddingLarge
|
||||
|
||||
Label {
|
||||
text: qsTr('Proxy settings')
|
||||
|
||||
@@ -6,8 +6,13 @@ Item {
|
||||
property alias auto_server: auto_server_cb.checked
|
||||
property alias address: address_tf.text
|
||||
|
||||
height: rootLayout.height
|
||||
|
||||
ColumnLayout {
|
||||
id: rootLayout
|
||||
|
||||
width: parent.width
|
||||
spacing: constants.paddingLarge
|
||||
|
||||
Label {
|
||||
text: qsTr('Server settings')
|
||||
@@ -31,6 +36,7 @@ Item {
|
||||
TextField {
|
||||
id: address_tf
|
||||
enabled: !auto_server_cb.checked
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,7 @@ WizardComponent {
|
||||
valid: true
|
||||
|
||||
onAccept: {
|
||||
var p = {}
|
||||
p['enabled'] = pc.proxy_enabled
|
||||
if (pc.proxy_enabled) {
|
||||
var type = pc.proxy_types[pc.proxy_type].toLowerCase()
|
||||
if (type == 'tor')
|
||||
type = 'socks5'
|
||||
p['mode'] = type
|
||||
p['host'] = pc.proxy_address
|
||||
p['port'] = pc.proxy_port
|
||||
p['user'] = pc.username
|
||||
p['password'] = pc.password
|
||||
}
|
||||
wizard_data['proxy'] = p
|
||||
wizard_data['proxy'] = pc.toProxyDict()
|
||||
}
|
||||
|
||||
ProxyConfig {
|
||||
|
||||
Reference in New Issue
Block a user