Skip to content

Commit

Permalink
Merge bitcoin-core/gui#708: Mask values on Transactions View
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto authored and jagdeep sidhu committed Mar 14, 2023
1 parent 10db931 commit 3449b9b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/qt/syscoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ void SyscoinGUI::createActions()
m_wallet_controller->closeAllWallets(this);
});
connect(m_mask_values_action, &QAction::toggled, this, &SyscoinGUI::setPrivacy);
connect(m_mask_values_action, &QAction::toggled, this, &SyscoinGUI::enableHistoryAction);
}
#endif // ENABLE_WALLET

Expand Down Expand Up @@ -694,6 +695,12 @@ void SyscoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
}

#ifdef ENABLE_WALLET
void SyscoinGUI::enableHistoryAction(bool privacy)
{
historyAction->setEnabled(!privacy);
if (historyAction->isChecked()) gotoOverviewPage();
}

void SyscoinGUI::setWalletController(WalletController* wallet_controller)
{
assert(!m_wallet_controller);
Expand Down Expand Up @@ -742,7 +749,9 @@ void SyscoinGUI::addWallet(WalletModel* walletModel)
connect(wallet_view, &WalletView::encryptionStatusChanged, this, &SyscoinGUI::updateWalletStatus);
connect(wallet_view, &WalletView::incomingTransaction, this, &SyscoinGUI::incomingTransaction);
connect(this, &SyscoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy);
wallet_view->setPrivacy(isPrivacyModeActivated());
const bool privacy = isPrivacyModeActivated();
wallet_view->setPrivacy(privacy);
enableHistoryAction(privacy);
const QString display_name = walletModel->getDisplayName();
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
}
Expand Down
2 changes: 2 additions & 0 deletions src/qt/syscoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ public Q_SLOTS:
void gotoVerifyMessageTab(QString addr = "");
/** Load Partially Signed Syscoin Transaction from file or clipboard */
void gotoLoadPSBT(bool from_clipboard = false);
/** Enable history action when privacy is changed */
void enableHistoryAction(bool privacy);

/** Show open dialog */
void openClicked();
Expand Down
15 changes: 15 additions & 0 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ void TransactionView::showDetails()
{
TransactionDescDialog *dlg = new TransactionDescDialog(selection.at(0));
dlg->setAttribute(Qt::WA_DeleteOnClose);
m_opened_dialogs.append(dlg);
dlg->show();
}
}
Expand Down Expand Up @@ -637,6 +638,11 @@ bool TransactionView::eventFilter(QObject *obj, QEvent *event)
return true;
}
}
if (event->type() == QEvent::EnabledChange) {
if (!isEnabled()) {
closeOpenedDialogs();
}
}
return QWidget::eventFilter(obj, event);
}

Expand All @@ -646,3 +652,12 @@ void TransactionView::updateWatchOnlyColumn(bool fHaveWatchOnly)
watchOnlyWidget->setVisible(fHaveWatchOnly);
transactionView->setColumnHidden(TransactionTableModel::Watchonly, !fHaveWatchOnly);
}

void TransactionView::closeOpenedDialogs()
{
// close all dialogs opened from this view
for (QDialog* dlg : m_opened_dialogs) {
dlg->close();
}
m_opened_dialogs.clear();
}
4 changes: 4 additions & 0 deletions src/qt/transactionview.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QKeyEvent>

class PlatformStyle;
class TransactionDescDialog;
class TransactionFilterProxy;
class WalletModel;

Expand Down Expand Up @@ -90,6 +91,8 @@ class TransactionView : public QWidget

const PlatformStyle* m_platform_style;

QList<TransactionDescDialog*> m_opened_dialogs;

private Q_SLOTS:
void contextualMenu(const QPoint &);
void dateRangeChanged();
Expand Down Expand Up @@ -121,6 +124,7 @@ public Q_SLOTS:
void changedAmount();
void changedSearch();
void exportClicked();
void closeOpenedDialogs();
void focusTransaction(const QModelIndex&);
void focusTransaction(const uint256& txid);
};
Expand Down
6 changes: 6 additions & 0 deletions src/qt/walletview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ WalletView::WalletView(WalletModel* wallet_model, const PlatformStyle* _platform
connect(transactionView, &TransactionView::message, this, &WalletView::message);

connect(this, &WalletView::setPrivacy, overviewPage, &OverviewPage::setPrivacy);
connect(this, &WalletView::setPrivacy, this, &WalletView::disableTransactionView);

// Receive and pass through messages from wallet model
connect(walletModel, &WalletModel::message, this, &WalletView::message);
Expand Down Expand Up @@ -297,3 +298,8 @@ void WalletView::showProgress(const QString &title, int nProgress)
}
}
}

void WalletView::disableTransactionView(bool disable)
{
transactionView->setDisabled(disable);
}
3 changes: 3 additions & 0 deletions src/qt/walletview.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public Q_SLOTS:
/** Show progress dialog e.g. for rescan */
void showProgress(const QString &title, int nProgress);

private Q_SLOTS:
void disableTransactionView(bool disable);

Q_SIGNALS:
void setPrivacy(bool privacy);
void transactionClicked();
Expand Down

0 comments on commit 3449b9b

Please sign in to comment.