rewrite server connect wizard to new wizard style
'last' property on WizardComponents is now queried from UI, not from the wizard. This allows the content of the WizardComponent itself to be taken into account.
This commit is contained in:
@@ -15,9 +15,7 @@ Wizard {
|
||||
|
||||
property string path
|
||||
|
||||
enter: null // disable transition
|
||||
|
||||
property QtObject wiz: Daemon.newWalletWizard
|
||||
wiz: Daemon.newWalletWizard
|
||||
|
||||
Component.onCompleted: {
|
||||
var view = wiz.start_wizard()
|
||||
|
||||
@@ -11,6 +11,8 @@ Wizard {
|
||||
|
||||
enter: null // disable transition
|
||||
|
||||
wiz: Daemon.serverConnectWizard
|
||||
|
||||
onAccepted: {
|
||||
var proxy = wizard_data['proxy']
|
||||
if (proxy && proxy['enabled'] == true) {
|
||||
@@ -25,29 +27,7 @@ Wizard {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
var start = _loadNextComponent(autoconnect)
|
||||
start.next.connect(function() {autoconnectDone()})
|
||||
var view = wiz.start_wizard()
|
||||
_loadNextComponent(view)
|
||||
}
|
||||
|
||||
function autoconnectDone() {
|
||||
var page = _loadNextComponent(proxyconfig, wizard_data)
|
||||
page.next.connect(function() {proxyconfigDone()})
|
||||
}
|
||||
|
||||
function proxyconfigDone() {
|
||||
var page = _loadNextComponent(serverconfig, wizard_data)
|
||||
}
|
||||
|
||||
property Component autoconnect: Component {
|
||||
WCAutoConnect {}
|
||||
}
|
||||
|
||||
property Component proxyconfig: Component {
|
||||
WCProxyConfig {}
|
||||
}
|
||||
|
||||
property Component serverconfig: Component {
|
||||
WCServerConfig {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import QtQuick.Layouts 1.0
|
||||
import QtQuick.Controls 2.1
|
||||
|
||||
import ".."
|
||||
import "../controls"
|
||||
|
||||
WizardComponent {
|
||||
valid: true
|
||||
last: serverconnectgroup.checkedButton.connecttype === 'auto'
|
||||
|
||||
onAccept: {
|
||||
function apply() {
|
||||
wizard_data['autoconnect'] = serverconnectgroup.checkedButton.connecttype === 'auto'
|
||||
}
|
||||
|
||||
@@ -22,17 +20,18 @@ WizardComponent {
|
||||
|
||||
ButtonGroup {
|
||||
id: serverconnectgroup
|
||||
onCheckedButtonChanged: checkIsLast()
|
||||
}
|
||||
|
||||
RadioButton {
|
||||
ButtonGroup.group: serverconnectgroup
|
||||
property string connecttype: 'auto'
|
||||
text: qsTr('Auto connect')
|
||||
checked: true
|
||||
}
|
||||
RadioButton {
|
||||
ButtonGroup.group: serverconnectgroup
|
||||
property string connecttype: 'manual'
|
||||
checked: true
|
||||
text: qsTr('Select servers manually')
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ Dialog {
|
||||
height: parent.height
|
||||
|
||||
property var wizard_data
|
||||
property alias pages : pages
|
||||
property alias pages: pages
|
||||
property QtObject wiz
|
||||
|
||||
function _setWizardData(wdata) {
|
||||
wizard_data = {}
|
||||
@@ -49,7 +50,6 @@ Dialog {
|
||||
if (newview.view) {
|
||||
console.log('next view: ' + newview.view)
|
||||
var newpage = _loadNextComponent(newview.view, newview.wizard_data)
|
||||
newpage.last = wiz.isLast(newview.wizard_data)
|
||||
} else {
|
||||
console.log('END')
|
||||
}
|
||||
@@ -57,7 +57,6 @@ Dialog {
|
||||
page.prev.connect(function() {
|
||||
var wdata = wiz.prev()
|
||||
console.log('prev view data: ' + JSON.stringify(wdata))
|
||||
page.last = wiz.isLast(wdata)
|
||||
})
|
||||
Object.assign(page.wizard_data, wdata) // deep copy
|
||||
page.ready = true // signal page it can access wizard_data
|
||||
|
||||
@@ -8,4 +8,19 @@ Item {
|
||||
property bool valid
|
||||
property bool last: false
|
||||
property bool ready: false
|
||||
|
||||
onAccept: {
|
||||
apply()
|
||||
}
|
||||
|
||||
function apply() { }
|
||||
function checkIsLast() {
|
||||
apply()
|
||||
last = wizard.wiz.isLast(wizard_data)
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
checkIsLast()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ from .qechannelopener import QEChannelOpener
|
||||
from .qelnpaymentdetails import QELnPaymentDetails
|
||||
from .qechanneldetails import QEChannelDetails
|
||||
from .qeswaphelper import QESwapHelper
|
||||
from .qewizard import QENewWalletWizard
|
||||
from .qewizard import QENewWalletWizard, QEServerConnectWizard
|
||||
|
||||
notification = None
|
||||
|
||||
@@ -219,6 +219,7 @@ class ElectrumQmlApplication(QGuiApplication):
|
||||
|
||||
qmlRegisterUncreatableType(QEAmount, 'org.electrum', 1, 0, 'Amount', 'Amount can only be used as property')
|
||||
qmlRegisterUncreatableType(QENewWalletWizard, 'org.electrum', 1, 0, 'NewWalletWizard', 'NewWalletWizard can only be used as property')
|
||||
qmlRegisterUncreatableType(QEServerConnectWizard, 'org.electrum', 1, 0, 'ServerConnectWizard', 'ServerConnectWizard can only be used as property')
|
||||
|
||||
self.engine = QQmlApplicationEngine(parent=self)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from .auth import AuthMixin, auth_protect
|
||||
from .qefx import QEFX
|
||||
from .qewallet import QEWallet
|
||||
from .qewalletdb import QEWalletDB
|
||||
from .qewizard import QENewWalletWizard
|
||||
from .qewizard import QENewWalletWizard, QEServerConnectWizard
|
||||
|
||||
# wallet list model. supports both wallet basenames (wallet file basenames)
|
||||
# and whole Wallet instances (loaded wallets)
|
||||
@@ -123,6 +123,7 @@ class QEDaemon(AuthMixin, QObject):
|
||||
_available_wallets = None
|
||||
_current_wallet = None
|
||||
_new_wallet_wizard = None
|
||||
_server_connect_wizard = None
|
||||
_path = None
|
||||
_use_single_password = False
|
||||
_password = None
|
||||
@@ -131,6 +132,7 @@ class QEDaemon(AuthMixin, QObject):
|
||||
availableWalletsChanged = pyqtSignal()
|
||||
fxChanged = pyqtSignal()
|
||||
newWalletWizardChanged = pyqtSignal()
|
||||
serverConnectWizardChanged = pyqtSignal()
|
||||
|
||||
walletLoaded = pyqtSignal()
|
||||
walletRequiresPassword = pyqtSignal()
|
||||
@@ -296,3 +298,10 @@ class QEDaemon(AuthMixin, QObject):
|
||||
self._new_wallet_wizard = QENewWalletWizard(self)
|
||||
|
||||
return self._new_wallet_wizard
|
||||
|
||||
@pyqtProperty(QEServerConnectWizard, notify=serverConnectWizardChanged)
|
||||
def serverConnectWizard(self):
|
||||
if not self._server_connect_wizard:
|
||||
self._server_connect_wizard = QEServerConnectWizard(self)
|
||||
|
||||
return self._server_connect_wizard
|
||||
|
||||
@@ -4,7 +4,7 @@ from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||
from PyQt5.QtQml import QQmlApplicationEngine
|
||||
|
||||
from electrum.logging import get_logger
|
||||
from electrum.gui.wizard import NewWalletWizard
|
||||
from electrum.gui.wizard import NewWalletWizard, ServerConnectWizard
|
||||
|
||||
class QEAbstractWizard(QObject):
|
||||
_logger = get_logger(__name__)
|
||||
@@ -99,3 +99,17 @@ class QENewWalletWizard(NewWalletWizard, QEAbstractWizard):
|
||||
except Exception as e:
|
||||
self._logger.error(repr(e))
|
||||
self.createError.emit(str(e))
|
||||
|
||||
class QEServerConnectWizard(ServerConnectWizard, QEAbstractWizard):
|
||||
|
||||
def __init__(self, daemon, parent = None):
|
||||
ServerConnectWizard.__init__(self, daemon)
|
||||
QEAbstractWizard.__init__(self, parent)
|
||||
self._daemon = daemon
|
||||
|
||||
# attach view names
|
||||
self.navmap_merge({
|
||||
'autoconnect': { 'gui': 'WCAutoConnect' },
|
||||
'proxy_config': { 'gui': 'WCProxyConfig' },
|
||||
'server_config': { 'gui': 'WCServerConfig' },
|
||||
})
|
||||
|
||||
@@ -287,3 +287,27 @@ class NewWalletWizard(AbstractWizard):
|
||||
|
||||
db.load_plugins()
|
||||
db.write(storage)
|
||||
|
||||
class ServerConnectWizard(AbstractWizard):
|
||||
|
||||
_logger = get_logger(__name__)
|
||||
|
||||
def __init__(self, daemon):
|
||||
self.navmap = {
|
||||
'autoconnect': {
|
||||
'next': 'proxy_config',
|
||||
'last': lambda v,d: d['autoconnect']
|
||||
},
|
||||
'proxy_config': {
|
||||
'next': 'server_config'
|
||||
},
|
||||
'server_config': {
|
||||
'last': True
|
||||
}
|
||||
}
|
||||
self._daemon = daemon
|
||||
|
||||
def start(self, initial_data = {}):
|
||||
self.reset()
|
||||
self._current = WizardViewState('autoconnect', initial_data, {})
|
||||
return self._current
|
||||
|
||||
Reference in New Issue
Block a user