Browse Source

Icons in tx table and memo improvement

pull/112/head
fekt 2 years ago
parent
commit
af98833558
  1. BIN
      res/remove.png
  2. 44
      src/mainwindow.cpp
  3. 30
      src/txtablemodel.cpp
  4. 1
      src/txtablemodel.h

BIN
res/remove.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

44
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();
}
}
}
});

30
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;
}

1
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;

Loading…
Cancel
Save