TxInfoDialog: added a clickable icon to view transaction on block explorer

This commit is contained in:
tobtoht 2021-10-22 18:11:02 +02:00
parent 19e8ed1b19
commit 484f61759e
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
4 changed files with 29 additions and 1 deletions

View file

@ -34,6 +34,7 @@
<file>assets/images/copy.png</file>
<file>assets/images/cutexmrfox.png</file>
<file>assets/images/edit.png</file>
<file>assets/images/external-link.svg</file>
<file>assets/images/exchange.png</file>
<file>assets/images/exchange_white.png</file>
<file>assets/images/expired.png</file>

View file

@ -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<AppContext> ctx, TransactionInfo *txInfo, QWidget *parent)
: QDialog(parent)
@ -26,6 +28,10 @@ TxInfoDialog::TxInfoDialog(QSharedPointer<AppContext> 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<AppContext> 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;

View file

@ -34,6 +34,7 @@ private:
void setData(TransactionInfo *tx);
void updateData();
void adjustHeight(QTextEdit *textEdit, qreal docHeight);
void viewOnBlockExplorer();
QScopedPointer<Ui::TxInfoDialog> ui;
QSharedPointer<AppContext> m_ctx;

View file

@ -19,7 +19,7 @@
<property name="title">
<string>Transaction ID:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_txid">
<property name="text">
@ -30,6 +30,19 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_viewOnBlockExplorer">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>