diff --git a/src/qt/transactiondescdialog.cpp b/src/qt/transactiondescdialog.cpp index 893752b227f..fe642285758 100644 --- a/src/qt/transactiondescdialog.cpp +++ b/src/qt/transactiondescdialog.cpp @@ -15,7 +15,8 @@ TransactionDescDialog::TransactionDescDialog(const QModelIndex &idx, QWidget *pa ui(new Ui::TransactionDescDialog) { ui->setupUi(this); - setWindowTitle(tr("Details for %1").arg(idx.data(TransactionTableModel::TxHashRole).toString())); + m_transaction_id = idx.data(TransactionTableModel::TxHashRole).toString(); + setWindowTitle(tr("Details for %1").arg(m_transaction_id)); QString desc = idx.data(TransactionTableModel::LongDescriptionRole).toString(); ui->detailText->setHtml(desc); diff --git a/src/qt/transactiondescdialog.h b/src/qt/transactiondescdialog.h index 3204b22657b..e44b3c940bb 100644 --- a/src/qt/transactiondescdialog.h +++ b/src/qt/transactiondescdialog.h @@ -6,6 +6,7 @@ #define BITCOIN_QT_TRANSACTIONDESCDIALOG_H #include +#include namespace Ui { class TransactionDescDialog; @@ -24,8 +25,11 @@ class TransactionDescDialog : public QDialog explicit TransactionDescDialog(const QModelIndex &idx, QWidget *parent = nullptr); ~TransactionDescDialog(); + QString getTransactionId() {return m_transaction_id;}; + private: Ui::TransactionDescDialog *ui; + QString m_transaction_id; }; #endif // BITCOIN_QT_TRANSACTIONDESCDIALOG_H diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 7e24dbd3ec9..3aa7db55a2b 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -528,13 +529,15 @@ void TransactionView::showDetails() QModelIndexList selection = transactionView->selectionModel()->selectedRows(); if(!selection.isEmpty()) { - TransactionDescDialog *dlg = new TransactionDescDialog(selection.at(0)); - dlg->setAttribute(Qt::WA_DeleteOnClose); - m_opened_dialogs.append(dlg); - connect(dlg, &QObject::destroyed, [this, dlg] { - m_opened_dialogs.removeOne(dlg); - }); - dlg->show(); + if(!detailsAlreadyShown(selection.at(0))) { + TransactionDescDialog *dlg = new TransactionDescDialog(selection.at(0)); + dlg->setAttribute(Qt::WA_DeleteOnClose); + m_opened_dialogs.append(dlg); + connect(dlg, &QObject::destroyed, [this, dlg] { + m_opened_dialogs.removeOne(dlg); + }); + dlg->show(); + } } } @@ -663,3 +666,14 @@ void TransactionView::closeOpenedDialogs() } m_opened_dialogs.clear(); } + +bool TransactionView::detailsAlreadyShown(const QModelIndex &idx) +{ + for (TransactionDescDialog* dlg : m_opened_dialogs) { + if (dlg->getTransactionId() == idx.data(TransactionTableModel::TxHashRole).toString()) { + GUIUtil::bringToFront(dlg); + return true; + } + } + return false; +} diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 29fb722afea..464c43fd641 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -108,6 +108,7 @@ private Q_SLOTS: void updateWatchOnlyColumn(bool fHaveWatchOnly); void abandonTx(); void bumpFee(bool checked); + bool detailsAlreadyShown(const QModelIndex &idx); Q_SIGNALS: void doubleClicked(const QModelIndex&);