mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
qt: Give PrivateSend separate instances of SendCoinsDialog + CCoinControl (#3625)
Prior to this commit there are (imo) flaws in the behaviour of the PrivateSend tab. - If you enter an address, label, add a recipient, do whatever in the normal Send tab its also reflected in the PrivateSend tab - If you select fully mixed coins in the Send tab's CoinControl they are also selected in the PrivateSend tab if you switch over. - If you select non-fully mixed coins in the Send tab's CoinControl you get a warning when switching over to PrivateSend tab due to non-fully mixed coins selected in CoinControl. With giving the private send tab separate instances of `SendCoinsDialog` and `CCoinControl` they are independent from each other which just makes more sense imo and by doing this the points above are solved. I would say this just better reflects the actual behaviour of a tab.
This commit is contained in:
parent
09cd844785
commit
ca76dd0868
@ -34,6 +34,7 @@
|
||||
|
||||
QList<CAmount> CoinControlDialog::payAmounts;
|
||||
bool CoinControlDialog::fSubtractFeeFromAmount = false;
|
||||
CoinControlDialog::Mode CoinControlDialog::mode{CoinControlDialog::Mode::NORMAL};
|
||||
|
||||
bool CCoinControlWidgetItem::operator<(const QTreeWidgetItem &other) const {
|
||||
int column = treeWidget()->sortColumn();
|
||||
@ -514,16 +515,6 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
||||
continue;
|
||||
}
|
||||
|
||||
// unselect non-fully-mixed, this can happen when users switch from Send to PrivateSend
|
||||
if (coinControl()->IsUsingPrivateSend()) {
|
||||
int nRounds = model->getRealOutpointPrivateSendRounds(outpt);
|
||||
if (nRounds < privateSendClient.nPrivateSendRounds) {
|
||||
coinControl()->UnSelect(outpt);
|
||||
fUnselectedNonMixed = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Quantity
|
||||
nQuantity++;
|
||||
|
||||
@ -669,10 +660,22 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
||||
}
|
||||
}
|
||||
|
||||
void CoinControlDialog::usePrivateSend(bool fUsePrivateSend)
|
||||
{
|
||||
CoinControlDialog::mode = fUsePrivateSend ? CoinControlDialog::Mode::PRIVATESEND : CoinControlDialog::Mode::NORMAL;
|
||||
}
|
||||
|
||||
CCoinControl* CoinControlDialog::coinControl()
|
||||
{
|
||||
static CCoinControl coin_control;
|
||||
return &coin_control;
|
||||
if (CoinControlDialog::mode == CoinControlDialog::Mode::NORMAL) {
|
||||
static CCoinControl coinControlNormal;
|
||||
coinControlNormal.UsePrivateSend(false);
|
||||
return &coinControlNormal;
|
||||
} else {
|
||||
static CCoinControl coinControlPrivateSend;
|
||||
coinControlPrivateSend.UsePrivateSend(true);
|
||||
return &coinControlPrivateSend;
|
||||
}
|
||||
}
|
||||
|
||||
void CoinControlDialog::updateView()
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
static QList<CAmount> payAmounts;
|
||||
static CCoinControl *coinControl();
|
||||
static bool fSubtractFeeFromAmount;
|
||||
static void usePrivateSend(bool fUsePrivateSend);
|
||||
|
||||
private:
|
||||
Ui::CoinControlDialog *ui;
|
||||
@ -83,6 +84,13 @@ private:
|
||||
};
|
||||
friend class CCoinControlWidgetItem;
|
||||
|
||||
enum class Mode {
|
||||
NORMAL,
|
||||
PRIVATESEND,
|
||||
};
|
||||
|
||||
static CoinControlDialog::Mode mode;
|
||||
|
||||
private Q_SLOTS:
|
||||
void showMenu(const QPoint &);
|
||||
void copyAmount();
|
||||
|
@ -51,14 +51,14 @@ int getIndexForConfTarget(int target) {
|
||||
return confTargets.size() - 1;
|
||||
}
|
||||
|
||||
SendCoinsDialog::SendCoinsDialog(QWidget* parent) :
|
||||
SendCoinsDialog::SendCoinsDialog(bool _fPrivateSend, QWidget* parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SendCoinsDialog),
|
||||
clientModel(0),
|
||||
model(0),
|
||||
fNewRecipientAllowed(true),
|
||||
fFeeMinimized(true),
|
||||
fPrivateSend(false)
|
||||
fPrivateSend(_fPrivateSend)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -155,6 +155,14 @@ SendCoinsDialog::SendCoinsDialog(QWidget* parent) :
|
||||
ui->customFee->setValue(settings.value("nTransactionFee").toLongLong());
|
||||
ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool());
|
||||
minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool());
|
||||
|
||||
if (fPrivateSend) {
|
||||
ui->sendButton->setText("PrivateS&end");
|
||||
ui->sendButton->setToolTip("Confirm the PrivateSend action");
|
||||
} else {
|
||||
ui->sendButton->setText("S&end");
|
||||
ui->sendButton->setToolTip("Confirm the send action");
|
||||
}
|
||||
}
|
||||
|
||||
void SendCoinsDialog::setClientModel(ClientModel *_clientModel)
|
||||
@ -629,7 +637,6 @@ void SendCoinsDialog::updateDisplayUnit()
|
||||
{
|
||||
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance(),
|
||||
model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance());
|
||||
CoinControlDialog::coinControl()->UsePrivateSend(fPrivateSend);
|
||||
coinControlUpdateLabels();
|
||||
ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
|
||||
updateMinFeeLabel();
|
||||
@ -788,19 +795,11 @@ void SendCoinsDialog::updateCoinControlState(CCoinControl& ctrl)
|
||||
ctrl.m_confirm_target = getConfTargetForIndex(ui->confTargetSelector->currentIndex());
|
||||
}
|
||||
|
||||
void SendCoinsDialog::setPrivateSend(bool privateSend)
|
||||
void SendCoinsDialog::showEvent(QShowEvent* event)
|
||||
{
|
||||
if (fPrivateSend != privateSend) {
|
||||
fPrivateSend = privateSend;
|
||||
coinControlUpdateLabels();
|
||||
updateDisplayUnit();
|
||||
if (privateSend) {
|
||||
ui->sendButton->setText("PrivateS&end");
|
||||
ui->sendButton->setToolTip("Confirm the PrivateSend action");
|
||||
} else {
|
||||
ui->sendButton->setText("S&end");
|
||||
ui->sendButton->setToolTip("Confirm the send action");
|
||||
}
|
||||
QWidget::showEvent(event);
|
||||
if (!event->spontaneous()) {
|
||||
CoinControlDialog::usePrivateSend(fPrivateSend);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QShowEvent>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
|
||||
@ -32,7 +33,7 @@ class SendCoinsDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SendCoinsDialog(QWidget* parent = 0);
|
||||
explicit SendCoinsDialog(bool fPrivateSend = false, QWidget* parent = 0);
|
||||
~SendCoinsDialog();
|
||||
|
||||
void setClientModel(ClientModel *clientModel);
|
||||
@ -45,7 +46,6 @@ public:
|
||||
void setAddress(const QString &address);
|
||||
void pasteEntry(const SendCoinsRecipient &rv);
|
||||
bool handlePaymentRequest(const SendCoinsRecipient &recipient);
|
||||
void setPrivateSend(bool privateSend);
|
||||
|
||||
public Q_SLOTS:
|
||||
void clear();
|
||||
@ -74,6 +74,8 @@ private:
|
||||
// Update the passed in CCoinControl with state from the GUI
|
||||
void updateCoinControlState(CCoinControl& ctrl);
|
||||
|
||||
void showEvent(QShowEvent* event);
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_sendButton_clicked();
|
||||
void on_buttonChooseFee_clicked();
|
||||
|
@ -71,6 +71,7 @@ WalletView::WalletView(QWidget* parent) :
|
||||
|
||||
receiveCoinsPage = new ReceiveCoinsDialog();
|
||||
sendCoinsPage = new SendCoinsDialog();
|
||||
privateSendCoinsPage = new SendCoinsDialog(true);
|
||||
|
||||
usedSendingAddressesPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab, this);
|
||||
usedReceivingAddressesPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab, this);
|
||||
@ -79,6 +80,7 @@ WalletView::WalletView(QWidget* parent) :
|
||||
addWidget(transactionsPage);
|
||||
addWidget(receiveCoinsPage);
|
||||
addWidget(sendCoinsPage);
|
||||
addWidget(privateSendCoinsPage);
|
||||
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool()) {
|
||||
@ -99,8 +101,9 @@ WalletView::WalletView(QWidget* parent) :
|
||||
// Clicking on "Export" allows to export the transaction list
|
||||
connect(exportButton, SIGNAL(clicked()), transactionView, SLOT(exportClicked()));
|
||||
|
||||
// Pass through messages from sendCoinsPage
|
||||
// Pass through messages from SendCoinsDialog
|
||||
connect(sendCoinsPage, SIGNAL(message(QString,QString,unsigned int)), this, SIGNAL(message(QString,QString,unsigned int)));
|
||||
connect(privateSendCoinsPage, SIGNAL(message(QString, QString, unsigned int)), this, SIGNAL(message(QString, QString, unsigned int)));
|
||||
|
||||
// Pass through messages from transactionView
|
||||
connect(transactionView, SIGNAL(message(QString,QString,unsigned int)), this, SIGNAL(message(QString,QString,unsigned int)));
|
||||
@ -139,6 +142,7 @@ void WalletView::setClientModel(ClientModel *_clientModel)
|
||||
|
||||
overviewPage->setClientModel(_clientModel);
|
||||
sendCoinsPage->setClientModel(_clientModel);
|
||||
privateSendCoinsPage->setClientModel(_clientModel);
|
||||
QSettings settings;
|
||||
if (settings.value("fShowMasternodesTab").toBool()) {
|
||||
masternodeListPage->setClientModel(_clientModel);
|
||||
@ -158,6 +162,7 @@ void WalletView::setWalletModel(WalletModel *_walletModel)
|
||||
}
|
||||
receiveCoinsPage->setModel(_walletModel);
|
||||
sendCoinsPage->setModel(_walletModel);
|
||||
privateSendCoinsPage->setModel(_walletModel);
|
||||
usedReceivingAddressesPage->setModel(_walletModel ? _walletModel->getAddressTableModel() : nullptr);
|
||||
usedSendingAddressesPage->setModel(_walletModel ? _walletModel->getAddressTableModel() : nullptr);
|
||||
|
||||
@ -239,7 +244,6 @@ void WalletView::gotoReceiveCoinsPage()
|
||||
|
||||
void WalletView::gotoSendCoinsPage(QString addr)
|
||||
{
|
||||
sendCoinsPage->setPrivateSend(false);
|
||||
setCurrentWidget(sendCoinsPage);
|
||||
|
||||
if (!addr.isEmpty()) {
|
||||
@ -249,11 +253,10 @@ void WalletView::gotoSendCoinsPage(QString addr)
|
||||
|
||||
void WalletView::gotoPrivateSendCoinsPage(QString addr)
|
||||
{
|
||||
sendCoinsPage->setPrivateSend(true);
|
||||
setCurrentWidget(sendCoinsPage);
|
||||
setCurrentWidget(privateSendCoinsPage);
|
||||
|
||||
if (!addr.isEmpty())
|
||||
sendCoinsPage->setAddress(addr);
|
||||
privateSendCoinsPage->setAddress(addr);
|
||||
}
|
||||
|
||||
void WalletView::gotoSignMessageTab(QString addr)
|
||||
|
@ -63,6 +63,7 @@ private:
|
||||
QWidget *transactionsPage;
|
||||
ReceiveCoinsDialog *receiveCoinsPage;
|
||||
SendCoinsDialog *sendCoinsPage;
|
||||
SendCoinsDialog* privateSendCoinsPage;
|
||||
AddressBookPage *usedSendingAddressesPage;
|
||||
AddressBookPage *usedReceivingAddressesPage;
|
||||
MasternodeList *masternodeListPage;
|
||||
|
Loading…
Reference in New Issue
Block a user