mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-23 12:09:50 +00:00
Coins: add Edit Label to context menu
This commit is contained in:
parent
4489d50b72
commit
5d89931f9d
3 changed files with 17 additions and 1 deletions
|
@ -38,6 +38,9 @@ CoinsWidget::CoinsWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
|
||||||
// context menu
|
// context menu
|
||||||
ui->coins->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->coins->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
|
m_editLabelAction = new QAction("Edit Label", this);
|
||||||
|
connect(m_editLabelAction, &QAction::triggered, this, &CoinsWidget::editLabel);
|
||||||
|
|
||||||
m_thawOutputAction = new QAction("Thaw output", this);
|
m_thawOutputAction = new QAction("Thaw output", this);
|
||||||
m_freezeOutputAction = new QAction("Freeze output", this);
|
m_freezeOutputAction = new QAction("Freeze output", this);
|
||||||
|
|
||||||
|
@ -47,6 +50,7 @@ CoinsWidget::CoinsWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
|
||||||
m_viewOutputAction = new QAction(icons()->icon("info2.svg"), "Details", this);
|
m_viewOutputAction = new QAction(icons()->icon("info2.svg"), "Details", this);
|
||||||
m_sweepOutputAction = new QAction("Sweep output", this);
|
m_sweepOutputAction = new QAction("Sweep output", this);
|
||||||
m_sweepOutputsAction = new QAction("Sweep selected outputs", this);
|
m_sweepOutputsAction = new QAction("Sweep selected outputs", this);
|
||||||
|
|
||||||
connect(m_freezeOutputAction, &QAction::triggered, this, &CoinsWidget::freezeOutput);
|
connect(m_freezeOutputAction, &QAction::triggered, this, &CoinsWidget::freezeOutput);
|
||||||
connect(m_thawOutputAction, &QAction::triggered, this, &CoinsWidget::thawOutput);
|
connect(m_thawOutputAction, &QAction::triggered, this, &CoinsWidget::thawOutput);
|
||||||
connect(m_viewOutputAction, &QAction::triggered, this, &CoinsWidget::viewOutput);
|
connect(m_viewOutputAction, &QAction::triggered, this, &CoinsWidget::viewOutput);
|
||||||
|
@ -116,6 +120,7 @@ void CoinsWidget::showContextMenu(const QPoint &point) {
|
||||||
bool isUnlocked = c->unlocked();
|
bool isUnlocked = c->unlocked();
|
||||||
|
|
||||||
menu->addMenu(m_copyMenu);
|
menu->addMenu(m_copyMenu);
|
||||||
|
menu->addAction(m_editLabelAction);
|
||||||
|
|
||||||
if (!isSpent) {
|
if (!isSpent) {
|
||||||
isFrozen ? menu->addAction(m_thawOutputAction) : menu->addAction(m_freezeOutputAction);
|
isFrozen ? menu->addAction(m_thawOutputAction) : menu->addAction(m_freezeOutputAction);
|
||||||
|
@ -303,4 +308,10 @@ void CoinsWidget::thawCoins(const QVector<int> &indexes) {
|
||||||
m_ctx->updateBalance();
|
m_ctx->updateBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoinsWidget::editLabel() {
|
||||||
|
QModelIndex index = ui->coins->currentIndex().siblingAtColumn(m_model->ModelColumn::Label);
|
||||||
|
ui->coins->setCurrentIndex(index);
|
||||||
|
ui->coins->edit(index);
|
||||||
|
}
|
||||||
|
|
||||||
CoinsWidget::~CoinsWidget() = default;
|
CoinsWidget::~CoinsWidget() = default;
|
|
@ -41,6 +41,7 @@ private slots:
|
||||||
void onSweepOutput();
|
void onSweepOutput();
|
||||||
void onSweepMulti();
|
void onSweepMulti();
|
||||||
void setSearchFilter(const QString &filter);
|
void setSearchFilter(const QString &filter);
|
||||||
|
void editLabel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void freezeCoins(const QVector<int>& indexes);
|
void freezeCoins(const QVector<int>& indexes);
|
||||||
|
@ -70,6 +71,7 @@ private:
|
||||||
QAction *m_viewOutputAction;
|
QAction *m_viewOutputAction;
|
||||||
QAction *m_sweepOutputAction;
|
QAction *m_sweepOutputAction;
|
||||||
QAction *m_sweepOutputsAction;
|
QAction *m_sweepOutputsAction;
|
||||||
|
QAction *m_editLabelAction;
|
||||||
Coins *m_coins;
|
Coins *m_coins;
|
||||||
CoinsModel * m_model;
|
CoinsModel * m_model;
|
||||||
CoinsProxyModel * m_proxyModel;
|
CoinsProxyModel * m_proxyModel;
|
||||||
|
|
|
@ -61,7 +61,7 @@ QVariant CoinsModel::data(const QModelIndex &index, int role) const
|
||||||
QVariant result;
|
QVariant result;
|
||||||
|
|
||||||
bool found = m_coins->coin(index.row(), [this, &index, &result, &role](const CoinsInfo &cInfo) {
|
bool found = m_coins->coin(index.row(), [this, &index, &result, &role](const CoinsInfo &cInfo) {
|
||||||
if(role == Qt::DisplayRole || role == Qt::UserRole) {
|
if(role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::UserRole) {
|
||||||
result = parseTransactionInfo(cInfo, index.column(), role);
|
result = parseTransactionInfo(cInfo, index.column(), role);
|
||||||
}
|
}
|
||||||
else if (role == Qt::BackgroundRole) {
|
else if (role == Qt::BackgroundRole) {
|
||||||
|
@ -119,6 +119,9 @@ QVariant CoinsModel::data(const QModelIndex &index, int role) const
|
||||||
else if (!cInfo.unlocked()) {
|
else if (!cInfo.unlocked()) {
|
||||||
result = "Output is locked (needs more confirmations)";
|
result = "Output is locked (needs more confirmations)";
|
||||||
}
|
}
|
||||||
|
else if (cInfo.spent()) {
|
||||||
|
result = "Output is spent";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
|
Loading…
Reference in a new issue