diff --git a/programs/light_client/Asset.cpp b/programs/light_client/Asset.cpp index 545bbd3a..d2401e41 100644 --- a/programs/light_client/Asset.cpp +++ b/programs/light_client/Asset.cpp @@ -4,6 +4,13 @@ #include +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) { if (asset.id.instance() != id()) diff --git a/programs/light_client/Asset.hpp b/programs/light_client/Asset.hpp index ef34a473..67ee720e 100644 --- a/programs/light_client/Asset.hpp +++ b/programs/light_client/Asset.hpp @@ -30,6 +30,8 @@ public: power *= 10; 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); diff --git a/programs/light_client/qml/TransactionConfirmationForm.qml b/programs/light_client/qml/TransactionConfirmationForm.qml index e2ae5e4b..49d2d3c4 100644 --- a/programs/light_client/qml/TransactionConfirmationForm.qml +++ b/programs/light_client/qml/TransactionConfirmationForm.qml @@ -29,4 +29,39 @@ FormBase { trx.appendOperation(arg[op]) 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 + } }