diff --git a/res/remove.png b/res/remove.png new file mode 100644 index 0000000..8e738d6 Binary files /dev/null and b/res/remove.png differ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6aa7c08..36a98b4 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1620,11 +1620,51 @@ void MainWindow::setupTransactionsTab() { QString memo = txModel->getMemo(index.row()); if (!memo.isEmpty()) { - /* TODO: Add reply button/functionality */ - QMessageBox mb(QMessageBox::Information, tr("Memo"), memo, QMessageBox::Ok, this); + QMessageBox mb; + mb.setText(memo); + mb.setWindowTitle(tr("Memo")); + + QAbstractButton* buttonMemoReply = mb.addButton(tr("Reply"), QMessageBox::YesRole); mb.addButton(tr("OK"), QMessageBox::NoRole); + mb.setTextFormat(Qt::PlainText); mb.setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); mb.exec(); + + if (mb.clickedButton()==buttonMemoReply) { + qDebug() << "Reply clicked"; + + int lastPost = memo.trimmed().lastIndexOf(QRegExp("[\r\n]+")); + QString lastWord = memo.right(memo.length() - lastPost - 1); + + if (Settings::getInstance()->isSaplingAddress(lastWord)) { + + // 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); + }else{ + // TODO: This memo has no reply to address. Show alert or don't show button to begin with. + QMessageBox mb; + mb.setText(tr("Sorry! This memo has no reply to address.")); + mb.setWindowTitle(tr("Error")); + + mb.setTextFormat(Qt::PlainText); + mb.setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); + mb.exec(); + } + } } }); diff --git a/src/txtablemodel.cpp b/src/txtablemodel.cpp index 4afb531..e2ce779 100644 --- a/src/txtablemodel.cpp +++ b/src/txtablemodel.cpp @@ -162,7 +162,7 @@ void TxTableModel::updateAllData() { if (role == Qt::DecorationRole && index.column() == 0) { - qDebug() << "TX Type = " + dat.type; + //qDebug() << "TX Type = " + dat.type; if (!dat.memo.isEmpty()) { // If the memo is a Payment URI, then show a payment request icon @@ -176,9 +176,29 @@ void TxTableModel::updateAllData() { } } else { // TODO: Add appropriate icons for types of txs instead of empty pixmap - //if(this->getType(index.row()) == "incoming"){} + //qDebug() << "Type = " +getType(index.row()) + "Address = " +getAddr(index.row()) + "From Address = " +getFromAddr(index.row()); - // Empty pixmap to make it align + // Send + if(this->getType(index.row()) == "send"){ + QIcon icon(":/icons/res/tx_output.png"); + return QVariant(icon.pixmap(16, 16)); + } + + // Send T->Z - Untested + if(this->getType(index.row()) == "send" && !this->getFromAddr(index.row()).startsWith("zs1")){ + QIcon icon(":/icons/res/lock_closed.png"); + return QVariant(icon.pixmap(16, 16)); + } + + // Receive + if(this->getType(index.row()) == "receive"){ + QIcon icon(":/icons/res/tx_input.png"); + return QVariant(icon.pixmap(16, 16)); + } + + // TODO: Maybe detect mining/coinbase reward and show mining icon + + // Empty pixmap to make it align (old behavior) QPixmap p(16, 16); p.fill(Qt::white); return QVariant(p); @@ -222,6 +242,10 @@ QString TxTableModel::getAddr(int row) const { return modeldata->at(row).address.trimmed(); } +QString TxTableModel::getFromAddr(int row) const { + return modeldata->at(row).fromAddr.trimmed(); +} + qint64 TxTableModel::getDate(int row) const { return modeldata->at(row).datetime; } diff --git a/src/txtablemodel.h b/src/txtablemodel.h index 0ef7262..9e2d02d 100644 --- a/src/txtablemodel.h +++ b/src/txtablemodel.h @@ -20,6 +20,7 @@ public: QString getTxId(int row) const; QString getMemo(int row) const; QString getAddr(int row) const; + QString getFromAddr(int row) const; qint64 getDate(int row) const; QString getType(int row) const; qint64 getConfirmations(int row) const;