qt: Hide remaining PrivateSend UI if PrivateSend is not enabled (#3716)

* qt: Rename two PrivateSend related labels in OptionsDialog

* qt: Hide main PrivateSend UI elements if its not enabled

- Tab button
- Menu actions

* qt: Hide PrivateSend in OptionsDialog options if its not enabled.

* qt: Hide PrivateSend filter in TransactionView if its not enabled

* Update toolbar shortcuts to match toolbar buttons visibility

* Update src/qt/transactionview.cpp

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
This commit is contained in:
dustinface 2020-09-18 12:15:55 +02:00 committed by pasta
parent c7896eb657
commit f601122cbd
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984
7 changed files with 86 additions and 32 deletions

View File

@ -389,11 +389,6 @@ void BitcoinGUI::createActions()
overviewAction->setStatusTip(tr("Show general overview of wallet"));
overviewAction->setToolTip(overviewAction->statusTip());
overviewAction->setCheckable(true);
#ifdef Q_OS_MAC
overviewAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_1));
#else
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
#endif
tabGroup->addButton(overviewAction);
sendCoinsAction = new QToolButton(this);
@ -401,11 +396,6 @@ void BitcoinGUI::createActions()
sendCoinsAction->setStatusTip(tr("Send coins to a Dash address"));
sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
sendCoinsAction->setCheckable(true);
#ifdef Q_OS_MAC
sendCoinsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_2));
#else
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
#endif
tabGroup->addButton(sendCoinsAction);
sendCoinsMenuAction = new QAction(sendCoinsAction->text(), this);
@ -417,11 +407,6 @@ void BitcoinGUI::createActions()
privateSendCoinsAction->setStatusTip(tr("PrivateSend coins to a Dash address"));
privateSendCoinsAction->setToolTip(privateSendCoinsAction->statusTip());
privateSendCoinsAction->setCheckable(true);
#ifdef Q_OS_MAC
privateSendCoinsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_3));
#else
privateSendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
#endif
tabGroup->addButton(privateSendCoinsAction);
privateSendCoinsMenuAction = new QAction(privateSendCoinsAction->text(), this);
@ -433,11 +418,6 @@ void BitcoinGUI::createActions()
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and dash: URIs)"));
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
receiveCoinsAction->setCheckable(true);
#ifdef Q_OS_MAC
receiveCoinsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_4));
#else
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
#endif
tabGroup->addButton(receiveCoinsAction);
receiveCoinsMenuAction = new QAction(receiveCoinsAction->text(), this);
@ -449,11 +429,6 @@ void BitcoinGUI::createActions()
historyAction->setStatusTip(tr("Browse transaction history"));
historyAction->setToolTip(historyAction->statusTip());
historyAction->setCheckable(true);
#ifdef Q_OS_MAC
historyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_5));
#else
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
#endif
tabGroup->addButton(historyAction);
#ifdef ENABLE_WALLET
@ -464,11 +439,6 @@ void BitcoinGUI::createActions()
masternodeAction->setStatusTip(tr("Browse masternodes"));
masternodeAction->setToolTip(masternodeAction->statusTip());
masternodeAction->setCheckable(true);
#ifdef Q_OS_MAC
masternodeAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_6));
#else
masternodeAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
#endif
tabGroup->addButton(masternodeAction);
connect(masternodeAction, SIGNAL(clicked()), this, SLOT(showNormalIfMinimized()));
connect(masternodeAction, SIGNAL(clicked()), this, SLOT(gotoMasternodePage()));
@ -823,6 +793,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
}
#endif
}
updatePrivateSendVisibility();
}
#ifdef ENABLE_WALLET
@ -941,6 +913,8 @@ void BitcoinGUI::optionsClicked()
OptionsDialog dlg(this, enableWallet);
dlg.setModel(clientModel->getOptionsModel());
dlg.exec();
updatePrivateSendVisibility();
}
void BitcoinGUI::aboutClicked()
@ -1172,6 +1146,38 @@ void BitcoinGUI::updateProgressBarVisibility()
progressBar->setVisible(fShowProgressBar);
}
void BitcoinGUI::updatePrivateSendVisibility()
{
#ifdef ENABLE_WALLET
bool fEnabled = CPrivateSendClientOptions::IsEnabled();
#else
bool fEnabled = false;
#endif
// PrivateSend button is the third QToolButton, show/hide the underlying QAction
// Hiding the QToolButton itself doesn't work.
appToolBar->actions()[2]->setVisible(fEnabled);
privateSendCoinsMenuAction->setVisible(fEnabled);
showPrivateSendHelpAction->setVisible(fEnabled);
updateToolBarShortcuts();
}
void BitcoinGUI::updateToolBarShortcuts()
{
#ifdef Q_OS_MAC
auto modifier = Qt::CTRL;
#else
auto modifier = Qt::ALT;
#endif
int nKey = 0;
for (int i = 0; i < tabGroup->buttons().size(); ++i) {
if (appToolBar->actions()[i]->isVisible()) {
tabGroup->buttons()[i]->setShortcut(QKeySequence(modifier + Qt::Key_1 + nKey++));
} else {
tabGroup->buttons()[i]->setShortcut(QKeySequence());
}
}
}
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, const QString& blockHash, double nVerificationProgress, bool header)
{
#ifdef Q_OS_MAC

View File

@ -196,6 +196,10 @@ private:
void updateProgressBarVisibility();
void updatePrivateSendVisibility();
void updateToolBarShortcuts();
Q_SIGNALS:
/** Signal raised when a URI was entered or dragged to the GUI */
void receivedURI(const QString &uri);

View File

@ -306,7 +306,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4_Wallet">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="lblPrivateSendRoundsText">
<property name="toolTip">
<string>This setting determines the amount of individual masternodes that an input will be mixed through.&lt;br/&gt;More rounds of mixing gives a higher degree of privacy, but also costs more in fees.</string>
</property>
@ -333,7 +333,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="lblPrivateSendAmountText">
<property name="toolTip">
<string>This amount acts as a threshold to turn off PrivateSend once it's reached.</string>
</property>

View File

@ -161,6 +161,8 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
appearance = new AppearanceWidget(ui->widgetAppearance);
appearanceLayout->addWidget(appearance);
ui->widgetAppearance->setLayout(appearanceLayout);
updatePrivateSendVisibility();
}
OptionsDialog::~OptionsDialog()
@ -394,6 +396,28 @@ void OptionsDialog::updateDefaultProxyNets()
(strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachTor->setChecked(true) : ui->proxyReachTor->setChecked(false);
}
void OptionsDialog::updatePrivateSendVisibility()
{
#ifdef ENABLE_WALLET
bool fEnabled = CPrivateSendClientOptions::IsEnabled();
#else
bool fEnabled = false;
#endif
std::vector<QWidget*> vecWidgets{
ui->showAdvancedPSUI,
ui->showPrivateSendPopups,
ui->lowKeysWarning,
ui->privateSendMultiSession,
ui->privateSendAmount,
ui->lblPrivateSendAmountText,
ui->lblPrivateSendRoundsText,
ui->privateSendRounds,
};
for (auto w : vecWidgets) {
w->setVisible(fEnabled);
}
}
ProxyAddressValidator::ProxyAddressValidator(QObject *parent) :
QValidator(parent)
{

View File

@ -62,6 +62,8 @@ private Q_SLOTS:
/* query the networks, for which the default proxy is used */
void updateDefaultProxyNets();
void updatePrivateSendVisibility();
Q_SIGNALS:
void proxyIpChecks(QValidatedLineEdit *pUiProxyIp, int nProxyPort);

View File

@ -16,6 +16,7 @@
#include <qt/transactiontablemodel.h>
#include <qt/walletmodel.h>
#include <privatesend/privatesend-client.h>
#include <ui_interface.h>
#include <QCalendarWidget>
@ -27,6 +28,7 @@
#include <QHeaderView>
#include <QLabel>
#include <QLineEdit>
#include <QListView>
#include <QMenu>
#include <QPoint>
#include <QScrollBar>
@ -205,6 +207,8 @@ TransactionView::TransactionView(QWidget* parent) :
connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
connect(showAddressQRCodeAction, SIGNAL(triggered()), this, SLOT(showAddressQRCode()));
updatePrivateSendVisibility();
}
void TransactionView::setModel(WalletModel *_model)
@ -720,3 +724,16 @@ void TransactionView::updateWatchOnlyColumn(bool fHaveWatchOnly)
watchOnlyWidget->setVisible(fHaveWatchOnly);
transactionView->setColumnHidden(TransactionTableModel::Watchonly, !fHaveWatchOnly);
}
void TransactionView::updatePrivateSendVisibility()
{
bool fEnabled = CPrivateSendClientOptions::IsEnabled();
// If PrivateSend gets enabled use "All" else "Most common"
typeWidget->setCurrentIndex(fEnabled ? 0 : 1);
// Hide all PrivateSend related filters
QListView* typeList = qobject_cast<QListView*>(typeWidget->view());
std::vector<int> vecRows{4, 5, 6, 7, 8};
for (auto nRow : vecRows) {
typeList->setRowHidden(nRow, !fEnabled);
}
}

View File

@ -102,6 +102,7 @@ private Q_SLOTS:
void copyTxPlainText();
void openThirdPartyTxUrl(QString url);
void updateWatchOnlyColumn(bool fHaveWatchOnly);
void updatePrivateSendVisibility();
void abandonTx();
Q_SIGNALS: