Skip to content

Commit e20704b

Browse files
fanquakeluke-jr
authored andcommitted
Replace some instances of formatWithUnit with formatHtmlWithUnit
Strings in a HTML context should be using formatHtmlWithUnit. Github-Pull: bitcoin#7255 Rebased-From: 5fdf32d
1 parent 6f8346d commit e20704b

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

src/qt/bitcoinunits.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
111111
}
112112

113113

114-
// TODO: Review all remaining calls to BitcoinUnits::formatWithUnit to
115-
// TODO: determine whether the output is used in a plain text context
116-
// TODO: or an HTML context (and replace with
117-
// TODO: BtcoinUnits::formatHtmlWithUnit in the latter case). Hopefully
118-
// TODO: there aren't instances where the result could be used in
119-
// TODO: either context.
120-
121114
// NOTE: Using formatWithUnit in an HTML context risks wrapping
122115
// quantities at the thousands separator. More subtly, it also results
123116
// in a standard space rather than a thin space, due to a bug in Qt's

src/qt/bitcoinunits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class BitcoinUnits: public QAbstractListModel
8888
static QString format(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
8989
//! Format as string (with unit)
9090
static QString formatWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
91+
//! Format as HTML string (with unit)
9192
static QString formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
9293
//! Parse string to coin amount
9394
static bool parse(int unit, const QString &value, CAmount *val_out);

src/qt/coincontroldialog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,14 +637,14 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
637637

638638
// tool tips
639639
QString toolTip1 = tr("This label turns red if the transaction size is greater than 1000 bytes.") + "<br /><br />";
640-
toolTip1 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CWallet::GetRequiredFee(1000))) + "<br /><br />";
640+
toolTip1 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, CWallet::GetRequiredFee(1000))) + "<br /><br />";
641641
toolTip1 += tr("Can vary +/- 1 byte per input.");
642642

643643
QString toolTip2 = tr("Transactions with higher priority are more likely to get included into a block.") + "<br /><br />";
644644
toolTip2 += tr("This label turns red if the priority is smaller than \"medium\".") + "<br /><br />";
645-
toolTip2 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CWallet::GetRequiredFee(1000)));
645+
toolTip2 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, CWallet::GetRequiredFee(1000)));
646646

647-
QString toolTip3 = tr("This label turns red if any recipient receives an amount smaller than %1.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, ::minRelayTxFee.GetFee(546)));
647+
QString toolTip3 = tr("This label turns red if any recipient receives an amount smaller than %1.").arg(BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, ::minRelayTxFee.GetFee(546)));
648648

649649
// how many satoshis the estimated fee can vary per byte we guess wrong
650650
double dFeeVary;

src/qt/receiverequestdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void ReceiveRequestDialog::update()
144144
html += "<a href=\""+uri+"\">" + GUIUtil::HtmlEscape(uri) + "</a><br>";
145145
html += "<b>"+tr("Address")+"</b>: " + GUIUtil::HtmlEscape(info.address) + "<br>";
146146
if(info.amount)
147-
html += "<b>"+tr("Amount")+"</b>: " + BitcoinUnits::formatWithUnit(model->getDisplayUnit(), info.amount) + "<br>";
147+
html += "<b>"+tr("Amount")+"</b>: " + BitcoinUnits::formatHtmlWithUnit(model->getDisplayUnit(), info.amount) + "<br>";
148148
if(!info.label.isEmpty())
149149
html += "<b>"+tr("Label")+"</b>: " + GUIUtil::HtmlEscape(info.label) + "<br>";
150150
if(!info.message.isEmpty())

0 commit comments

Comments
 (0)