Move install wizard invocations to one place

Fixes bugs whereby install wizard invoked from the GUI was missing
various things, such as updating recently used list, setting up
timers, etc.
This commit is contained in:
Neil Booth 2015-12-31 12:02:16 +09:00
parent 93d05e8cfe
commit bcabfaeccb
2 changed files with 29 additions and 31 deletions

View file

@ -150,35 +150,28 @@ class ElectrumGui(MessageBoxMixin):
self.show_warning(str(e)) self.show_warning(str(e))
return return
action = wallet.get_action() action = wallet.get_action()
# run wizard
if action is not None: if action is not None:
return self.install_wizard(storage, action)
wallet.start_threads(self.network)
return self.create_window_for_wallet(wallet)
def install_wizard(self, storage, action):
wizard = InstallWizard(self.app, self.config, self.network, storage) wizard = InstallWizard(self.app, self.config, self.network, storage)
wallet = wizard.run(action) wallet = wizard.run(action)
# keep current wallet return self.create_window_for_wallet(wallet)
if not wallet:
return
else:
wallet.start_threads(self.network)
return wallet
def new_window(self, path, uri=None): def new_window(self, path, uri=None):
# Use a signal as can be called from daemon thread # Use a signal as can be called from daemon thread
self.app.emit(SIGNAL('new_window'), path, uri) self.app.emit(SIGNAL('new_window'), path, uri)
def start_new_window(self, path, uri): def create_window_for_wallet(self, wallet):
for w in self.windows:
if w.wallet.storage.path == path:
w.bring_to_top()
break
else:
wallet = self.load_wallet_file(path)
if not wallet: if not wallet:
return return
w = ElectrumWindow(self, wallet) w = ElectrumWindow(self, wallet)
w.connect_slots(self.timer) w.connect_slots(self.timer)
# add to recently visited w.update_recently_visited(wallet.storage.path)
w.update_recently_visited(path)
# initial configuration # initial configuration
if self.config.get('hide_gui') is True and self.tray.isVisible(): if self.config.get('hide_gui') is True and self.tray.isVisible():
w.hide() w.hide()
@ -187,8 +180,17 @@ class ElectrumGui(MessageBoxMixin):
self.windows.append(w) self.windows.append(w)
self.build_tray_menu() self.build_tray_menu()
run_hook('on_new_window', w) run_hook('on_new_window', w)
return w
if uri: def start_new_window(self, path, uri):
for w in self.windows:
if w.wallet.storage.path == path:
w.bring_to_top()
break
else:
w = self.load_wallet_file(path)
if uri and w:
w.pay_to_URI(uri) w.pay_to_URI(uri)
return w return w

View file

@ -50,7 +50,6 @@ from network_dialog import NetworkDialog
from qrcodewidget import QRCodeWidget, QRDialog from qrcodewidget import QRCodeWidget, QRDialog
from qrtextedit import ShowQRTextEdit from qrtextedit import ShowQRTextEdit
from transaction_dialog import show_transaction from transaction_dialog import show_transaction
from installwizard import InstallWizard
@ -385,10 +384,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
if storage.file_exists: if storage.file_exists:
self.show_critical(_("File exists")) self.show_critical(_("File exists"))
return return
wizard = InstallWizard(self.app, self.config, self.network, storage) self.gui_object.install_wizard(storage, 'new')
wallet = wizard.run('new')
if wallet:
self.new_window(full_path)
def init_menubar(self): def init_menubar(self):
menubar = QMenuBar() menubar = QMenuBar()