Browse Source

Use real text rather than image-rendered text for unit selector

The width of each unit is measured to set a fixed width for the widget, and the color is set to match the other status widgets.
0.13
Luke Dashjr 10 years ago
parent
commit
dd3f69736a
  1. 3
      src/Makefile.qt.include
  2. 3
      src/qt/bitcoin.qrc
  3. 12
      src/qt/bitcoingui.cpp
  4. BIN
      src/qt/res/icons/unit_btc.png
  5. BIN
      src/qt/res/icons/unit_mbtc.png
  6. BIN
      src/qt/res/icons/unit_ubtc.png

3
src/Makefile.qt.include

@ -256,9 +256,6 @@ RES_ICONS = \
qt/res/icons/tx_input.png \ qt/res/icons/tx_input.png \
qt/res/icons/tx_output.png \ qt/res/icons/tx_output.png \
qt/res/icons/tx_mined.png \ qt/res/icons/tx_mined.png \
qt/res/icons/unit_btc.png \
qt/res/icons/unit_mbtc.png \
qt/res/icons/unit_ubtc.png \
qt/res/icons/verify.png qt/res/icons/verify.png
BITCOIN_QT_CPP = \ BITCOIN_QT_CPP = \

3
src/qt/bitcoin.qrc

@ -35,9 +35,6 @@
<file alias="tx_input">res/icons/tx_input.png</file> <file alias="tx_input">res/icons/tx_input.png</file>
<file alias="tx_output">res/icons/tx_output.png</file> <file alias="tx_output">res/icons/tx_output.png</file>
<file alias="tx_inout">res/icons/tx_inout.png</file> <file alias="tx_inout">res/icons/tx_inout.png</file>
<file alias="unit_btc">res/icons/unit_btc.png</file>
<file alias="unit_mbtc">res/icons/unit_mbtc.png</file>
<file alias="unit_ubtc">res/icons/unit_ubtc.png</file>
<file alias="lock_closed">res/icons/lock_closed.png</file> <file alias="lock_closed">res/icons/lock_closed.png</file>
<file alias="lock_open">res/icons/lock_open.png</file> <file alias="lock_open">res/icons/lock_open.png</file>
<file alias="key">res/icons/key.png</file> <file alias="key">res/icons/key.png</file>

12
src/qt/bitcoingui.cpp

@ -1027,6 +1027,16 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() :
{ {
createContextMenu(); createContextMenu();
setToolTip(tr("Unit to show amounts in. Click to select another unit.")); setToolTip(tr("Unit to show amounts in. Click to select another unit."));
QList<BitcoinUnits::Unit> units = BitcoinUnits::availableUnits();
int max_width = 0;
const QFontMetrics fm(font());
foreach (const BitcoinUnits::Unit unit, units)
{
max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit)));
}
setMinimumSize(max_width, 0);
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
setStyleSheet(QString("QLabel { color : %1 }").arg(SingleColor().name()));
} }
/** So that it responds to button clicks */ /** So that it responds to button clicks */
@ -1066,7 +1076,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)
{ {
setPixmap(SingleColorIcon(":/icons/unit_" + BitcoinUnits::id(newUnits)).pixmap(31,STATUSBAR_ICONSIZE)); setText(BitcoinUnits::name(newUnits));
} }
/** Shows context menu with Display Unit options by the mouse coordinates */ /** Shows context menu with Display Unit options by the mouse coordinates */

BIN
src/qt/res/icons/unit_btc.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

BIN
src/qt/res/icons/unit_mbtc.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
src/qt/res/icons/unit_ubtc.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Loading…
Cancel
Save