mirror of
https://github.com/feather-wallet/feather.git
synced 2024-11-17 01:37:53 +00:00
TxConfAdv: allow copy context menus
This commit is contained in:
parent
002d7d3353
commit
a8eac7efeb
2 changed files with 44 additions and 1 deletions
|
@ -48,7 +48,16 @@ TxConfAdvDialog::TxConfAdvDialog(Wallet *wallet, const QString &description, QWi
|
|||
ui->txid->hide();
|
||||
ui->label_txid->hide();
|
||||
}
|
||||
|
||||
|
||||
ui->treeInputs->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->treeOutputs->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->treeInputs, &QTreeView::customContextMenuRequested, [this](const QPoint &point){
|
||||
this->setupContextMenu(point, ui->treeInputs);
|
||||
});
|
||||
connect(ui->treeOutputs, &QTreeView::customContextMenuRequested, [this](const QPoint &point){
|
||||
this->setupContextMenu(point, ui->treeOutputs);
|
||||
});
|
||||
|
||||
this->adjustSize();
|
||||
}
|
||||
|
||||
|
@ -217,4 +226,35 @@ void TxConfAdvDialog::closeDialog() {
|
|||
QDialog::reject();
|
||||
}
|
||||
|
||||
void TxConfAdvDialog::setupContextMenu(const QPoint &point, QTreeWidget *tree) {
|
||||
if (!tree) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *header = tree->headerItem();
|
||||
if (!header) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* menu = new QMenu(this);
|
||||
for (int column = 0; column < tree->columnCount(); column++)
|
||||
{
|
||||
menu->addAction(QString("Copy %1").arg(header->text(column)), this, [this, column, point, tree]{
|
||||
this->copyFromTree(point, column, tree);
|
||||
});
|
||||
}
|
||||
|
||||
menu->popup(tree->viewport()->mapToGlobal(point));
|
||||
}
|
||||
|
||||
void TxConfAdvDialog::copyFromTree(const QPoint &point, int column, QTreeWidget *tree) {
|
||||
QModelIndex index = tree->indexAt(point);
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex dataIndex = index.sibling(index.row(), column);
|
||||
Utils::copyToClipboard(dataIndex.data().toString());
|
||||
}
|
||||
|
||||
TxConfAdvDialog::~TxConfAdvDialog() = default;
|
|
@ -8,6 +8,7 @@
|
|||
#include <QMenu>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTextCharFormat>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include "components.h"
|
||||
#include "libwalletqt/PendingTransaction.h"
|
||||
|
@ -34,6 +35,8 @@ private:
|
|||
void broadcastTransaction();
|
||||
void closeDialog();
|
||||
void setAmounts(quint64 amount, quint64 fee);
|
||||
void setupContextMenu(const QPoint &point, QTreeWidget *tree);
|
||||
void copyFromTree(const QPoint &point, int column, QTreeWidget *tree);
|
||||
|
||||
void signedCopy();
|
||||
void signedSaveFile();
|
||||
|
|
Loading…
Reference in a new issue