diff --git a/src/dialog/txconfdialog.cpp b/src/dialog/txconfdialog.cpp index a57e6b7..fef1c6c 100644 --- a/src/dialog/txconfdialog.cpp +++ b/src/dialog/txconfdialog.cpp @@ -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 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 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()); diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index 1764aa5..44f597c 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -576,4 +576,15 @@ QString Utils::amountToCurrencyString(double amount, const QString ¤cyCode return locale.toCurrencyString(amount, "$"); return locale.toCurrencyString(amount); +} + +int Utils::maxLength(const QVector &array) { + int maxLength = 0; + for (const auto &str: array) { + auto length = str.length(); + if (length > maxLength) { + maxLength = length; + } + } + return maxLength; } \ No newline at end of file diff --git a/src/utils/utils.h b/src/utils/utils.h index c6fb832..049a3c0 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -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 &array); template static QString QtEnumToString (const QEnum value)