Merge #16432: qt: Add privacy to the Overview page
8d75115844
qt: Add privacy feature to Overview page (Hennadii Stepanov)73d8ef7274
qt: Add BitcoinUnits::formatWithPrivacy() function (Hennadii Stepanov) Pull request description: This PR allows to hide/reveal values on the Overviewpage by checking/unchecking Menu->Settings-> Mask Values Closes #16407 Privacy mode is OFF (the default behavior): ![Screenshot from 2020-01-02 15-08-28](https://user-images.githubusercontent.com/32963518/71669074-28ab6980-2d74-11ea-8e54-4973aa307192.png) Privacy mode is ON: ![Screenshot from 2020-01-02 15-10-23 cropped](https://user-images.githubusercontent.com/32963518/71669082-2d701d80-2d74-11ea-9df5-d4acc4982dbe.png) ACKs for top commit: jonatack: Tested ACK8d75115
jonasschnelli: Tested ACK8d75115844
Tree-SHA512: 42f396d5bf0d343b306fb7e925f86f66b3fc3a257af370a812f4be181b5269298f9b23bd8a3ce25ab61de92908c4018d8c2dc8591d11bc58d79c4eb7206fc6ec
This commit is contained in:
commit
5f75c5e7df
11 changed files with 96 additions and 29 deletions
|
@ -354,6 +354,11 @@ void BitcoinGUI::createActions()
|
||||||
showHelpMessageAction->setMenuRole(QAction::NoRole);
|
showHelpMessageAction->setMenuRole(QAction::NoRole);
|
||||||
showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Bitcoin command-line options").arg(PACKAGE_NAME));
|
showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Bitcoin command-line options").arg(PACKAGE_NAME));
|
||||||
|
|
||||||
|
m_mask_values_action = new QAction(tr("&Mask values"), this);
|
||||||
|
m_mask_values_action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_M));
|
||||||
|
m_mask_values_action->setStatusTip(tr("Mask the values in the Overview tab"));
|
||||||
|
m_mask_values_action->setCheckable(true);
|
||||||
|
|
||||||
connect(quitAction, &QAction::triggered, qApp, QApplication::quit);
|
connect(quitAction, &QAction::triggered, qApp, QApplication::quit);
|
||||||
connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked);
|
connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked);
|
||||||
connect(aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt);
|
connect(aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt);
|
||||||
|
@ -416,6 +421,8 @@ void BitcoinGUI::createActions()
|
||||||
connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater);
|
connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater);
|
||||||
activity->create();
|
activity->create();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::setPrivacy);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
|
@ -456,6 +463,8 @@ void BitcoinGUI::createMenuBar()
|
||||||
settings->addAction(encryptWalletAction);
|
settings->addAction(encryptWalletAction);
|
||||||
settings->addAction(changePassphraseAction);
|
settings->addAction(changePassphraseAction);
|
||||||
settings->addSeparator();
|
settings->addSeparator();
|
||||||
|
settings->addAction(m_mask_values_action);
|
||||||
|
settings->addSeparator();
|
||||||
}
|
}
|
||||||
settings->addAction(optionsAction);
|
settings->addAction(optionsAction);
|
||||||
|
|
||||||
|
@ -1414,6 +1423,12 @@ void BitcoinGUI::unsubscribeFromCoreSignals()
|
||||||
m_handler_question->disconnect();
|
m_handler_question->disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BitcoinGUI::isPrivacyModeActivated() const
|
||||||
|
{
|
||||||
|
assert(m_mask_values_action);
|
||||||
|
return m_mask_values_action->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
|
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
|
||||||
optionsModel(nullptr),
|
optionsModel(nullptr),
|
||||||
menu(nullptr)
|
menu(nullptr)
|
||||||
|
|
|
@ -99,6 +99,8 @@ public:
|
||||||
/** Disconnect core signals from GUI client */
|
/** Disconnect core signals from GUI client */
|
||||||
void unsubscribeFromCoreSignals();
|
void unsubscribeFromCoreSignals();
|
||||||
|
|
||||||
|
bool isPrivacyModeActivated() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *e) override;
|
void changeEvent(QEvent *e) override;
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
@ -155,6 +157,7 @@ private:
|
||||||
QAction* m_close_wallet_action{nullptr};
|
QAction* m_close_wallet_action{nullptr};
|
||||||
QAction* m_wallet_selector_label_action = nullptr;
|
QAction* m_wallet_selector_label_action = nullptr;
|
||||||
QAction* m_wallet_selector_action = nullptr;
|
QAction* m_wallet_selector_action = nullptr;
|
||||||
|
QAction* m_mask_values_action{nullptr};
|
||||||
|
|
||||||
QLabel *m_wallet_selector_label = nullptr;
|
QLabel *m_wallet_selector_label = nullptr;
|
||||||
QComboBox* m_wallet_selector = nullptr;
|
QComboBox* m_wallet_selector = nullptr;
|
||||||
|
@ -207,6 +210,7 @@ Q_SIGNALS:
|
||||||
void receivedURI(const QString &uri);
|
void receivedURI(const QString &uri);
|
||||||
/** Signal raised when RPC console shown */
|
/** Signal raised when RPC console shown */
|
||||||
void consoleShown(RPCConsole* console);
|
void consoleShown(RPCConsole* console);
|
||||||
|
void setPrivacy(bool privacy);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/** Set number of connections shown in the UI */
|
/** Set number of connections shown in the UI */
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
BitcoinUnits::BitcoinUnits(QObject *parent):
|
BitcoinUnits::BitcoinUnits(QObject *parent):
|
||||||
QAbstractListModel(parent),
|
QAbstractListModel(parent),
|
||||||
unitlist(availableUnits())
|
unitlist(availableUnits())
|
||||||
|
@ -94,7 +96,7 @@ int BitcoinUnits::decimals(int unit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators)
|
QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators, bool justify)
|
||||||
{
|
{
|
||||||
// Note: not using straight sprintf here because we do NOT want
|
// Note: not using straight sprintf here because we do NOT want
|
||||||
// localized number formatting.
|
// localized number formatting.
|
||||||
|
@ -106,6 +108,7 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
|
||||||
qint64 n_abs = (n > 0 ? n : -n);
|
qint64 n_abs = (n > 0 ? n : -n);
|
||||||
qint64 quotient = n_abs / coin;
|
qint64 quotient = n_abs / coin;
|
||||||
QString quotient_str = QString::number(quotient);
|
QString quotient_str = QString::number(quotient);
|
||||||
|
if (justify) quotient_str = quotient_str.rightJustified(16 - num_decimals, ' ');
|
||||||
|
|
||||||
// Use SI-style thin space separators as these are locale independent and can't be
|
// Use SI-style thin space separators as these are locale independent and can't be
|
||||||
// confused with the decimal marker.
|
// confused with the decimal marker.
|
||||||
|
@ -150,6 +153,17 @@ QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool p
|
||||||
return QString("<span style='white-space: nowrap;'>%1</span>").arg(str);
|
return QString("<span style='white-space: nowrap;'>%1</span>").arg(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString BitcoinUnits::formatWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy)
|
||||||
|
{
|
||||||
|
assert(amount >= 0);
|
||||||
|
QString value;
|
||||||
|
if (privacy) {
|
||||||
|
value = format(unit, 0, false, separators, true).replace('0', '#');
|
||||||
|
} else {
|
||||||
|
value = format(unit, amount, false, separators, true);
|
||||||
|
}
|
||||||
|
return value + QString(" ") + shortName(unit);
|
||||||
|
}
|
||||||
|
|
||||||
bool BitcoinUnits::parse(int unit, const QString &value, CAmount *val_out)
|
bool BitcoinUnits::parse(int unit, const QString &value, CAmount *val_out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,11 +72,13 @@ public:
|
||||||
//! Number of decimals left
|
//! Number of decimals left
|
||||||
static int decimals(int unit);
|
static int decimals(int unit);
|
||||||
//! Format as string
|
//! Format as string
|
||||||
static QString format(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
|
static QString format(int unit, const CAmount& amount, bool plussign = false, SeparatorStyle separators = separatorStandard, bool justify = false);
|
||||||
//! Format as string (with unit)
|
//! Format as string (with unit)
|
||||||
static QString formatWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
|
static QString formatWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
|
||||||
//! Format as HTML string (with unit)
|
//! Format as HTML string (with unit)
|
||||||
static QString formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
|
static QString formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
|
||||||
|
//! Format as string (with unit) of fixed length to preserve privacy, if it is set.
|
||||||
|
static QString formatWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy);
|
||||||
//! Parse string to coin amount
|
//! Parse string to coin amount
|
||||||
static bool parse(int unit, const QString &value, CAmount *val_out);
|
static bool parse(int unit, const QString &value, CAmount *val_out);
|
||||||
//! Gets title for amount column including current display unit if optionsModel reference available */
|
//! Gets title for amount column including current display unit if optionsModel reference available */
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>596</width>
|
<width>798</width>
|
||||||
<height>342</height>
|
<height>318</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -118,6 +118,7 @@
|
||||||
<widget class="QLabel" name="labelWatchPending">
|
<widget class="QLabel" name="labelWatchPending">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<family>Monospace</family>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -129,7 +130,7 @@
|
||||||
<string>Unconfirmed transactions to watch-only addresses</string>
|
<string>Unconfirmed transactions to watch-only addresses</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">0.000 000 00 BTC</string>
|
<string notr="true">0.00000000 BTC</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
@ -143,6 +144,7 @@
|
||||||
<widget class="QLabel" name="labelUnconfirmed">
|
<widget class="QLabel" name="labelUnconfirmed">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<family>Monospace</family>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -154,7 +156,7 @@
|
||||||
<string>Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance</string>
|
<string>Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">0.000 000 00 BTC</string>
|
<string notr="true">0.00000000 BTC</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
@ -168,6 +170,7 @@
|
||||||
<widget class="QLabel" name="labelWatchImmature">
|
<widget class="QLabel" name="labelWatchImmature">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<family>Monospace</family>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -179,7 +182,7 @@
|
||||||
<string>Mined balance in watch-only addresses that has not yet matured</string>
|
<string>Mined balance in watch-only addresses that has not yet matured</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">0.000 000 00 BTC</string>
|
<string notr="true">0.00000000 BTC</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
@ -226,6 +229,7 @@
|
||||||
<widget class="QLabel" name="labelImmature">
|
<widget class="QLabel" name="labelImmature">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<family>Monospace</family>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -237,7 +241,7 @@
|
||||||
<string>Mined balance that has not yet matured</string>
|
<string>Mined balance that has not yet matured</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">0.000 000 00 BTC</string>
|
<string notr="true">0.00000000 BTC</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
@ -271,6 +275,7 @@
|
||||||
<widget class="QLabel" name="labelTotal">
|
<widget class="QLabel" name="labelTotal">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<family>Monospace</family>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -282,7 +287,7 @@
|
||||||
<string>Your current total balance</string>
|
<string>Your current total balance</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">0.000 000 00 BTC</string>
|
<string notr="true">21 000 000.00000000 BTC</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
@ -296,6 +301,7 @@
|
||||||
<widget class="QLabel" name="labelWatchTotal">
|
<widget class="QLabel" name="labelWatchTotal">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<family>Monospace</family>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -307,7 +313,7 @@
|
||||||
<string>Current total balance in watch-only addresses</string>
|
<string>Current total balance in watch-only addresses</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">0.000 000 00 BTC</string>
|
<string notr="true">21 000 000.00000000 BTC</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
@ -338,6 +344,7 @@
|
||||||
<widget class="QLabel" name="labelBalance">
|
<widget class="QLabel" name="labelBalance">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<family>Monospace</family>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -349,7 +356,7 @@
|
||||||
<string>Your current spendable balance</string>
|
<string>Your current spendable balance</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">0.000 000 00 BTC</string>
|
<string notr="true">21 000 000.00000000 BTC</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
@ -363,6 +370,7 @@
|
||||||
<widget class="QLabel" name="labelWatchAvailable">
|
<widget class="QLabel" name="labelWatchAvailable">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
<family>Monospace</family>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
|
@ -374,7 +382,7 @@
|
||||||
<string>Your current balance in watch-only addresses</string>
|
<string>Your current balance in watch-only addresses</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">0.000 000 00 BTC</string>
|
<string notr="true">21 000 000.00000000 BTC</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
#include <qt/walletmodel.h>
|
#include <qt/walletmodel.h>
|
||||||
|
|
||||||
#include <QAbstractItemDelegate>
|
#include <QAbstractItemDelegate>
|
||||||
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QStatusTipEvent>
|
||||||
|
|
||||||
#define DECORATION_SIZE 54
|
#define DECORATION_SIZE 54
|
||||||
#define NUM_ITEMS 5
|
#define NUM_ITEMS 5
|
||||||
|
@ -152,6 +154,21 @@ void OverviewPage::handleOutOfSyncWarningClicks()
|
||||||
Q_EMIT outOfSyncWarningClicked();
|
Q_EMIT outOfSyncWarningClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OverviewPage::setPrivacy(bool privacy)
|
||||||
|
{
|
||||||
|
m_privacy = privacy;
|
||||||
|
if (m_balances.balance != -1) {
|
||||||
|
setBalance(m_balances);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->listTransactions->setVisible(!m_privacy);
|
||||||
|
|
||||||
|
const QString status_tip = m_privacy ? tr("Privacy mode activated for the Overview tab. To unmask the values, uncheck Settings->Mask values.") : "";
|
||||||
|
setStatusTip(status_tip);
|
||||||
|
QStatusTipEvent event(status_tip);
|
||||||
|
QApplication::sendEvent(this, &event);
|
||||||
|
}
|
||||||
|
|
||||||
OverviewPage::~OverviewPage()
|
OverviewPage::~OverviewPage()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
@ -163,25 +180,25 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
|
||||||
m_balances = balances;
|
m_balances = balances;
|
||||||
if (walletModel->wallet().isLegacy()) {
|
if (walletModel->wallet().isLegacy()) {
|
||||||
if (walletModel->wallet().privateKeysDisabled()) {
|
if (walletModel->wallet().privateKeysDisabled()) {
|
||||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelBalance->setText(BitcoinUnits::formatWithPrivacy(unit, balances.watch_only_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
} else {
|
} else {
|
||||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balances.balance, false, BitcoinUnits::separatorAlways));
|
ui->labelBalance->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelWatchAvailable->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelWatchAvailable->setText(BitcoinUnits::formatWithPrivacy(unit, balances.watch_only_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelWatchPending->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelWatchPending->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelWatchImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelWatchImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelWatchTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelWatchTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.watch_only_balance + balances.unconfirmed_watch_only_balance + balances.immature_watch_only_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balances.balance, false, BitcoinUnits::separatorAlways));
|
ui->labelBalance->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, balances.unconfirmed_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.unconfirmed_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelImmature->setText(BitcoinUnits::formatWithUnit(unit, balances.immature_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelImmature->setText(BitcoinUnits::formatWithPrivacy(unit, balances.immature_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
ui->labelTotal->setText(BitcoinUnits::formatWithUnit(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, false, BitcoinUnits::separatorAlways));
|
ui->labelTotal->setText(BitcoinUnits::formatWithPrivacy(unit, balances.balance + balances.unconfirmed_balance + balances.immature_balance, BitcoinUnits::separatorAlways, m_privacy));
|
||||||
}
|
}
|
||||||
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
|
// only show immature (newly mined) balance if it's non-zero, so as not to complicate things
|
||||||
// for the non-mining users
|
// for the non-mining users
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setBalance(const interfaces::WalletBalances& balances);
|
void setBalance(const interfaces::WalletBalances& balances);
|
||||||
|
void setPrivacy(bool privacy);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void transactionClicked(const QModelIndex &index);
|
void transactionClicked(const QModelIndex &index);
|
||||||
|
@ -49,6 +50,7 @@ private:
|
||||||
ClientModel *clientModel;
|
ClientModel *clientModel;
|
||||||
WalletModel *walletModel;
|
WalletModel *walletModel;
|
||||||
interfaces::WalletBalances m_balances;
|
interfaces::WalletBalances m_balances;
|
||||||
|
bool m_privacy{false};
|
||||||
|
|
||||||
TxViewDelegate *txdelegate;
|
TxViewDelegate *txdelegate;
|
||||||
std::unique_ptr<TransactionFilterProxy> filter;
|
std::unique_ptr<TransactionFilterProxy> filter;
|
||||||
|
|
|
@ -201,7 +201,7 @@ void TestGUI(interfaces::Node& node)
|
||||||
OverviewPage overviewPage(platformStyle.get());
|
OverviewPage overviewPage(platformStyle.get());
|
||||||
overviewPage.setWalletModel(&walletModel);
|
overviewPage.setWalletModel(&walletModel);
|
||||||
QLabel* balanceLabel = overviewPage.findChild<QLabel*>("labelBalance");
|
QLabel* balanceLabel = overviewPage.findChild<QLabel*>("labelBalance");
|
||||||
QString balanceText = balanceLabel->text();
|
QString balanceText = balanceLabel->text().trimmed();
|
||||||
int unit = walletModel.getOptionsModel()->getDisplayUnit();
|
int unit = walletModel.getOptionsModel()->getDisplayUnit();
|
||||||
CAmount balance = walletModel.wallet().getBalance();
|
CAmount balance = walletModel.wallet().getBalance();
|
||||||
QString balanceComparison = BitcoinUnits::formatWithUnit(unit, balance, false, BitcoinUnits::separatorAlways);
|
QString balanceComparison = BitcoinUnits::formatWithUnit(unit, balance, false, BitcoinUnits::separatorAlways);
|
||||||
|
|
|
@ -53,6 +53,7 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||||
walletView->setClientModel(clientModel);
|
walletView->setClientModel(clientModel);
|
||||||
walletView->setWalletModel(walletModel);
|
walletView->setWalletModel(walletModel);
|
||||||
walletView->showOutOfSyncWarning(bOutOfSync);
|
walletView->showOutOfSyncWarning(bOutOfSync);
|
||||||
|
walletView->setPrivacy(gui->isPrivacyModeActivated());
|
||||||
|
|
||||||
WalletView* current_wallet_view = currentWalletView();
|
WalletView* current_wallet_view = currentWalletView();
|
||||||
if (current_wallet_view) {
|
if (current_wallet_view) {
|
||||||
|
@ -73,6 +74,7 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||||
connect(walletView, &WalletView::encryptionStatusChanged, gui, &BitcoinGUI::updateWalletStatus);
|
connect(walletView, &WalletView::encryptionStatusChanged, gui, &BitcoinGUI::updateWalletStatus);
|
||||||
connect(walletView, &WalletView::incomingTransaction, gui, &BitcoinGUI::incomingTransaction);
|
connect(walletView, &WalletView::incomingTransaction, gui, &BitcoinGUI::incomingTransaction);
|
||||||
connect(walletView, &WalletView::hdEnabledStatusChanged, gui, &BitcoinGUI::updateWalletStatus);
|
connect(walletView, &WalletView::hdEnabledStatusChanged, gui, &BitcoinGUI::updateWalletStatus);
|
||||||
|
connect(gui, &BitcoinGUI::setPrivacy, walletView, &WalletView::setPrivacy);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,8 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent):
|
||||||
connect(sendCoinsPage, &SendCoinsDialog::message, this, &WalletView::message);
|
connect(sendCoinsPage, &SendCoinsDialog::message, this, &WalletView::message);
|
||||||
// Pass through messages from transactionView
|
// Pass through messages from transactionView
|
||||||
connect(transactionView, &TransactionView::message, this, &WalletView::message);
|
connect(transactionView, &TransactionView::message, this, &WalletView::message);
|
||||||
|
|
||||||
|
connect(this, &WalletView::setPrivacy, overviewPage, &OverviewPage::setPrivacy);
|
||||||
}
|
}
|
||||||
|
|
||||||
WalletView::~WalletView()
|
WalletView::~WalletView()
|
||||||
|
|
|
@ -115,6 +115,7 @@ public Q_SLOTS:
|
||||||
void requestedSyncWarningInfo();
|
void requestedSyncWarningInfo();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
void setPrivacy(bool privacy);
|
||||||
void transactionClicked();
|
void transactionClicked();
|
||||||
void coinsSent();
|
void coinsSent();
|
||||||
/** Fired when a message should be reported to the user */
|
/** Fired when a message should be reported to the user */
|
||||||
|
|
Loading…
Reference in a new issue