Reply to context menu
This commit is contained in:
@@ -937,6 +937,34 @@ void MainWindow::setupTransactionsTab() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If memo contains a reply to addess, add a "Reply to" menu item
|
||||||
|
if (!memo.isEmpty()) {
|
||||||
|
int lastPost = memo.trimmed().lastIndexOf(QRegExp("[\r\n]+"));
|
||||||
|
QString lastWord = memo.right(memo.length() - lastPost - 1);
|
||||||
|
qDebug() << lastWord;
|
||||||
|
if (Settings::getInstance()->isSaplingAddress(lastWord) ||
|
||||||
|
Settings::getInstance()->isSproutAddress(lastWord)) {
|
||||||
|
menu.addAction(tr("Reply to ") + lastWord.left(25) + "...", [=]() {
|
||||||
|
// First, cancel any pending stuff in the send tab by pretending to click
|
||||||
|
// the cancel button
|
||||||
|
cancelButton();
|
||||||
|
|
||||||
|
// Then set up the fields in the send tab
|
||||||
|
ui->Address1->setText(lastWord);
|
||||||
|
ui->Address1->setCursorPosition(0);
|
||||||
|
ui->Amount1->setText("0.0001");
|
||||||
|
|
||||||
|
// And switch to the send tab.
|
||||||
|
ui->tabWidget->setCurrentIndex(1);
|
||||||
|
|
||||||
|
qApp->processEvents();
|
||||||
|
|
||||||
|
// Click the memo button
|
||||||
|
this->memoButtonClicked(1, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menu.exec(ui->transactionsTable->viewport()->mapToGlobal(pos));
|
menu.exec(ui->transactionsTable->viewport()->mapToGlobal(pos));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ private:
|
|||||||
void addNewZaddr(bool sapling);
|
void addNewZaddr(bool sapling);
|
||||||
std::function<void(bool)> addZAddrsToComboList(bool sapling);
|
std::function<void(bool)> addZAddrsToComboList(bool sapling);
|
||||||
|
|
||||||
void memoButtonClicked(int number);
|
void memoButtonClicked(int number, bool includeReplyTo = false);
|
||||||
void setMemoEnabled(int number, bool enabled);
|
void setMemoEnabled(int number, bool enabled);
|
||||||
|
|
||||||
QString doSendTxValidations(Tx tx);
|
QString doSendTxValidations(Tx tx);
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ void MainWindow::setMemoEnabled(int number, bool enabled) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::memoButtonClicked(int number) {
|
void MainWindow::memoButtonClicked(int number, bool includeReplyTo) {
|
||||||
// Memos can only be used with zAddrs. So check that first
|
// Memos can only be used with zAddrs. So check that first
|
||||||
auto addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") + QString::number(number));
|
auto addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") + QString::number(number));
|
||||||
if (!AddressBook::addressFromAddressLabel(addr->text()).startsWith("z")) {
|
if (!AddressBook::addressFromAddressLabel(addr->text()).startsWith("z")) {
|
||||||
@@ -293,8 +293,7 @@ void MainWindow::memoButtonClicked(int number) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Insert From Address button
|
auto fnAddReplyTo = [=, &dialog]() {
|
||||||
QObject::connect(memoDialog.btnInsertFrom, &QPushButton::clicked, [=, &dialog] () {
|
|
||||||
QString replyTo = ui->inputsCombo->currentText();
|
QString replyTo = ui->inputsCombo->currentText();
|
||||||
if (!Settings::isZAddress(replyTo)) {
|
if (!Settings::isZAddress(replyTo)) {
|
||||||
replyTo = rpc->getDefaultSaplingAddress();
|
replyTo = rpc->getDefaultSaplingAddress();
|
||||||
@@ -305,18 +304,23 @@ void MainWindow::memoButtonClicked(int number) {
|
|||||||
if (curText.endsWith(replyTo))
|
if (curText.endsWith(replyTo))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memoDialog.memoTxt->setPlainText(memoDialog.memoTxt->toPlainText() +
|
memoDialog.memoTxt->setPlainText(curText + "\n" + tr("Reply to") + ":\n" + replyTo);
|
||||||
"\n" + tr("Reply to") + ":\n" + replyTo);
|
|
||||||
|
|
||||||
// MacOS has a really annoying bug where the Plaintext doesn't refresh when the content is
|
// MacOS has a really annoying bug where the Plaintext doesn't refresh when the content is
|
||||||
// updated. So we do this ugly hack - resize the window slightly to force it to refresh
|
// updated. So we do this ugly hack - resize the window slightly to force it to refresh
|
||||||
dialog.setGeometry(dialog.geometry().adjusted(0,0,0,1));
|
dialog.setGeometry(dialog.geometry().adjusted(0,0,0,1));
|
||||||
dialog.setGeometry(dialog.geometry().adjusted(0,0,0,-1));
|
dialog.setGeometry(dialog.geometry().adjusted(0,0,0,-1));
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// Insert From Address button
|
||||||
|
QObject::connect(memoDialog.btnInsertFrom, &QPushButton::clicked, fnAddReplyTo);
|
||||||
|
|
||||||
memoDialog.memoTxt->setPlainText(currentMemo);
|
memoDialog.memoTxt->setPlainText(currentMemo);
|
||||||
memoDialog.memoTxt->setFocus();
|
memoDialog.memoTxt->setFocus();
|
||||||
|
|
||||||
|
if (includeReplyTo)
|
||||||
|
fnAddReplyTo();
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
memoTxt->setText(memoDialog.memoTxt->toPlainText());
|
memoTxt->setText(memoDialog.memoTxt->toPlainText());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,19 +54,31 @@ void Settings::setTestnet(bool isTestnet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isSaplingAddress(QString addr) {
|
bool Settings::isSaplingAddress(QString addr) {
|
||||||
|
if (!isValidAddress(addr))
|
||||||
|
return false;
|
||||||
|
|
||||||
return ( isTestnet() && addr.startsWith("ztestsapling")) ||
|
return ( isTestnet() && addr.startsWith("ztestsapling")) ||
|
||||||
(!isTestnet() && addr.startsWith("zs"));
|
(!isTestnet() && addr.startsWith("zs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isSproutAddress(QString addr) {
|
bool Settings::isSproutAddress(QString addr) {
|
||||||
|
if (!isValidAddress(addr))
|
||||||
|
return false;
|
||||||
|
|
||||||
return isZAddress(addr) && !isSaplingAddress(addr);
|
return isZAddress(addr) && !isSaplingAddress(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isZAddress(QString addr) {
|
bool Settings::isZAddress(QString addr) {
|
||||||
|
if (!isValidAddress(addr))
|
||||||
|
return false;
|
||||||
|
|
||||||
return addr.startsWith("z");
|
return addr.startsWith("z");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::isTAddress(QString addr) {
|
bool Settings::isTAddress(QString addr) {
|
||||||
|
if (!isValidAddress(addr))
|
||||||
|
return false;
|
||||||
|
|
||||||
return addr.startsWith("t");
|
return addr.startsWith("t");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user