diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 4d75632fbbd6..5107a7f7e940 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -376,11 +376,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); @@ -388,11 +383,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); @@ -404,11 +394,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); @@ -420,11 +405,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); @@ -436,11 +416,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 @@ -451,11 +426,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())); @@ -817,6 +787,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel) } #endif } + + updatePrivateSendVisibility(); } #ifdef ENABLE_WALLET @@ -951,6 +923,8 @@ void BitcoinGUI::optionsClicked() OptionsDialog dlg(this, enableWallet); dlg.setModel(clientModel->getOptionsModel()); dlg.exec(); + + updatePrivateSendVisibility(); } void BitcoinGUI::aboutClicked() @@ -1182,6 +1156,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 diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index e4998dd8f82a..2862eb75db56 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -198,6 +198,10 @@ class BitcoinGUI : public QMainWindow 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); diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 43f67725d869..86fa14bec4ce 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -295,7 +295,7 @@ - + This setting determines the amount of individual masternodes that an input will be mixed through.<br/>More rounds of mixing gives a higher degree of privacy, but also costs more in fees. @@ -322,7 +322,7 @@ - + This amount acts as a threshold to turn off PrivateSend once it's reached. diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 46484aa141ff..671933c1bdaf 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -153,6 +153,8 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : appearance = new AppearanceWidget(ui->widgetAppearance); appearanceLayout->addWidget(appearance); ui->widgetAppearance->setLayout(appearanceLayout); + + updatePrivateSendVisibility(); } OptionsDialog::~OptionsDialog() @@ -389,6 +391,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 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) { diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 6ca5d246e569..99848c120bac 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -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); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 88b21b8b7d94..ed7a4858bf2a 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -202,6 +204,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) @@ -742,3 +746,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(typeWidget->view()); + std::vector vecRows{4, 5, 6, 7, 8}; + for (auto nRow : vecRows) { + typeList->setRowHidden(nRow, !fEnabled); + } +} diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 465ba14b6f72..727738edcbfe 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -104,6 +104,7 @@ private Q_SLOTS: void copyTxPlainText(); void openThirdPartyTxUrl(QString url); void updateWatchOnlyColumn(bool fHaveWatchOnly); + void updatePrivateSendVisibility(); void abandonTx(); Q_SIGNALS: