@ -8,7 +8,7 @@ import electrum
from electrum . i18n import _
from electrum . i18n import _
from seed_dialog import SeedDisplayLayout , SeedWarningLayout , SeedInputLayout
from seed_dialog import SeedDisplayLayout , SeedWarningLayout , SeedInputLayout
from network_dialog import NetworkDialog
from network_dialog import NetworkChoiceLayout
from util import *
from util import *
from password_dialog import PasswordLayout , PW_NEW , PW_PASSPHRASE
from password_dialog import PasswordLayout , PW_NEW , PW_PASSPHRASE
@ -110,12 +110,17 @@ class InstallWizard(WindowModalDialog, WizardBase):
self . show ( )
self . show ( )
self . raise_ ( )
self . raise_ ( )
def finished ( self ) :
''' Ensure the dialog is closed. '''
self . accept ( )
self . refresh_gui ( )
def set_icon ( self , filename ) :
def set_icon ( self , filename ) :
prior_filename , self . icon_filename = self . icon_filename , filename
prior_filename , self . icon_filename = self . icon_filename , filename
self . logo . setPixmap ( QPixmap ( filename ) . scaledToWidth ( 70 ) )
self . logo . setPixmap ( QPixmap ( filename ) . scaledToWidth ( 70 ) )
return prior_filename
return prior_filename
def set_main_layout ( self , layout , title = None ) :
def set_main_layout ( self , layout , title = None , raise_on_cancel = True ) :
self . title . setText ( title or " " )
self . title . setText ( title or " " )
self . title . setVisible ( bool ( title ) )
self . title . setVisible ( bool ( title ) )
# Get rid of any prior layout
# Get rid of any prior layout
@ -127,7 +132,8 @@ class InstallWizard(WindowModalDialog, WizardBase):
self . next_button . setEnabled ( True )
self . next_button . setEnabled ( True )
self . main_widget . setVisible ( True )
self . main_widget . setVisible ( True )
self . please_wait . setVisible ( False )
self . please_wait . setVisible ( False )
if not self . loop . exec_ ( ) :
result = self . loop . exec_ ( )
if not result and raise_on_cancel :
raise UserCancelled
raise UserCancelled
self . title . setVisible ( False )
self . title . setVisible ( False )
self . cancel_button . setEnabled ( False )
self . cancel_button . setEnabled ( False )
@ -135,6 +141,7 @@ class InstallWizard(WindowModalDialog, WizardBase):
self . main_widget . setVisible ( False )
self . main_widget . setVisible ( False )
self . please_wait . setVisible ( True )
self . please_wait . setVisible ( True )
self . refresh_gui ( )
self . refresh_gui ( )
return result
def refresh_gui ( self ) :
def refresh_gui ( self ) :
# For some reason, to refresh the GUI this needs to be called twice
# For some reason, to refresh the GUI this needs to be called twice
@ -204,9 +211,6 @@ class InstallWizard(WindowModalDialog, WizardBase):
the password or None for no password . """
the password or None for no password . """
return self . pw_layout ( msg or MSG_ENTER_PASSWORD , PW_NEW )
return self . pw_layout ( msg or MSG_ENTER_PASSWORD , PW_NEW )
def choose_server ( self , network ) :
self . network_dialog ( network )
def show_restore ( self , wallet , network ) :
def show_restore ( self , wallet , network ) :
if network :
if network :
def task ( ) :
def task ( ) :
@ -295,35 +299,26 @@ class InstallWizard(WindowModalDialog, WizardBase):
self . set_main_layout ( vbox )
self . set_main_layout ( vbox )
return get_texts ( )
return get_texts ( )
def network_dialog ( self , network ) :
def choose_server ( self , network ) :
grid = QGridLayout ( )
title = _ ( " Electrum communicates with remote servers to get "
grid . setSpacing ( 5 )
" information about your transactions and addresses. The "
label = QLabel ( _ ( " 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 if you have a preference though feel free to select a server manually. " ) + " \n \n " \
" servers all fulfil the same purpose only differing in "
+ _ ( " How do you want to connect to a server: " ) + " " )
" hardware. In most cases you simply want to let Electrum "
label . setWordWrap ( True )
" pick one at random. However if you prefer feel free to "
grid . addWidget ( label , 0 , 0 )
" select a server manually. " )
gb = QGroupBox ( )
choices = [ _ ( " Auto connect " ) , _ ( " Select server manually " ) ]
b1 = QRadioButton ( gb )
choices_title = _ ( " How do you want to connect to a server? " )
b1 . setText ( _ ( " Auto connect " ) )
clayout = ChoicesLayout ( choices_title , choices )
b1 . setChecked ( True )
self . set_main_layout ( clayout . layout ( ) , title )
b2 = QRadioButton ( gb )
b2 . setText ( _ ( " Select server manually " ) )
auto_connect = True
grid . addWidget ( b1 , 1 , 0 )
if clayout . selected_index ( ) == 1 :
grid . addWidget ( b2 , 2 , 0 )
nlayout = NetworkChoiceLayout ( network , self . config , wizard = True )
vbox = QVBoxLayout ( )
if self . set_main_layout ( nlayout . layout ( ) , raise_on_cancel = False ) :
vbox . addLayout ( grid )
nlayout . accept ( )
vbox . addStretch ( 1 )
auto_connect = False
vbox . addLayout ( Buttons ( CancelButton ( self ) , OkButton ( self , _ ( ' Next ' ) ) ) )
self . config . set_key ( ' auto_connect ' , auto_connect , True )
network . auto_connect = auto_connect
self . set_layout ( vbox )
if not self . exec_ ( ) :
return
if b2 . isChecked ( ) :
NetworkDialog ( network , self . config , None ) . do_exec ( )
else :
self . config . set_key ( ' auto_connect ' , True , True )
network . auto_connect = True
def query_choice ( self , msg , choices ) :
def query_choice ( self , msg , choices ) :
clayout = ChoicesLayout ( msg , choices )
clayout = ChoicesLayout ( msg , choices )