[GUI] Early work on visualizing a transaction
Super ugly right now, just showing that the data is actually there
This commit is contained in:
parent
5d7ae4e6a8
commit
2c77085bdf
3 changed files with 44 additions and 0 deletions
|
|
@ -4,6 +4,13 @@
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
QString Asset::formatAmount(qint64 amount) const
|
||||||
|
{
|
||||||
|
graphene::chain::asset_object ao;
|
||||||
|
ao.precision = m_precision;
|
||||||
|
return QString::fromStdString(ao.amount_to_string(amount));
|
||||||
|
}
|
||||||
|
|
||||||
void Asset::update(const graphene::chain::asset_object& asset)
|
void Asset::update(const graphene::chain::asset_object& asset)
|
||||||
{
|
{
|
||||||
if (asset.id.instance() != id())
|
if (asset.id.instance() != id())
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ public:
|
||||||
power *= 10;
|
power *= 10;
|
||||||
return power;
|
return power;
|
||||||
}
|
}
|
||||||
|
/// Given an amount like 123401, return "1234.01"
|
||||||
|
Q_INVOKABLE QString formatAmount(qint64 amount) const;
|
||||||
|
|
||||||
void update(const graphene::chain::asset_object& asset);
|
void update(const graphene::chain::asset_object& asset);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,4 +29,39 @@ FormBase {
|
||||||
trx.appendOperation(arg[op])
|
trx.appendOperation(arg[op])
|
||||||
console.log(JSON.stringify(trx))
|
console.log(JSON.stringify(trx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: transactionDelegate
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: Scaling.cm(10)
|
||||||
|
height: childrenRect.height + Scaling.cm(1)
|
||||||
|
radius: Scaling.mm(3)
|
||||||
|
color: "#EEEEEE"
|
||||||
|
border.width: Scaling.mm(.25)
|
||||||
|
border.color: "black"
|
||||||
|
|
||||||
|
Column {
|
||||||
|
y: Scaling.cm(.5)
|
||||||
|
x: y
|
||||||
|
width: parent.width - Scaling.cm(1)
|
||||||
|
Repeater {
|
||||||
|
model: trx.operations
|
||||||
|
Label {
|
||||||
|
property Asset transferAsset: app.model.getAsset(modelData.amountType)
|
||||||
|
property Asset feeAsset: app.model.getAsset(modelData.feeType)
|
||||||
|
text: qsTr("Transfer %1 %2 from %3 to %4\nFee: %5 %6").arg(transferAsset.formatAmount(modelData.amount))
|
||||||
|
.arg(transferAsset.symbol)
|
||||||
|
.arg(app.model.getAccount(modelData.sender).name)
|
||||||
|
.arg(app.model.getAccount(modelData.receiver).name)
|
||||||
|
.arg(feeAsset.formatAmount(modelData.fee))
|
||||||
|
.arg(feeAsset.symbol)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loader {
|
||||||
|
sourceComponent: trx && Array.prototype.slice.call(trx.operations).length > 0? transactionDelegate : undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue