Skip to content

Commit

Permalink
Merge #12035: [qt] change µBTC to bits
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jonasschnelli committed Jan 4, 2018
2 parents a1136f0 + ebcee1d commit eeb6d52
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions doc/bips.md
Expand Up @@ -34,3 +34,4 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.13.0**):
* [`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)).
* [`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)).
* [`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)).
* [`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)).
6 changes: 3 additions & 3 deletions src/qt/bitcoingui.cpp
Expand Up @@ -1206,7 +1206,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *pl
const QFontMetrics fm(font());
for (const BitcoinUnits::Unit unit : units)
{
max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit)));
max_width = qMax(max_width, fm.width(BitcoinUnits::longName(unit)));
}
setMinimumSize(max_width, 0);
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
Expand All @@ -1225,7 +1225,7 @@ void UnitDisplayStatusBarControl::createContextMenu()
menu = new QMenu(this);
for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
{
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
QAction *menuAction = new QAction(QString(BitcoinUnits::longName(u)), this);
menuAction->setData(QVariant(u));
menu->addAction(menuAction);
}
Expand All @@ -1250,7 +1250,7 @@ void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *_optionsModel)
/** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits)
{
setText(BitcoinUnits::name(newUnits));
setText(BitcoinUnits::longName(newUnits));
}

/** Shows context menu with Display Unit options by the mouse coordinates */
Expand Down
21 changes: 15 additions & 6 deletions src/qt/bitcoinunits.cpp
Expand Up @@ -36,24 +36,33 @@ bool BitcoinUnits::valid(int unit)
}
}

QString BitcoinUnits::name(int unit)
QString BitcoinUnits::longName(int unit)
{
switch(unit)
{
case BTC: return QString("BTC");
case mBTC: return QString("mBTC");
case uBTC: return QString::fromUtf8("μBTC");
case uBTC: return QString::fromUtf8("µBTC (bits)");
default: return QString("???");
}
}

QString BitcoinUnits::shortName(int unit)
{
switch(unit)
{
case uBTC: return QString::fromUtf8("bits");
default: return longName(unit);
}
}

QString BitcoinUnits::description(int unit)
{
switch(unit)
{
case BTC: return QString("Bitcoins");
case mBTC: return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)");
case uBTC: return QString("Micro-Bitcoins (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
case uBTC: return QString("Micro-Bitcoins (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
default: return QString("???");
}
}
Expand Down Expand Up @@ -121,7 +130,7 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator

QString BitcoinUnits::formatWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
{
return format(unit, amount, plussign, separators) + QString(" ") + name(unit);
return format(unit, amount, plussign, separators) + QString(" ") + shortName(unit);
}

QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
Expand Down Expand Up @@ -176,7 +185,7 @@ QString BitcoinUnits::getAmountColumnTitle(int unit)
QString amountTitle = QObject::tr("Amount");
if (BitcoinUnits::valid(unit))
{
amountTitle += " ("+BitcoinUnits::name(unit) + ")";
amountTitle += " ("+BitcoinUnits::shortName(unit) + ")";
}
return amountTitle;
}
Expand All @@ -197,7 +206,7 @@ QVariant BitcoinUnits::data(const QModelIndex &index, int role) const
{
case Qt::EditRole:
case Qt::DisplayRole:
return QVariant(name(unit));
return QVariant(longName(unit));
case Qt::ToolTipRole:
return QVariant(description(unit));
case UnitRole:
Expand Down
4 changes: 3 additions & 1 deletion src/qt/bitcoinunits.h
Expand Up @@ -76,8 +76,10 @@ class BitcoinUnits: public QAbstractListModel
static QList<Unit> availableUnits();
//! Is unit ID valid?
static bool valid(int unit);
//! Long name
static QString longName(int unit);
//! Short name
static QString name(int unit);
static QString shortName(int unit);
//! Longer description
static QString description(int unit);
//! Number of Satoshis (1e-8) per unit
Expand Down
2 changes: 1 addition & 1 deletion src/qt/recentrequeststablemodel.cpp
Expand Up @@ -123,7 +123,7 @@ void RecentRequestsTableModel::updateAmountColumnTitle()
/** Gets title for amount column including current display unit if optionsModel reference available. */
QString RecentRequestsTableModel::getAmountTitle()
{
return (this->walletModel->getOptionsModel() != nullptr) ? tr("Requested") + " ("+BitcoinUnits::name(this->walletModel->getOptionsModel()->getDisplayUnit()) + ")" : "";
return (this->walletModel->getOptionsModel() != nullptr) ? tr("Requested") + " ("+BitcoinUnits::shortName(this->walletModel->getOptionsModel()->getDisplayUnit()) + ")" : "";
}

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

0 comments on commit eeb6d52

Please sign in to comment.