diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7be6943..1a81f29 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -470,18 +470,27 @@ void MainWindow::onWalletOpened() { 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(WalletManager::displayAmount(spendable, false)); - if (balance > spendable) { - label_str += QString(" (+%1 XMR unconfirmed)").arg(WalletManager::displayAmount(balance - spendable, false)); + bool hide = config()->get(Config::hideBalance).toBool(); + int displaySetting = config()->get(Config::balanceDisplay).toInt(); + + QString balance_str = "Balance: "; + if (hide) { + balance_str += "HIDDEN"; + } + else if (displaySetting == Config::totalBalance) { + balance_str += QString("%1 XMR").arg(WalletManager::displayAmount(balance, false)); + } + else if (displaySetting == Config::spendable || displaySetting == Config::spendablePlusUnconfirmed) { + balance_str += QString("%1 XMR").arg(WalletManager::displayAmount(spendable, false)); + + if (displaySetting == Config::spendablePlusUnconfirmed && balance > spendable) { + balance_str += QString(" (+%1 XMR unconfirmed)").arg(WalletManager::displayAmount(balance - spendable, false)); + } } - if (hide) - label_str = "Balance: HIDDEN"; - m_statusLabelBalance->setToolTip("Click for details"); - m_statusLabelBalance->setText(label_str); + m_statusLabelBalance->setText(balance_str); m_balanceWidget->setHidden(hide); } diff --git a/src/settings.cpp b/src/settings.cpp index 2843318..845f7a3 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -74,7 +74,11 @@ Settings::Settings(QSharedPointer ctx, QWidget *parent) connect(ui->comboBox_dateFormat, QOverload::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_dateFormatChanged); connect(ui->comboBox_timeFormat, QOverload::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_timeFormatChanged); - // setup preferred fiat currency combobox + // Balance display combobox + ui->comboBox_balanceDisplay->setCurrentIndex(config()->get(Config::balanceDisplay).toInt()); + connect(ui->comboBox_balanceDisplay, QOverload::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_balanceDisplayChanged); + + // Preferred fiat currency combobox QStringList fiatCurrencies; for (int index = 0; index < ui->comboBox_fiatCurrency->count(); index++) fiatCurrencies << ui->comboBox_fiatCurrency->itemText(index); @@ -155,6 +159,11 @@ void Settings::comboBox_timeFormatChanged(int pos) { config()->set(Config::timeFormat, m_timeFormats.at(pos)); } +void Settings::comboBox_balanceDisplayChanged(int pos) { + config()->set(Config::balanceDisplay, pos); + m_ctx->updateBalance(); +} + void Settings::copyToClipboard() { ui->textLogs->copy(); } diff --git a/src/settings.h b/src/settings.h index 10c0ba6..24d01db 100644 --- a/src/settings.h +++ b/src/settings.h @@ -40,6 +40,7 @@ public slots: void comboBox_amountPrecisionChanged(int pos); void comboBox_dateFormatChanged(int pos); void comboBox_timeFormatChanged(int pos); + void comboBox_balanceDisplayChanged(int pos); void comboBox_blockExplorerChanged(int pos); void comboBox_redditFrontendChanged(int pos); diff --git a/src/settings.ui b/src/settings.ui index 71787f3..533afdf 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -162,6 +162,32 @@ + + + + Balance display: + + + + + + + + Total balance + + + + + Spendable balance (+ unconfirmed balance) + + + + + Spendable balance + + + + diff --git a/src/utils/config.cpp b/src/utils/config.cpp index ee0e732..7d84f00 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -57,6 +57,7 @@ static const QHash configStrings = { {Config::amountPrecision, {QS("amountPrecision"), 12}}, {Config::dateFormat, {QS("dateFormat"), "yyyy-MM-dd"}}, {Config::timeFormat, {QS("timeFormat"), "HH:mm"}}, + {Config::balanceDisplay, {QS("balanceDisplay"), Config::BalanceDisplay::spendablePlusUnconfirmed}}, {Config::multiBroadcast, {QS("multiBroadcast"), true}}, {Config::warnOnExternalLink,{QS("warnOnExternalLink"), true}}, diff --git a/src/utils/config.h b/src/utils/config.h index d810328..1a5f922 100644 --- a/src/utils/config.h +++ b/src/utils/config.h @@ -55,6 +55,7 @@ public: amountPrecision, dateFormat, timeFormat, + balanceDisplay, multiBroadcast, warnOnExternalLink, @@ -78,6 +79,12 @@ public: allTor }; + enum BalanceDisplay { + totalBalance = 0, + spendablePlusUnconfirmed, + spendable + }; + ~Config() override; QVariant get(ConfigKey key); QString getFileName();