properly count open channels, add open channel to hamburger menu
This commit is contained in:
@@ -25,6 +25,15 @@ Pane {
|
|||||||
icon.source: '../../icons/status_waiting.png'
|
icon.source: '../../icons/status_waiting.png'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MenuSeparator {}
|
||||||
|
MenuItem {
|
||||||
|
icon.color: 'transparent'
|
||||||
|
action: Action {
|
||||||
|
text: qsTr('Open Channel');
|
||||||
|
onTriggered: app.stack.push(Qt.resolvedUrl('OpenChannel.qml'))
|
||||||
|
icon.source: '../../icons/lightning.png'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
@@ -39,7 +48,7 @@ Pane {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.columnSpan: 2
|
Layout.columnSpan: 2
|
||||||
text: qsTr('You have %1 open channels').arg(listview.count)
|
text: qsTr('You have %1 open channels').arg(Daemon.currentWallet.channelModel.numOpenChannels)
|
||||||
color: Material.accentColor
|
color: Material.accentColor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from PyQt5.QtCore import Qt, QAbstractListModel, QModelIndex
|
|||||||
from electrum.logging import get_logger
|
from electrum.logging import get_logger
|
||||||
from electrum.util import Satoshis, register_callback, unregister_callback
|
from electrum.util import Satoshis, register_callback, unregister_callback
|
||||||
from electrum.lnutil import LOCAL, REMOTE
|
from electrum.lnutil import LOCAL, REMOTE
|
||||||
|
from electrum.lnchannel import ChannelState
|
||||||
|
|
||||||
from .qetypes import QEAmount
|
from .qetypes import QEAmount
|
||||||
|
|
||||||
@@ -88,12 +89,18 @@ class QEChannelListModel(QAbstractListModel):
|
|||||||
item['node_alias'] = lnworker.get_node_alias(lnc.node_id) or lnc.node_id.hex()
|
item['node_alias'] = lnworker.get_node_alias(lnc.node_id) or lnc.node_id.hex()
|
||||||
item['short_cid'] = lnc.short_id_for_GUI()
|
item['short_cid'] = lnc.short_id_for_GUI()
|
||||||
item['state'] = lnc.get_state_for_GUI()
|
item['state'] = lnc.get_state_for_GUI()
|
||||||
|
item['state_code'] = lnc.get_state()
|
||||||
item['capacity'] = QEAmount(amount_sat=lnc.get_capacity())
|
item['capacity'] = QEAmount(amount_sat=lnc.get_capacity())
|
||||||
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))
|
||||||
self._logger.debug(repr(item))
|
self._logger.debug(repr(item))
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
numOpenChannelsChanged = pyqtSignal()
|
||||||
|
@pyqtProperty(int, notify=numOpenChannelsChanged)
|
||||||
|
def numOpenChannels(self):
|
||||||
|
return sum([1 if x['state_code'] == ChannelState.OPEN else 0 for x in self.channels])
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def init_model(self):
|
def init_model(self):
|
||||||
self._logger.debug('init_model')
|
self._logger.debug('init_model')
|
||||||
@@ -129,6 +136,7 @@ class QEChannelListModel(QAbstractListModel):
|
|||||||
|
|
||||||
mi = self.createIndex(modelindex, 0)
|
mi = self.createIndex(modelindex, 0)
|
||||||
self.dataChanged.emit(mi, mi, self._ROLE_KEYS)
|
self.dataChanged.emit(mi, mi, self._ROLE_KEYS)
|
||||||
|
self.numOpenChannelsChanged.emit()
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def new_channel(self, cid):
|
def new_channel(self, cid):
|
||||||
@@ -141,3 +149,4 @@ class QEChannelListModel(QAbstractListModel):
|
|||||||
self.beginInsertRows(QModelIndex(), 0, 0)
|
self.beginInsertRows(QModelIndex(), 0, 0)
|
||||||
self.channels.insert(0,item)
|
self.channels.insert(0,item)
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
|
self.numOpenChannelsChanged.emit()
|
||||||
|
|||||||
Reference in New Issue
Block a user