diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 49c17d9..c09a184 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -504,7 +504,7 @@ void MainWindow::addressBook() { void MainWindow::donate() { // Set up a donation to me :) - removeExtraAddresses(); + clearSendForm(); ui->Address1->setText(Settings::getDonationAddr( Settings::getInstance()->isSaplingAddress(ui->inputsCombo->currentText()))); @@ -735,7 +735,7 @@ void MainWindow::payZcashURI() { } // Now, set the fields on the send tab - removeExtraAddresses(); + clearSendForm(); ui->Address1->setText(addr); ui->Address1->setCursorPosition(0); ui->Amount1->setText(QString::number(amount)); @@ -933,7 +933,7 @@ void MainWindow::setupBalancesTab() { // If there's a to address, add that as well if (!to.isEmpty()) { // Remember to clear any existing address fields, because we are creating a new transaction. - this->removeExtraAddresses(); + this->clearSendForm(); ui->Address1->setText(to); } @@ -1326,6 +1326,8 @@ MainWindow::~MainWindow() delete rpc; delete labelCompleter; + delete sendTxRecurringInfo; + delete loadingMovie; delete logger; } diff --git a/src/mainwindow.h b/src/mainwindow.h index d4e0458..f177dba 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -65,7 +65,7 @@ private: void setupSettingsModal(); void setupStatusBar(); - void removeExtraAddresses(); + void clearSendForm(); Tx createTxFromSendPage(); bool confirmTx(Tx tx, RecurringPaymentInfo* rpi); diff --git a/src/recurring.cpp b/src/recurring.cpp index 1d4429b..b8e6672 100644 --- a/src/recurring.cpp +++ b/src/recurring.cpp @@ -75,12 +75,8 @@ RecurringPaymentInfo* Recurring::getNewRecurringFromTx(QWidget* parent, MainWind if (d.exec() == QDialog::Accepted) { // Construct a new Object and return it auto r = new RecurringPaymentInfo(); - r->toAddr = tx.toAddrs[0].addr; - r->memo = tx.toAddrs[0].txtMemo; - r->amt = tx.toAddrs[0].amount; - r->currency = Settings::getTokenName(); + updateInfoWithTx(r, tx); r->desc = ui.txtDesc->text(); - r->fromAddr = tx.fromAddr; r->numPayments = ui.txtNumPayments->text().toInt(); r->schedule = (Schedule)ui.cmbSchedule->currentData().toInt(); r->startDate = QDateTime::currentDateTime(); @@ -92,6 +88,14 @@ RecurringPaymentInfo* Recurring::getNewRecurringFromTx(QWidget* parent, MainWind } } +void Recurring::updateInfoWithTx(RecurringPaymentInfo* r, Tx tx) { + r->toAddr = tx.toAddrs[0].addr; + r->memo = tx.toAddrs[0].txtMemo; + r->amt = tx.toAddrs[0].amount; + r->currency = Settings::getTokenName(); + r->fromAddr = tx.fromAddr; +} + QDateTime Recurring::getNextPaymentDate(Schedule s) { auto nextDate = QDateTime::currentDateTime(); diff --git a/src/recurring.h b/src/recurring.h index 1268ca2..32f62ec 100644 --- a/src/recurring.h +++ b/src/recurring.h @@ -40,7 +40,9 @@ public: Recurring() = default; static RecurringPaymentInfo* getNewRecurringFromTx(QWidget* parent, MainWindow* main, Tx tx, RecurringPaymentInfo* rpi); - static QDateTime getNextPaymentDate(Schedule s); + + static QDateTime getNextPaymentDate(Schedule s); + static void updateInfoWithTx(RecurringPaymentInfo* r, Tx tx); }; diff --git a/src/sendtab.cpp b/src/sendtab.cpp index bfa877f..a126aaf 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -98,7 +98,7 @@ void MainWindow::setupSendTab() { QObject::connect(ui->btnRecurSchedule, &QPushButton::clicked, this, &MainWindow::editSchedule); // Set the default state for the whole page - removeExtraAddresses(); + clearSendForm(); } void MainWindow::editSchedule() { @@ -359,7 +359,7 @@ void MainWindow::memoButtonClicked(int number, bool includeReplyTo) { } } -void MainWindow::removeExtraAddresses() { +void MainWindow::clearSendForm() { // The last one is a spacer, so ignore that int totalItems = ui->sendToWidgets->children().size() - 2; @@ -503,6 +503,10 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) { return splitted; }; + // Update the recurring info with the latest Tx + if (rpi != nullptr) { + Recurring::updateInfoWithTx(rpi, tx); + } // Show a confirmation dialog QDialog d(this); @@ -644,7 +648,7 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) { // Show the dialog and submit it if the user confirms if (d.exec() == QDialog::Accepted) { // Then delete the additional fields from the sendTo tab - removeExtraAddresses(); + clearSendForm(); return true; } else { return false; @@ -666,17 +670,20 @@ void MainWindow::sendButton() { // abort the Tx return; } - + // Show a dialog to confirm the Tx if (confirmTx(tx, sendTxRecurringInfo)) { // And send the Tx rpc->executeTransaction(tx, + // Submitted [=] (QString opid) { ui->statusBar->showMessage(tr("Computing Tx: ") % opid); }, + // Accepted [=] (QString opid, QString txid) { ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); }, + // Errored out [=] (QString opid, QString errStr) { ui->statusBar->showMessage(QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000); @@ -710,6 +717,6 @@ QString MainWindow::doSendTxValidations(Tx tx) { } void MainWindow::cancelButton() { - removeExtraAddresses(); + clearSendForm(); }