Browse Source

do not expose network to wizard. update message in issue #1972

283
ThomasV 8 years ago
parent
commit
7ea91dde2e
  1. 3
      gui/kivy/main_window.py
  2. 1
      gui/kivy/uix/dialogs/installwizard.py
  3. 23
      gui/qt/__init__.py
  4. 31
      gui/qt/installwizard.py
  5. 2
      gui/qt/network_dialog.py
  6. 3
      lib/base_wizard.py

3
gui/kivy/main_window.py

@ -410,6 +410,7 @@ class ElectrumWindow(App):
def on_wizard_complete(self, instance, wallet):
if wallet:
wallet.start_threads(self.daemon.network)
self.daemon.add_wallet(wallet)
self.load_wallet(wallet)
self.on_resume()
@ -425,7 +426,7 @@ class ElectrumWindow(App):
self.on_resume()
else:
Logger.debug('Electrum: Wallet not found. Launching install wizard')
wizard = Factory.InstallWizard(self.electrum_config, self.network, path)
wizard = Factory.InstallWizard(self.electrum_config, path)
wizard.bind(on_wizard_complete=self.on_wizard_complete)
action = wizard.storage.get_action()
wizard.run(action)

1
gui/kivy/uix/dialogs/installwizard.py

@ -759,7 +759,6 @@ class InstallWizard(BaseWizard, Widget):
t.start()
def terminate(self, **kwargs):
self.wallet.start_threads(self.network)
self.dispatch('on_wizard_complete', self.wallet)
def choice_dialog(self, **kwargs):

23
gui/qt/__init__.py

@ -161,12 +161,11 @@ class ElectrumGui:
else:
wallet = self.daemon.load_wallet(path)
if not wallet:
wizard = InstallWizard(self.config, self.app, self.plugins, self.daemon.network, path)
wizard = InstallWizard(self.config, self.app, self.plugins, path)
wallet = wizard.run_and_get_wallet()
if not wallet:
return
#if wallet.get_action():
# return
wallet.start_threads(self.daemon.network)
self.daemon.add_wallet(wallet)
w = self.create_window_for_wallet(wallet)
if uri:
@ -181,23 +180,31 @@ class ElectrumGui:
self.config.save_last_wallet(window.wallet)
run_hook('on_close_window', window)
def init_network(self):
# Show network dialog if config does not exist
if self.daemon.network:
if self.config.get('auto_connect') is None:
wizard = InstallWizard(self.config, self.app, self.plugins, None)
wizard.init_network(self.daemon.network)
wizard.terminate()
def main(self):
try:
self.init_network()
except:
traceback.print_exc(file=sys.stdout)
return
self.timer.start()
self.config.open_last_wallet()
path = self.config.get_wallet_path()
if not self.start_new_window(path, self.config.get('url')):
return
signal.signal(signal.SIGINT, lambda *args: self.app.quit())
# main loop
self.app.exec_()
# Shut down the timer cleanly
self.timer.stop()
# clipboard persistence. see http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg17328.html
event = QtCore.QEvent(QtCore.QEvent.Clipboard)
self.app.sendEvent(self.app.clipboard(), event)
self.tray.hide()

31
gui/qt/installwizard.py

@ -95,9 +95,9 @@ def wizard_dialog(func):
# WindowModalDialog must come first as it overrides show_error
class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
def __init__(self, config, app, plugins, network, storage):
def __init__(self, config, app, plugins, storage):
BaseWizard.__init__(self, config, network, storage)
BaseWizard.__init__(self, config, storage)
QDialog.__init__(self, None)
self.setWindowTitle('Electrum - ' + _('Install Wizard'))
@ -146,10 +146,6 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
self.refresh_gui() # Need for QT on MacOSX. Lame.
def run_and_get_wallet(self):
# Show network dialog if config does not exist
if self.network:
if self.config.get('auto_connect') is None:
self.choose_server(self.network)
path = self.storage.path
if self.storage.requires_split():
@ -337,7 +333,6 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
self.run(action)
def terminate(self):
self.wallet.start_threads(self.network)
self.emit(QtCore.SIGNAL('accept'))
def waiting_dialog(self, task, msg):
@ -391,25 +386,29 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
self.set_main_layout(vbox, _('Master Public Key'))
return None
def choose_server(self, network):
title = _("Electrum communicates with remote servers to get "
def init_network(self, network):
message = _("Electrum communicates with remote servers to get "
"information about your transactions and addresses. The "
"servers all fulfil 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 = [_("Auto connect"), _("Select server manually")]
choices_title = _("How do you want to connect to a server? ")
clayout = ChoicesLayout(choices_title, choices)
title = _("How do you want to connect to a server? ")
clayout = ChoicesLayout(message, choices)
self.set_main_layout(clayout.layout(), title)
auto_connect = True
if clayout.selected_index() == 1:
r = clayout.selected_index()
if r == 0:
auto_connect = True
elif r == 1:
auto_connect = True
nlayout = NetworkChoiceLayout(network, self.config, wizard=True)
if self.set_main_layout(nlayout.layout(), raise_on_cancel=False):
nlayout.accept()
if self.set_main_layout(nlayout.layout()):
auto_connect = False
self.config.set_key('auto_connect', auto_connect, True)
else:
auto_connect = True
network.auto_connect = auto_connect
self.config.set_key('auto_connect', auto_connect, True)
@wizard_dialog
def multisig_dialog(self, run_next):

2
gui/qt/network_dialog.py

@ -73,7 +73,7 @@ class NetworkChoiceLayout(object):
else:
status += "\n" + _("Disconnected from server")
else:
status = _("Please choose a server.") + "\n" + _("Select 'Cancel' if you are offline.")
status = _("Please choose a server.") + "\n" + _("Press 'Next' if you are offline.")
vbox = QVBoxLayout()
hbox = QHBoxLayout()

3
lib/base_wizard.py

@ -32,10 +32,9 @@ from plugins import run_hook
class BaseWizard(object):
def __init__(self, config, network, path):
def __init__(self, config, path):
super(BaseWizard, self).__init__()
self.config = config
self.network = network
self.storage = WalletStorage(path)
self.wallet = None
self.stack = []

Loading…
Cancel
Save