add account menus and details window
This commit is contained in:
@@ -1034,6 +1034,22 @@ class ElectrumWindow(QMainWindow):
|
|||||||
self.update_receive_tab()
|
self.update_receive_tab()
|
||||||
self.update_history_tab()
|
self.update_history_tab()
|
||||||
|
|
||||||
|
def edit_account_label(self, k):
|
||||||
|
text, ok = QInputDialog.getText(self, _('Rename account'), _('Name') + ':')
|
||||||
|
if ok:
|
||||||
|
label = unicode(text)
|
||||||
|
self.set_label(k,label)
|
||||||
|
self.update_receive_tab()
|
||||||
|
|
||||||
|
def create_account_menu(self, position, k, item):
|
||||||
|
menu = QMenu()
|
||||||
|
if item.isExpanded():
|
||||||
|
menu.addAction(_("Reduce"), lambda: item.setExpanded(False))
|
||||||
|
else:
|
||||||
|
menu.addAction(_("Expand"), lambda: item.setExpanded(True))
|
||||||
|
menu.addAction(_("Rename"), lambda: self.edit_account_label(k))
|
||||||
|
menu.addAction(_("View details"), lambda: self.show_account_details(k))
|
||||||
|
menu.exec_(self.receive_list.viewport().mapToGlobal(position))
|
||||||
|
|
||||||
def create_receive_menu(self, position):
|
def create_receive_menu(self, position):
|
||||||
# fixme: this function apparently has a side effect.
|
# fixme: this function apparently has a side effect.
|
||||||
@@ -1042,10 +1058,16 @@ class ElectrumWindow(QMainWindow):
|
|||||||
|
|
||||||
item = self.receive_list.itemAt(position)
|
item = self.receive_list.itemAt(position)
|
||||||
if not item: return
|
if not item: return
|
||||||
|
|
||||||
addr = unicode(item.text(0))
|
addr = unicode(item.text(0))
|
||||||
if not is_valid(addr):
|
if not is_valid(addr):
|
||||||
item.setExpanded(not item.isExpanded())
|
k = str(item.data(0,32).toString())
|
||||||
|
if k:
|
||||||
|
self.create_account_menu(position, k, item)
|
||||||
|
else:
|
||||||
|
item.setExpanded(not item.isExpanded())
|
||||||
return
|
return
|
||||||
|
|
||||||
menu = QMenu()
|
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(_("QR code"), lambda: self.show_qrcode("bitcoin:" + addr, _("Address")) )
|
menu.addAction(_("QR code"), lambda: self.show_qrcode("bitcoin:" + addr, _("Address")) )
|
||||||
@@ -1144,6 +1166,11 @@ class ElectrumWindow(QMainWindow):
|
|||||||
account_item = QTreeWidgetItem( [ name, '', self.format_amount(c+u), ''] )
|
account_item = QTreeWidgetItem( [ name, '', self.format_amount(c+u), ''] )
|
||||||
l.addTopLevelItem(account_item)
|
l.addTopLevelItem(account_item)
|
||||||
account_item.setExpanded(True)
|
account_item.setExpanded(True)
|
||||||
|
account_item.setData(0, 32, k)
|
||||||
|
|
||||||
|
if not self.wallet.is_seeded(k):
|
||||||
|
icon = QIcon(":icons/key.png")
|
||||||
|
account_item.setIcon(0, icon)
|
||||||
|
|
||||||
for is_change in ([0,1] if self.expert_mode else [0]):
|
for is_change in ([0,1] if self.expert_mode else [0]):
|
||||||
if self.expert_mode:
|
if self.expert_mode:
|
||||||
@@ -1965,3 +1992,33 @@ class ElectrumWindow(QMainWindow):
|
|||||||
vbox.addLayout(close_button(d))
|
vbox.addLayout(close_button(d))
|
||||||
|
|
||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
|
|
||||||
|
def show_account_details(self, k):
|
||||||
|
d = QDialog(self)
|
||||||
|
d.setWindowTitle(_('Account Details'))
|
||||||
|
d.setModal(1)
|
||||||
|
|
||||||
|
vbox = QVBoxLayout(d)
|
||||||
|
roots = self.wallet.get_roots(k)
|
||||||
|
|
||||||
|
name = self.wallet.get_account_name(k)
|
||||||
|
label = QLabel('Name: ' + name)
|
||||||
|
vbox.addWidget(label)
|
||||||
|
|
||||||
|
acctype = '2 of 2' if len(roots) == 2 else '2 of 3' if len(roots) == 3 else 'Single key'
|
||||||
|
vbox.addWidget(QLabel('Type: ' + acctype))
|
||||||
|
|
||||||
|
label = QLabel('Derivation: ' + k)
|
||||||
|
vbox.addWidget(label)
|
||||||
|
|
||||||
|
#for root in roots:
|
||||||
|
# mpk = self.wallet.master_public_keys[root]
|
||||||
|
# text = QTextEdit()
|
||||||
|
# text.setReadOnly(True)
|
||||||
|
# text.setMaximumHeight(120)
|
||||||
|
# text.setText(repr(mpk))
|
||||||
|
# vbox.addWidget(text)
|
||||||
|
|
||||||
|
vbox.addLayout(close_button(d))
|
||||||
|
d.exec_()
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ from PyQt4.QtCore import *
|
|||||||
import PyQt4.QtCore as QtCore
|
import PyQt4.QtCore as QtCore
|
||||||
|
|
||||||
from electrum import transaction
|
from electrum import transaction
|
||||||
from qt_util import MyTreeWidget
|
from util import MyTreeWidget
|
||||||
|
|
||||||
class TxDialog(QDialog):
|
class TxDialog(QDialog):
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<file>icons/clock4.png</file>
|
<file>icons/clock4.png</file>
|
||||||
<file>icons/clock5.png</file>
|
<file>icons/clock5.png</file>
|
||||||
<file>icons/confirmed.png</file>
|
<file>icons/confirmed.png</file>
|
||||||
|
<file>icons/key.png</file>
|
||||||
<file>icons/lock.png</file>
|
<file>icons/lock.png</file>
|
||||||
<file>icons/unlock.png</file>
|
<file>icons/unlock.png</file>
|
||||||
<file>icons/preferences.png</file>
|
<file>icons/preferences.png</file>
|
||||||
|
|||||||
@@ -491,6 +491,20 @@ class Wallet:
|
|||||||
raise BaseException("Address not found", address)
|
raise BaseException("Address not found", address)
|
||||||
|
|
||||||
|
|
||||||
|
def get_roots(self, account):
|
||||||
|
roots = []
|
||||||
|
for a in account.split('&'):
|
||||||
|
s = a.strip()
|
||||||
|
m = re.match("(m/\d+'/)(\d+)", s)
|
||||||
|
roots.append( m.group(1) )
|
||||||
|
return roots
|
||||||
|
|
||||||
|
def is_seeded(self, account):
|
||||||
|
for root in self.get_roots(account):
|
||||||
|
if root not in self.master_private_keys.keys():
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def rebase_sequence(self, account, sequence):
|
def rebase_sequence(self, account, sequence):
|
||||||
c, i = sequence
|
c, i = sequence
|
||||||
dd = []
|
dd = []
|
||||||
|
|||||||
Reference in New Issue
Block a user