diff --git a/gui/qt/history_list.py b/gui/qt/history_list.py index 7a43d068c..f8e0b07ed 100644 --- a/gui/qt/history_list.py +++ b/gui/qt/history_list.py @@ -72,9 +72,10 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop): fx = self.parent.fx if fx and fx.show_history(): headers.extend(['%s '%fx.ccy + _('Value')]) - headers.extend(['%s '%fx.ccy + _('Acquisition price')]) - headers.extend(['%s '%fx.ccy + _('Capital Gains')]) self.editable_columns |= {6} + if fx.get_history_capital_gains_config(): + headers.extend(['%s '%fx.ccy + _('Acquisition price')]) + headers.extend(['%s '%fx.ccy + _('Capital Gains')]) else: self.editable_columns -= {6} self.update_headers(headers) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 435134285..f01b00794 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -2846,6 +2846,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): # Fiat Currency hist_checkbox = QCheckBox() + hist_capgains_checkbox = QCheckBox() fiat_address_checkbox = QCheckBox() ccy_combo = QComboBox() ex_combo = QComboBox() @@ -2867,6 +2868,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): if not self.fx: return fiat_address_checkbox.setChecked(self.fx.get_fiat_address_config()) + def update_history_capgains_cb(): + if not self.fx: return + hist_capgains_checkbox.setChecked(self.fx.get_history_capital_gains_config()) + hist_capgains_checkbox.setEnabled(hist_checkbox.isChecked()) + def update_exchanges(): if not self.fx: return b = self.fx.is_enabled() @@ -2905,6 +2911,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): if self.fx.is_enabled() and checked: # reset timeout to get historical rates self.fx.timeout = 0 + update_history_capgains_cb() + + def on_history_capgains(checked): + if not self.fx: return + self.fx.set_history_capital_gains_config(checked) + self.history_list.refresh_headers() def on_fiat_address(checked): if not self.fx: return @@ -2914,16 +2926,19 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): update_currencies() update_history_cb() + update_history_capgains_cb() update_fiat_address_cb() update_exchanges() ccy_combo.currentIndexChanged.connect(on_currency) hist_checkbox.stateChanged.connect(on_history) + hist_capgains_checkbox.stateChanged.connect(on_history_capgains) fiat_address_checkbox.stateChanged.connect(on_fiat_address) ex_combo.currentIndexChanged.connect(on_exchange) fiat_widgets = [] fiat_widgets.append((QLabel(_('Fiat currency')), ccy_combo)) fiat_widgets.append((QLabel(_('Show history rates')), hist_checkbox)) + fiat_widgets.append((QLabel(_('Show capital gains in history')), hist_capgains_checkbox)) fiat_widgets.append((QLabel(_('Show Fiat balance for addresses')), fiat_address_checkbox)) fiat_widgets.append((QLabel(_('Source')), ex_combo)) diff --git a/lib/exchange_rate.py b/lib/exchange_rate.py index 5c0193153..7b9c86cc8 100644 --- a/lib/exchange_rate.py +++ b/lib/exchange_rate.py @@ -451,6 +451,12 @@ class FxThread(ThreadJob): def set_history_config(self, b): self.config.set_key('history_rates', bool(b)) + def get_history_capital_gains_config(self): + return bool(self.config.get('history_rates_capital_gains', False)) + + def set_history_capital_gains_config(self, b): + self.config.set_key('history_rates_capital_gains', bool(b)) + def get_fiat_address_config(self): return bool(self.config.get('fiat_address'))