qml: add setters to QEAmount to allow updating values, as replacing QEAmount instances
makes Qt unhappy in a few cases when it still holds references to the old instance, which happened occasionally in e.g. qetxfinalizer
This commit is contained in:
@@ -36,6 +36,12 @@ class QEAmount(QObject):
|
|||||||
return 0
|
return 0
|
||||||
return self._amount_sat
|
return self._amount_sat
|
||||||
|
|
||||||
|
@satsInt.setter
|
||||||
|
def satsInt(self, sats):
|
||||||
|
if self._amount_sat != sats:
|
||||||
|
self._amount_sat = sats
|
||||||
|
self.valueChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty('qint64', notify=valueChanged)
|
@pyqtProperty('qint64', notify=valueChanged)
|
||||||
def msatsInt(self):
|
def msatsInt(self):
|
||||||
if self._amount_msat is None: # should normally be defined when accessing this property
|
if self._amount_msat is None: # should normally be defined when accessing this property
|
||||||
@@ -43,6 +49,12 @@ class QEAmount(QObject):
|
|||||||
return 0
|
return 0
|
||||||
return self._amount_msat
|
return self._amount_msat
|
||||||
|
|
||||||
|
@msatsInt.setter
|
||||||
|
def msatsInt(self, msats):
|
||||||
|
if self._amount_msat != msats:
|
||||||
|
self._amount_msat = msats
|
||||||
|
self.valueChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty(str, notify=valueChanged)
|
@pyqtProperty(str, notify=valueChanged)
|
||||||
def satsStr(self):
|
def satsStr(self):
|
||||||
return str(self._amount_sat)
|
return str(self._amount_sat)
|
||||||
@@ -55,6 +67,12 @@ class QEAmount(QObject):
|
|||||||
def isMax(self):
|
def isMax(self):
|
||||||
return self._is_max
|
return self._is_max
|
||||||
|
|
||||||
|
@isMax.setter
|
||||||
|
def isMax(self, ismax):
|
||||||
|
if self._is_max != ismax:
|
||||||
|
self._is_max = ismax
|
||||||
|
self.valueChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty(bool, notify=valueChanged)
|
@pyqtProperty(bool, notify=valueChanged)
|
||||||
def isEmpty(self):
|
def isEmpty(self):
|
||||||
return not(self._is_max or self._amount_sat or self._amount_msat)
|
return not(self._is_max or self._amount_sat or self._amount_msat)
|
||||||
|
|||||||
Reference in New Issue
Block a user