diff --git a/data/style.css b/data/style.css index bb7e1bbd..ffc9bb49 100644 --- a/data/style.css +++ b/data/style.css @@ -77,3 +77,9 @@ MiniWindow QPushButton { { color: #333; } + +#history::item +{ + color: #888; +} + diff --git a/lib/gui_lite.py b/lib/gui_lite.py index b8dda84a..c7ceacdd 100644 --- a/lib/gui_lite.py +++ b/lib/gui_lite.py @@ -12,6 +12,7 @@ import sys import time import wallet import webbrowser +import history_widget try: import lib.gui_qt as gui_qt @@ -174,16 +175,33 @@ class MiniWindow(QDialog): main_layout.addWidget(self.amount_input, 2, 0) main_layout.addWidget(self.send_button, 2, 1) + self.history_list = history_widget.HistoryWidget() + self.history_list.setObjectName("history") + self.history_list.hide() + self.history_list.setAlternatingRowColors(True) + main_layout.addWidget(self.history_list, 3, 0, 1, -1) + menubar = QMenuBar() electrum_menu = menubar.addMenu(_("&Bitcoin")) - #electrum_menu.addMenu(_("&Servers")) - #electrum_menu.addSeparator() electrum_menu.addAction(_("&Quit")) view_menu = menubar.addMenu(_("&View")) expert_gui = view_menu.addAction(_("&Pro Mode")) self.connect(expert_gui, SIGNAL("triggered()"), expand_callback) + show_history = view_menu.addAction(_("Show History")) + show_history.setCheckable(True) + self.connect(show_history, SIGNAL("toggled(bool)"), self.show_history) + + help_menu = menubar.addMenu(_("&Help")) + the_website = help_menu.addAction(_("&Website")) + self.connect(the_website, SIGNAL("triggered()"), self.the_website) + help_menu.addSeparator() + report_bug = help_menu.addAction(_("&Report Bug")) + self.connect(report_bug, SIGNAL("triggered()"), self.show_report_bug) + show_about = help_menu.addAction(_("&About")) + self.connect(show_about, SIGNAL("triggered()"), self.show_about) + main_layout.setMenuBar(menubar) quit_shortcut = QShortcut(QKeySequence("Ctrl+Q"), self) @@ -309,9 +327,18 @@ class MiniWindow(QDialog): def update_completions(self, completions): self.address_completions.setStringList(completions) + def update_history(self, tx_history): + for tx in tx_history[-10:]: + address = tx["default_label"] + amount = D(tx["value"]) / 10**8 + self.history_list.append(address, amount) + def acceptbit(self): self.actuator.acceptbit(self.quote_currencies[0]) + def the_website(self): + webbrowser.open("http://electrum-desktop.com") + def show_about(self): QMessageBox.about(self, "Electrum", _("Electrum's focus is speed, with low resource usage and simplifying Bitcoin. You do not need to perform regular backups, because your wallet can be recovered from a secret phrase that you can memorize or write on paper. Startup times are instant because it operates in conjuction with high-performance servers that handle the most complicated parts of the Bitcoin system.")) @@ -320,6 +347,12 @@ class MiniWindow(QDialog): QMessageBox.information(self, "Electrum - " + _("Reporting Bugs"), _("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): SHOW_CONNECTING = 1 @@ -565,6 +598,7 @@ class MiniDriver(QObject): if self.wallet.up_to_date: self.update_balance() self.update_completions() + self.update_history() def initializing(self): if self.state == self.INITIALIZING: @@ -603,6 +637,10 @@ class MiniDriver(QObject): completions = completions + self.wallet.aliases.keys() 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__": app = QApplication(sys.argv) with open(rsrc("style.css")) as style_file: diff --git a/lib/gui_qt.py b/lib/gui_qt.py index 4b6214d2..d8f26fc5 100644 --- a/lib/gui_qt.py +++ b/lib/gui_qt.py @@ -291,7 +291,7 @@ class ElectrumWindow(QMainWindow): l.setColumnWidth(2, 350) l.setColumnWidth(3, 140) l.setColumnWidth(4, 140) - l.setHeaderLabels( [ '', _( 'Date' ), _( 'Description' ) , _('Amount'), _('Balance')] ) + l.setHeaderLabels( [ '', _( 'Date' ), _( 'To / From' ) , _('Amount'), _('Balance')] ) self.connect(l, SIGNAL('itemDoubleClicked(QTreeWidgetItem*, int)'), self.tx_label_clicked) self.connect(l, SIGNAL('itemChanged(QTreeWidgetItem*, int)'), self.tx_label_changed) l.setContextMenuPolicy(Qt.CustomContextMenu) diff --git a/lib/history_widget.py b/lib/history_widget.py new file mode 100644 index 00000000..946490cc --- /dev/null +++ b/lib/history_widget.py @@ -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) + diff --git a/lib/wallet.py b/lib/wallet.py index d5b487ed..fcc846e8 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -892,11 +892,10 @@ class Wallet: if tx['value']<0: for o_addr in tx['outputs']: if not self.is_mine(o_addr): - dest_label = self.labels.get(o_addr) - if dest_label: - default_label = 'to: ' + dest_label - else: - default_label = 'to: ' + o_addr + try: + default_label = self.labels[o_addr] + except KeyError: + default_label = o_addr else: for o_addr in tx['outputs']: if self.is_mine(o_addr) and not self.is_change(o_addr): @@ -910,10 +909,10 @@ class Wallet: if o_addr: dest_label = self.labels.get(o_addr) - if dest_label: - default_label = 'at: ' + dest_label - else: - default_label = 'at: ' + o_addr + try: + default_label = self.labels[o_addr] + except KeyError: + default_label = o_addr tx['default_label'] = default_label diff --git a/setup.py b/setup.py index 770c59af..1a92365d 100644 --- a/setup.py +++ b/setup.py @@ -29,10 +29,7 @@ if platform.system() != 'Windows' and platform.system() != 'Darwin': data_files += [ (util.appdata_dir(), ["data/background.png", "data/style.css"]), (os.path.join(util.appdata_dir(), "icons"), [ - "data/icons/accounts.png", "data/icons/confirmed.png", - "data/icons/expand.png", - "data/icons/interact.png", "data/icons/unconfirmed.png" ]) ] @@ -62,7 +59,7 @@ setup(name = "Electrum", author = "thomasv", author_email = "thomasv@gitorious", license = "GNU GPLv3", - url = "http://ecdsa/electrum", + url = "http://electrum-desktop.com", long_description = """Lightweight Bitcoin Wallet""" )