Skip to content

Commit

Permalink
GUI: Option to remove asset name for GUIUtil::formatAssetAmount
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr authored and instagibbs committed Apr 9, 2019
1 parent 85f0ad8 commit 2953613
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,14 @@ QString boostPathToQString(const fs::path &path)
return QString::fromStdString(path.string(utf8));
}

QString formatAssetAmount(const CAsset& asset, const CAmount& amount, const int bitcoin_unit, BitcoinUnits::SeparatorStyle separators)
QString formatAssetAmount(const CAsset& asset, const CAmount& amount, const int bitcoin_unit, BitcoinUnits::SeparatorStyle separators, bool include_asset_name)
{
if (asset == Params().GetConsensus().pegged_asset) {
return BitcoinUnits::formatWithUnit(bitcoin_unit, amount, false, separators);
if (include_asset_name) {
return BitcoinUnits::formatWithUnit(bitcoin_unit, amount, false, separators);
} else {
return BitcoinUnits::format(bitcoin_unit, amount, false, separators);
}
}

qlonglong whole = amount / 100000000;
Expand All @@ -790,7 +794,9 @@ QString formatAssetAmount(const CAsset& asset, const CAmount& amount, const int
if (asset_label.empty()) {
asset_label = asset.GetHex();
}
str += QString(" ") + QString::fromStdString(asset_label);
if (include_asset_name) {
str += QString(" ") + QString::fromStdString(asset_label);
}
return str;
}

Expand Down
2 changes: 1 addition & 1 deletion src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ namespace GUIUtil
QString boostPathToQString(const fs::path &path);

/* Format an amount of assets in a user-friendly style */
QString formatAssetAmount(const CAsset&, const CAmount&, int bitcoin_unit, BitcoinUnits::SeparatorStyle);
QString formatAssetAmount(const CAsset&, const CAmount&, int bitcoin_unit, BitcoinUnits::SeparatorStyle, bool include_asset_name = true);

/* Format one or more asset+amounts in a user-friendly style */
QString formatMultiAssetAmount(const CAmountMap&, int bitcoin_unit, BitcoinUnits::SeparatorStyle, QString line_separator);
Expand Down

0 comments on commit 2953613

Please sign in to comment.