mirror of
https://git.wownero.com/wowlet/wowlet.git
synced 2024-08-15 01:03:14 +00:00
Merge pull request 'TxConfDialog: Justify amounts' (#234) from tobtoht/feather:txconf_justify_amounts into master
Reviewed-on: https://git.wownero.com/feather/feather/pulls/234
This commit is contained in:
commit
2c0b04559e
3 changed files with 25 additions and 7 deletions
|
@ -32,16 +32,22 @@ TxConfDialog::TxConfDialog(AppContext *ctx, PendingTransaction *tx, const QStrin
|
|||
};
|
||||
|
||||
QString amount = WalletManager::displayAmount(tx->amount());
|
||||
QString amount_fiat = convert(tx->amount() / globals::cdiv);
|
||||
ui->label_amount->setText(QString("%1 (%2 %3)").arg(amount, amount_fiat, preferredCur));
|
||||
|
||||
QString fee = WalletManager::displayAmount(tx->fee());
|
||||
QString fee_fiat = convert(tx->fee() / globals::cdiv);
|
||||
ui->label_fee->setText(QString("%1 (%2 %3)").arg(fee, fee_fiat, preferredCur));
|
||||
|
||||
QString total = WalletManager::displayAmount(tx->amount() + tx->fee());
|
||||
QVector<QString> amounts = {amount, fee, total};
|
||||
int maxLength = Utils::maxLength(amounts);
|
||||
std::for_each(amounts.begin(), amounts.end(), [maxLength](QString& amount){amount = amount.rightJustified(maxLength, ' ');});
|
||||
|
||||
QString amount_fiat = convert(tx->amount() / globals::cdiv);
|
||||
QString fee_fiat = convert(tx->fee() / globals::cdiv);
|
||||
QString total_fiat = convert((tx->amount() + tx->fee()) / globals::cdiv);
|
||||
ui->label_total->setText(QString("%1 (%2 %3)").arg(total, total_fiat, preferredCur));
|
||||
QVector<QString> amounts_fiat = {amount_fiat, fee_fiat, total_fiat};
|
||||
int maxLengthFiat = Utils::maxLength(amounts_fiat);
|
||||
std::for_each(amounts_fiat.begin(), amounts_fiat.end(), [maxLengthFiat](QString& amount){amount = amount.rightJustified(maxLengthFiat, ' ');});
|
||||
|
||||
ui->label_amount->setText(QString("%1 (%2 %3)").arg(amounts[0], amounts_fiat[0], preferredCur));
|
||||
ui->label_fee->setText(QString("%1 (%2 %3)").arg(amounts[1], amounts_fiat[1], preferredCur));
|
||||
ui->label_total->setText(QString("%1 (%2 %3)").arg(amounts[2], amounts_fiat[2], preferredCur));
|
||||
|
||||
ui->label_address->setText(ModelUtils::displayAddress(address, 2));
|
||||
ui->label_address->setFont(ModelUtils::getMonospaceFont());
|
||||
|
|
|
@ -577,3 +577,14 @@ QString Utils::amountToCurrencyString(double amount, const QString ¤cyCode
|
|||
|
||||
return locale.toCurrencyString(amount);
|
||||
}
|
||||
|
||||
int Utils::maxLength(const QVector<QString> &array) {
|
||||
int maxLength = 0;
|
||||
for (const auto &str: array) {
|
||||
auto length = str.length();
|
||||
if (length > maxLength) {
|
||||
maxLength = length;
|
||||
}
|
||||
}
|
||||
return maxLength;
|
||||
}
|
|
@ -96,6 +96,7 @@ public:
|
|||
static double roundSignificant(double N, double n);
|
||||
static QString formatBytes(quint64 bytes);
|
||||
static QString amountToCurrencyString(double amount, const QString ¤cyCode);
|
||||
static int maxLength(const QVector<QString> &array);
|
||||
|
||||
template<typename QEnum>
|
||||
static QString QtEnumToString (const QEnum value)
|
||||
|
|
Loading…
Reference in a new issue