From 484f61759e41b822e66a93c1dd2e814dea11bbe8 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Fri, 22 Oct 2021 18:11:02 +0200 Subject: [PATCH] TxInfoDialog: added a clickable icon to view transaction on block explorer --- src/assets.qrc | 1 + src/dialog/TxInfoDialog.cpp | 13 +++++++++++++ src/dialog/TxInfoDialog.h | 1 + src/dialog/TxInfoDialog.ui | 15 ++++++++++++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/assets.qrc b/src/assets.qrc index 09e28c3..bf99e01 100644 --- a/src/assets.qrc +++ b/src/assets.qrc @@ -34,6 +34,7 @@ assets/images/copy.png assets/images/cutexmrfox.png assets/images/edit.png + assets/images/external-link.svg assets/images/exchange.png assets/images/exchange_white.png assets/images/expired.png diff --git a/src/dialog/TxInfoDialog.cpp b/src/dialog/TxInfoDialog.cpp index 14920e5..eb0bfef 100644 --- a/src/dialog/TxInfoDialog.cpp +++ b/src/dialog/TxInfoDialog.cpp @@ -9,6 +9,7 @@ #include "appcontext.h" #include "config.h" +#include "constants.h" #include "libwalletqt/Coins.h" #include "libwalletqt/CoinsInfo.h" #include "libwalletqt/TransactionHistory.h" @@ -16,6 +17,7 @@ #include "libwalletqt/WalletManager.h" #include "model/ModelUtils.h" #include "Utils.h" +#include "utils/Icons.h" TxInfoDialog::TxInfoDialog(QSharedPointer ctx, TransactionInfo *txInfo, QWidget *parent) : QDialog(parent) @@ -26,6 +28,10 @@ TxInfoDialog::TxInfoDialog(QSharedPointer ctx, TransactionInfo *txIn { ui->setupUi(this); + ui->btn_viewOnBlockExplorer->setIcon(icons()->icon("external-link.svg")); + ui->btn_viewOnBlockExplorer->setToolTip("View on block explorer"); + connect(ui->btn_viewOnBlockExplorer, &QPushButton::clicked, this, &TxInfoDialog::viewOnBlockExplorer); + m_txid = txInfo->hash(); ui->label_txid->setText(m_txid); @@ -85,6 +91,9 @@ TxInfoDialog::TxInfoDialog(QSharedPointer ctx, TransactionInfo *txIn } this->adjustSize(); + + // Don't autofocus any of the buttons. There is probably a better way for this. + ui->label_txid->setFocus(); } void TxInfoDialog::adjustHeight(QTextEdit *textEdit, qreal docHeight) { @@ -168,4 +177,8 @@ void TxInfoDialog::createTxProof() { m_txProofDialog->getTxKey(); } +void TxInfoDialog::viewOnBlockExplorer() { + Utils::externalLinkWarning(this, Utils::blockExplorerLink(config()->get(Config::blockExplorer).toString(), constants::networkType, m_txid)); +} + TxInfoDialog::~TxInfoDialog() = default; \ No newline at end of file diff --git a/src/dialog/TxInfoDialog.h b/src/dialog/TxInfoDialog.h index 0de4a37..36bc46f 100644 --- a/src/dialog/TxInfoDialog.h +++ b/src/dialog/TxInfoDialog.h @@ -34,6 +34,7 @@ private: void setData(TransactionInfo *tx); void updateData(); void adjustHeight(QTextEdit *textEdit, qreal docHeight); + void viewOnBlockExplorer(); QScopedPointer ui; QSharedPointer m_ctx; diff --git a/src/dialog/TxInfoDialog.ui b/src/dialog/TxInfoDialog.ui index 5545e78..22405d9 100644 --- a/src/dialog/TxInfoDialog.ui +++ b/src/dialog/TxInfoDialog.ui @@ -19,7 +19,7 @@ Transaction ID: - + @@ -30,6 +30,19 @@ + + + + + 0 + 0 + + + + + + +