commit 9c144c11ef0e5cccd152d4ffe436dfc236a280da
parent 95a2e27c5a03edb3c8cd537cf9333e70e2ee834e
Author: ThomasV <thomasv1@gmx.de>
Date: Wed, 25 Dec 2013 01:34:16 -0800
Merge pull request #516 from imrehg/contacts
Access the "New Contact" menuitem in the contact list context menu
Diffstat:
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -1217,18 +1217,20 @@ class ElectrumWindow(QMainWindow):
def create_contact_menu(self, position):
item = self.contacts_list.itemAt(position)
- if not item: return
- addr = unicode(item.text(0))
- label = unicode(item.text(1))
- is_editable = item.data(0,32).toBool()
- payto_addr = item.data(0,33).toString()
menu = QMenu()
- menu.addAction(_("Copy to Clipboard"), lambda: self.app.clipboard().setText(addr))
- menu.addAction(_("Pay to"), lambda: self.payto(payto_addr))
- menu.addAction(_("QR code"), lambda: self.show_qrcode("bitcoin:" + addr, _("Address")))
- if is_editable:
- menu.addAction(_("Edit label"), lambda: self.edit_label(False))
- menu.addAction(_("Delete"), lambda: self.delete_contact(addr))
+ if not item:
+ menu.addAction(_("New contact"), lambda: self.new_contact_dialog())
+ else:
+ addr = unicode(item.text(0))
+ label = unicode(item.text(1))
+ is_editable = item.data(0,32).toBool()
+ payto_addr = item.data(0,33).toString()
+ menu.addAction(_("Copy to Clipboard"), lambda: self.app.clipboard().setText(addr))
+ menu.addAction(_("Pay to"), lambda: self.payto(payto_addr))
+ menu.addAction(_("QR code"), lambda: self.show_qrcode("bitcoin:" + addr, _("Address")))
+ if is_editable:
+ menu.addAction(_("Edit label"), lambda: self.edit_label(False))
+ menu.addAction(_("Delete"), lambda: self.delete_contact(addr))
run_hook('create_contact_menu', menu, item)
menu.exec_(self.contacts_list.viewport().mapToGlobal(position))