|
|
@ -715,6 +715,7 @@ class ElectrumWindow(QMainWindow): |
|
|
|
self.save_request_button = QPushButton(_('Save')) |
|
|
|
self.save_request_button.clicked.connect(self.save_payment_request) |
|
|
|
grid.addWidget(self.save_request_button, 3, 1) |
|
|
|
|
|
|
|
clear_button = QPushButton(_('New')) |
|
|
|
clear_button.clicked.connect(self.new_receive_address) |
|
|
|
grid.addWidget(clear_button, 3, 2) |
|
|
@ -731,8 +732,11 @@ class ElectrumWindow(QMainWindow): |
|
|
|
self.receive_list.customContextMenuRequested.connect(self.receive_list_menu) |
|
|
|
self.receive_list.currentItemChanged.connect(self.receive_item_changed) |
|
|
|
self.receive_list.itemClicked.connect(self.receive_item_changed) |
|
|
|
self.receive_list.setHeaderLabels( [_('Address'), _('Message'), _('Amount')] ) |
|
|
|
self.receive_list.setColumnWidth(0, 340) |
|
|
|
self.receive_list.setHeaderLabels( [_('Date'), _('Account'), _('Address'), _('Message'), _('Amount')] ) |
|
|
|
self.receive_list.setSortingEnabled(True) |
|
|
|
self.receive_list.setColumnWidth(0, 130) |
|
|
|
self.receive_list.hideColumn(1) # the update will show it if necessary |
|
|
|
self.receive_list.setColumnWidth(2, 340) |
|
|
|
h = self.receive_list.header() |
|
|
|
h.setStretchLastSection(False) |
|
|
|
h.setResizeMode(1, QHeaderView.Stretch) |
|
|
@ -744,15 +748,16 @@ class ElectrumWindow(QMainWindow): |
|
|
|
def receive_item_changed(self, item): |
|
|
|
if item is None: |
|
|
|
return |
|
|
|
addr = str(item.text(0)) |
|
|
|
amount, message = self.receive_requests[addr] |
|
|
|
addr = str(item.text(2)) |
|
|
|
req = self.receive_requests[addr] |
|
|
|
date, amount, message = req["date"], req["amount"], req["msg"] |
|
|
|
self.receive_address_e.setText(addr) |
|
|
|
self.receive_message_e.setText(message) |
|
|
|
self.receive_amount_e.setAmount(amount) |
|
|
|
|
|
|
|
|
|
|
|
def receive_list_delete(self, item): |
|
|
|
addr = str(item.text(0)) |
|
|
|
addr = str(item.text(2)) |
|
|
|
self.receive_requests.pop(addr) |
|
|
|
self.wallet.storage.put('receive_requests', self.receive_requests) |
|
|
|
self.update_receive_tab() |
|
|
@ -761,11 +766,12 @@ class ElectrumWindow(QMainWindow): |
|
|
|
def receive_list_menu(self, position): |
|
|
|
item = self.receive_list.itemAt(position) |
|
|
|
menu = QMenu() |
|
|
|
menu.addAction(_("Copy to clipboard"), lambda: self.app.clipboard().setText(str(item.text(0)))) |
|
|
|
menu.addAction(_("Copy to clipboard"), lambda: self.app.clipboard().setText(str(item.text(2)))) |
|
|
|
menu.addAction(_("Delete"), lambda: self.receive_list_delete(item)) |
|
|
|
menu.exec_(self.receive_list.viewport().mapToGlobal(position)) |
|
|
|
|
|
|
|
def save_payment_request(self): |
|
|
|
date = time.strftime("%c") |
|
|
|
addr = str(self.receive_address_e.text()) |
|
|
|
amount = self.receive_amount_e.get_amount() |
|
|
|
message = unicode(self.receive_message_e.text()) |
|
|
@ -773,7 +779,7 @@ class ElectrumWindow(QMainWindow): |
|
|
|
QMessageBox.warning(self, _('Error'), _('No message or amount'), _('OK')) |
|
|
|
return |
|
|
|
self.receive_requests = self.wallet.storage.get('receive_requests',{}) |
|
|
|
self.receive_requests[addr] = (amount, message) |
|
|
|
self.receive_requests[addr] = {"date":date, "amount":amount, "msg":message} |
|
|
|
self.wallet.storage.put('receive_requests', self.receive_requests) |
|
|
|
self.update_receive_tab() |
|
|
|
|
|
|
@ -829,18 +835,45 @@ class ElectrumWindow(QMainWindow): |
|
|
|
|
|
|
|
def update_receive_tab(self): |
|
|
|
self.receive_requests = self.wallet.storage.get('receive_requests',{}) |
|
|
|
|
|
|
|
# hide receive tab if no receive requests available |
|
|
|
b = len(self.receive_requests) > 0 |
|
|
|
self.receive_list.setVisible(b) |
|
|
|
self.receive_requests_label.setVisible(b) |
|
|
|
|
|
|
|
# check if it is necessary to show the account |
|
|
|
if len(self.wallet.get_accounts()) > 1: |
|
|
|
self.receive_list.showColumn(1) |
|
|
|
else: |
|
|
|
self.receive_list.hideColumn(1) |
|
|
|
|
|
|
|
# update the receive address if necessary |
|
|
|
current_address = self.receive_address_e.text() |
|
|
|
domain = self.wallet.get_account_addresses(self.current_account, include_change=False) |
|
|
|
if not current_address in domain: |
|
|
|
self.new_receive_address() |
|
|
|
|
|
|
|
# clear the list and fill it again |
|
|
|
self.receive_list.clear() |
|
|
|
for address, v in self.receive_requests.items(): |
|
|
|
amount, message = v |
|
|
|
item = QTreeWidgetItem( [ address, message, self.format_amount(amount) if amount else ""] ) |
|
|
|
item.setFont(0, QFont(MONOSPACE_FONT)) |
|
|
|
for address, req in self.receive_requests.viewitems(): |
|
|
|
try: |
|
|
|
date, amount, message = req["date"], req["amount"], req["msg"] |
|
|
|
except: |
|
|
|
# REMOVE LATER - fix for current electrum 2.0 wallets |
|
|
|
# deletes all requests so that you don't need to edit your wallets manually |
|
|
|
print "removing old receive_requests" |
|
|
|
self.wallet.storage.put('receive_requests', {}) |
|
|
|
return |
|
|
|
# only show requests for the current account |
|
|
|
if address not in domain: |
|
|
|
continue |
|
|
|
account = self.wallet.get_account_from_address(address) |
|
|
|
item = QTreeWidgetItem( [ date, account, address, message, self.format_amount(amount) if amount else ""]) |
|
|
|
item.setFont(2, QFont(MONOSPACE_FONT)) |
|
|
|
self.receive_list.addTopLevelItem(item) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_receive_qr(self): |
|
|
|
import urlparse, urllib |
|
|
|
addr = str(self.receive_address_e.text()) |
|
|
@ -2404,10 +2437,10 @@ class ElectrumWindow(QMainWindow): |
|
|
|
|
|
|
|
h, b = ok_cancel_buttons2(d, _('Export')) |
|
|
|
vbox.addLayout(h) |
|
|
|
|
|
|
|
|
|
|
|
run_hook('export_history_dialog', self,hbox) |
|
|
|
self.update() |
|
|
|
|
|
|
|
|
|
|
|
if not d.exec_(): |
|
|
|
return |
|
|
|
|
|
|
|