Skip to content

Commit 94f104c

Browse files
qt: mask values on transactions view
1 parent 4f841cb commit 94f104c

File tree

7 files changed

+61
-2
lines changed

7 files changed

+61
-2
lines changed

src/qt/bitcoingui.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ void BitcoinGUI::createActions()
456456
m_wallet_controller->closeAllWallets(this);
457457
});
458458
connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::setPrivacy);
459+
connect(m_mask_values_action, &QAction::toggled, this, &BitcoinGUI::enableHistoryAction);
459460
}
460461
#endif // ENABLE_WALLET
461462

@@ -668,6 +669,12 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
668669
}
669670

670671
#ifdef ENABLE_WALLET
672+
void BitcoinGUI::enableHistoryAction(bool privacy)
673+
{
674+
historyAction->setEnabled(!privacy);
675+
if (historyAction->isChecked()) gotoOverviewPage();
676+
}
677+
671678
void BitcoinGUI::setWalletController(WalletController* wallet_controller)
672679
{
673680
assert(!m_wallet_controller);
@@ -716,7 +723,9 @@ void BitcoinGUI::addWallet(WalletModel* walletModel)
716723
connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus);
717724
connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction);
718725
connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy);
719-
wallet_view->setPrivacy(isPrivacyModeActivated());
726+
const bool privacy = isPrivacyModeActivated();
727+
wallet_view->setPrivacy(privacy);
728+
enableHistoryAction(privacy);
720729
const QString display_name = walletModel->getDisplayName();
721730
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
722731
}

src/qt/bitcoingui.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ public Q_SLOTS:
288288
void gotoVerifyMessageTab(QString addr = "");
289289
/** Load Partially Signed Bitcoin Transaction from file or clipboard */
290290
void gotoLoadPSBT(bool from_clipboard = false);
291+
/** Enable history action when privacy is changed */
292+
void enableHistoryAction(bool privacy);
291293

292294
/** Show open dialog */
293295
void openClicked();

src/qt/overviewpage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
166166

167167
void OverviewPage::handleTransactionClicked(const QModelIndex &index)
168168
{
169-
if(filter)
169+
if(filter && !m_privacy)
170170
Q_EMIT transactionClicked(filter->mapToSource(index));
171171
}
172172

src/qt/transactionview.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,22 @@ void TransactionView::editLabel()
522522
}
523523
}
524524

525+
QPoint TransactionView::nextDialogPosition(int dialogWidth)
526+
{
527+
QPoint lastDialogPos;
528+
if (!m_openedDialogs.isEmpty()) {
529+
TransactionDescDialog* lastDialog = m_openedDialogs.last();
530+
lastDialogPos = lastDialog->pos() + QPoint(50, 50);
531+
} else {
532+
QWidget *parent = this->parentWidget();
533+
QRect parentRect = parent->frameGeometry();
534+
QPoint center = parentRect.center();
535+
int x = center.x() - dialogWidth / 2;
536+
lastDialogPos = mapToGlobal(QPoint(x, 0));
537+
}
538+
return lastDialogPos;
539+
}
540+
525541
void TransactionView::showDetails()
526542
{
527543
if(!transactionView->selectionModel())
@@ -531,6 +547,8 @@ void TransactionView::showDetails()
531547
{
532548
TransactionDescDialog *dlg = new TransactionDescDialog(selection.at(0));
533549
dlg->setAttribute(Qt::WA_DeleteOnClose);
550+
dlg->move(nextDialogPosition(dlg->width()));
551+
m_openedDialogs.append(dlg);
534552
dlg->show();
535553
}
536554
}
@@ -637,6 +655,11 @@ bool TransactionView::eventFilter(QObject *obj, QEvent *event)
637655
return true;
638656
}
639657
}
658+
if (event->type() == QEvent::EnabledChange) {
659+
if (!isEnabled()) {
660+
closeOpenedDialogs();
661+
}
662+
}
640663
return QWidget::eventFilter(obj, event);
641664
}
642665

@@ -646,3 +669,12 @@ void TransactionView::updateWatchOnlyColumn(bool fHaveWatchOnly)
646669
watchOnlyWidget->setVisible(fHaveWatchOnly);
647670
transactionView->setColumnHidden(TransactionTableModel::Watchonly, !fHaveWatchOnly);
648671
}
672+
673+
void TransactionView::closeOpenedDialogs()
674+
{
675+
// close all dialogs opened from this view
676+
for (QDialog* dlg : m_openedDialogs) {
677+
dlg->close();
678+
}
679+
m_openedDialogs.clear();
680+
}

src/qt/transactionview.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
#define BITCOIN_QT_TRANSACTIONVIEW_H
77

88
#include <qt/guiutil.h>
9+
#include <qt/transactiondescdialog.h>
910

1011
#include <uint256.h>
1112

1213
#include <QWidget>
1314
#include <QKeyEvent>
1415

1516
class PlatformStyle;
17+
class TransactionDescDialog;
1618
class TransactionFilterProxy;
1719
class WalletModel;
1820

@@ -90,6 +92,10 @@ class TransactionView : public QWidget
9092

9193
const PlatformStyle* m_platform_style;
9294

95+
QList<TransactionDescDialog *> m_openedDialogs;
96+
97+
QPoint nextDialogPosition(int dialogWidth);
98+
9399
private Q_SLOTS:
94100
void contextualMenu(const QPoint &);
95101
void dateRangeChanged();
@@ -121,6 +127,7 @@ public Q_SLOTS:
121127
void changedAmount();
122128
void changedSearch();
123129
void exportClicked();
130+
void closeOpenedDialogs();
124131
void focusTransaction(const QModelIndex&);
125132
void focusTransaction(const uint256& txid);
126133
};

src/qt/walletview.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ WalletView::WalletView(WalletModel* wallet_model, const PlatformStyle* _platform
9393
connect(transactionView, &TransactionView::message, this, &WalletView::message);
9494

9595
connect(this, &WalletView::setPrivacy, overviewPage, &OverviewPage::setPrivacy);
96+
connect(this, &WalletView::setPrivacy, this, &WalletView::disableTransactionView);
9697

9798
// Receive and pass through messages from wallet model
9899
connect(walletModel, &WalletModel::message, this, &WalletView::message);
@@ -278,3 +279,8 @@ void WalletView::showProgress(const QString &title, int nProgress)
278279
}
279280
}
280281
}
282+
283+
void WalletView::disableTransactionView(bool disable)
284+
{
285+
transactionView->setDisabled(disable);
286+
}

src/qt/walletview.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public Q_SLOTS:
107107
/** Show progress dialog e.g. for rescan */
108108
void showProgress(const QString &title, int nProgress);
109109

110+
private Q_SLOTS:
111+
void disableTransactionView(bool disable);
112+
110113
Q_SIGNALS:
111114
void setPrivacy(bool privacy);
112115
void transactionClicked();

0 commit comments

Comments
 (0)