mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 11:39:25 +00:00
settings: add option to show fiat balance in statusbar
This commit is contained in:
parent
00915ee8a0
commit
da0d7e7100
8 changed files with 37 additions and 4 deletions
|
@ -116,6 +116,9 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa
|
|||
|
||||
this->onWalletOpened();
|
||||
|
||||
connect(&appData()->prices, &Prices::fiatPricesUpdated, this, &MainWindow::updateBalance);
|
||||
connect(&appData()->prices, &Prices::cryptoPricesUpdated, this, &MainWindow::updateBalance);
|
||||
|
||||
#ifdef DONATE_BEG
|
||||
this->donationNag();
|
||||
#endif
|
||||
|
@ -581,6 +584,10 @@ void MainWindow::onWalletOpened() {
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateBalance() {
|
||||
this->onBalanceUpdated(m_wallet->balance(), m_wallet->unlockedBalance());
|
||||
}
|
||||
|
||||
void MainWindow::onBalanceUpdated(quint64 balance, quint64 spendable) {
|
||||
bool hide = conf()->get(Config::hideBalance).toBool();
|
||||
int displaySetting = conf()->get(Config::balanceDisplay).toInt();
|
||||
|
@ -601,6 +608,12 @@ void MainWindow::onBalanceUpdated(quint64 balance, quint64 spendable) {
|
|||
}
|
||||
}
|
||||
|
||||
if (conf()->get(Config::balanceShowFiat).toBool()) {
|
||||
QString fiatCurrency = conf()->get(Config::preferredFiatCurrency).toString();
|
||||
double balanceFiatAmount = appData()->prices.convert("XMR", fiatCurrency, balance / constants::cdiv);
|
||||
balance_str += QString(" (%1)").arg(Utils::amountToCurrencyString(balanceFiatAmount, fiatCurrency));
|
||||
}
|
||||
|
||||
m_statusLabelBalance->setToolTip("Click for details");
|
||||
m_statusLabelBalance->setText(balance_str);
|
||||
}
|
||||
|
|
|
@ -131,6 +131,7 @@ private slots:
|
|||
void onTxPoolBacklog(const QVector<quint64> &backlog, quint64 originalFeeLevel, quint64 automaticFeeLevel);
|
||||
|
||||
// libwalletqt
|
||||
void updateBalance();
|
||||
void onBalanceUpdated(quint64 balance, quint64 spendable);
|
||||
void onSyncStatus(quint64 height, quint64 target, bool daemonSync);
|
||||
void onWalletOpened();
|
||||
|
|
|
@ -131,10 +131,18 @@ void Settings::setupAppearanceTab() {
|
|||
emit updateBalance();
|
||||
});
|
||||
|
||||
// [Balance show fiat]
|
||||
ui->checkBox_balanceShowFiat->setChecked(conf()->get(Config::balanceShowFiat).toBool());
|
||||
connect(ui->checkBox_balanceShowFiat, &QCheckBox::toggled, [this](bool toggled){
|
||||
conf()->set(Config::balanceShowFiat, toggled);
|
||||
emit updateBalance();
|
||||
});
|
||||
|
||||
// [Preferred fiat currency]
|
||||
QStringList availableFiatCurrencies = appData()->prices.rates.keys();
|
||||
for (const auto ¤cy : availableFiatCurrencies) {
|
||||
ui->comboBox_fiatCurrency->addItem(currency);
|
||||
emit updateBalance();
|
||||
}
|
||||
|
||||
QStringList fiatCurrencies;
|
||||
|
@ -151,6 +159,7 @@ void Settings::setupAppearanceTab() {
|
|||
QString selection = ui->comboBox_fiatCurrency->itemText(index);
|
||||
conf()->set(Config::preferredFiatCurrency, selection);
|
||||
emit preferredFiatCurrencyChanged(selection);
|
||||
emit updateBalance();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -129,17 +129,17 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Fiat currency:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QComboBox" name="comboBox_fiatCurrency"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -152,6 +152,13 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_balanceShowFiat">
|
||||
<property name="text">
|
||||
<string>Show fiat balance in statusbar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -439,6 +439,7 @@ QLocale getCurrencyLocale(const QString ¤cyCode) {
|
|||
for (const auto& locale_: allLocales) {
|
||||
if (locale_.currencySymbol(QLocale::CurrencyIsoCode) == currencyCode) {
|
||||
locale = locale_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
localeCache[currencyCode] = locale;
|
||||
|
|
|
@ -80,6 +80,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
|||
{Config::dateFormat, {QS("dateFormat"), "yyyy-MM-dd"}},
|
||||
{Config::timeFormat, {QS("timeFormat"), "HH:mm"}},
|
||||
{Config::balanceDisplay, {QS("balanceDisplay"), Config::BalanceDisplay::spendablePlusUnconfirmed}},
|
||||
{Config::balanceShowFiat, {QS("balanceShowFiat"), false}},
|
||||
{Config::inactivityLockEnabled, {QS("inactivityLockEnabled"), false}},
|
||||
{Config::inactivityLockTimeout, {QS("inactivityLockTimeout"), 10}},
|
||||
{Config::lockOnMinimize, {QS("lockOnMinimize"), false}},
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
dateFormat,
|
||||
timeFormat,
|
||||
balanceDisplay,
|
||||
balanceShowFiat,
|
||||
preferredFiatCurrency,
|
||||
|
||||
// Network -> Proxy
|
||||
|
|
|
@ -67,7 +67,7 @@ BalanceTickerWidget::BalanceTickerWidget(QWidget *parent, Wallet *wallet, bool t
|
|||
|
||||
connect(m_wallet, &Wallet::balanceUpdated, this, &BalanceTickerWidget::updateDisplay);
|
||||
connect(&appData()->prices, &Prices::fiatPricesUpdated, this, &BalanceTickerWidget::updateDisplay);
|
||||
connect(&appData()->prices, &Prices::fiatPricesUpdated, this, &BalanceTickerWidget::updateDisplay);
|
||||
connect(&appData()->prices, &Prices::cryptoPricesUpdated, this, &BalanceTickerWidget::updateDisplay);
|
||||
}
|
||||
|
||||
void BalanceTickerWidget::updateDisplay() {
|
||||
|
|
Loading…
Reference in a new issue