electrum

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

commit 26e966c3e0284b3a93faf617ccca6ceb945f3a6d
parent 52d41a4339c70a367e8555f4d9ad6eff22561290
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 24 Feb 2018 17:34:08 +0100

hide address and history toolbars, move functions back into menu.

Diffstat:
Mgui/qt/address_list.py | 2+-
Mgui/qt/history_list.py | 87+++++++++++++++++++++++++++++++++++--------------------------------------------
Mgui/qt/main_window.py | 25++++++++++++++++---------
Mgui/qt/util.py | 18++++++++++++++++++
4 files changed, 73 insertions(+), 59 deletions(-)

diff --git a/gui/qt/address_list.py b/gui/qt/address_list.py @@ -49,7 +49,7 @@ class AddressList(MyTreeWidget): for t in [_('All'), _('Unused'), _('Funded'), _('Used')]: self.used_button.addItem(t) - def get_list_header(self): + def create_toolbar_buttons(self): return QLabel(_("Filter:")), self.change_button, self.used_button def refresh_headers(self): diff --git a/gui/qt/history_list.py b/gui/qt/history_list.py @@ -82,11 +82,14 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop): def on_combo(self, x): s = self.period_combo.itemText(x) + x = s == _('Custom') + self.start_button.setEnabled(x) + self.end_button.setEnabled(x) if s == _('All'): self.start_timestamp = None self.end_timestamp = None - elif s == _('Custom'): - start_date = self.select_date() + self.start_button.setText("-") + self.end_button.setText("-") else: try: year = int(s) @@ -96,64 +99,46 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop): end_date = datetime.datetime(year+1, 1, 1) self.start_timestamp = time.mktime(start_date.timetuple()) self.end_timestamp = time.mktime(end_date.timetuple()) + self.start_button.setText(_('From') + ' ' + str(start_date)) + self.end_button.setText(_('To') + ' ' + str(end_date)) self.update() - def get_list_header(self): + def create_toolbar_buttons(self): self.period_combo = QComboBox() + self.start_button = QPushButton('-') + self.start_button.pressed.connect(self.select_start_date) + self.start_button.setEnabled(False) + self.end_button = QPushButton('-') + self.end_button.pressed.connect(self.select_end_date) + self.end_button.setEnabled(False) self.period_combo.addItems([_('All'), _('Custom')]) self.period_combo.activated.connect(self.on_combo) - self.summary_button = QPushButton(_('Summary')) - self.summary_button.pressed.connect(self.show_summary) - self.export_button = QPushButton(_('Export')) - self.export_button.pressed.connect(self.export_history_dialog) - self.plot_button = QPushButton(_('Plot')) - self.plot_button.pressed.connect(self.plot_history_dialog) - return self.period_combo, self.summary_button, self.export_button, self.plot_button + return self.period_combo, self.start_button, self.end_button - def select_date(self): - h = self.summary - d = WindowModalDialog(self, _("Custom dates")) + def select_start_date(self): + self.start_timestamp = self.select_date(self.start_button) + self.update() + + def select_end_date(self): + self.end_timestamp = self.select_date(self.end_button) + self.update() + + def select_date(self, button): + d = WindowModalDialog(self, _("Select date")) d.setMinimumSize(600, 150) - d.b = True - d.start_date = None - d.end_date = None + d.date = None vbox = QVBoxLayout() - grid = QGridLayout() - start_edit = QPushButton() - def on_start(): - start_edit.setText('') - d.b = True - d.start_date = None - start_edit.pressed.connect(on_start) - def on_end(): - end_edit.setText('') - d.b = False - d.end_date = None - end_edit = QPushButton() - end_edit.pressed.connect(on_end) - grid.addWidget(QLabel(_("Start date")), 0, 0) - grid.addWidget(start_edit, 0, 1) - grid.addWidget(QLabel(_("End date")), 1, 0) - grid.addWidget(end_edit, 1, 1) def on_date(date): - ts = time.mktime(date.toPyDate().timetuple()) - if d.b: - d.start_date = ts - start_edit.setText(date.toString()) - else: - d.end_date = ts - end_edit.setText(date.toString()) + d.date = date cal = QCalendarWidget() cal.setGridVisible(True) cal.clicked[QDate].connect(on_date) - vbox.addLayout(grid) vbox.addWidget(cal) vbox.addLayout(Buttons(OkButton(d), CancelButton(d))) d.setLayout(vbox) if d.exec_(): - self.start_timestamp = d.start_date - self.end_timestamp = d.end_date - self.update() + button.setText(d.date.toString()) + return time.mktime(d.date.toPyDate().timetuple()) def show_summary(self): h = self.summary @@ -162,7 +147,7 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop): if start_date is None or end_date is None: self.parent.show_message(_("Nothing to summarize.")) return - format_amount = lambda x: self.parent.format_amount(x) + ' ' + self.parent.base_unit() + format_amount = lambda x: self.parent.format_amount(x.value) + ' ' + self.parent.base_unit() d = WindowModalDialog(self, _("Summary")) d.setMinimumSize(600, 150) vbox = QVBoxLayout() @@ -172,13 +157,17 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop): grid.addWidget(QLabel(_("End")), 1, 0) grid.addWidget(QLabel(end_date.isoformat(' ')), 1, 1) grid.addWidget(QLabel(_("Initial balance")), 2, 0) - grid.addWidget(QLabel(format_amount(h['start_balance'].value)), 2, 1) + grid.addWidget(QLabel(format_amount(h['start_balance'])), 2, 1) grid.addWidget(QLabel(str(h.get('start_fiat_balance'))), 2, 2) grid.addWidget(QLabel(_("Final balance")), 4, 0) - grid.addWidget(QLabel(format_amount(h['end_balance'].value)), 4, 1) + grid.addWidget(QLabel(format_amount(h['end_balance'])), 4, 1) grid.addWidget(QLabel(str(h.get('end_fiat_balance'))), 4, 2) - grid.addWidget(QLabel(_("Income")), 6, 0) - grid.addWidget(QLabel(str(h.get('fiat_income'))), 6, 2) + grid.addWidget(QLabel(_("Income")), 5, 0) + grid.addWidget(QLabel(format_amount(h.get('income'))), 5, 1) + grid.addWidget(QLabel(str(h.get('fiat_income'))), 5, 2) + grid.addWidget(QLabel(_("Expenditures")), 6, 0) + grid.addWidget(QLabel(format_amount(h.get('expenditures'))), 6, 1) + grid.addWidget(QLabel(str(h.get('fiat_expenditures'))), 6, 2) grid.addWidget(QLabel(_("Capital gains")), 7, 0) grid.addWidget(QLabel(str(h.get('capital_gains'))), 7, 2) grid.addWidget(QLabel(_("Unrealized gains")), 8, 0) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -475,9 +475,16 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.import_address_menu = wallet_menu.addAction(_("Import addresses"), self.import_addresses) wallet_menu.addSeparator() + history_menu = wallet_menu.addMenu(_("&Addresses")) + history_menu.addAction(_("&Filter"), lambda: self.address_list.show_toolbar(True)) labels_menu = wallet_menu.addMenu(_("&Labels")) labels_menu.addAction(_("&Import"), self.do_import_labels) labels_menu.addAction(_("&Export"), self.do_export_labels) + history_menu = wallet_menu.addMenu(_("&History")) + history_menu.addAction(_("&Filter"), lambda: self.history_list.show_toolbar(True)) + history_menu.addAction(_("&Summary"), self.history_list.show_summary) + history_menu.addAction(_("&Plot"), self.history_list.plot_history_dialog) + history_menu.addAction(_("&Export"), self.history_list.export_history_dialog) contacts_menu = wallet_menu.addMenu(_("Contacts")) contacts_menu.addAction(_("&New"), self.new_contact_dialog) contacts_menu.addAction(_("Import"), lambda: self.contact_list.import_contacts()) @@ -747,7 +754,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): from .history_list import HistoryList self.history_list = l = HistoryList(self) l.searchable_list = l - return self.create_list_tab(l, l.get_list_header()) + return self.create_list_tab(l, l.create_toolbar()) def show_address(self, addr): from . import address_dialog @@ -1720,26 +1727,22 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.utxo_list.update() self.update_fee() - def create_list_tab(self, l, list_header=None): + def create_list_tab(self, l, toolbar=None): w = QWidget() w.searchable_list = l vbox = QVBoxLayout() w.setLayout(vbox) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) - if list_header: - hbox = QHBoxLayout() - for b in list_header: - hbox.addWidget(b) - hbox.addStretch() - vbox.addLayout(hbox) + if toolbar: + vbox.addLayout(toolbar) vbox.addWidget(l) return w def create_addresses_tab(self): from .address_list import AddressList self.address_list = l = AddressList(self) - return self.create_list_tab(l, l.get_list_header()) + return self.create_list_tab(l, l.create_toolbar()) def create_utxo_tab(self): from .utxo_list import UTXOList @@ -1967,6 +1970,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.update_lock_icon() def toggle_search(self): + tab = self.tabs.currentWidget() + #if hasattr(tab, 'searchable_list'): + # tab.searchable_list.toggle_toolbar() + #return self.search_box.setHidden(not self.search_box.isHidden()) if not self.search_box.isHidden(): self.search_box.setFocus(1) diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -516,6 +516,24 @@ class MyTreeWidget(QTreeWidget): item.setHidden(all([item.text(column).lower().find(p) == -1 for column in columns])) + def create_toolbar(self): + hbox = QHBoxLayout() + buttons = self.create_toolbar_buttons() + for b in buttons: + b.setVisible(False) + hbox.addWidget(b) + hide_button = QPushButton('x') + hide_button.setVisible(False) + hide_button.pressed.connect(lambda: self.show_toolbar(False)) + self.toolbar_buttons = buttons + (hide_button,) + hbox.addStretch() + hbox.addWidget(hide_button) + return hbox + + def show_toolbar(self, x): + for b in self.toolbar_buttons: + b.setVisible(x) + class ButtonsWidget(QWidget):