Browse Source

[qt] change µBTC to bits

* Now that we have bip176, change "µBTC" to the more colloquial "bits"

* We retain the `µBTC (bits)` description in dropdowns and status bars.
  The more concise "bits" is used when appended to numbers.

Signed-off-by: William Casarin <jb55@jb55.com>
0.16
William Casarin 7 years ago
parent
commit
275b2eeed4
  1. 6
      src/qt/bitcoingui.cpp
  2. 21
      src/qt/bitcoinunits.cpp
  3. 4
      src/qt/bitcoinunits.h
  4. 2
      src/qt/recentrequeststablemodel.cpp

6
src/qt/bitcoingui.cpp

@ -1206,7 +1206,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *pl
const QFontMetrics fm(font()); const QFontMetrics fm(font());
for (const BitcoinUnits::Unit unit : units) 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); setMinimumSize(max_width, 0);
setAlignment(Qt::AlignRight | Qt::AlignVCenter); setAlignment(Qt::AlignRight | Qt::AlignVCenter);
@ -1225,7 +1225,7 @@ void UnitDisplayStatusBarControl::createContextMenu()
menu = new QMenu(this); menu = new QMenu(this);
for (BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) 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)); menuAction->setData(QVariant(u));
menu->addAction(menuAction); menu->addAction(menuAction);
} }
@ -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 */ /** 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) void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits)
{ {
setText(BitcoinUnits::name(newUnits)); setText(BitcoinUnits::longName(newUnits));
} }
/** Shows context menu with Display Unit options by the mouse coordinates */ /** Shows context menu with Display Unit options by the mouse coordinates */

21
src/qt/bitcoinunits.cpp

@ -36,24 +36,33 @@ bool BitcoinUnits::valid(int unit)
} }
} }
QString BitcoinUnits::name(int unit) QString BitcoinUnits::longName(int unit)
{ {
switch(unit) switch(unit)
{ {
case BTC: return QString("BTC"); case BTC: return QString("BTC");
case mBTC: return QString("mBTC"); case mBTC: return QString("mBTC");
case uBTC: return QString::fromUtf8("μBTC"); case uBTC: return QString::fromUtf8("µBTC (bits)");
default: return QString("???"); 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) QString BitcoinUnits::description(int unit)
{ {
switch(unit) switch(unit)
{ {
case BTC: return QString("Bitcoins"); case BTC: return QString("Bitcoins");
case mBTC: return QString("Milli-Bitcoins (1 / 1" THIN_SP_UTF8 "000)"); 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("???"); default: return QString("???");
} }
} }
@ -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) 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) QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
@ -176,7 +185,7 @@ QString BitcoinUnits::getAmountColumnTitle(int unit)
QString amountTitle = QObject::tr("Amount"); QString amountTitle = QObject::tr("Amount");
if (BitcoinUnits::valid(unit)) if (BitcoinUnits::valid(unit))
{ {
amountTitle += " ("+BitcoinUnits::name(unit) + ")"; amountTitle += " ("+BitcoinUnits::shortName(unit) + ")";
} }
return amountTitle; return amountTitle;
} }
@ -197,7 +206,7 @@ QVariant BitcoinUnits::data(const QModelIndex &index, int role) const
{ {
case Qt::EditRole: case Qt::EditRole:
case Qt::DisplayRole: case Qt::DisplayRole:
return QVariant(name(unit)); return QVariant(longName(unit));
case Qt::ToolTipRole: case Qt::ToolTipRole:
return QVariant(description(unit)); return QVariant(description(unit));
case UnitRole: case UnitRole:

4
src/qt/bitcoinunits.h

@ -76,8 +76,10 @@ public:
static QList<Unit> availableUnits(); static QList<Unit> availableUnits();
//! Is unit ID valid? //! Is unit ID valid?
static bool valid(int unit); static bool valid(int unit);
//! Long name
static QString longName(int unit);
//! Short name //! Short name
static QString name(int unit); static QString shortName(int unit);
//! Longer description //! Longer description
static QString description(int unit); static QString description(int unit);
//! Number of Satoshis (1e-8) per unit //! Number of Satoshis (1e-8) per unit

2
src/qt/recentrequeststablemodel.cpp

@ -123,7 +123,7 @@ void RecentRequestsTableModel::updateAmountColumnTitle()
/** Gets title for amount column including current display unit if optionsModel reference available. */ /** Gets title for amount column including current display unit if optionsModel reference available. */
QString RecentRequestsTableModel::getAmountTitle() 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 QModelIndex RecentRequestsTableModel::index(int row, int column, const QModelIndex &parent) const

Loading…
Cancel
Save