Browse Source

qenetwork: add height and fiat changed signals

patch-4
Sander van Grieken 3 years ago
parent
commit
3a8e787b58
  1. 34
      electrum/gui/qml/qenetwork.py

34
electrum/gui/qml/qenetwork.py

@ -15,62 +15,64 @@ class QENetwork(QObject):
register_callback(self.on_proxy_set, ['proxy_set']) register_callback(self.on_proxy_set, ['proxy_set'])
register_callback(self.on_status, ['status']) register_callback(self.on_status, ['status'])
register_callback(self.on_fee_histogram, ['fee_histogram']) register_callback(self.on_fee_histogram, ['fee_histogram'])
register_callback(self.on_fiat, ['on_quotes','on_history'])
_logger = get_logger(__name__) _logger = get_logger(__name__)
networkUpdated = pyqtSignal() networkUpdated = pyqtSignal()
blockchainUpdated = pyqtSignal() blockchainUpdated = pyqtSignal()
heightChanged = pyqtSignal([int], arguments=['height'])
defaultServerChanged = pyqtSignal() defaultServerChanged = pyqtSignal()
proxySet = pyqtSignal() proxySet = pyqtSignal()
proxyChanged = pyqtSignal() proxyChanged = pyqtSignal()
statusChanged = pyqtSignal() statusChanged = pyqtSignal()
feeHistogramUpdated = pyqtSignal() feeHistogramUpdated = pyqtSignal()
fiatUpdated = pyqtSignal()
dataChanged = pyqtSignal() # dummy to silence warnings # shared signal for static properties
dataChanged = pyqtSignal()
_num_updates = 0
_server = ""
_height = 0 _height = 0
_status = "" _status = ""
def on_network_updated(self, event, *args): def on_network_updated(self, event, *args):
self._num_updates = self._num_updates + 1
self.networkUpdated.emit() self.networkUpdated.emit()
def on_blockchain_updated(self, event, *args): def on_blockchain_updated(self, event, *args):
self._logger.info('chainupdate: ' + str(event) + str(args)) if self._height != self.network.get_local_height():
self._height = self.network.get_local_height() self._height = self.network.get_local_height()
self._logger.debug('new height: %d' % self._height)
self.heightChanged.emit(self._height)
self.blockchainUpdated.emit() self.blockchainUpdated.emit()
def on_default_server_changed(self, event, *args): def on_default_server_changed(self, event, *args):
netparams = self.network.get_parameters()
self._server = str(netparams.server)
self.defaultServerChanged.emit() self.defaultServerChanged.emit()
def on_proxy_set(self, event, *args): def on_proxy_set(self, event, *args):
self._logger.info('proxy set') self._logger.debug('proxy set')
self.proxySet.emit() self.proxySet.emit()
def on_status(self, event, *args): def on_status(self, event, *args):
self._logger.debug('status updated: %s' % self.network.connection_status) self._logger.debug('status updated: %s' % self.network.connection_status)
self._status = self.network.connection_status if self._status != self.network.connection_status:
self.statusChanged.emit() self._status = self.network.connection_status
self.statusChanged.emit()
def on_fee_histogram(self, event, *args): def on_fee_histogram(self, event, *args):
self._logger.debug('fee histogram updated') self._logger.debug('fee histogram updated')
self.feeHistogramUpdated.emit() self.feeHistogramUpdated.emit()
@pyqtProperty(int,notify=networkUpdated) def on_fiat(self, event, *args):
def updates(self): self._logger.debug('new fiat quotes')
return self._num_updates self.fiatUpdated.emit()
@pyqtProperty(int,notify=blockchainUpdated) @pyqtProperty(int,notify=heightChanged)
def height(self): def height(self):
return self._height return self._height
@pyqtProperty('QString',notify=defaultServerChanged) @pyqtProperty('QString',notify=defaultServerChanged)
def server(self): def server(self):
return self._server return str(self.network.get_parameters().server)
@server.setter @server.setter
def server(self, server): def server(self, server):

Loading…
Cancel
Save