electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 26a6fa3082ccfe1336460ddc2db3e550e2a355ea
parent 2aaf250a4a4094ea52c980e682d666e2ffd6947e
Author: ThomasV <thomasv@electrum.org>
Date:   Wed, 28 Feb 2018 09:01:27 +0100

Merge pull request #3985 from SomberNight/addresses_tab_type_col

qt addresses tab: new column for type
Diffstat:
Mgui/qt/address_list.py | 38+++++++++++++++++++++++---------------
Mgui/qt/transaction_dialog.py | 2+-
Mgui/qt/util.py | 3+++
Mgui/qt/utxo_list.py | 3++-
4 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/gui/qt/address_list.py b/gui/qt/address_list.py @@ -24,18 +24,19 @@ # SOFTWARE. import webbrowser -from .util import * from electrum.i18n import _ from electrum.util import block_explorer_URL from electrum.plugins import run_hook from electrum.bitcoin import is_address +from .util import * + class AddressList(MyTreeWidget): - filter_columns = [0, 1, 2] # Address, Label, Balance + filter_columns = [0, 1, 2, 3] # Type, Address, Label, Balance def __init__(self, parent=None): - MyTreeWidget.__init__(self, parent, self.create_menu, [], 1) + MyTreeWidget.__init__(self, parent, self.create_menu, [], 2) self.refresh_headers() self.setSelectionMode(QAbstractItemView.ExtendedSelection) self.show_change = 0 @@ -53,7 +54,7 @@ class AddressList(MyTreeWidget): return QLabel(_("Filter:")), self.change_button, self.used_button def refresh_headers(self): - headers = [ _('Address'), _('Label'), _('Balance')] + headers = [_('Type'), _('Address'), _('Label'), _('Balance')] fx = self.parent.fx if fx and fx.get_fiat_address_config(): headers.extend([_(fx.get_currency()+' Balance')]) @@ -95,23 +96,30 @@ class AddressList(MyTreeWidget): continue if self.show_used == 3 and not is_used: continue - balance_text = self.parent.format_amount(balance) + balance_text = self.parent.format_amount(balance, whitespaces=True) fx = self.parent.fx if fx and fx.get_fiat_address_config(): rate = fx.exchange_rate() fiat_balance = fx.value_str(balance, rate) - address_item = QTreeWidgetItem([address, label, balance_text, fiat_balance, "%d"%num]) - address_item.setTextAlignment(3, Qt.AlignRight) + address_item = QTreeWidgetItem(['', address, label, balance_text, fiat_balance, "%d"%num]) + address_item.setTextAlignment(4, Qt.AlignRight) + address_item.setFont(4, QFont(MONOSPACE_FONT)) + else: + address_item = QTreeWidgetItem(['', address, label, balance_text, "%d"%num]) + address_item.setFont(3, QFont(MONOSPACE_FONT)) + if self.wallet.is_change(address): + address_item.setText(0, _('change')) + address_item.setBackground(0, ColorScheme.YELLOW.as_color(True)) else: - address_item = QTreeWidgetItem([address, label, balance_text, "%d"%num]) - address_item.setTextAlignment(2, Qt.AlignRight) - address_item.setFont(0, QFont(MONOSPACE_FONT)) - address_item.setData(0, Qt.UserRole, address) - address_item.setData(0, Qt.UserRole+1, True) # label can be edited + address_item.setText(0, _('receiving')) + address_item.setBackground(0, ColorScheme.GREEN.as_color(True)) + address_item.setFont(1, QFont(MONOSPACE_FONT)) + address_item.setData(1, Qt.UserRole, address) + address_item.setData(1, Qt.UserRole+1, True) # label can be edited if self.wallet.is_frozen(address): - address_item.setBackground(0, ColorScheme.BLUE.as_color(True)) + address_item.setBackground(1, ColorScheme.BLUE.as_color(True)) if self.wallet.is_beyond_limit(address): - address_item.setBackground(0, ColorScheme.RED.as_color(True)) + address_item.setBackground(1, ColorScheme.RED.as_color(True)) self.addChild(address_item) if address == current_address: self.setCurrentItem(address_item) @@ -122,7 +130,7 @@ class AddressList(MyTreeWidget): can_delete = self.wallet.can_delete_address() selected = self.selectedItems() multi_select = len(selected) > 1 - addrs = [item.text(0) for item in selected] + addrs = [item.text(1) for item in selected] if not addrs: return if not multi_select: diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py @@ -263,7 +263,7 @@ class TxDialog(QDialog, MessageBoxMixin): rec.setBackground(QBrush(ColorScheme.GREEN.as_color(background=True))) rec.setToolTip(_("Wallet receive address")) chg = QTextCharFormat() - chg.setBackground(QBrush(QColor("yellow"))) + chg.setBackground(QBrush(ColorScheme.YELLOW.as_color(background=True))) chg.setToolTip(_("Wallet change address")) def text_format(addr): diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -405,6 +405,8 @@ class MyTreeWidget(QTreeWidget): self.update_headers(headers) self.current_filter = "" + self.setRootIsDecorated(False) # remove left margin + def update_headers(self, headers): self.setColumnCount(len(headers)) self.setHeaderLabels(headers) @@ -656,6 +658,7 @@ class ColorScheme: dark_scheme = False GREEN = ColorSchemeItem("#117c11", "#8af296") + YELLOW = ColorSchemeItem("#ffff00", "#ffff00") RED = ColorSchemeItem("#7c1111", "#f18c8c") BLUE = ColorSchemeItem("#123b7c", "#8cb3f2") DEFAULT = ColorSchemeItem("black", "white") diff --git a/gui/qt/utxo_list.py b/gui/qt/utxo_list.py @@ -46,9 +46,10 @@ class UTXOList(MyTreeWidget): height = x.get('height') name = self.get_name(x) label = self.wallet.get_label(x.get('prevout_hash')) - amount = self.parent.format_amount(x['value']) + amount = self.parent.format_amount(x['value'], whitespaces=True) utxo_item = QTreeWidgetItem([address, label, amount, '%d'%height, name[0:10] + '...' + name[-2:]]) utxo_item.setFont(0, QFont(MONOSPACE_FONT)) + utxo_item.setFont(2, QFont(MONOSPACE_FONT)) utxo_item.setFont(4, QFont(MONOSPACE_FONT)) utxo_item.setData(0, Qt.UserRole, name) if self.wallet.is_frozen(address):