fix --offline mode in Qt GUI
This commit is contained in:
parent
fb3e09c24e
commit
eb4018de1c
|
@ -57,10 +57,10 @@ class HistoryList(MyTreeWidget):
|
||||||
self.setColumnHidden(1, True)
|
self.setColumnHidden(1, True)
|
||||||
|
|
||||||
def refresh_headers(self):
|
def refresh_headers(self):
|
||||||
ccy = self.parent.fx.ccy
|
|
||||||
headers = ['', '', _('Date'), _('Description') , _('Amount'), _('Balance')]
|
headers = ['', '', _('Date'), _('Description') , _('Amount'), _('Balance')]
|
||||||
if self.parent.fx.show_history():
|
fx = self.parent.fx
|
||||||
headers.extend(['%s '%ccy + _('Amount'), '%s '%ccy + _('Balance')])
|
if fx and fx.show_history():
|
||||||
|
headers.extend(['%s '%fx.ccy + _('Amount'), '%s '%fx.ccy + _('Balance')])
|
||||||
self.update_headers(headers)
|
self.update_headers(headers)
|
||||||
|
|
||||||
def get_domain(self):
|
def get_domain(self):
|
||||||
|
@ -75,7 +75,7 @@ class HistoryList(MyTreeWidget):
|
||||||
current_tx = item.data(0, Qt.UserRole).toString() if item else None
|
current_tx = item.data(0, Qt.UserRole).toString() if item else None
|
||||||
self.clear()
|
self.clear()
|
||||||
fx = self.parent.fx
|
fx = self.parent.fx
|
||||||
fx.history_used_spot = False
|
if fx: fx.history_used_spot = False
|
||||||
for h_item in h:
|
for h_item in h:
|
||||||
tx_hash, height, conf, timestamp, value, balance = h_item
|
tx_hash, height, conf, timestamp, value, balance = h_item
|
||||||
status, status_str = self.wallet.get_tx_status(tx_hash, height, conf, timestamp)
|
status, status_str = self.wallet.get_tx_status(tx_hash, height, conf, timestamp)
|
||||||
|
@ -84,7 +84,7 @@ class HistoryList(MyTreeWidget):
|
||||||
balance_str = self.parent.format_amount(balance, whitespaces=True)
|
balance_str = self.parent.format_amount(balance, whitespaces=True)
|
||||||
label = self.wallet.get_label(tx_hash)
|
label = self.wallet.get_label(tx_hash)
|
||||||
entry = ['', tx_hash, status_str, label, v_str, balance_str]
|
entry = ['', tx_hash, status_str, label, v_str, balance_str]
|
||||||
if fx.show_history():
|
if fx and fx.show_history():
|
||||||
date = timestamp_to_datetime(time.time() if conf <= 0 else timestamp)
|
date = timestamp_to_datetime(time.time() if conf <= 0 else timestamp)
|
||||||
for amount in [value, balance]:
|
for amount in [value, balance]:
|
||||||
text = fx.historical_value_str(amount, date)
|
text = fx.historical_value_str(amount, date)
|
||||||
|
|
|
@ -601,7 +601,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
edit.setStyleSheet(BLACK_FG)
|
edit.setStyleSheet(BLACK_FG)
|
||||||
fiat_e.is_last_edited = (edit == fiat_e)
|
fiat_e.is_last_edited = (edit == fiat_e)
|
||||||
amount = edit.get_amount()
|
amount = edit.get_amount()
|
||||||
rate = self.fx.exchange_rate()
|
rate = self.fx.exchange_rate() if self.fx else None
|
||||||
if rate is None or amount is None:
|
if rate is None or amount is None:
|
||||||
if edit is fiat_e:
|
if edit is fiat_e:
|
||||||
btc_e.setText("")
|
btc_e.setText("")
|
||||||
|
@ -729,8 +729,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
grid.addWidget(self.receive_amount_e, 2, 1)
|
grid.addWidget(self.receive_amount_e, 2, 1)
|
||||||
self.receive_amount_e.textChanged.connect(self.update_receive_qr)
|
self.receive_amount_e.textChanged.connect(self.update_receive_qr)
|
||||||
|
|
||||||
self.fiat_receive_e = AmountEdit(self.fx.get_currency)
|
self.fiat_receive_e = AmountEdit(self.fx.get_currency if self.fx else '')
|
||||||
if not self.fx.is_enabled():
|
if not self.fx or not self.fx.is_enabled():
|
||||||
self.fiat_receive_e.setVisible(False)
|
self.fiat_receive_e.setVisible(False)
|
||||||
grid.addWidget(self.fiat_receive_e, 2, 2, Qt.AlignLeft)
|
grid.addWidget(self.fiat_receive_e, 2, 2, Qt.AlignLeft)
|
||||||
self.connect_fields(self, self.receive_amount_e, self.fiat_receive_e, None)
|
self.connect_fields(self, self.receive_amount_e, self.fiat_receive_e, None)
|
||||||
|
@ -988,8 +988,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
grid.addWidget(amount_label, 4, 0)
|
grid.addWidget(amount_label, 4, 0)
|
||||||
grid.addWidget(self.amount_e, 4, 1)
|
grid.addWidget(self.amount_e, 4, 1)
|
||||||
|
|
||||||
self.fiat_send_e = AmountEdit(self.fx.get_currency)
|
self.fiat_send_e = AmountEdit(self.fx.get_currency if self.fx else '')
|
||||||
if not self.fx.is_enabled():
|
if not self.fx or not self.fx.is_enabled():
|
||||||
self.fiat_send_e.setVisible(False)
|
self.fiat_send_e.setVisible(False)
|
||||||
grid.addWidget(self.fiat_send_e, 4, 2)
|
grid.addWidget(self.fiat_send_e, 4, 2)
|
||||||
self.amount_e.frozen.connect(
|
self.amount_e.frozen.connect(
|
||||||
|
@ -1115,7 +1115,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
'''Recalculate the fee. If the fee was manually input, retain it, but
|
'''Recalculate the fee. If the fee was manually input, retain it, but
|
||||||
still build the TX to see if there are enough funds.
|
still build the TX to see if there are enough funds.
|
||||||
'''
|
'''
|
||||||
if self.config.is_dynfee() and not self.config.has_fee_estimates():
|
if not self.config.get('offline') and self.config.is_dynfee() and not self.config.has_fee_estimates():
|
||||||
self.statusBar().showMessage(_('Waiting for fee estimates...'))
|
self.statusBar().showMessage(_('Waiting for fee estimates...'))
|
||||||
return False
|
return False
|
||||||
freeze_fee = (self.fee_e.isModified()
|
freeze_fee = (self.fee_e.isModified()
|
||||||
|
@ -2315,7 +2315,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
self._do_import(title, msg, lambda x: self.wallet.import_key(x, password))
|
self._do_import(title, msg, lambda x: self.wallet.import_key(x, password))
|
||||||
|
|
||||||
def update_fiat(self):
|
def update_fiat(self):
|
||||||
b = self.fx.is_enabled()
|
b = self.fx and self.fx.is_enabled()
|
||||||
self.fiat_send_e.setVisible(b)
|
self.fiat_send_e.setVisible(b)
|
||||||
self.fiat_receive_e.setVisible(b)
|
self.fiat_receive_e.setVisible(b)
|
||||||
self.history_list.refresh_headers()
|
self.history_list.refresh_headers()
|
||||||
|
@ -2566,6 +2566,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
ex_combo = QComboBox()
|
ex_combo = QComboBox()
|
||||||
|
|
||||||
def update_currencies():
|
def update_currencies():
|
||||||
|
if not self.fx: return
|
||||||
currencies = sorted(self.fx.get_currencies(self.fx.get_history_config()))
|
currencies = sorted(self.fx.get_currencies(self.fx.get_history_config()))
|
||||||
ccy_combo.clear()
|
ccy_combo.clear()
|
||||||
ccy_combo.addItems([_('None')] + currencies)
|
ccy_combo.addItems([_('None')] + currencies)
|
||||||
|
@ -2573,10 +2574,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
ccy_combo.setCurrentIndex(ccy_combo.findText(self.fx.get_currency()))
|
ccy_combo.setCurrentIndex(ccy_combo.findText(self.fx.get_currency()))
|
||||||
|
|
||||||
def update_history_cb():
|
def update_history_cb():
|
||||||
|
if not self.fx: return
|
||||||
hist_checkbox.setChecked(self.fx.get_history_config())
|
hist_checkbox.setChecked(self.fx.get_history_config())
|
||||||
hist_checkbox.setEnabled(self.fx.is_enabled())
|
hist_checkbox.setEnabled(self.fx.is_enabled())
|
||||||
|
|
||||||
def update_exchanges():
|
def update_exchanges():
|
||||||
|
if not self.fx: return
|
||||||
b = self.fx.is_enabled()
|
b = self.fx.is_enabled()
|
||||||
ex_combo.setEnabled(b)
|
ex_combo.setEnabled(b)
|
||||||
if b:
|
if b:
|
||||||
|
@ -2590,6 +2593,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
ex_combo.setCurrentIndex(ex_combo.findText(self.fx.config_exchange()))
|
ex_combo.setCurrentIndex(ex_combo.findText(self.fx.config_exchange()))
|
||||||
|
|
||||||
def on_currency(hh):
|
def on_currency(hh):
|
||||||
|
if not self.fx: return
|
||||||
b = bool(ccy_combo.currentIndex())
|
b = bool(ccy_combo.currentIndex())
|
||||||
ccy = str(ccy_combo.currentText()) if b else None
|
ccy = str(ccy_combo.currentText()) if b else None
|
||||||
self.fx.set_enabled(b)
|
self.fx.set_enabled(b)
|
||||||
|
@ -2601,10 +2605,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
|
|
||||||
def on_exchange(idx):
|
def on_exchange(idx):
|
||||||
exchange = str(ex_combo.currentText())
|
exchange = str(ex_combo.currentText())
|
||||||
if self.fx.is_enabled() and exchange and exchange != self.fx.exchange.name():
|
if self.fx and self.fx.is_enabled() and exchange and exchange != self.fx.exchange.name():
|
||||||
self.fx.set_exchange(exchange)
|
self.fx.set_exchange(exchange)
|
||||||
|
|
||||||
def on_history(checked):
|
def on_history(checked):
|
||||||
|
if not self.fx: return
|
||||||
self.fx.set_history_config(checked)
|
self.fx.set_history_config(checked)
|
||||||
update_exchanges()
|
update_exchanges()
|
||||||
self.history_list.refresh_headers()
|
self.history_list.refresh_headers()
|
||||||
|
|
Loading…
Reference in New Issue