@ -157,7 +157,8 @@ class ElectrumWindow(QMainWindow):
self . tabs = tabs = QTabWidget ( self )
tabs . addTab ( self . create_history_tab ( ) , ' History ' )
tabs . addTab ( self . create_send_tab ( ) , ' Send ' )
if self . wallet . seed :
tabs . addTab ( self . create_send_tab ( ) , ' Send ' )
tabs . addTab ( self . create_receive_tab ( ) , ' Receive ' )
tabs . addTab ( self . create_contacts_tab ( ) , ' Contacts ' )
tabs . addTab ( self . create_wall_tab ( ) , ' Wall ' )
@ -166,7 +167,9 @@ class ElectrumWindow(QMainWindow):
self . setCentralWidget ( tabs )
self . create_status_bar ( )
self . setGeometry ( 100 , 100 , 840 , 400 )
self . setWindowTitle ( ' Electrum ' + self . wallet . electrum_version )
title = ' Electrum ' + self . wallet . electrum_version + ' - ' + self . wallet . path
if not self . wallet . seed : title + = ' [seedless] '
self . setWindowTitle ( title )
self . show ( )
QShortcut ( QKeySequence ( " Ctrl+W " ) , self , self . close )
@ -178,8 +181,9 @@ class ElectrumWindow(QMainWindow):
def connect_slots ( self , sender ) :
self . connect ( sender , QtCore . SIGNAL ( ' timersignal ' ) , self . check_recipient )
self . previous_payto_e = ' '
if self . wallet . seed :
self . connect ( sender , QtCore . SIGNAL ( ' timersignal ' ) , self . check_recipient )
self . previous_payto_e = ' '
def check_recipient ( self ) :
if self . payto_e . hasFocus ( ) :
@ -512,42 +516,62 @@ class ElectrumWindow(QMainWindow):
entry . setPalette ( palette )
def get_current_addr ( self , is_recv ) :
if is_recv :
l = self . receive_list
else :
l = self . contacts_list
i = l . currentItem ( )
if i :
return unicode ( i . text ( 0 ) )
else :
return ' '
def clear_buttons ( self , hbox ) :
while hbox . count ( ) : hbox . removeItem ( hbox . itemAt ( 0 ) )
def add_receive_buttons ( self ) :
def add_buttons ( self , l , hbox , is_recv ) :
self . clear_buttons ( hbox )
l = self . receive_list
hbox = self . receive_buttons_hbox
i = l . currentItem ( )
if not i : return
addr = unicode ( i . text ( 0 ) )
hbox . addWidget ( EnterButton ( " QR " , lambda : self . show_address_qrcode ( self . get_current_addr ( True ) ) ) )
hbox . addWidget ( EnterButton ( " Copy to Clipboard " , lambda : self . app . clipboard ( ) . setText ( self . get_current_addr ( True ) ) ) )
hbox . addWidget ( EnterButton ( " QR " , lambda : self . show_address_qrcode ( addr ) ) )
hbox . addWidget ( EnterButton ( " Copy to Clipboard " , lambda : self . app . clipboard ( ) . setText ( addr ) ) )
if is_recv :
def toggle_freeze ( addr ) :
if addr in self . wallet . frozen_addresses :
self . wallet . frozen_addresses . remove ( addr )
else :
self . wallet . frozen_addresses . append ( addr )
self . wallet . save ( )
self . update_receive_tab ( )
def toggle_freeze ( ) :
addr = self . get_current_addr ( True )
if not addr : return
if addr in self . wallet . frozen_addresses :
self . wallet . frozen_addresses . remove ( addr )
else :
self . wallet . frozen_addresses . append ( addr )
self . wallet . save ( )
self . update_receive_tab ( )
t = " Unfreeze " if addr in self . wallet . frozen_addresses else " Freeze "
hbox . addWidget ( EnterButton ( t , lambda : toggle_freeze ( addr ) ) )
self . freezeButton = b = EnterButton ( " Freeze " , toggle_freeze )
hbox . addWidget ( b )
hbox . addStretch ( 1 )
else :
def payto ( addr ) :
if not addr : return
self . tabs . setCurrentIndex ( 1 )
self . payto_e . setText ( addr )
self . amount_e . setFocus ( )
hbox . addWidget ( EnterButton ( ' Pay to ' , lambda : payto ( addr ) ) )
hbox . addWidget ( EnterButton ( " New " , self . newaddress_dialog ) )
def add_contacts_buttons ( self ) :
l = self . contacts_list
hbox = self . contacts_buttons_hbox
hbox . addWidget ( EnterButton ( " QR " , lambda : self . show_address_qrcode ( self . get_current_addr ( False ) ) ) )
hbox . addWidget ( EnterButton ( " Copy to Clipboard " , lambda : self . app . clipboard ( ) . setText ( self . get_current_addr ( False ) ) ) )
def payto ( ) :
addr = self . get_current_addr ( False )
if not addr : return
self . tabs . setCurrentIndex ( 1 )
self . payto_e . setText ( addr )
self . amount_e . setFocus ( )
hbox . addWidget ( EnterButton ( ' Pay to ' , lambda : payto ( ) ) )
hbox . addWidget ( EnterButton ( " New " , self . newaddress_dialog ) )
hbox . addStretch ( 1 )
def update_receive_buttons ( self ) :
addr = self . get_current_addr ( True )
t = " Unfreeze " if addr in self . wallet . frozen_addresses else " Freeze "
self . freezeButton . setText ( t )
def create_receive_tab ( self ) :
l = QTreeWidget ( self )
@ -573,11 +597,15 @@ class ElectrumWindow(QMainWindow):
hbox . setSpacing ( 0 )
buttons . setLayout ( hbox )
self . connect ( l , SIGNAL ( ' itemDoubleClicked(QTreeWidgetItem*, int) ' ) , lambda a , b : self . address_label_clicked ( a , b , l ) )
self . connect ( l , SIGNAL ( ' itemChanged(QTreeWidgetItem*, int) ' ) , lambda a , b : self . address_label_changed ( a , b , l ) )
self . connect ( l , SIGNAL ( ' itemClicked(QTreeWidgetItem*, int) ' ) , lambda : self . add_buttons ( l , hbox , True ) )
l . selectionModel ( ) . currentChanged . connect ( self . update_receive_buttons )
self . receive_list = l
self . receive_buttons_hbox = hbox
self . add_receive_buttons ( )
return w
def create_contacts_tab ( self ) :
@ -606,16 +634,13 @@ class ElectrumWindow(QMainWindow):
self . connect ( l , SIGNAL ( ' itemDoubleClicked(QTreeWidgetItem*, int) ' ) , lambda a , b : self . address_label_clicked ( a , b , l ) )
self . connect ( l , SIGNAL ( ' itemChanged(QTreeWidgetItem*, int) ' ) , lambda a , b : self . address_label_changed ( a , b , l ) )
self . connect ( l , SIGNAL ( ' itemActivated(QTreeWidgetItem*, int) ' ) , self . show_contact_details )
self . connect ( l , SIGNAL ( ' itemClicked(QTreeWidgetItem*, int) ' ) , lambda : self . add_buttons ( l , hbox , False ) )
self . contacts_list = l
self . contacts_buttons_hbox = hbox
self . add_contacts_buttons ( )
return w
def update_receive_tab ( self ) :
self . receive_list . clear ( )
self . clear_buttons ( self . receive_buttons_hbox )
for address in self . wallet . all_addresses ( ) :
if self . wallet . is_change ( address ) : continue
label = self . wallet . labels . get ( address , ' ' )
@ -647,7 +672,6 @@ class ElectrumWindow(QMainWindow):
def update_contacts_tab ( self ) :
self . contacts_list . clear ( )
self . clear_buttons ( self . contacts_buttons_hbox )
for alias , v in self . wallet . aliases . items ( ) :
s , target = v
@ -674,9 +698,11 @@ class ElectrumWindow(QMainWindow):
def create_status_bar ( self ) :
sb = QStatusBar ( )
sb . setFixedHeight ( 35 )
sb . addPermanentWidget ( StatusBarButton ( QIcon ( " :icons/lock.png " ) , " Password " , lambda : self . change_password_dialog ( self . wallet , self ) ) )
if self . wallet . seed :
sb . addPermanentWidget ( StatusBarButton ( QIcon ( " :icons/lock.png " ) , " Password " , lambda : self . change_password_dialog ( self . wallet , self ) ) )
sb . addPermanentWidget ( StatusBarButton ( QIcon ( " :icons/preferences.png " ) , " Preferences " , self . settings_dialog ) )
sb . addPermanentWidget ( StatusBarButton ( QIcon ( " :icons/seed.png " ) , " Seed " , lambda : self . show_seed_dialog ( self . wallet , self ) ) )
if self . wallet . seed :
sb . addPermanentWidget ( StatusBarButton ( QIcon ( " :icons/seed.png " ) , " Seed " , lambda : self . show_seed_dialog ( self . wallet , self ) ) )
self . status_button = StatusBarButton ( QIcon ( " :icons/status_disconnected.png " ) , " Network " , lambda : self . network_dialog ( self . wallet , self ) )
sb . addPermanentWidget ( self . status_button )
self . setStatusBar ( sb )
@ -695,6 +721,11 @@ class ElectrumWindow(QMainWindow):
@staticmethod
def show_seed_dialog ( wallet , parent = None ) :
from electrum import mnemonic
if not wallet . seed :
QMessageBox . information ( parent , ' Message ' , ' No seed ' , ' OK ' )
return
if wallet . use_encryption :
password = parent . password_dialog ( )
if not password : return
@ -852,6 +883,11 @@ class ElectrumWindow(QMainWindow):
@staticmethod
def change_password_dialog ( wallet , parent = None ) :
if not wallet . seed :
QMessageBox . information ( parent , ' Message ' , ' No seed ' , ' OK ' )
return
d = QDialog ( parent )
d . setModal ( 1 )