Access the "New Contact" menuitem in the contact list context menu

Contacts are managed in the contacts tab with a context menu.
Previously the menu is only shown when clicking on an existing contact,
clicking outside of the list shows nothing, and to create a new contact
one had to go in the main menu -> Wallet -> New Contact.

Change behaviour such that when in the contact menu, clicking outside
the existing contacts brings up the choice of creating a new contact.
This commit is contained in:
Gergely Imreh 2013-12-25 00:33:29 +08:00
parent f4f418e9ec
commit 6e9e292dc7
1 changed files with 13 additions and 11 deletions

View File

@ -1217,12 +1217,14 @@ class ElectrumWindow(QMainWindow):
def create_contact_menu(self, position): def create_contact_menu(self, position):
item = self.contacts_list.itemAt(position) item = self.contacts_list.itemAt(position)
if not item: return menu = QMenu()
if not item:
menu.addAction(_("New contact"), lambda: self.new_contact_dialog())
else:
addr = unicode(item.text(0)) addr = unicode(item.text(0))
label = unicode(item.text(1)) label = unicode(item.text(1))
is_editable = item.data(0,32).toBool() is_editable = item.data(0,32).toBool()
payto_addr = item.data(0,33).toString() payto_addr = item.data(0,33).toString()
menu = QMenu()
menu.addAction(_("Copy to Clipboard"), lambda: self.app.clipboard().setText(addr)) menu.addAction(_("Copy to Clipboard"), lambda: self.app.clipboard().setText(addr))
menu.addAction(_("Pay to"), lambda: self.payto(payto_addr)) menu.addAction(_("Pay to"), lambda: self.payto(payto_addr))
menu.addAction(_("QR code"), lambda: self.show_qrcode("bitcoin:" + addr, _("Address"))) menu.addAction(_("QR code"), lambda: self.show_qrcode("bitcoin:" + addr, _("Address")))