qml: render reserved channel capacity in a darker tone, take frozen into account
This commit is contained in:
committed by
accumulator
parent
4900d01344
commit
2cf4cc1978
@@ -170,6 +170,10 @@ Pane {
|
|||||||
capacity: channeldetails.capacity
|
capacity: channeldetails.capacity
|
||||||
localCapacity: channeldetails.localCapacity
|
localCapacity: channeldetails.localCapacity
|
||||||
remoteCapacity: channeldetails.remoteCapacity
|
remoteCapacity: channeldetails.remoteCapacity
|
||||||
|
canSend: channeldetails.canSend
|
||||||
|
canReceive: channeldetails.canReceive
|
||||||
|
frozenForSending: channeldetails.frozenForSending
|
||||||
|
frozenForReceiving: channeldetails.frozenForReceiving
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
|||||||
@@ -41,8 +41,10 @@ Item {
|
|||||||
property color colorProgress: '#ffffff80'
|
property color colorProgress: '#ffffff80'
|
||||||
property color colorDone: '#ff80ff80'
|
property color colorDone: '#ff80ff80'
|
||||||
|
|
||||||
property color colorLightningLocal: "blue"
|
property color colorLightningLocal: "#6060ff"
|
||||||
|
property color colorLightningLocalReserve: "#0000a0"
|
||||||
property color colorLightningRemote: "yellow"
|
property color colorLightningRemote: "yellow"
|
||||||
|
property color colorLightningRemoteReserve: Qt.darker(colorLightningRemote, 1.5)
|
||||||
property color colorChannelOpen: "#ff80ff80"
|
property color colorChannelOpen: "#ff80ff80"
|
||||||
|
|
||||||
property color colorPiechartTotal: Material.accentColor
|
property color colorPiechartTotal: Material.accentColor
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ Item {
|
|||||||
property Amount capacity
|
property Amount capacity
|
||||||
property Amount localCapacity
|
property Amount localCapacity
|
||||||
property Amount remoteCapacity
|
property Amount remoteCapacity
|
||||||
|
property Amount canSend
|
||||||
|
property Amount canReceive
|
||||||
|
property bool frozenForSending: false
|
||||||
|
property bool frozenForReceiving: false
|
||||||
|
|
||||||
height: 10
|
height: 10
|
||||||
implicitWidth: 100
|
implicitWidth: 100
|
||||||
@@ -16,32 +20,56 @@ Item {
|
|||||||
onWidthChanged: {
|
onWidthChanged: {
|
||||||
var cap = capacity.satsInt * 1000
|
var cap = capacity.satsInt * 1000
|
||||||
var twocap = cap * 2
|
var twocap = cap * 2
|
||||||
b1.width = width * (cap - localCapacity.msatsInt) / twocap
|
l1.width = width * (cap - localCapacity.msatsInt) / twocap
|
||||||
b2.width = width * localCapacity.msatsInt / twocap
|
if (frozenForSending) {
|
||||||
b3.width = width * remoteCapacity.msatsInt / twocap
|
l2.width = width * localCapacity.msatsInt / twocap
|
||||||
b4.width = width * (cap - remoteCapacity.msatsInt) / twocap
|
l3.width = 0
|
||||||
|
} else {
|
||||||
|
l2.width = width * (localCapacity.msatsInt - canSend.msatsInt) / twocap
|
||||||
|
l3.width = width * canSend.msatsInt / twocap
|
||||||
|
}
|
||||||
|
if (frozenForReceiving) {
|
||||||
|
r3.width = 0
|
||||||
|
r2.width = width * remoteCapacity.msatsInt / twocap
|
||||||
|
} else {
|
||||||
|
r3.width = width * canReceive.msatsInt / twocap
|
||||||
|
r2.width = width * (remoteCapacity.msatsInt - canReceive.msatsInt) / twocap
|
||||||
|
}
|
||||||
|
r1.width = width * (cap - remoteCapacity.msatsInt) / twocap
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: b1
|
id: l1
|
||||||
x: 0
|
x: 0
|
||||||
height: parent.height
|
height: parent.height
|
||||||
color: 'gray'
|
color: 'gray'
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: b2
|
id: l2
|
||||||
anchors.left: b1.right
|
anchors.left: l1.right
|
||||||
|
height: parent.height
|
||||||
|
color: constants.colorLightningLocalReserve
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
id: l3
|
||||||
|
anchors.left: l2.right
|
||||||
height: parent.height
|
height: parent.height
|
||||||
color: constants.colorLightningLocal
|
color: constants.colorLightningLocal
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: b3
|
id: r3
|
||||||
anchors.left: b2.right
|
anchors.left: l3.right
|
||||||
height: parent.height
|
height: parent.height
|
||||||
color: constants.colorLightningRemote
|
color: constants.colorLightningRemote
|
||||||
}
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: b4
|
id: r2
|
||||||
anchors.left: b3.right
|
anchors.left: r3.right
|
||||||
|
height: parent.height
|
||||||
|
color: constants.colorLightningRemoteReserve
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
id: r1
|
||||||
|
anchors.left: r2.right
|
||||||
height: parent.height
|
height: parent.height
|
||||||
color: 'gray'
|
color: 'gray'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ ItemDelegate {
|
|||||||
capacity: model.capacity
|
capacity: model.capacity
|
||||||
localCapacity: model.local_capacity
|
localCapacity: model.local_capacity
|
||||||
remoteCapacity: model.remote_capacity
|
remoteCapacity: model.remote_capacity
|
||||||
|
canSend: model.can_send
|
||||||
|
canReceive: model.can_receive
|
||||||
|
frozenForSending: model.send_frozen
|
||||||
|
frozenForReceiving: model.receive_frozen
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
|||||||
_logger = get_logger(__name__)
|
_logger = get_logger(__name__)
|
||||||
|
|
||||||
# define listmodel rolemap
|
# define listmodel rolemap
|
||||||
_ROLE_NAMES=('cid','state','state_code','initiator','capacity','can_send',
|
_ROLE_NAMES=('cid', 'state', 'state_code', 'initiator', 'capacity', 'can_send',
|
||||||
'can_receive','l_csv_delay','r_csv_delay','send_frozen','receive_frozen',
|
'can_receive', 'l_csv_delay', 'r_csv_delay', 'send_frozen', 'receive_frozen',
|
||||||
'type','node_id','node_alias','short_cid','funding_tx','is_trampoline',
|
'type', 'node_id', 'node_alias', 'short_cid', 'funding_tx', 'is_trampoline',
|
||||||
'is_backup', 'is_imported', 'local_capacity', 'remote_capacity')
|
'is_backup', 'is_imported', 'local_capacity', 'remote_capacity')
|
||||||
_ROLE_KEYS = range(Qt.UserRole, Qt.UserRole + len(_ROLE_NAMES))
|
_ROLE_KEYS = range(Qt.UserRole, Qt.UserRole + len(_ROLE_NAMES))
|
||||||
_ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES]))
|
_ROLE_MAP = dict(zip(_ROLE_KEYS, [bytearray(x.encode()) for x in _ROLE_NAMES]))
|
||||||
@@ -93,12 +93,16 @@ class QEChannelListModel(QAbstractListModel, QtEventListener):
|
|||||||
item['can_receive'] = QEAmount()
|
item['can_receive'] = QEAmount()
|
||||||
item['local_capacity'] = QEAmount()
|
item['local_capacity'] = QEAmount()
|
||||||
item['remote_capacity'] = QEAmount()
|
item['remote_capacity'] = QEAmount()
|
||||||
|
item['send_frozen'] = True
|
||||||
|
item['receive_frozen'] = True
|
||||||
item['is_imported'] = lnc.is_imported
|
item['is_imported'] = lnc.is_imported
|
||||||
else:
|
else:
|
||||||
item['can_send'] = QEAmount(amount_msat=lnc.available_to_spend(LOCAL))
|
item['can_send'] = QEAmount(amount_msat=lnc.available_to_spend(LOCAL))
|
||||||
item['can_receive'] = QEAmount(amount_msat=lnc.available_to_spend(REMOTE))
|
item['can_receive'] = QEAmount(amount_msat=lnc.available_to_spend(REMOTE))
|
||||||
item['local_capacity'] = QEAmount(amount_msat=lnc.balance(LOCAL))
|
item['local_capacity'] = QEAmount(amount_msat=lnc.balance(LOCAL))
|
||||||
item['remote_capacity'] = QEAmount(amount_msat=lnc.balance(REMOTE))
|
item['remote_capacity'] = QEAmount(amount_msat=lnc.balance(REMOTE))
|
||||||
|
item['send_frozen'] = lnc.is_frozen_for_sending()
|
||||||
|
item['receive_frozen'] = lnc.is_frozen_for_receiving()
|
||||||
item['is_imported'] = False
|
item['is_imported'] = False
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user