|
@ -61,7 +61,7 @@ void MainWindow::setupSendTab() { |
|
|
// Disable custom fees if settings say no
|
|
|
// Disable custom fees if settings say no
|
|
|
ui->minerFeeAmt->setReadOnly(!Settings::getInstance()->getAllowCustomFees()); |
|
|
ui->minerFeeAmt->setReadOnly(!Settings::getInstance()->getAllowCustomFees()); |
|
|
QObject::connect(ui->minerFeeAmt, &QLineEdit::textChanged, [=](auto txt) { |
|
|
QObject::connect(ui->minerFeeAmt, &QLineEdit::textChanged, [=](auto txt) { |
|
|
ui->lblMinerFeeUSD->setText(Settings::getUSDFormat(txt.toDouble())); |
|
|
ui->lblMinerFeeUSD->setText(Settings::getUSDFromZecAmount(txt.toDouble())); |
|
|
}); |
|
|
}); |
|
|
ui->minerFeeAmt->setText(Settings::getDecimalString(Settings::getMinerFee())); |
|
|
ui->minerFeeAmt->setText(Settings::getDecimalString(Settings::getMinerFee())); |
|
|
|
|
|
|
|
@ -69,7 +69,7 @@ void MainWindow::setupSendTab() { |
|
|
QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, [=] (int pos) { |
|
|
QObject::connect(ui->tabWidget, &QTabWidget::currentChanged, [=] (int pos) { |
|
|
if (pos == 1) { |
|
|
if (pos == 1) { |
|
|
QString txt = ui->minerFeeAmt->text(); |
|
|
QString txt = ui->minerFeeAmt->text(); |
|
|
ui->lblMinerFeeUSD->setText(Settings::getUSDFormat(txt.toDouble())); |
|
|
ui->lblMinerFeeUSD->setText(Settings::getUSDFromZecAmount(txt.toDouble())); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
//Fees validator
|
|
|
//Fees validator
|
|
@ -84,30 +84,42 @@ void MainWindow::setupSendTab() { |
|
|
// Recurring button
|
|
|
// Recurring button
|
|
|
QObject::connect(ui->chkRecurring, &QCheckBox::stateChanged, [=] (int checked) { |
|
|
QObject::connect(ui->chkRecurring, &QCheckBox::stateChanged, [=] (int checked) { |
|
|
if (checked) { |
|
|
if (checked) { |
|
|
ui->btnRecurSchedule->setEnabled(true); |
|
|
ui->btnRecurSchedule->setEnabled(true); |
|
|
|
|
|
|
|
|
|
|
|
// If this is the first time the button is checked, open the edit schedule dialog
|
|
|
|
|
|
if (sendTxRecurringInfo == nullptr) { |
|
|
|
|
|
ui->btnRecurSchedule->click(); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
ui->btnRecurSchedule->setEnabled(false); |
|
|
ui->btnRecurSchedule->setEnabled(false); |
|
|
ui->lblRecurDesc->setText(""); |
|
|
ui->lblRecurDesc->setText(""); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Recurring schedule button
|
|
|
// Recurring schedule button
|
|
|
QObject::connect(ui->btnRecurSchedule, &QPushButton::clicked, this, &MainWindow::editSchedule); |
|
|
QObject::connect(ui->btnRecurSchedule, &QPushButton::clicked, this, &MainWindow::editSchedule); |
|
|
|
|
|
|
|
|
// Hide the recurring section for now
|
|
|
|
|
|
ui->chkRecurring->setVisible(false); |
|
|
|
|
|
ui->lblRecurDesc->setVisible(false); |
|
|
|
|
|
ui->btnRecurSchedule->setVisible(false); |
|
|
|
|
|
|
|
|
|
|
|
// Set the default state for the whole page
|
|
|
// Set the default state for the whole page
|
|
|
removeExtraAddresses(); |
|
|
clearSendForm(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void MainWindow::editSchedule() { |
|
|
void MainWindow::editSchedule() { |
|
|
// Open the edit schedule dialog
|
|
|
// Open the edit schedule dialog
|
|
|
Recurring::showEditDialog(this, this, createTxFromSendPage()); |
|
|
RecurringPaymentInfo* recurringInfo = Recurring::getInstance()->getNewRecurringFromTx(this, this, |
|
|
|
|
|
createTxFromSendPage(), this->sendTxRecurringInfo); |
|
|
|
|
|
if (recurringInfo == nullptr) { |
|
|
|
|
|
// User pressed cancel.
|
|
|
|
|
|
// If there is no existing recurring info, uncheck the recurring box
|
|
|
|
|
|
if (sendTxRecurringInfo == nullptr) { |
|
|
|
|
|
ui->chkRecurring->setCheckState(Qt::Unchecked); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
delete this->sendTxRecurringInfo; |
|
|
|
|
|
|
|
|
|
|
|
this->sendTxRecurringInfo = recurringInfo; |
|
|
|
|
|
ui->lblRecurDesc->setText(recurringInfo->getScheduleDescription()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void MainWindow::updateLabelsAutoComplete() { |
|
|
void MainWindow::updateLabelsAutoComplete() { |
|
@ -190,7 +202,7 @@ void MainWindow::inputComboTextChanged(int index) { |
|
|
auto balFmt = Settings::getZECDisplayFormat(bal); |
|
|
auto balFmt = Settings::getZECDisplayFormat(bal); |
|
|
|
|
|
|
|
|
ui->sendAddressBalance->setText(balFmt); |
|
|
ui->sendAddressBalance->setText(balFmt); |
|
|
ui->sendAddressBalanceUSD->setText(Settings::getUSDFormat(bal)); |
|
|
ui->sendAddressBalanceUSD->setText(Settings::getUSDFromZecAmount(bal)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -295,7 +307,13 @@ void MainWindow::addressChanged(int itemNumber, const QString& text) { |
|
|
|
|
|
|
|
|
void MainWindow::amountChanged(int item, const QString& text) { |
|
|
void MainWindow::amountChanged(int item, const QString& text) { |
|
|
auto usd = ui->sendToWidgets->findChild<QLabel*>(QString("AmtUSD") % QString::number(item)); |
|
|
auto usd = ui->sendToWidgets->findChild<QLabel*>(QString("AmtUSD") % QString::number(item)); |
|
|
usd->setText(Settings::getUSDFormat(text.toDouble())); |
|
|
usd->setText(Settings::getUSDFromZecAmount(text.toDouble())); |
|
|
|
|
|
|
|
|
|
|
|
// If there is a recurring payment, update the info there as well
|
|
|
|
|
|
if (sendTxRecurringInfo != nullptr) { |
|
|
|
|
|
Recurring::getInstance()->updateInfoWithTx(sendTxRecurringInfo, createTxFromSendPage()); |
|
|
|
|
|
ui->lblRecurDesc->setText(sendTxRecurringInfo->getScheduleDescription()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void MainWindow::setMemoEnabled(int number, bool enabled) { |
|
|
void MainWindow::setMemoEnabled(int number, bool enabled) { |
|
@ -380,7 +398,7 @@ void MainWindow::memoButtonClicked(int number, bool includeReplyTo) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void MainWindow::removeExtraAddresses() { |
|
|
void MainWindow::clearSendForm() { |
|
|
// The last one is a spacer, so ignore that
|
|
|
// The last one is a spacer, so ignore that
|
|
|
int totalItems = ui->sendToWidgets->children().size() - 2; |
|
|
int totalItems = ui->sendToWidgets->children().size() - 2; |
|
|
|
|
|
|
|
@ -413,6 +431,8 @@ void MainWindow::removeExtraAddresses() { |
|
|
ui->chkRecurring->setCheckState(Qt::Unchecked); |
|
|
ui->chkRecurring->setCheckState(Qt::Unchecked); |
|
|
ui->btnRecurSchedule->setEnabled(false); |
|
|
ui->btnRecurSchedule->setEnabled(false); |
|
|
ui->lblRecurDesc->setText(""); |
|
|
ui->lblRecurDesc->setText(""); |
|
|
|
|
|
delete sendTxRecurringInfo; |
|
|
|
|
|
sendTxRecurringInfo = nullptr; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void MainWindow::maxAmountChecked(int checked) { |
|
|
void MainWindow::maxAmountChecked(int checked) { |
|
@ -513,7 +533,7 @@ Tx MainWindow::createTxFromSendPage() { |
|
|
return tx; |
|
|
return tx; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool MainWindow::confirmTx(Tx tx) { |
|
|
bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) { |
|
|
auto fnSplitAddressForWrap = [=] (const QString& a) -> QString { |
|
|
auto fnSplitAddressForWrap = [=] (const QString& a) -> QString { |
|
|
if (!a.startsWith("z")) return a; |
|
|
if (!a.startsWith("z")) return a; |
|
|
|
|
|
|
|
@ -522,6 +542,11 @@ bool MainWindow::confirmTx(Tx tx) { |
|
|
return splitted; |
|
|
return splitted; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Update the recurring info with the latest Tx
|
|
|
|
|
|
if (rpi != nullptr) { |
|
|
|
|
|
Recurring::getInstance()->updateInfoWithTx(rpi, tx); |
|
|
|
|
|
rpi->updateHash(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Show a confirmation dialog
|
|
|
// Show a confirmation dialog
|
|
|
QDialog d(this); |
|
|
QDialog d(this); |
|
@ -576,7 +601,7 @@ bool MainWindow::confirmTx(Tx tx) { |
|
|
// Amount (USD)
|
|
|
// Amount (USD)
|
|
|
auto AmtUSD = new QLabel(confirm.sendToAddrs); |
|
|
auto AmtUSD = new QLabel(confirm.sendToAddrs); |
|
|
AmtUSD->setObjectName(QString("AmtUSD") % QString::number(i + 1)); |
|
|
AmtUSD->setObjectName(QString("AmtUSD") % QString::number(i + 1)); |
|
|
AmtUSD->setText(Settings::getUSDFormat(toAddr.amount)); |
|
|
AmtUSD->setText(Settings::getUSDFromZecAmount(toAddr.amount)); |
|
|
AmtUSD->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); |
|
|
AmtUSD->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter); |
|
|
confirm.gridLayout->addWidget(AmtUSD, row, 2, 1, 1); |
|
|
confirm.gridLayout->addWidget(AmtUSD, row, 2, 1, 1); |
|
|
|
|
|
|
|
@ -627,7 +652,7 @@ bool MainWindow::confirmTx(Tx tx) { |
|
|
minerFeeUSD->setObjectName(QStringLiteral("minerFeeUSD")); |
|
|
minerFeeUSD->setObjectName(QStringLiteral("minerFeeUSD")); |
|
|
minerFeeUSD->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
|
minerFeeUSD->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); |
|
|
confirm.gridLayout->addWidget(minerFeeUSD, row, 2, 1, 1); |
|
|
confirm.gridLayout->addWidget(minerFeeUSD, row, 2, 1, 1); |
|
|
minerFeeUSD->setText(Settings::getUSDFormat(tx.fee)); |
|
|
minerFeeUSD->setText(Settings::getUSDFromZecAmount(tx.fee)); |
|
|
|
|
|
|
|
|
if (Settings::getInstance()->getAllowCustomFees() && tx.fee != Settings::getMinerFee()) { |
|
|
if (Settings::getInstance()->getAllowCustomFees() && tx.fee != Settings::getMinerFee()) { |
|
|
confirm.warningLabel->setVisible(true); |
|
|
confirm.warningLabel->setVisible(true); |
|
@ -637,6 +662,15 @@ bool MainWindow::confirmTx(Tx tx) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Recurring payment info
|
|
|
|
|
|
if (rpi == nullptr) { |
|
|
|
|
|
confirm.grpRecurring->setVisible(false); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
confirm.grpRecurring->setVisible(true); |
|
|
|
|
|
confirm.lblRecurringDesc->setText(rpi->getScheduleDescription()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Syncing warning
|
|
|
// Syncing warning
|
|
|
confirm.syncingWarning->setVisible(Settings::getInstance()->isSyncing()); |
|
|
confirm.syncingWarning->setVisible(Settings::getInstance()->isSyncing()); |
|
|
|
|
|
|
|
@ -652,13 +686,7 @@ bool MainWindow::confirmTx(Tx tx) { |
|
|
confirm.sendFrom->setToolTip(tooltip); |
|
|
confirm.sendFrom->setToolTip(tooltip); |
|
|
|
|
|
|
|
|
// Show the dialog and submit it if the user confirms
|
|
|
// Show the dialog and submit it if the user confirms
|
|
|
if (d.exec() == QDialog::Accepted) { |
|
|
return d.exec() == QDialog::Accepted; |
|
|
// Then delete the additional fields from the sendTo tab
|
|
|
|
|
|
removeExtraAddresses(); |
|
|
|
|
|
return true; |
|
|
|
|
|
} else { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Send button clicked
|
|
|
// Send button clicked
|
|
@ -676,17 +704,26 @@ void MainWindow::sendButton() { |
|
|
// abort the Tx
|
|
|
// abort the Tx
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Show a dialog to confirm the Tx
|
|
|
// Show a dialog to confirm the Tx
|
|
|
if (confirmTx(tx)) { |
|
|
if (confirmTx(tx, sendTxRecurringInfo)) { |
|
|
|
|
|
// Add it to the list
|
|
|
|
|
|
Recurring::getInstance()->addRecurringInfo(*sendTxRecurringInfo); |
|
|
|
|
|
|
|
|
|
|
|
// Then delete the additional fields from the sendTo tab
|
|
|
|
|
|
clearSendForm(); |
|
|
|
|
|
|
|
|
// And send the Tx
|
|
|
// And send the Tx
|
|
|
rpc->executeTransaction(tx, |
|
|
rpc->executeTransaction(tx, |
|
|
|
|
|
// Submitted
|
|
|
[=] (QString opid) { |
|
|
[=] (QString opid) { |
|
|
ui->statusBar->showMessage(tr("Computing Tx: ") % opid); |
|
|
ui->statusBar->showMessage(tr("Computing Tx: ") % opid); |
|
|
}, |
|
|
}, |
|
|
[=] (QString, QString txid) { |
|
|
// Accepted
|
|
|
|
|
|
[=] (QString opid, QString txid) { |
|
|
ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); |
|
|
ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); |
|
|
}, |
|
|
}, |
|
|
|
|
|
// Errored out
|
|
|
[=] (QString opid, QString errStr) { |
|
|
[=] (QString opid, QString errStr) { |
|
|
ui->statusBar->showMessage(QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000); |
|
|
ui->statusBar->showMessage(QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000); |
|
|
|
|
|
|
|
@ -720,6 +757,6 @@ QString MainWindow::doSendTxValidations(Tx tx) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void MainWindow::cancelButton() { |
|
|
void MainWindow::cancelButton() { |
|
|
removeExtraAddresses(); |
|
|
clearSendForm(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|