mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
Permit multiselect in contacts tab
You can select multiple contacts, and still do all the actions you could do on a single contact. In particular, paying to them all and removing them all. This covers the first two bullet points of #1372. Finally, make the new contact dialog box have a sensible width that can display a full address without scrolling
This commit is contained in:
parent
607664e663
commit
62fe37a863
1 changed files with 31 additions and 18 deletions
|
@ -1508,6 +1508,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
def create_contacts_tab(self):
|
def create_contacts_tab(self):
|
||||||
l = MyTreeWidget(self, self.create_contact_menu, [_('Name'), _('Address'), _('Type')], 1, [0, 1])
|
l = MyTreeWidget(self, self.create_contact_menu, [_('Name'), _('Address'), _('Type')], 1, [0, 1])
|
||||||
|
l.setSelectionMode(QAbstractItemView.ExtendedSelection)
|
||||||
l.item_edited = self.contact_edited
|
l.item_edited = self.contact_edited
|
||||||
self.contacts_list = l
|
self.contacts_list = l
|
||||||
return self.create_list_tab(l)
|
return self.create_list_tab(l)
|
||||||
|
@ -1639,12 +1640,16 @@ class ElectrumWindow(QMainWindow):
|
||||||
self.tabs.setCurrentIndex(1)
|
self.tabs.setCurrentIndex(1)
|
||||||
self.payto_e.paytomany()
|
self.payto_e.paytomany()
|
||||||
|
|
||||||
def payto(self, addr):
|
def payto_contacts(self, labels):
|
||||||
if not addr:
|
paytos = [self.get_contact_payto(label) for label in labels]
|
||||||
return
|
|
||||||
self.tabs.setCurrentIndex(1)
|
self.tabs.setCurrentIndex(1)
|
||||||
self.payto_e.setText(addr)
|
if len(paytos) == 1:
|
||||||
|
self.payto_e.setText(paytos[0])
|
||||||
self.amount_e.setFocus()
|
self.amount_e.setFocus()
|
||||||
|
else:
|
||||||
|
text = "\n".join([payto + ", 0" for payto in paytos])
|
||||||
|
self.payto_e.setText(text)
|
||||||
|
self.payto_e.setFocus()
|
||||||
|
|
||||||
def contact_edited(self, item, column, prior):
|
def contact_edited(self, item, column, prior):
|
||||||
if column == 0: # Remove old contact if renamed
|
if column == 0: # Remove old contact if renamed
|
||||||
|
@ -1662,29 +1667,35 @@ class ElectrumWindow(QMainWindow):
|
||||||
self.update_completions()
|
self.update_completions()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def delete_contact(self, x):
|
def delete_contacts(self, labels):
|
||||||
if not self.question(_("Do you want to remove")+" %s "%x +_("from your list of contacts?")):
|
if not self.question(_("Remove %s from your list of contacts?")
|
||||||
|
% " + ".join(labels)):
|
||||||
return
|
return
|
||||||
self.contacts.pop(x)
|
for label in labels:
|
||||||
|
self.contacts.pop(label)
|
||||||
self.update_history_tab()
|
self.update_history_tab()
|
||||||
self.update_contacts_tab()
|
self.update_contacts_tab()
|
||||||
self.update_completions()
|
self.update_completions()
|
||||||
|
|
||||||
def create_contact_menu(self, position):
|
def create_contact_menu(self, position):
|
||||||
item = self.contacts_list.itemAt(position)
|
|
||||||
menu = QMenu()
|
menu = QMenu()
|
||||||
if not item:
|
selected = self.contacts_list.selectedItems()
|
||||||
|
if not selected:
|
||||||
menu.addAction(_("New contact"), lambda: self.new_contact_dialog())
|
menu.addAction(_("New contact"), lambda: self.new_contact_dialog())
|
||||||
else:
|
else:
|
||||||
key = unicode(item.text(0))
|
labels = [unicode(item.text(0)) for item in selected]
|
||||||
menu.addAction(_("Copy to Clipboard"), lambda: self.app.clipboard().setText(key))
|
addrs = [unicode(item.text(1)) for item in selected]
|
||||||
menu.addAction(_("Pay to"), lambda: self.payto(self.get_contact_payto(key)))
|
menu.addAction(_("Copy to Clipboard"), lambda:
|
||||||
menu.addAction(_("Delete"), lambda: self.delete_contact(key))
|
self.app.clipboard().setText('\n'.join(labels)))
|
||||||
addr_URL = block_explorer_URL(self.config, 'addr', unicode(item.text(1)))
|
menu.addAction(_("Pay to"), lambda: self.payto_contacts(labels))
|
||||||
if addr_URL:
|
menu.addAction(_("Delete"), lambda: self.delete_contacts(labels))
|
||||||
menu.addAction(_("View on block explorer"), lambda: webbrowser.open(addr_URL))
|
URLs = [URL for URL in [block_explorer_URL(self.config, 'addr', addr)
|
||||||
|
for addr in addrs] if URL is not None]
|
||||||
|
if URLs:
|
||||||
|
menu.addAction(_("View on block explorer"),
|
||||||
|
lambda: map(webbrowser.open, URLs))
|
||||||
|
|
||||||
run_hook('create_contact_menu', menu, item)
|
run_hook('create_contact_menu', menu, selected)
|
||||||
menu.exec_(self.contacts_list.viewport().mapToGlobal(position))
|
menu.exec_(self.contacts_list.viewport().mapToGlobal(position))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1941,7 +1952,9 @@ class ElectrumWindow(QMainWindow):
|
||||||
vbox.addWidget(QLabel(_('New Contact') + ':'))
|
vbox.addWidget(QLabel(_('New Contact') + ':'))
|
||||||
grid = QGridLayout()
|
grid = QGridLayout()
|
||||||
line1 = QLineEdit()
|
line1 = QLineEdit()
|
||||||
|
line1.setFixedWidth(280)
|
||||||
line2 = QLineEdit()
|
line2 = QLineEdit()
|
||||||
|
line2.setFixedWidth(280)
|
||||||
grid.addWidget(QLabel(_("Address")), 1, 0)
|
grid.addWidget(QLabel(_("Address")), 1, 0)
|
||||||
grid.addWidget(line1, 1, 1)
|
grid.addWidget(line1, 1, 1)
|
||||||
grid.addWidget(QLabel(_("Name")), 2, 0)
|
grid.addWidget(QLabel(_("Name")), 2, 0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue