From dd3f69736a6e25044b8802057ba9982592575cdb Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 27 Dec 2014 19:19:51 +0000 Subject: 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. --- src/Makefile.qt.include | 3 --- src/qt/bitcoin.qrc | 3 --- src/qt/bitcoingui.cpp | 12 +++++++++++- src/qt/res/icons/unit_btc.png | Bin 1318 -> 0 bytes src/qt/res/icons/unit_mbtc.png | Bin 1407 -> 0 bytes src/qt/res/icons/unit_ubtc.png | Bin 1369 -> 0 bytes 6 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 src/qt/res/icons/unit_btc.png delete mode 100644 src/qt/res/icons/unit_mbtc.png delete mode 100644 src/qt/res/icons/unit_ubtc.png diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 8b782b2ad5..806b4f9556 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -256,9 +256,6 @@ RES_ICONS = \ qt/res/icons/tx_input.png \ qt/res/icons/tx_output.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 BITCOIN_QT_CPP = \ diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index b54f2e2ed6..bcaf95d91c 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -35,9 +35,6 @@ res/icons/tx_input.png res/icons/tx_output.png res/icons/tx_inout.png - res/icons/unit_btc.png - res/icons/unit_mbtc.png - res/icons/unit_ubtc.png res/icons/lock_closed.png res/icons/lock_open.png res/icons/key.png diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 3b8fd985a0..2810eae052 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1027,6 +1027,16 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() : { createContextMenu(); setToolTip(tr("Unit to show amounts in. Click to select another unit.")); + QList 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 */ @@ -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 */ 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 */ diff --git a/src/qt/res/icons/unit_btc.png b/src/qt/res/icons/unit_btc.png deleted file mode 100644 index f3246fa999..0000000000 Binary files a/src/qt/res/icons/unit_btc.png and /dev/null differ diff --git a/src/qt/res/icons/unit_mbtc.png b/src/qt/res/icons/unit_mbtc.png deleted file mode 100644 index 4e82b65274..0000000000 Binary files a/src/qt/res/icons/unit_mbtc.png and /dev/null differ diff --git a/src/qt/res/icons/unit_ubtc.png b/src/qt/res/icons/unit_ubtc.png deleted file mode 100644 index 96b254770d..0000000000 Binary files a/src/qt/res/icons/unit_ubtc.png and /dev/null differ -- cgit v1.2.3