Merge pull request 'Make balance display more concise' (#278) from tobtoht/feather:concise_balance into master

Reviewed-on: feather/feather#278
remotes/1691844314220217825/master
tobtoht 3 years ago
commit 5b679da427

@ -665,9 +665,9 @@ void MainWindow::onBalanceUpdated(quint64 balance, quint64 spendable) {
qDebug() << Q_FUNC_INFO;
bool hide = config()->get(Config::hideBalance).toBool();
QString label_str = QString("Balance: %1 XMR").arg(QString::number(spendable / globals::cdiv, 'f'));
QString label_str = QString("Balance: %1 XMR").arg(Utils::balanceFormat(spendable));
if (balance > spendable)
label_str += QString(" (+%1 XMR unconfirmed)").arg(QString::number((balance - spendable) / globals::cdiv, 'f'));
label_str += QString(" (+%1 XMR unconfirmed)").arg(Utils::balanceFormat(balance - spendable));
if (hide)
label_str = "Balance: HIDDEN";
@ -842,7 +842,7 @@ void MainWindow::create_status_bar() {
this->statusBar()->addWidget(m_statusLabelNetStats);
m_statusLabelBalance = new ClickableLabel(this);
m_statusLabelBalance->setText("Balance: 0.00 XMR");
m_statusLabelBalance->setText("Balance: 0 XMR");
m_statusLabelBalance->setTextInteractionFlags(Qt::TextSelectableByMouse);
this->statusBar()->addPermanentWidget(m_statusLabelBalance);
connect(m_statusLabelBalance, &ClickableLabel::clicked, this, &MainWindow::showBalanceDialog);

@ -13,6 +13,7 @@
#include "utils/config.h"
#include "utils/tails.h"
#include "utils/whonix.h"
#include "globals.h"
// Application log for current session
QVector<logMessage> applicationLog = QVector<logMessage>(); // todo: replace with ring buffer
@ -532,3 +533,12 @@ int Utils::maxLength(const QVector<QString> &array) {
}
return maxLength;
}
QString Utils::balanceFormat(quint64 balance) {
QString str = QString::number(balance / globals::cdiv, 'f', 4);
str.remove(QRegExp("0+$"));
str.remove(QRegExp("\\.$"));
return str;
}

@ -98,6 +98,7 @@ public:
static QString amountToCurrencyString(double amount, const QString &currencyCode);
static int maxLength(const QVector<QString> &array);
static QMap<QString, QLocale> localeCache;
static QString balanceFormat(quint64 balance);
template<typename QEnum>
static QString QtEnumToString (const QEnum value)

Loading…
Cancel
Save