Skip to content

Commit 8be260a

Browse files
Merge pull request dashpay#5796 from knst/bp-v21-qt-1
backport: bitcoin#15202, bitcoin#15768, bitcoin#16432, bitcoin#17597 (Qt dash core wallet improvements)
2 parents 0e314fe + 2cda5f5 commit 8be260a

29 files changed

+448
-146
lines changed

src/qt/addressbookpage.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ AddressBookPage::AddressBookPage(Mode _mode, Tabs _tab, QWidget* parent) :
139139
GUIUtil::updateFonts();
140140

141141
GUIUtil::disableMacFocusRect(this);
142+
143+
GUIUtil::handleCloseWindowShortcut(this);
142144
}
143145

144146
AddressBookPage::~AddressBookPage()

src/qt/askpassphrasedialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri
9191
connect(ui->passEdit1, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
9292
connect(ui->passEdit2, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
9393
connect(ui->passEdit3, &QLineEdit::textChanged, this, &AskPassphraseDialog::textChanged);
94+
95+
GUIUtil::handleCloseWindowShortcut(this);
9496
}
9597

9698
AskPassphraseDialog::~AskPassphraseDialog()

src/qt/bitcoingui.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
238238
});
239239
timerCustomCss->start(200);
240240
}
241+
242+
GUIUtil::handleCloseWindowShortcut(this);
241243
}
242244

243245
BitcoinGUI::~BitcoinGUI()
@@ -445,6 +447,9 @@ void BitcoinGUI::createActions()
445447
m_create_wallet_action->setEnabled(false);
446448
m_create_wallet_action->setStatusTip(tr("Create a new wallet"));
447449

450+
m_close_all_wallets_action = new QAction(tr("Close All Wallets..."), this);
451+
m_close_all_wallets_action->setStatusTip(tr("Close all wallets"));
452+
448453
showHelpMessageAction = new QAction(tr("&Command-line options"), this);
449454
showHelpMessageAction->setMenuRole(QAction::NoRole);
450455
showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Dash command-line options").arg(PACKAGE_NAME));
@@ -453,6 +458,11 @@ void BitcoinGUI::createActions()
453458
showCoinJoinHelpAction->setMenuRole(QAction::NoRole);
454459
showCoinJoinHelpAction->setStatusTip(tr("Show the %1 basic information").arg(strCoinJoinName));
455460

461+
m_mask_values_action = new QAction(tr("&Mask values"), this);
462+
m_mask_values_action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_M));
463+
m_mask_values_action->setStatusTip(tr("Mask the values in the Overview tab"));
464+
m_mask_values_action->setCheckable(true);
465+
456466
connect(quitAction, &QAction::triggered, qApp, QApplication::quit);
457467
connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked);
458468
connect(aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt);
@@ -532,6 +542,11 @@ void BitcoinGUI::createActions()
532542
connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater);
533543
activity->create();
534544
});
545+
connect(m_close_all_wallets_action, &QAction::triggered, [this] {
546+
m_wallet_controller->closeAllWallets(this);
547+
});
548+
549+
connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::setPrivacy);
535550
}
536551
#endif // ENABLE_WALLET
537552
}
@@ -553,6 +568,7 @@ void BitcoinGUI::createMenuBar()
553568
file->addAction(m_create_wallet_action);
554569
file->addAction(m_open_wallet_action);
555570
file->addAction(m_close_wallet_action);
571+
file->addAction(m_close_all_wallets_action);
556572
file->addSeparator();
557573
file->addAction(openAction);
558574
file->addAction(backupWalletAction);
@@ -576,6 +592,8 @@ void BitcoinGUI::createMenuBar()
576592
settings->addAction(unlockWalletAction);
577593
settings->addAction(lockWalletAction);
578594
settings->addSeparator();
595+
settings->addAction(m_mask_values_action);
596+
settings->addSeparator();
579597
}
580598
settings->addAction(optionsAction);
581599

@@ -972,6 +990,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
972990
usedReceivingAddressesAction->setEnabled(enabled);
973991
openAction->setEnabled(enabled);
974992
m_close_wallet_action->setEnabled(enabled);
993+
m_close_all_wallets_action->setEnabled(enabled);
975994
}
976995

977996
void BitcoinGUI::createTrayIcon()
@@ -1999,6 +2018,12 @@ void BitcoinGUI::handleRestart(QStringList args)
19992018
Q_EMIT requestedRestart(args);
20002019
}
20012020

2021+
bool BitcoinGUI::isPrivacyModeActivated() const
2022+
{
2023+
assert(m_mask_values_action);
2024+
return m_mask_values_action->isChecked();
2025+
}
2026+
20022027
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() :
20032028
optionsModel(nullptr),
20042029
menu(nullptr)

src/qt/bitcoingui.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class BitcoinGUI : public QMainWindow
103103
/** Disconnect core signals from GUI client */
104104
void unsubscribeFromCoreSignals();
105105

106+
bool isPrivacyModeActivated() const;
107+
106108
protected:
107109
void changeEvent(QEvent *e) override;
108110
void closeEvent(QCloseEvent *event) override;
@@ -171,7 +173,9 @@ class BitcoinGUI : public QMainWindow
171173
QMenu* m_open_wallet_menu{nullptr};
172174
QAction* m_close_wallet_action{nullptr};
173175
QAction* showCoinJoinHelpAction = nullptr;
176+
QAction* m_close_all_wallets_action{nullptr};
174177
QAction* m_wallet_selector_action = nullptr;
178+
QAction* m_mask_values_action{nullptr};
175179

176180
QComboBox* m_wallet_selector = nullptr;
177181

@@ -252,6 +256,7 @@ class BitcoinGUI : public QMainWindow
252256
void consoleShown(RPCConsole* console);
253257
/** Restart handling */
254258
void requestedRestart(QStringList args);
259+
void setPrivacy(bool privacy);
255260

256261
public Q_SLOTS:
257262
/** Set number of connections shown in the UI */

src/qt/bitcoinunits.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <QSettings>
1010
#include <QStringList>
1111

12+
#include <cassert>
13+
1214
BitcoinUnits::BitcoinUnits(QObject *parent):
1315
QAbstractListModel(parent),
1416
unitlist(availableUnits())
@@ -115,7 +117,7 @@ int BitcoinUnits::decimals(int unit)
115117
}
116118
}
117119

118-
QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators)
120+
QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorStyle separators, bool justify)
119121
{
120122
// Note: not using straight sprintf here because we do NOT want
121123
// localized number formatting.
@@ -127,6 +129,7 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
127129
qint64 n_abs = (n > 0 ? n : -n);
128130
qint64 quotient = n_abs / coin;
129131
QString quotient_str = QString::number(quotient);
132+
if (justify) quotient_str = quotient_str.rightJustified(16 - num_decimals, ' ');
130133

131134
// Use SI-style thin space separators as these are locale independent and can't be
132135
// confused with the decimal marker.
@@ -171,6 +174,18 @@ QString BitcoinUnits::formatHtmlWithUnit(int unit, const CAmount& amount, bool p
171174
return QString("<span style='white-space: nowrap;'>%1</span>").arg(str);
172175
}
173176

177+
QString BitcoinUnits::formatWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy)
178+
{
179+
assert(amount >= 0);
180+
QString value;
181+
if (privacy) {
182+
value = format(unit, 0, false, separators, true).replace('0', '#');
183+
} else {
184+
value = format(unit, amount, false, separators, true);
185+
}
186+
return value + QString(" ") + name(unit);
187+
}
188+
174189
QString BitcoinUnits::floorWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
175190
{
176191
QSettings settings;
@@ -182,9 +197,13 @@ QString BitcoinUnits::floorWithUnit(int unit, const CAmount& amount, bool plussi
182197
return result + QString(" ") + name(unit);
183198
}
184199

185-
QString BitcoinUnits::floorHtmlWithUnit(int unit, const CAmount& amount, bool plussign, SeparatorStyle separators)
200+
QString BitcoinUnits::floorHtmlWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy)
186201
{
187-
QString str(floorWithUnit(unit, amount, plussign, separators));
202+
assert(amount >= 0);
203+
QString str = privacy
204+
? floorWithUnit(unit, 0, false, separators).replace('0', '#')
205+
: floorWithUnit(unit, amount, false, separators);
206+
188207
str.replace(QChar(THIN_SP_CP), QString(THIN_SP_HTML));
189208
return QString("<span style='white-space: nowrap;'>%1</span>").arg(str);
190209
}

src/qt/bitcoinunits.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,17 @@ class BitcoinUnits: public QAbstractListModel
7171
//! Number of decimals left
7272
static int decimals(int unit);
7373
//! Format as string
74-
static QString format(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
74+
static QString format(int unit, const CAmount& amount, bool plussign = false, SeparatorStyle separators = separatorStandard, bool justify = false);
7575
static QString simpleFormat(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
7676
//! Format as string (with unit)
7777
static QString formatWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
7878
//! Format as HTML string (with unit)
7979
static QString formatHtmlWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
80+
//! Format as string (with unit) of fixed length to preserve privacy, if it is set.
81+
static QString formatWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy);
8082
//! Format as string (with unit) but floor value up to "digits" settings
8183
static QString floorWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
82-
static QString floorHtmlWithUnit(int unit, const CAmount& amount, bool plussign=false, SeparatorStyle separators=separatorStandard);
84+
static QString floorHtmlWithPrivacy(int unit, const CAmount& amount, SeparatorStyle separators, bool privacy);
8385
//! Parse string to coin amount
8486
static bool parse(int unit, const QString &value, CAmount *val_out);
8587
//! Gets title for amount column including current display unit if optionsModel reference available */

src/qt/coincontroldialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ CoinControlDialog::CoinControlDialog(CCoinControl& coin_control, WalletModel* _m
160160
updateLabelLocked();
161161
CoinControlDialog::updateLabels(m_coin_control, _model, this);
162162
}
163+
164+
GUIUtil::handleCloseWindowShortcut(this);
163165
}
164166

165167
CoinControlDialog::~CoinControlDialog()

src/qt/editaddressdialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ EditAddressDialog::EditAddressDialog(Mode _mode, QWidget *parent) :
4545
GUIUtil::ItemDelegate* delegate = new GUIUtil::ItemDelegate(mapper);
4646
connect(delegate, &GUIUtil::ItemDelegate::keyEscapePressed, this, &EditAddressDialog::reject);
4747
mapper->setItemDelegate(delegate);
48+
49+
GUIUtil::handleCloseWindowShortcut(this);
4850
}
4951

5052
EditAddressDialog::~EditAddressDialog()

src/qt/forms/overviewpage.ui

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>960</width>
10-
<height>585</height>
9+
<width>798</width>
10+
<height>318</height>
1111
</rect>
1212
</property>
1313
<property name="minimumSize">
@@ -116,7 +116,7 @@
116116
<string>Unconfirmed transactions to watch-only addresses</string>
117117
</property>
118118
<property name="text">
119-
<string notr="true">0.000 000 00 BTC</string>
119+
<string notr="true">0.00000000 BTC</string>
120120
</property>
121121
<property name="alignment">
122122
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -135,7 +135,7 @@
135135
<string>Total of transactions that have yet to be confirmed, and do not yet count toward the spendable balance</string>
136136
</property>
137137
<property name="text">
138-
<string notr="true">0.000 000 00 BTC</string>
138+
<string notr="true">0.00000000 BTC</string>
139139
</property>
140140
<property name="alignment">
141141
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -154,7 +154,7 @@
154154
<string>Mined balance in watch-only addresses that has not yet matured</string>
155155
</property>
156156
<property name="text">
157-
<string notr="true">0.000 000 00 BTC</string>
157+
<string notr="true">0.00000000 BTC</string>
158158
</property>
159159
<property name="alignment">
160160
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -206,7 +206,7 @@
206206
<string>Mined balance that has not yet matured</string>
207207
</property>
208208
<property name="text">
209-
<string notr="true">0.000 000 00 BTC</string>
209+
<string notr="true">0.00000000 BTC</string>
210210
</property>
211211
<property name="alignment">
212212
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -245,7 +245,7 @@
245245
<string>Your current total balance</string>
246246
</property>
247247
<property name="text">
248-
<string notr="true">0.000000 00 BTC</string>
248+
<string notr="true">21 000 000.00000000 BTC</string>
249249
</property>
250250
<property name="alignment">
251251
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -264,7 +264,7 @@
264264
<string>Current total balance in watch-only addresses</string>
265265
</property>
266266
<property name="text">
267-
<string notr="true">0.000000 00 BTC</string>
267+
<string notr="true">21 000 000.00000000 BTC</string>
268268
</property>
269269
<property name="alignment">
270270
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -300,7 +300,7 @@
300300
<string>Your current spendable balance</string>
301301
</property>
302302
<property name="text">
303-
<string notr="true">0.000000 00 BTC</string>
303+
<string notr="true">21 000 000.00000000 BTC</string>
304304
</property>
305305
<property name="alignment">
306306
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@@ -319,7 +319,7 @@
319319
<string>Your current balance in watch-only addresses</string>
320320
</property>
321321
<property name="text">
322-
<string notr="true">0.000000 00 BTC</string>
322+
<string notr="true">21 000 000.00000000 BTC</string>
323323
</property>
324324
<property name="alignment">
325325
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>

0 commit comments

Comments
 (0)