send: disable send button during tx broadcast

This commit is contained in:
tobtoht 2023-12-15 14:10:55 +01:00
parent f8bf233600
commit 55a8955377
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
5 changed files with 20 additions and 13 deletions

View file

@ -1577,7 +1577,7 @@ void MainWindow::onKeysCorrupted() {
if (!m_criticalWarningShown) {
m_criticalWarningShown = true;
Utils::showError(this, "Wallet keys are corrupted", "WARNING!\n\nTo prevent LOSS OF FUNDS do NOT continue to use this wallet file.\n\nRestore your wallet from seed.\n\nPlease report this incident to the Feather developers.\n\nWARNING!");
m_sendWidget->disableSendButton();
m_sendWidget->disallowSending();
}
}

View file

@ -32,8 +32,10 @@ SendWidget::SendWidget(Wallet *wallet, QWidget *parent)
QValidator *validator = new QRegularExpressionValidator(rx, this);
ui->lineAmount->setValidator(validator);
connect(m_wallet, &Wallet::initiateTransaction, this, &SendWidget::onInitiateTransaction);
connect(m_wallet, &Wallet::transactionCreated, this, &SendWidget::onEndTransaction);
connect(m_wallet, &Wallet::initiateTransaction, this, &SendWidget::disableSendButton);
connect(m_wallet, &Wallet::transactionCreated, this, &SendWidget::enableSendButton);
connect(m_wallet, &Wallet::beginCommitTransaction, this, &SendWidget::disableSendButton);
connect(m_wallet, &Wallet::transactionCommitted, this, &SendWidget::enableSendButton);
connect(WalletManager::instance(), &WalletManager::openAliasResolved, this, &SendWidget::onOpenAliasResolved);
@ -349,18 +351,19 @@ void SendWidget::payToMany() {
ui->lineAddress->payToMany();
}
void SendWidget::onInitiateTransaction() {
void SendWidget::disableSendButton() {
ui->btnSend->setEnabled(false);
}
void SendWidget::onEndTransaction() {
if (!m_sendDisabled) {
ui->btnSend->setEnabled(true);
void SendWidget::enableSendButton() {
if (m_disallowSending) {
return;
}
ui->btnSend->setEnabled(true);
}
void SendWidget::disableSendButton() {
m_sendDisabled = true;
void SendWidget::disallowSending() {
m_disallowSending = true;
ui->btnSend->setEnabled(false);
}

View file

@ -38,11 +38,12 @@ public slots:
void updateConversionLabel();
void onOpenAliasResolved(const QString &openAlias, const QString &address, bool dnssecValid);
void onPreferredFiatCurrencyChanged();
void disableSendButton();
void setWebsocketEnabled(bool enabled);
void onInitiateTransaction();
void onEndTransaction();
void disableSendButton();
void enableSendButton();
void disallowSending();
private slots:
void onDataPasted(const QString &data);
@ -57,7 +58,7 @@ private:
QScopedPointer<Ui::SendWidget> ui;
Wallet *m_wallet;
bool m_sendDisabled = false;
bool m_disallowSending = false;
};
#endif // FEATHER_SENDWIDGET_H

View file

@ -834,6 +834,8 @@ void Wallet::onTransactionCreated(Monero::PendingTransaction *mtx, const QVector
// Phase 3: Commit or dispose
void Wallet::commitTransaction(PendingTransaction *tx, const QString &description) {
emit beginCommitTransaction();
// Clear list of selected transfers
this->setSelectedInputs({});

View file

@ -431,6 +431,7 @@ signals:
void deviceButtonPressed();
void deviceError(const QString &message);
void walletPassphraseNeeded(bool onDevice);
void beginCommitTransaction();
void transactionCommitted(bool status, PendingTransaction *t, const QStringList& txid, const QMap<QString, QString> &txHexMap);
void deviceShowAddressShowed();
void transactionProofVerified(TxProofResult result);