commit 015e274dabfd811622e02d96321351a4731c8db1
parent 0ef7320d7ddcee34e6fd29e203da36142fa7744d
Author: ThomasV <thomasv@electrum.org>
Date: Sat, 5 Sep 2015 09:11:48 +0200
rework exchange_rate hooks
Diffstat:
3 files changed, 20 insertions(+), 26 deletions(-)
diff --git a/gui/kivy/tools/buildozer.spec b/gui/kivy/tools/buildozer.spec
@@ -32,7 +32,7 @@ version.filename = %(source.dir)s/lib/version.py
#version = 1.9.8
# (list) Application requirements
-requirements = tlslite, openssl, pyopenssl, pil, qrcode, ecdsa, pbkdf2, pyasn1, pyasn1-modules, plyer==master, kivy==master
+requirements = requests, dnspython, openssl, pil, qrcode, ecdsa, pbkdf2, plyer==master, kivy==master
# (str) Presplash of the application
presplash.filename = %(source.dir)s/gui/kivy/theming/splash.png
diff --git a/gui/qt/history_widget.py b/gui/qt/history_widget.py
@@ -28,7 +28,9 @@ from electrum.plugins import run_hook
class HistoryWidget(MyTreeWidget):
def __init__(self, parent=None):
- MyTreeWidget.__init__(self, parent, self.create_menu, ['', '', _('Date'), _('Description') , _('Amount'), _('Balance')], 3)
+ headers = ['', '', _('Date'), _('Description') , _('Amount'), _('Balance')]
+ run_hook('history_tab_headers', headers)
+ MyTreeWidget.__init__(self, parent, self.create_menu, headers, 3)
self.setColumnHidden(1, True)
self.config = self.parent.config
self.setSortingEnabled(False)
@@ -63,11 +65,12 @@ class HistoryWidget(MyTreeWidget):
v_str = self.parent.format_amount(value, True, whitespaces=True)
balance_str = self.parent.format_amount(balance, whitespaces=True)
label, is_default_label = self.wallet.get_label(tx_hash)
- item = EditableItem(['', tx_hash, time_str, label, v_str, balance_str])
+ entry = ['', tx_hash, time_str, label, v_str, balance_str]
+ run_hook('history_tab_update', tx, entry)
+ item = EditableItem(entry)
item.setIcon(0, icon)
- item.setFont(3, QFont(MONOSPACE_FONT))
- item.setFont(4, QFont(MONOSPACE_FONT))
- item.setFont(5, QFont(MONOSPACE_FONT))
+ for i in range(len(entry)):
+ item.setFont(i, QFont(MONOSPACE_FONT))
if value < 0:
item.setForeground(4, QBrush(QColor("#BC1E1E")))
if tx_hash:
@@ -78,7 +81,6 @@ class HistoryWidget(MyTreeWidget):
if current_tx == tx_hash:
self.setCurrentItem(item)
entries.append((item, tx))
- run_hook('history_tab_update', self.parent, entries)
def update_item(self, tx_hash, conf, timestamp):
icon, time_str = self.get_icon(conf, timestamp)
diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py
@@ -337,27 +337,19 @@ class Plugin(BasePlugin):
return True
@hook
- def history_tab_update(self, window, entries):
+ def history_tab_headers(self, headers):
+ headers.append(_('Fiat Amount'))
+
+ @hook
+ def history_tab_update(self, tx, entry):
if not self.config_history():
return
- history_list = window.history_list
- history_list.setColumnCount(7)
- # For unclear reasons setting this column to ResizeToContents
- # makes e.g. label editing very slow
- history_list.setColumnWidth(6, 130)
- #window.history_list.header().setResizeMode(6, QHeaderView.ResizeToConte
- history_list.setHeaderLabels([ '', '', _('Date'), _('Description') , _('Amount'), _('Balance'), _('Fiat Amount')] )
- for item, tx in entries:
- tx_hash, conf, value, timestamp, balance = tx
- date = timestamp_to_datetime(timestamp)
- if not date:
- date = timestmap_to_datetime(0)
- text = self.exchange.historical_value_str(self.fiat_unit(),
- value, date)
- item.setText(6, "%16s" % text)
- item.setFont(6, QFont(MONOSPACE_FONT))
- if value < 0:
- item.setForeground(6, QBrush(QColor("#BC1E1E")))
+ tx_hash, conf, value, timestamp, balance = tx
+ date = timestamp_to_datetime(timestamp)
+ if not date:
+ date = timestmap_to_datetime(0)
+ text = self.exchange.historical_value_str(self.fiat_unit(), value, date)
+ entry.append("%16s"%text)
def settings_widget(self, window):
return EnterButton(_('Settings'), self.settings_dialog)