qml: piechart from wallet.get_balances_for_piechart
This commit is contained in:
@@ -56,14 +56,21 @@ Pane {
|
|||||||
implicitHeight: 220 // TODO: sane value dependent on screen
|
implicitHeight: 220 // TODO: sane value dependent on screen
|
||||||
innerOffset: 6
|
innerOffset: 6
|
||||||
function updateSlices() {
|
function updateSlices() {
|
||||||
var totalB = Daemon.currentWallet.totalBalance.satsInt
|
var p = Daemon.currentWallet.getBalancesForPiechart()
|
||||||
var onchainB = Daemon.currentWallet.confirmedBalance.satsInt
|
var total = p['total']
|
||||||
var frozenB = Daemon.currentWallet.frozenBalance.satsInt
|
|
||||||
var lnB = Daemon.currentWallet.lightningBalance.satsInt
|
|
||||||
piechart.slices = [
|
piechart.slices = [
|
||||||
{ v: lnB/totalB, color: constants.colorPiechartLightning, text: 'Lightning' },
|
{ v: p['lightning']/total,
|
||||||
{ v: (onchainB-frozenB)/totalB, color: constants.colorPiechartOnchain, text: 'On-chain' },
|
color: constants.colorPiechartLightning, text: qsTr('Lightning') },
|
||||||
{ v: frozenB/totalB, color: constants.colorPiechartFrozen, text: 'On-chain (frozen)' },
|
{ v: p['confirmed']/total,
|
||||||
|
color: constants.colorPiechartOnchain, text: 'On-chain' },
|
||||||
|
{ v: p['frozen']/total,
|
||||||
|
color: constants.colorPiechartFrozen, text: 'On-chain (frozen)' },
|
||||||
|
{ v: p['unconfirmed']/total,
|
||||||
|
color: constants.colorPiechartFrozen, text: 'Unconfirmed' },
|
||||||
|
{ v: p['unmatured']/total,
|
||||||
|
color: constants.colorPiechartFrozen, text: 'Unmatured' },
|
||||||
|
{ v: p['f_lightning']/total,
|
||||||
|
color: constants.colorPiechartLightningFrozen, text: 'Frozen Lightning' },
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +161,7 @@ Pane {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonContainer {
|
ButtonContainer {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
FlatButton {
|
FlatButton {
|
||||||
|
|||||||
@@ -48,7 +48,11 @@ Item {
|
|||||||
|
|
||||||
property color colorPiechartOnchain: Qt.darker(Material.accentColor, 1.50)
|
property color colorPiechartOnchain: Qt.darker(Material.accentColor, 1.50)
|
||||||
property color colorPiechartFrozen: 'gray'
|
property color colorPiechartFrozen: 'gray'
|
||||||
property color colorPiechartLightning: 'orange' //Qt.darker(Material.accentColor, 1.20)
|
property color colorPiechartLightning: 'orange'
|
||||||
|
property color colorPiechartLightningFrozen: Qt.darker('orange', 1.20)
|
||||||
|
property color colorPiechartUnconfirmed: Qt.darker(Material.accentColor, 2.00)
|
||||||
|
property color colorPiechartUnmatured: 'magenta'
|
||||||
|
|
||||||
property color colorPiechartParticipant: 'gray'
|
property color colorPiechartParticipant: 'gray'
|
||||||
property color colorPiechartSignature: 'yellow'
|
property color colorPiechartSignature: 'yellow'
|
||||||
|
|
||||||
|
|||||||
@@ -745,3 +745,16 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
tx = self.wallet.db.get_transaction(txid)
|
tx = self.wallet.db.get_transaction(txid)
|
||||||
txqr = tx.to_qr_data()
|
txqr = tx.to_qr_data()
|
||||||
return [str(tx), txqr[0], txqr[1]]
|
return [str(tx), txqr[0], txqr[1]]
|
||||||
|
|
||||||
|
@pyqtSlot(result='QVariantMap')
|
||||||
|
def getBalancesForPiechart(self):
|
||||||
|
confirmed, unconfirmed, unmatured, frozen, lightning, f_lightning = balances = self.wallet.get_balances_for_piechart()
|
||||||
|
return {
|
||||||
|
'confirmed': confirmed,
|
||||||
|
'unconfirmed': unconfirmed,
|
||||||
|
'unmatured': unmatured,
|
||||||
|
'frozen': frozen,
|
||||||
|
'lightning': int(lightning),
|
||||||
|
'f_lightning': int(f_lightning),
|
||||||
|
'total': sum([int(x) for x in list(balances)])
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user