From af98833558c66397dba33baf3b749bede2daa1ca Mon Sep 17 00:00:00 2001 From: fekt Date: Sun, 9 Oct 2022 20:28:33 -0400 Subject: [PATCH] Icons in tx table and memo improvement --- res/remove.png | Bin 0 -> 1723 bytes src/mainwindow.cpp | 44 +++++++++++++++++++++++++++++++++++++++++-- src/txtablemodel.cpp | 30 ++++++++++++++++++++++++++--- src/txtablemodel.h | 1 + 4 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 res/remove.png diff --git a/res/remove.png b/res/remove.png new file mode 100644 index 0000000000000000000000000000000000000000..8e738d6301fe8666a4de6495fc1bdda87c2dcce0 GIT binary patch literal 1723 zcmV;s21NOZP)1XPWXmqcTQCfn@`!3d{rhzzxvyBsVhV zJWy3&Zjgq6CE&m#piXiia}Fu6bdbh?72r4^r2FJpbQx1%{|7Y;>=gjgeX<7(cRes! z_%{m-s$DjLTGs&s27p!IIwDxNaxJcCT=_W@mcfhY3WDf!)IL#`)u%%7-2on#CW8qc%QM+Hj4L65Em|n~txT}mpnbEj$6^p*5_~j`XZ?&N zE6E|N>!(FLZ6E}&RSReB^U^1H!gC8}@@l5QWT7=x>Rs1l<-$9QKjvDNz)TZnR=O^g z`rp(zqr{#}fJrKv>Gr*+3xV}mZ1;z=0A`vu_@-+M7T}F(-lJDwl96koz$eF`VpF6q z2V;AgANXWwvoW8*OyA4T9E_C=(VPRX0>XMFb0$M0eU@WA%VNDxJNa=|i)h;+U{Xb5;wP(m26hW=JVRLH_rP)mRyFju4*3AKWH8~HhxOw; zB(x5&&Ry40$q`9wza<~QOzN{`7gp<^)W>(k8hJy&113w}zbX zFvmpJuoBr=Cb=$E7hv-S6Kw>1RXIUR0c+gzvuqgHaoz>kzQIH@f!CJ{;I+k=uS3F; zIcE&)xNikaf|NG~PRza>c5s&_&;-_H=$)u+rmhWg87nrxY9^87jL%3D9iUC77-O;n ztci@D!6Y(WvjH}0Fu_8AgRM2RykUtB3kLQawE;G5Fu_zH*U>|-v^$}7fOToJ4qECy zWnj-~8(>X?3F-m;eVw2++H(DKhm}bCPHWGm4X|Z{37!P@sCW9-G*ZBt46O501A8vp z09!YxeC*934AKc&VPGW=&}l0{*KL69rX2h<$3Wpj&x*J$G$@9i<%nOU}{V zMoMUxSrphA>iRXMO^5@>CkO` zWZQZ@I7fDHR@YQyt|@i?M&|t0@JeLi6%AlU7QoaLftXSRGzllNBpgk1i!;ql6G>xA zB-K>y$Wpbn7$VMM2-9+-n#04Dt=y;Bg;R{S~EKwtXmUOV~gyXY*_OVA)vZdkn2%Gio(!+8@||V-?HR zMIX8lm}y_&Y+4sNGzXjOB3N^UY7S=Ee(z7r{e2Dl0Gl>%&bIxYLxam-W$5$U;mu>( zv^h+JONSP+hb3+yYtyVbObc0U(i~xvW^IEWSsV10UNjKjMFR=t^(v28uJTBvS*TtR(fD<8OAGyx%^ql zvFI{ZC>s^nLp~&>P6q)Y9mt$Rg|$m0LBpz)@9ukYE+?I{`!aSE*A~YZp0CJeWmKBK zG^Nebx->L9k}da{{CijaZ&^M&Ex%g}y(RBTVBIci1O=v|z*H2N0#gYh{{YgetMemo(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;