mirror of
https://github.com/feather-wallet/feather.git
synced 2025-01-09 12:29:44 +00:00
Settings: balance display
This commit is contained in:
parent
50a77307f4
commit
43d9624f5c
6 changed files with 62 additions and 9 deletions
|
@ -470,18 +470,27 @@ void MainWindow::onWalletOpened() {
|
||||||
|
|
||||||
void MainWindow::onBalanceUpdated(quint64 balance, quint64 spendable) {
|
void MainWindow::onBalanceUpdated(quint64 balance, quint64 spendable) {
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
bool hide = config()->get(Config::hideBalance).toBool();
|
|
||||||
|
|
||||||
QString label_str = QString("Balance: %1 XMR").arg(WalletManager::displayAmount(spendable, false));
|
bool hide = config()->get(Config::hideBalance).toBool();
|
||||||
if (balance > spendable) {
|
int displaySetting = config()->get(Config::balanceDisplay).toInt();
|
||||||
label_str += QString(" (+%1 XMR unconfirmed)").arg(WalletManager::displayAmount(balance - spendable, false));
|
|
||||||
|
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->setToolTip("Click for details");
|
||||||
m_statusLabelBalance->setText(label_str);
|
m_statusLabelBalance->setText(balance_str);
|
||||||
m_balanceWidget->setHidden(hide);
|
m_balanceWidget->setHidden(hide);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,11 @@ Settings::Settings(QSharedPointer<AppContext> ctx, QWidget *parent)
|
||||||
connect(ui->comboBox_dateFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_dateFormatChanged);
|
connect(ui->comboBox_dateFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_dateFormatChanged);
|
||||||
connect(ui->comboBox_timeFormat, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_timeFormatChanged);
|
connect(ui->comboBox_timeFormat, QOverload<int>::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<int>::of(&QComboBox::currentIndexChanged), this, &Settings::comboBox_balanceDisplayChanged);
|
||||||
|
|
||||||
|
// Preferred fiat currency combobox
|
||||||
QStringList fiatCurrencies;
|
QStringList fiatCurrencies;
|
||||||
for (int index = 0; index < ui->comboBox_fiatCurrency->count(); index++)
|
for (int index = 0; index < ui->comboBox_fiatCurrency->count(); index++)
|
||||||
fiatCurrencies << ui->comboBox_fiatCurrency->itemText(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));
|
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() {
|
void Settings::copyToClipboard() {
|
||||||
ui->textLogs->copy();
|
ui->textLogs->copy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public slots:
|
||||||
void comboBox_amountPrecisionChanged(int pos);
|
void comboBox_amountPrecisionChanged(int pos);
|
||||||
void comboBox_dateFormatChanged(int pos);
|
void comboBox_dateFormatChanged(int pos);
|
||||||
void comboBox_timeFormatChanged(int pos);
|
void comboBox_timeFormatChanged(int pos);
|
||||||
|
void comboBox_balanceDisplayChanged(int pos);
|
||||||
|
|
||||||
void comboBox_blockExplorerChanged(int pos);
|
void comboBox_blockExplorerChanged(int pos);
|
||||||
void comboBox_redditFrontendChanged(int pos);
|
void comboBox_redditFrontendChanged(int pos);
|
||||||
|
|
|
@ -162,6 +162,32 @@
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QComboBox" name="comboBox_timeFormat"/>
|
<widget class="QComboBox" name="comboBox_timeFormat"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Balance display:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QComboBox" name="comboBox_balanceDisplay">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Total balance</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Spendable balance (+ unconfirmed balance)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Spendable balance</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -57,6 +57,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
||||||
{Config::amountPrecision, {QS("amountPrecision"), 12}},
|
{Config::amountPrecision, {QS("amountPrecision"), 12}},
|
||||||
{Config::dateFormat, {QS("dateFormat"), "yyyy-MM-dd"}},
|
{Config::dateFormat, {QS("dateFormat"), "yyyy-MM-dd"}},
|
||||||
{Config::timeFormat, {QS("timeFormat"), "HH:mm"}},
|
{Config::timeFormat, {QS("timeFormat"), "HH:mm"}},
|
||||||
|
{Config::balanceDisplay, {QS("balanceDisplay"), Config::BalanceDisplay::spendablePlusUnconfirmed}},
|
||||||
|
|
||||||
{Config::multiBroadcast, {QS("multiBroadcast"), true}},
|
{Config::multiBroadcast, {QS("multiBroadcast"), true}},
|
||||||
{Config::warnOnExternalLink,{QS("warnOnExternalLink"), true}},
|
{Config::warnOnExternalLink,{QS("warnOnExternalLink"), true}},
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
amountPrecision,
|
amountPrecision,
|
||||||
dateFormat,
|
dateFormat,
|
||||||
timeFormat,
|
timeFormat,
|
||||||
|
balanceDisplay,
|
||||||
|
|
||||||
multiBroadcast,
|
multiBroadcast,
|
||||||
warnOnExternalLink,
|
warnOnExternalLink,
|
||||||
|
@ -78,6 +79,12 @@ public:
|
||||||
allTor
|
allTor
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum BalanceDisplay {
|
||||||
|
totalBalance = 0,
|
||||||
|
spendablePlusUnconfirmed,
|
||||||
|
spendable
|
||||||
|
};
|
||||||
|
|
||||||
~Config() override;
|
~Config() override;
|
||||||
QVariant get(ConfigKey key);
|
QVariant get(ConfigKey key);
|
||||||
QString getFileName();
|
QString getFileName();
|
||||||
|
|
Loading…
Reference in a new issue