Browse Source

fix parameters for aliases

283
ThomasV 13 years ago
parent
commit
69927304e2
  1. 38
      lib/gui_qt.py

38
lib/gui_qt.py

@ -669,22 +669,27 @@ class ElectrumWindow(QMainWindow):
menu.exec_(self.receive_list.viewport().mapToGlobal(position)) menu.exec_(self.receive_list.viewport().mapToGlobal(position))
def payto(self, addr): def payto(self, x, is_alias):
if not addr: return if not x: return
label = self.wallet.labels.get(addr) if is_alias:
label = x
s, addr = self.wallet.aliases.get(x)
else:
addr = x
label = self.wallet.labels.get(addr)
m_addr = label + ' <' + addr + '>' if label else addr m_addr = label + ' <' + addr + '>' if label else addr
self.tabs.setCurrentIndex(1) self.tabs.setCurrentIndex(1)
self.payto_e.setText(m_addr) self.payto_e.setText(m_addr)
self.amount_e.setFocus() self.amount_e.setFocus()
def delete_contact(self, addr, is_alias): def delete_contact(self, x, is_alias):
if self.question("Do you want to remove %s from your list of contacts?"%addr): if self.question("Do you want to remove %s from your list of contacts?"%x):
if not is_alias and addr in self.wallet.addressbook: if not is_alias and x in self.wallet.addressbook:
self.wallet.addressbook.remove(addr) self.wallet.addressbook.remove(x)
if addr in self.wallet.labels.keys(): if x in self.wallet.labels.keys():
self.wallet.labels.pop(addr) self.wallet.labels.pop(x)
elif is_alias and addr in self.wallet.aliases: elif is_alias and x in self.wallet.aliases:
self.wallet.aliases.pop(addr) self.wallet.aliases.pop(x)
self.update_history_tab() self.update_history_tab()
self.update_contacts_tab() self.update_contacts_tab()
self.update_completions() self.update_completions()
@ -697,17 +702,18 @@ class ElectrumWindow(QMainWindow):
item = self.contacts_list.itemAt(position) item = self.contacts_list.itemAt(position)
if not item: return if not item: return
addr = unicode(item.text(0)) addr = unicode(item.text(0))
label = unicode(item.text(1))
is_alias = label in self.wallet.aliases.keys()
x = label if is_alias else addr
menu = QMenu() menu = QMenu()
menu.addAction(_("Pay to"), lambda: self.payto(addr)) menu.addAction(_("Pay to"), lambda: self.payto(x, is_alias))
menu.addAction(_("Copy to Clipboard"), lambda: self.app.clipboard().setText(addr)) menu.addAction(_("Copy to Clipboard"), lambda: self.app.clipboard().setText(addr))
menu.addAction(_("View QR code"),lambda: self.show_address_qrcode(addr)) menu.addAction(_("View QR code"),lambda: self.show_address_qrcode(addr))
label = unicode( item.text(1) ) if not is_alias:
if label not in self.wallet.aliases.keys():
menu.addAction(_("Edit label"), lambda: self.edit_label(False)) menu.addAction(_("Edit label"), lambda: self.edit_label(False))
menu.addAction(_("Delete"), lambda: self.delete_contact(addr,False))
else: else:
menu.addAction(_("View alias details"), lambda: self.show_contact_details(label)) menu.addAction(_("View alias details"), lambda: self.show_contact_details(label))
menu.addAction(_("Delete"), lambda: self.delete_contact(label,True)) menu.addAction(_("Delete"), lambda: self.delete_contact(x,is_alias))
menu.exec_(self.contacts_list.viewport().mapToGlobal(position)) menu.exec_(self.contacts_list.viewport().mapToGlobal(position))

Loading…
Cancel
Save