qt,qml: add checkboxes for advanced network config on welcome page, remove separate proxy-ask and autoconnect pages
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
|
||||
import "../controls"
|
||||
|
||||
WizardComponent {
|
||||
valid: true
|
||||
title: qsTr('Server')
|
||||
|
||||
function apply() {
|
||||
wizard_data['autoconnect'] = serverconnectgroup.checkedButton.connecttype === 'auto'
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
width: parent.width
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr('How do you want to connect to a server?')
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
InfoTextArea {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr('Electrum communicates with remote servers to get information about your transactions and addresses. The servers all fulfill the same purpose only differing in hardware. In most cases you simply want to let Electrum pick one at random. However if you prefer feel free to select a server manually.')
|
||||
}
|
||||
|
||||
ButtonGroup {
|
||||
id: serverconnectgroup
|
||||
onCheckedButtonChanged: checkIsLast()
|
||||
}
|
||||
|
||||
ElRadioButton {
|
||||
Layout.fillWidth: true
|
||||
ButtonGroup.group: serverconnectgroup
|
||||
property string connecttype: 'auto'
|
||||
text: qsTr('Auto connect')
|
||||
checked: true
|
||||
}
|
||||
ElRadioButton {
|
||||
Layout.fillWidth: true
|
||||
ButtonGroup.group: serverconnectgroup
|
||||
property string connecttype: 'manual'
|
||||
text: qsTr('Select servers manually')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Controls.Material
|
||||
|
||||
import "../controls"
|
||||
|
||||
WizardComponent {
|
||||
valid: true
|
||||
title: qsTr('Proxy')
|
||||
|
||||
function apply() {
|
||||
wizard_data['want_proxy'] = wantproxygroup.checkedButton.wantproxy
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
width: parent.width
|
||||
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: qsTr('Do you use a local proxy service such as TOR to reach the internet?')
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
ButtonGroup {
|
||||
id: wantproxygroup
|
||||
onCheckedButtonChanged: checkIsLast()
|
||||
}
|
||||
|
||||
ElRadioButton {
|
||||
ButtonGroup.group: wantproxygroup
|
||||
property bool wantproxy: true
|
||||
text: qsTr('Yes')
|
||||
}
|
||||
ElRadioButton {
|
||||
ButtonGroup.group: wantproxygroup
|
||||
property bool wantproxy: false
|
||||
text: qsTr('No')
|
||||
checked: true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ WizardComponent {
|
||||
title: qsTr('Server')
|
||||
|
||||
function apply() {
|
||||
wizard_data['autoconnect'] = sc.address == ""
|
||||
wizard_data['autoconnect'] = sc.address.trim() == ""
|
||||
wizard_data['server'] = sc.address
|
||||
}
|
||||
|
||||
|
||||
@@ -2,22 +2,16 @@ import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
|
||||
// import org.electrum 1.0
|
||||
|
||||
import "../controls"
|
||||
|
||||
WizardComponent {
|
||||
valid: true
|
||||
title: qsTr('Electrum Bitcoin Wallet')
|
||||
wizard_title: qsTr('Electrum Bitcoin Wallet')
|
||||
|
||||
function apply() {
|
||||
wizard_data['use_defaults'] = use_defaults.checked
|
||||
wizard_data['want_proxy'] = false
|
||||
if (use_defaults.checked) {
|
||||
wizard_data['autoconnect'] = true
|
||||
} else {
|
||||
wizard_data['autoconnect'] = undefined
|
||||
}
|
||||
wizard_data['use_defaults'] = !config_advanced.checked
|
||||
wizard_data['want_proxy'] = config_advanced.checked && config_proxy.checked
|
||||
wizard_data['autoconnect'] = !config_server.checked || !config_advanced.checked
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
@@ -29,22 +23,37 @@ WizardComponent {
|
||||
source: Qt.resolvedUrl('../../../icons/electrum_presplash.png')
|
||||
// reduce spacing a bit
|
||||
Layout.topMargin: -50
|
||||
Layout.bottomMargin: -160
|
||||
}
|
||||
|
||||
Label {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: qsTr('Welcome')
|
||||
font.pixelSize: constants.fontSizeXLarge
|
||||
Layout.bottomMargin: constants.paddingXXLarge
|
||||
Layout.bottomMargin: -120
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: use_defaults
|
||||
id: config_advanced
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: qsTr('Use default network settings')
|
||||
checked: true
|
||||
text: qsTr('Advanced network settings')
|
||||
checked: false
|
||||
onCheckedChanged: checkIsLast()
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
opacity: config_advanced.checked ? 1 : 0
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: 300 }
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: config_proxy
|
||||
text: qsTr('Configure Proxy')
|
||||
checked: false
|
||||
onCheckedChanged: checkIsLast()
|
||||
}
|
||||
CheckBox {
|
||||
id: config_server
|
||||
text: qsTr('Select Server')
|
||||
checked: false
|
||||
onCheckedChanged: checkIsLast()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,8 +148,6 @@ class QEServerConnectWizard(ServerConnectWizard, QEAbstractWizard):
|
||||
# attach view names
|
||||
self.navmap_merge({
|
||||
'welcome': {'gui': 'WCWelcome'},
|
||||
'autoconnect': {'gui': 'WCAutoConnect'},
|
||||
'proxy_ask': {'gui': 'WCProxyAsk'},
|
||||
'proxy_config': {'gui': 'WCProxyConfig'},
|
||||
'server_config': {'gui': 'WCServerConfig'},
|
||||
})
|
||||
|
||||
@@ -2,12 +2,12 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QPixmap
|
||||
from PyQt5.QtWidgets import QCheckBox, QLabel, QHBoxLayout
|
||||
from PyQt5.QtWidgets import QCheckBox, QLabel, QHBoxLayout, QVBoxLayout, QWidget
|
||||
|
||||
from electrum.i18n import _
|
||||
from electrum.wizard import ServerConnectWizard
|
||||
from electrum.gui.qt.network_dialog import ProxyWidget, ServerWidget
|
||||
from electrum.gui.qt.util import ChoiceWidget, icon_path
|
||||
from electrum.gui.qt.util import icon_path
|
||||
from .wizard import QEAbstractWizard, WizardComponent
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -23,12 +23,11 @@ class QEServerConnectWizard(ServerConnectWizard, QEAbstractWizard):
|
||||
ServerConnectWizard.__init__(self, daemon)
|
||||
QEAbstractWizard.__init__(self, config, app)
|
||||
self.window_title = _('Network and server configuration')
|
||||
self.finish_label = _('Next')
|
||||
|
||||
# attach gui classes
|
||||
self.navmap_merge({
|
||||
'welcome': {'gui': WCWelcome, 'params': {'icon': ''}},
|
||||
'proxy_ask': {'gui': WCProxyAsk},
|
||||
'autoconnect': {'gui': WCAutoConnect},
|
||||
'proxy_config': {'gui': WCProxyConfig},
|
||||
'server_config': {'gui': WCServerConfig},
|
||||
})
|
||||
@@ -38,82 +37,57 @@ class WCWelcome(WizardComponent):
|
||||
def __init__(self, parent, wizard):
|
||||
WizardComponent.__init__(self, parent, wizard, title='')
|
||||
self.wizard_title = _('Electrum Bitcoin Wallet')
|
||||
self.use_defaults_w = QCheckBox(_('Use default network settings'))
|
||||
self.use_defaults_w.setChecked(True)
|
||||
self.use_defaults_w.stateChanged.connect(self.on_updated)
|
||||
self.use_advanced_w = QCheckBox(_('Advanced network settings'))
|
||||
self.use_advanced_w.setChecked(False)
|
||||
self.use_advanced_w.stateChanged.connect(self.on_advanced_changed)
|
||||
|
||||
self.img_label = QLabel()
|
||||
pixmap = QPixmap(icon_path('electrum_darkblue_1.png'))
|
||||
self.img_label.setPixmap(pixmap)
|
||||
self.img_label2 = QLabel()
|
||||
pixmap = QPixmap(icon_path('electrum_text.png'))
|
||||
self.img_label2.setPixmap(pixmap)
|
||||
hbox = QHBoxLayout()
|
||||
hbox.addStretch(1)
|
||||
hbox.addWidget(self.img_label)
|
||||
hbox.addWidget(self.img_label2)
|
||||
hbox.addStretch(1)
|
||||
self.layout().addLayout(hbox)
|
||||
self.welcome_label = QLabel('Welcome')
|
||||
font = self.welcome_label.font()
|
||||
font.setPointSize(font.pointSize() + 3)
|
||||
self.welcome_label.setFont(font)
|
||||
self.layout().addStretch(1)
|
||||
self.layout().addWidget(self.welcome_label, False, Qt.AlignHCenter)
|
||||
self.layout().addStretch(1)
|
||||
self.layout().addWidget(self.use_defaults_w, False, Qt.AlignHCenter)
|
||||
self.layout().addStretch(1)
|
||||
hbox_img = QHBoxLayout()
|
||||
hbox_img.addStretch(1)
|
||||
hbox_img.addWidget(self.img_label)
|
||||
hbox_img.addWidget(self.img_label2)
|
||||
hbox_img.addStretch(1)
|
||||
|
||||
self.config_proxy_w = QCheckBox(_('Configure Proxy'))
|
||||
self.config_proxy_w.setChecked(False)
|
||||
self.config_proxy_w.setVisible(False)
|
||||
self.config_proxy_w.stateChanged.connect(self.on_updated)
|
||||
self.config_server_w = QCheckBox(_('Select Server'))
|
||||
self.config_server_w.setChecked(False)
|
||||
self.config_server_w.setVisible(False)
|
||||
self.config_server_w.stateChanged.connect(self.on_updated)
|
||||
options_w = QWidget()
|
||||
vbox = QVBoxLayout()
|
||||
vbox.addWidget(self.config_proxy_w)
|
||||
vbox.addWidget(self.config_server_w)
|
||||
vbox.addStretch(1)
|
||||
options_w.setLayout(vbox)
|
||||
|
||||
self.layout().addLayout(hbox_img)
|
||||
self.layout().addSpacing(50)
|
||||
self.layout().addWidget(self.use_advanced_w, False, Qt.AlignHCenter)
|
||||
self.layout().addWidget(options_w, False, Qt.AlignHCenter)
|
||||
self._valid = True
|
||||
|
||||
def apply(self):
|
||||
self.wizard_data['use_defaults'] = self.use_defaults_w.isChecked()
|
||||
self.wizard_data['want_proxy'] = False
|
||||
if self.use_defaults_w.isChecked():
|
||||
self.wizard_data['autoconnect'] = True
|
||||
else:
|
||||
self.wizard_data['autoconnect'] = None
|
||||
|
||||
|
||||
class WCAutoConnect(WizardComponent):
|
||||
def __init__(self, parent, wizard):
|
||||
WizardComponent.__init__(self, parent, wizard, title=_("How do you want to connect to a server? "))
|
||||
message = _("Electrum communicates with remote servers to get "
|
||||
"information about your transactions and addresses. The "
|
||||
"servers all fulfill the same purpose only differing in "
|
||||
"hardware. In most cases you simply want to let Electrum "
|
||||
"pick one at random. However if you prefer feel free to "
|
||||
"select a server manually.")
|
||||
choices = [('autoconnect', _("Auto connect")),
|
||||
('select', _("Select server manually"))]
|
||||
self.choice_w = ChoiceWidget(message=message, choices=choices, selected='autoconnect')
|
||||
self.choice_w.itemSelected.connect(self.on_updated)
|
||||
self.layout().addWidget(self.choice_w)
|
||||
self.layout().addStretch(1)
|
||||
self._valid = True
|
||||
def on_advanced_changed(self):
|
||||
self.config_proxy_w.setVisible(self.use_advanced_w.isChecked())
|
||||
self.config_server_w.setVisible(self.use_advanced_w.isChecked())
|
||||
self.on_updated()
|
||||
|
||||
def apply(self):
|
||||
self.wizard_data['autoconnect'] = (self.choice_w.selected_item[0] == 'autoconnect')
|
||||
|
||||
|
||||
class WCProxyAsk(WizardComponent):
|
||||
def __init__(self, parent, wizard):
|
||||
WizardComponent.__init__(self, parent, wizard, title=_("Proxy"))
|
||||
message = _("Do you use a local proxy service such as TOR to reach the internet?")
|
||||
choices = [
|
||||
('no', _("No")),
|
||||
('yes', _("Yes")),
|
||||
]
|
||||
self.choice_w = ChoiceWidget(message=message, choices=choices, selected='no')
|
||||
self.layout().addWidget(self.choice_w)
|
||||
self.layout().addStretch(1)
|
||||
self._valid = True
|
||||
|
||||
def apply(self):
|
||||
self.wizard_data['want_proxy'] = (self.choice_w.selected_item[0] == 'yes')
|
||||
self.wizard_data['use_defaults'] = not self.use_advanced_w.isChecked()
|
||||
self.wizard_data['want_proxy'] = self.use_advanced_w.isChecked() and self.config_proxy_w.isChecked()
|
||||
self.wizard_data['autoconnect'] = not self.use_advanced_w.isChecked() or not self.config_server_w.isChecked()
|
||||
|
||||
|
||||
class WCProxyConfig(WizardComponent):
|
||||
def __init__(self, parent, wizard):
|
||||
WizardComponent.__init__(self, parent, wizard, title=_("Proxy"))
|
||||
WizardComponent.__init__(self, parent, wizard, title=_('Proxy'))
|
||||
self.pw = ProxyWidget(self)
|
||||
self.pw.proxy_cb.setChecked(True)
|
||||
self.pw.proxy_host.setText('localhost')
|
||||
@@ -128,11 +102,11 @@ class WCProxyConfig(WizardComponent):
|
||||
|
||||
class WCServerConfig(WizardComponent):
|
||||
def __init__(self, parent, wizard):
|
||||
WizardComponent.__init__(self, parent, wizard, title=_("Server"))
|
||||
WizardComponent.__init__(self, parent, wizard, title=_('Server'))
|
||||
self.sw = ServerWidget(wizard._daemon.network, self)
|
||||
self.layout().addWidget(self.sw)
|
||||
self._valid = True
|
||||
|
||||
def apply(self):
|
||||
self.wizard_data['autoconnect'] = self.sw.autoconnect_cb.isChecked()
|
||||
self.wizard_data['autoconnect'] = self.sw.server_e.text().strip() == ''
|
||||
self.wizard_data['server'] = self.sw.server_e.text()
|
||||
|
||||
@@ -6,7 +6,7 @@ from typing import TYPE_CHECKING
|
||||
from PyQt5.QtCore import Qt, QTimer, pyqtSignal, pyqtSlot, QSize
|
||||
from PyQt5.QtGui import QPixmap
|
||||
from PyQt5.QtWidgets import (QDialog, QPushButton, QWidget, QLabel, QVBoxLayout, QScrollArea,
|
||||
QHBoxLayout, QLayout, QStackedWidget)
|
||||
QHBoxLayout, QLayout)
|
||||
|
||||
from electrum.i18n import _
|
||||
from electrum.logging import get_logger
|
||||
@@ -40,6 +40,7 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
|
||||
|
||||
self.title = QLabel()
|
||||
self.window_title = ''
|
||||
self.finish_label = _('Finish')
|
||||
|
||||
self.main_widget = ResizableStackedWidget(self)
|
||||
|
||||
@@ -64,9 +65,6 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
|
||||
|
||||
error_layout = QVBoxLayout()
|
||||
error_layout.addStretch(1)
|
||||
# error_l = QLabel(_("Error!"))
|
||||
# error_l.setAlignment(Qt.AlignCenter)
|
||||
# error_layout.addWidget(error_l)
|
||||
self.error_msg = WWLabel()
|
||||
self.error_msg.setAlignment(Qt.AlignCenter)
|
||||
error_layout.addWidget(self.error_msg)
|
||||
@@ -172,7 +170,7 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
|
||||
self.title.setText(f'<b>{page.title}</b>' if page.title else '')
|
||||
self.back_button.setText(_('Back') if self.can_go_back() else _('Cancel'))
|
||||
self.back_button.setEnabled(not page.busy)
|
||||
self.next_button.setText(_('Next') if not self.is_last(page.wizard_data) else _('Finish'))
|
||||
self.next_button.setText(_('Next') if not self.is_last(page.wizard_data) else self.finish_label)
|
||||
self.next_button.setEnabled(not page.busy and page.valid)
|
||||
self.main_widget.setVisible(not page.busy and not bool(page.error))
|
||||
self.please_wait.setVisible(page.busy)
|
||||
|
||||
@@ -655,21 +655,14 @@ class ServerConnectWizard(AbstractWizard):
|
||||
AbstractWizard.__init__(self)
|
||||
self.navmap = {
|
||||
'welcome': {
|
||||
'next': 'proxy_ask',
|
||||
'next': lambda d: 'proxy_config' if d['want_proxy'] else 'server_config',
|
||||
'accept': self.do_configure_autoconnect,
|
||||
'last': lambda d: d['use_defaults']
|
||||
},
|
||||
'proxy_ask': {
|
||||
'next': lambda d: 'proxy_config' if d['want_proxy'] else 'autoconnect'
|
||||
},
|
||||
'autoconnect': {
|
||||
'next': 'server_config',
|
||||
'accept': self.do_configure_autoconnect,
|
||||
'last': lambda d: d['autoconnect']
|
||||
'last': lambda d: bool(d['autoconnect'] and not d['want_proxy'])
|
||||
},
|
||||
'proxy_config': {
|
||||
'next': 'autoconnect',
|
||||
'accept': self.do_configure_proxy
|
||||
'next': 'server_config',
|
||||
'accept': self.do_configure_proxy,
|
||||
'last': lambda d: bool(d['autoconnect'])
|
||||
},
|
||||
'server_config': {
|
||||
'accept': self.do_configure_server,
|
||||
@@ -687,26 +680,28 @@ class ServerConnectWizard(AbstractWizard):
|
||||
net_params = self._daemon.network.get_parameters()
|
||||
if not proxy_settings['enabled']:
|
||||
proxy_settings = None
|
||||
net_params = net_params._replace(proxy=proxy_settings)
|
||||
net_params = net_params._replace(proxy=proxy_settings, auto_connect=bool(wizard_data['autoconnect']))
|
||||
self._daemon.network.run_from_another_thread(self._daemon.network.set_parameters(net_params))
|
||||
|
||||
def do_configure_server(self, wizard_data: dict):
|
||||
self._logger.debug(f'configuring server: {wizard_data!r}')
|
||||
net_params = self._daemon.network.get_parameters()
|
||||
try:
|
||||
server = ServerAddr.from_str_with_inference(wizard_data['server'])
|
||||
if not server:
|
||||
raise Exception('failed to parse server %s' % wizard_data['server'])
|
||||
except Exception:
|
||||
return
|
||||
server = ''
|
||||
if not wizard_data['autoconnect']:
|
||||
try:
|
||||
server = ServerAddr.from_str_with_inference(wizard_data['server'])
|
||||
if not server:
|
||||
raise Exception('failed to parse server %s' % wizard_data['server'])
|
||||
except Exception:
|
||||
return
|
||||
net_params = net_params._replace(server=server, auto_connect=wizard_data['autoconnect'])
|
||||
self._daemon.network.run_from_another_thread(self._daemon.network.set_parameters(net_params))
|
||||
|
||||
def do_configure_autoconnect(self, wizard_data: dict):
|
||||
self._logger.debug(f'configuring autoconnect: {wizard_data!r}')
|
||||
if self._daemon.config.cv.NETWORK_AUTO_CONNECT.is_modifiable():
|
||||
if autoconnect := wizard_data.get('autoconnect') is not None:
|
||||
self._daemon.config.NETWORK_AUTO_CONNECT = autoconnect
|
||||
if wizard_data.get('autoconnect') is not None:
|
||||
self._daemon.config.NETWORK_AUTO_CONNECT = wizard_data.get('autoconnect')
|
||||
|
||||
def start(self, initial_data: dict = None) -> WizardViewState:
|
||||
if initial_data is None:
|
||||
|
||||
Reference in New Issue
Block a user