Skip to content

Commit eeb6d52

Browse files
committed
Merge #12035: [qt] change µBTC to bits
ebcee1d bips: add bip176 (Bits Denomination) (William Casarin) 275b2ee [qt] change µBTC to bits (William Casarin) Pull request description: Now that we have bip176, change "µBTC" to the more colloquial "bits" Tree-SHA512: eba5e5f89c392728a4f0a3bd81a9779a117b8d72a490390fd031d4e7cc56c2bfee0016aba7ef9535903e8cf2262ce46497283424e378906d0e3bf5b0d2d981c7
2 parents a1136f0 + ebcee1d commit eeb6d52

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

doc/bips.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.13.0**):
3434
* [`BIP 147`](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki): NULLDUMMY softfork as of **v0.13.1** ([PR 8636](https://github.com/bitcoin/bitcoin/pull/8636) and [PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)).
3535
* [`BIP 152`](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki): Compact block transfer and related optimizations are used as of **v0.13.0** ([PR 8068](https://github.com/bitcoin/bitcoin/pull/8068)).
3636
* [`BIP 159`](https://github.com/bitcoin/bips/blob/master/bip-0159.mediawiki): NODE_NETWORK_LIMITED service bit [signaling only] is supported as of **v0.16.0** ([PR 10740](https://github.com/bitcoin/bitcoin/pull/10740)).
37+
* [`BIP 176`](https://github.com/bitcoin/bips/blob/master/bip-0176.mediawiki): Bits Denomination [QT only] is supported as of **v0.16.0** ([PR 12035](https://github.com/bitcoin/bitcoin/pull/12035)).

src/qt/bitcoingui.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *pl
12061206
const QFontMetrics fm(font());
12071207
for (const BitcoinUnits::Unit unit : units)
12081208
{
1209-
max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit)));
1209+
max_width = qMax(max_width, fm.width(BitcoinUnits::longName(unit)));
12101210
}
12111211
setMinimumSize(max_width, 0);
12121212
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@@ -1225,7 +1225,7 @@ void UnitDisplayStatusBarControl::createContextMenu()
12251225
menu = new QMenu(this);
12261226
for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
12271227
{
1228-
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
1228+
QAction *menuAction = new QAction(QString(BitcoinUnits::longName(u)), this);
12291229
menuAction->setData(QVariant(u));
12301230
menu->addAction(menuAction);
12311231
}
@@ -1250,7 +1250,7 @@ void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *_optionsModel)
12501250
/** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
12511251
void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits)
12521252
{
1253-
setText(BitcoinUnits::name(newUnits));
1253+
setText(BitcoinUnits::longName(newUnits));
12541254
}
12551255

12561256
/** Shows context menu with Display Unit options by the mouse coordinates */

src/qt/bitcoinunits.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,33 @@ bool BitcoinUnits::valid(int unit)
3636
}
3737
}
3838

39-
QString BitcoinUnits::name(int unit)
39+
QString BitcoinUnits::longName(int unit)
4040
{
4141
switch(unit)
4242
{
4343
case BTC: return QString("BTC");
4444
case mBTC: return QString("mBTC");
45-
case uBTC: return QString::fromUtf8("μBTC");
45+
case uBTC: return QString::fromUtf8("µBTC (bits)");
4646
default: return QString("???");
4747
}
4848
}
4949

50+
QString BitcoinUnits::shortName(int unit)
51+
{
52+
switch(unit)
53+
{
54+
case uBTC: return QString::fromUtf8("bits");
55+
default: return longName(unit);
56+
}
57+
}
58+
5059
QString BitcoinUnits::description(int unit)
5160
{
5261
switch(unit)
5362
{
5463
case BTC: return QString("Bitcoins");
5564
case mBTC: return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)");
56-
case uBTC: return QString("Micro-Bitcoins (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
65+
case uBTC: return QString("Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
5766
default: return QString("???");
5867
}
5968
}
@@ -121,7 +130,7 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
121130

122131
QString BitcoinUnits::formatWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
123132
{
124-
return format(unit, amount, plussign, separators) + QString(" ") + name(unit);
133+
return format(unit, amount, plussign, separators) + QString(" ") + shortName(unit);
125134
}
126135

127136
QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
@@ -176,7 +185,7 @@ QString BitcoinUnits::getAmountColumnTitle(int unit)
176185
QString amountTitle = QObject::tr("Amount");
177186
if (BitcoinUnits::valid(unit))
178187
{
179-
amountTitle += " ("+BitcoinUnits::name(unit) + ")";
188+
amountTitle += " ("+BitcoinUnits::shortName(unit) + ")";
180189
}
181190
return amountTitle;
182191
}
@@ -197,7 +206,7 @@ QVariant BitcoinUnits::data(const QModelIndex &index, int role) const
197206
{
198207
case Qt::EditRole:
199208
case Qt::DisplayRole:
200-
return QVariant(name(unit));
209+
return QVariant(longName(unit));
201210
case Qt::ToolTipRole:
202211
return QVariant(description(unit));
203212
case UnitRole:

src/qt/bitcoinunits.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ class BitcoinUnits: public QAbstractListModel
7676
static QList<Unit> availableUnits();
7777
//! Is unit ID valid?
7878
static bool valid(int unit);
79+
//! Long name
80+
static QString longName(int unit);
7981
//! Short name
80-
static QString name(int unit);
82+
static QString shortName(int unit);
8183
//! Longer description
8284
static QString description(int unit);
8385
//! Number of Satoshis (1e-8) per unit

src/qt/recentrequeststablemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void RecentRequestsTableModel::updateAmountColumnTitle()
123123
/** Gets title for amount column including current display unit if optionsModel reference available. */
124124
QString RecentRequestsTableModel::getAmountTitle()
125125
{
126-
return (this->walletModel->getOptionsModel() != nullptr) ? tr("Requested") + " ("+BitcoinUnits::name(this->walletModel->getOptionsModel()->getDisplayUnit()) + ")" : "";
126+
return (this->walletModel->getOptionsModel() != nullptr) ? tr("Requested") + " ("+BitcoinUnits::shortName(this->walletModel->getOptionsModel()->getDisplayUnit()) + ")" : "";
127127
}
128128

129129
QModelIndex RecentRequestsTableModel::index(int row, int column, const QModelIndex &parent) const

0 commit comments

Comments
 (0)