qt,qml: add a welcome page as initial page for server connect wizard
This is much less intimidating than asking if the user wants to use a proxy out of the gate.
This commit is contained in:
BIN
electrum/gui/icons/electrum_darkblue_1.png
Normal file
BIN
electrum/gui/icons/electrum_darkblue_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
BIN
electrum/gui/icons/electrum_text.png
Normal file
BIN
electrum/gui/icons/electrum_text.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 KiB |
@@ -6,6 +6,7 @@ import "../controls"
|
||||
|
||||
WizardComponent {
|
||||
valid: true
|
||||
title: qsTr('Server')
|
||||
|
||||
function apply() {
|
||||
wizard_data['autoconnect'] = serverconnectgroup.checkedButton.connecttype === 'auto'
|
||||
|
||||
@@ -7,6 +7,7 @@ import "../controls"
|
||||
|
||||
WizardComponent {
|
||||
valid: true
|
||||
title: qsTr('Proxy')
|
||||
|
||||
function apply() {
|
||||
wizard_data['want_proxy'] = wantproxygroup.checkedButton.wantproxy
|
||||
|
||||
@@ -6,6 +6,7 @@ import "../controls"
|
||||
|
||||
WizardComponent {
|
||||
valid: true
|
||||
title: qsTr('Proxy')
|
||||
|
||||
function apply() {
|
||||
wizard_data['proxy'] = pc.toProxyDict()
|
||||
|
||||
@@ -7,6 +7,7 @@ import "../controls"
|
||||
WizardComponent {
|
||||
valid: true
|
||||
last: true
|
||||
title: qsTr('Server')
|
||||
|
||||
function apply() {
|
||||
wizard_data['autoconnect'] = sc.address == ""
|
||||
|
||||
48
electrum/gui/qml/components/wizard/WCWelcome.qml
Normal file
48
electrum/gui/qml/components/wizard/WCWelcome.qml
Normal file
@@ -0,0 +1,48 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Controls
|
||||
|
||||
// import org.electrum 1.0
|
||||
|
||||
import "../controls"
|
||||
|
||||
WizardComponent {
|
||||
valid: true
|
||||
title: qsTr('Electrum Bitcoin Wallet')
|
||||
|
||||
function apply() {
|
||||
wizard_data['use_defaults'] = use_defaults.checked
|
||||
if (use_defaults.checked) {
|
||||
wizard_data['autoconnect'] = true
|
||||
wizard_data['want_proxy'] = false
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
width: parent.width
|
||||
|
||||
Image {
|
||||
Layout.fillWidth: true
|
||||
fillMode: Image.PreserveAspectFit
|
||||
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
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: use_defaults
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: qsTr('Use default network settings')
|
||||
checked: true
|
||||
onCheckedChanged: checkIsLast()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,8 @@ ElDialog {
|
||||
|
||||
padding: 0
|
||||
|
||||
title: wizardTitle + (pages.currentItem.title ? ' - ' + pages.currentItem.title : '')
|
||||
title: (pages.currentItem.wizard_title ? pages.currentItem.wizard_title : wizardTitle) +
|
||||
(pages.currentItem.title ? ' - ' + pages.currentItem.title : '')
|
||||
iconSource: '../../../icons/electrum.png'
|
||||
|
||||
// android back button triggers close() on Popups. Disabling close here,
|
||||
|
||||
@@ -10,6 +10,7 @@ Pane {
|
||||
property var wizard_data : ({})
|
||||
property bool valid
|
||||
property bool last: false
|
||||
property string wizard_title: ''
|
||||
property string title: ''
|
||||
property bool securePage: false
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ class QEServerConnectWizard(ServerConnectWizard, QEAbstractWizard):
|
||||
|
||||
# attach view names
|
||||
self.navmap_merge({
|
||||
'welcome': {'gui': 'WCWelcome'},
|
||||
'autoconnect': {'gui': 'WCAutoConnect'},
|
||||
'proxy_ask': {'gui': 'WCProxyAsk'},
|
||||
'proxy_config': {'gui': 'WCProxyConfig'},
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QPixmap
|
||||
from PyQt5.QtWidgets import QCheckBox, QLabel, QHBoxLayout
|
||||
|
||||
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
|
||||
from electrum.gui.qt.util import ChoiceWidget, icon_path
|
||||
from .wizard import QEAbstractWizard, WizardComponent
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -18,18 +22,55 @@ class QEServerConnectWizard(ServerConnectWizard, QEAbstractWizard):
|
||||
def __init__(self, config: 'SimpleConfig', app: 'QElectrumApplication', plugins: 'Plugins', daemon: 'Daemon', parent=None):
|
||||
ServerConnectWizard.__init__(self, daemon)
|
||||
QEAbstractWizard.__init__(self, config, app)
|
||||
|
||||
self.setWindowTitle(_('Network and server configuration'))
|
||||
self.window_title = _('Network and server configuration')
|
||||
|
||||
# attach gui classes
|
||||
self.navmap_merge({
|
||||
'autoconnect': { 'gui': WCAutoConnect },
|
||||
'proxy_ask': { 'gui': WCProxyAsk },
|
||||
'proxy_config': { 'gui': WCProxyConfig },
|
||||
'server_config': { 'gui': WCServerConfig },
|
||||
'welcome': {'gui': WCWelcome, 'params': {'icon': ''}},
|
||||
'proxy_ask': {'gui': WCProxyAsk},
|
||||
'autoconnect': {'gui': WCAutoConnect},
|
||||
'proxy_config': {'gui': WCProxyConfig},
|
||||
'server_config': {'gui': WCServerConfig},
|
||||
})
|
||||
|
||||
|
||||
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.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)
|
||||
self._valid = True
|
||||
|
||||
def apply(self):
|
||||
self.wizard_data['use_defaults'] = self.use_defaults_w.isChecked()
|
||||
if self.use_defaults_w.isChecked():
|
||||
self.wizard_data['autoconnect'] = True
|
||||
self.wizard_data['want_proxy'] = False
|
||||
|
||||
|
||||
class WCAutoConnect(WizardComponent):
|
||||
def __init__(self, parent, wizard):
|
||||
WizardComponent.__init__(self, parent, wizard, title=_("How do you want to connect to a server? "))
|
||||
|
||||
@@ -55,8 +55,7 @@ class QENewWalletWizard(NewWalletWizard, QEAbstractWizard, MessageBoxMixin):
|
||||
def __init__(self, config: 'SimpleConfig', app: 'QElectrumApplication', plugins: 'Plugins', daemon: Daemon, path, *, start_viewstate=None):
|
||||
NewWalletWizard.__init__(self, daemon, plugins)
|
||||
QEAbstractWizard.__init__(self, config, app, start_viewstate=start_viewstate)
|
||||
|
||||
self.setWindowTitle(_('Create/Restore wallet'))
|
||||
self.window_title = _('Create/Restore wallet')
|
||||
|
||||
self._path = path
|
||||
self._password = None
|
||||
|
||||
@@ -39,6 +39,7 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
|
||||
self.setMinimumSize(600, 400)
|
||||
|
||||
self.title = QLabel()
|
||||
self.window_title = ''
|
||||
|
||||
self.main_widget = ResizableStackedWidget(self)
|
||||
|
||||
@@ -125,7 +126,7 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
|
||||
viewstate = self._current = self.start_viewstate
|
||||
else:
|
||||
viewstate = self.start_wizard()
|
||||
self.load_next_component(viewstate.view, viewstate.wizard_data)
|
||||
self.load_next_component(viewstate.view, viewstate.wizard_data, viewstate.params)
|
||||
|
||||
def load_next_component(self, view, wdata=None, params=None):
|
||||
if wdata is None:
|
||||
@@ -167,6 +168,7 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
|
||||
|
||||
def update(self):
|
||||
page = self.main_widget.currentWidget()
|
||||
self.setWindowTitle(page.wizard_title if page.wizard_title else self.window_title)
|
||||
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)
|
||||
@@ -178,8 +180,11 @@ class QEAbstractWizard(QDialog, MessageBoxMixin):
|
||||
self.error_msg.setText(str(page.error))
|
||||
self.error.setVisible(not page.busy and bool(page.error))
|
||||
icon = page.params.get('icon', icon_path('electrum.png'))
|
||||
if icon != self.icon_filename:
|
||||
if icon and icon != self.icon_filename:
|
||||
self.set_icon(icon)
|
||||
self.logo.setVisible(True)
|
||||
else:
|
||||
self.logo.setVisible(False)
|
||||
|
||||
def on_back_button_clicked(self):
|
||||
if self.can_go_back():
|
||||
@@ -238,6 +243,7 @@ class WizardComponent(QWidget):
|
||||
self.setLayout(layout if layout else QVBoxLayout(self))
|
||||
self.wizard_data = {}
|
||||
self.title = title if title is not None else 'No title'
|
||||
self.wizard_title = None
|
||||
self.busy_msg = ''
|
||||
self.wizard = wizard
|
||||
self._error = ''
|
||||
|
||||
@@ -264,7 +264,9 @@ class NewWalletWizard(AbstractWizard):
|
||||
if initial_data is None:
|
||||
initial_data = {}
|
||||
self.reset()
|
||||
self._current = WizardViewState('wallet_name', initial_data, {})
|
||||
start_view = 'wallet_name'
|
||||
params = self.navmap[start_view].get('params', {})
|
||||
self._current = WizardViewState(start_view, initial_data, params)
|
||||
return self._current
|
||||
|
||||
def is_single_password(self) -> bool:
|
||||
@@ -652,14 +654,18 @@ class ServerConnectWizard(AbstractWizard):
|
||||
def __init__(self, daemon: 'Daemon'):
|
||||
AbstractWizard.__init__(self)
|
||||
self.navmap = {
|
||||
'welcome': {
|
||||
'next': 'proxy_ask',
|
||||
'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']
|
||||
},
|
||||
'proxy_ask': {
|
||||
'next': lambda d: 'proxy_config' if d['want_proxy'] else 'autoconnect'
|
||||
},
|
||||
'proxy_config': {
|
||||
'next': 'autoconnect',
|
||||
'accept': self.do_configure_proxy
|
||||
@@ -704,5 +710,7 @@ class ServerConnectWizard(AbstractWizard):
|
||||
if initial_data is None:
|
||||
initial_data = {}
|
||||
self.reset()
|
||||
self._current = WizardViewState('proxy_ask', initial_data, {})
|
||||
start_view = 'welcome'
|
||||
params = self.navmap[start_view].get('params', {})
|
||||
self._current = WizardViewState(start_view, initial_data, params)
|
||||
return self._current
|
||||
|
||||
Reference in New Issue
Block a user