Added history to lite view.
This commit is contained in:
@@ -12,6 +12,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import wallet
|
import wallet
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import history_widget
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import lib.gui_qt as gui_qt
|
import lib.gui_qt as gui_qt
|
||||||
@@ -174,6 +175,10 @@ class MiniWindow(QDialog):
|
|||||||
main_layout.addWidget(self.amount_input, 2, 0)
|
main_layout.addWidget(self.amount_input, 2, 0)
|
||||||
main_layout.addWidget(self.send_button, 2, 1)
|
main_layout.addWidget(self.send_button, 2, 1)
|
||||||
|
|
||||||
|
self.history_list = history_widget.HistoryWidget()
|
||||||
|
self.history_list.hide()
|
||||||
|
main_layout.addWidget(self.history_list, 3, 0, 1, -1)
|
||||||
|
|
||||||
menubar = QMenuBar()
|
menubar = QMenuBar()
|
||||||
electrum_menu = menubar.addMenu(_("&Bitcoin"))
|
electrum_menu = menubar.addMenu(_("&Bitcoin"))
|
||||||
electrum_menu.addMenu(_("&Servers"))
|
electrum_menu.addMenu(_("&Servers"))
|
||||||
@@ -185,7 +190,9 @@ class MiniWindow(QDialog):
|
|||||||
self.connect(expert_gui, SIGNAL("triggered()"), expand_callback)
|
self.connect(expert_gui, SIGNAL("triggered()"), expand_callback)
|
||||||
view_menu.addMenu(_("&Themes"))
|
view_menu.addMenu(_("&Themes"))
|
||||||
view_menu.addSeparator()
|
view_menu.addSeparator()
|
||||||
view_menu.addAction(_("Show History"))
|
show_history = view_menu.addAction(_("Show History"))
|
||||||
|
show_history.setCheckable(True)
|
||||||
|
self.connect(show_history, SIGNAL("toggled(bool)"), self.show_history)
|
||||||
|
|
||||||
settings_menu = menubar.addMenu(_("&Settings"))
|
settings_menu = menubar.addMenu(_("&Settings"))
|
||||||
settings_menu.addAction(_("&Configure Electrum"))
|
settings_menu.addAction(_("&Configure Electrum"))
|
||||||
@@ -320,6 +327,12 @@ class MiniWindow(QDialog):
|
|||||||
def update_completions(self, completions):
|
def update_completions(self, completions):
|
||||||
self.address_completions.setStringList(completions)
|
self.address_completions.setStringList(completions)
|
||||||
|
|
||||||
|
def update_history(self, tx_history):
|
||||||
|
for tx in tx_history[-10:]:
|
||||||
|
address = tx["dest_address"]
|
||||||
|
amount = D(tx["value"]) / 10**8
|
||||||
|
self.history_list.append(address, amount)
|
||||||
|
|
||||||
def acceptbit(self):
|
def acceptbit(self):
|
||||||
self.actuator.acceptbit(self.quote_currencies[0])
|
self.actuator.acceptbit(self.quote_currencies[0])
|
||||||
|
|
||||||
@@ -331,6 +344,12 @@ class MiniWindow(QDialog):
|
|||||||
QMessageBox.information(self, "Electrum - " + _("Reporting Bugs"),
|
QMessageBox.information(self, "Electrum - " + _("Reporting Bugs"),
|
||||||
_("Email bug reports to %s") % "genjix" + "@" + "riseup.net")
|
_("Email bug reports to %s") % "genjix" + "@" + "riseup.net")
|
||||||
|
|
||||||
|
def show_history(self, toggle_state):
|
||||||
|
if toggle_state:
|
||||||
|
self.history_list.show()
|
||||||
|
else:
|
||||||
|
self.history_list.hide()
|
||||||
|
|
||||||
class BalanceLabel(QLabel):
|
class BalanceLabel(QLabel):
|
||||||
|
|
||||||
SHOW_CONNECTING = 1
|
SHOW_CONNECTING = 1
|
||||||
@@ -576,6 +595,7 @@ class MiniDriver(QObject):
|
|||||||
if self.wallet.up_to_date:
|
if self.wallet.up_to_date:
|
||||||
self.update_balance()
|
self.update_balance()
|
||||||
self.update_completions()
|
self.update_completions()
|
||||||
|
self.update_history()
|
||||||
|
|
||||||
def initializing(self):
|
def initializing(self):
|
||||||
if self.state == self.INITIALIZING:
|
if self.state == self.INITIALIZING:
|
||||||
@@ -614,6 +634,10 @@ class MiniDriver(QObject):
|
|||||||
completions = completions + self.wallet.aliases.keys()
|
completions = completions + self.wallet.aliases.keys()
|
||||||
self.window.update_completions(completions)
|
self.window.update_completions(completions)
|
||||||
|
|
||||||
|
def update_history(self):
|
||||||
|
tx_history = self.wallet.get_tx_history()
|
||||||
|
self.window.update_history(tx_history)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
with open(rsrc("style.css")) as style_file:
|
with open(rsrc("style.css")) as style_file:
|
||||||
|
|||||||
19
lib/history_widget.py
Normal file
19
lib/history_widget.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from PyQt4.QtGui import *
|
||||||
|
from i18n import _
|
||||||
|
|
||||||
|
class HistoryWidget(QTreeWidget):
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
QTreeWidget.__init__(self, parent)
|
||||||
|
self.setColumnCount(2)
|
||||||
|
self.setHeaderLabels([_("Amount"), _("To / From")])
|
||||||
|
self.setIndentation(0)
|
||||||
|
|
||||||
|
def append(self, address, amount):
|
||||||
|
if amount >= 0:
|
||||||
|
display_amount = "+%s" % amount
|
||||||
|
else:
|
||||||
|
display_amount = "-%s" % (-amount)
|
||||||
|
item = QTreeWidgetItem([display_amount, address])
|
||||||
|
self.insertTopLevelItem(0, item)
|
||||||
|
|
||||||
@@ -897,6 +897,7 @@ class Wallet:
|
|||||||
default_label = 'to: ' + dest_label
|
default_label = 'to: ' + dest_label
|
||||||
else:
|
else:
|
||||||
default_label = 'to: ' + o_addr
|
default_label = 'to: ' + o_addr
|
||||||
|
dest_address = o_addr
|
||||||
else:
|
else:
|
||||||
for o_addr in tx['outputs']:
|
for o_addr in tx['outputs']:
|
||||||
if self.is_mine(o_addr) and not self.is_change(o_addr):
|
if self.is_mine(o_addr) and not self.is_change(o_addr):
|
||||||
@@ -914,8 +915,10 @@ class Wallet:
|
|||||||
default_label = 'at: ' + dest_label
|
default_label = 'at: ' + dest_label
|
||||||
else:
|
else:
|
||||||
default_label = 'at: ' + o_addr
|
default_label = 'at: ' + o_addr
|
||||||
|
dest_address = o_addr
|
||||||
|
|
||||||
tx['default_label'] = default_label
|
tx['default_label'] = default_label
|
||||||
|
tx['dest_address'] = dest_address
|
||||||
|
|
||||||
def mktx(self, to_address, amount, label, password, fee=None, change_addr=None, from_addr= None):
|
def mktx(self, to_address, amount, label, password, fee=None, change_addr=None, from_addr= None):
|
||||||
if not self.is_valid(to_address):
|
if not self.is_valid(to_address):
|
||||||
|
|||||||
Reference in New Issue
Block a user