Skip to content

Commit

Permalink
+ copyZSendMany[from/to] template context menu on ZAddressBookPage
Browse files Browse the repository at this point in the history
  • Loading branch information
DeckerSU committed Dec 17, 2018
1 parent 568f951 commit 9c191ed
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/qt/zaddressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,21 @@ ZAddressBookPage::ZAddressBookPage(const PlatformStyle *platformStyle, Mode _mod
QAction *copyAddressAction = new QAction(tr("&Copy Address"), this);
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
QAction *editAction = new QAction(tr("&Edit"), this);

QAction *copyZSendManyTo = new QAction(tr("Copy zsendmany (to) template"), this);
QAction *copyZSendManyFrom = new QAction(tr("Copy zsendmany (from) template"), this);

deleteAction = new QAction(ui->deleteAddress->text(), this);

// Build context menu
contextMenu = new QMenu(this);
contextMenu->addAction(copyAddressAction);
contextMenu->addAction(copyLabelAction);
contextMenu->addAction(editAction);

contextMenu->addAction(copyZSendManyTo);
contextMenu->addAction(copyZSendManyFrom);

if(tab == SendingTab)
contextMenu->addAction(deleteAction);
contextMenu->addSeparator();
Expand All @@ -97,6 +105,9 @@ ZAddressBookPage::ZAddressBookPage(const PlatformStyle *platformStyle, Mode _mod
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction()));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked()));

connect(copyZSendManyTo, SIGNAL(triggered()), this, SLOT(on_copyZSendManyTo_clicked()));
connect(copyZSendManyFrom, SIGNAL(triggered()), this, SLOT(on_copyZSendManyFrom_clicked()));

connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));

connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(accept()));
Expand Down Expand Up @@ -159,6 +170,28 @@ void ZAddressBookPage::setModel(ZAddressTableModel *_model)
selectionChanged();
}

void ZAddressBookPage::on_copyZSendManyFrom_clicked()
{
QModelIndexList selection = GUIUtil::getEntryData(ui->tableView, ZAddressTableModel::Address);
if(!selection.isEmpty())
{
QString commandTemplate;
commandTemplate = QString("z_sendmany %1 '[{\"address\":\"%2\",\"amount\":\"%3\"}]'").arg(selection.at(0).data(Qt::DisplayRole).toString(),QString("YOUR_Z_OR_T_ADDRESS_TO"),QString::number(0,'f',8));
GUIUtil::setClipboard(commandTemplate);
}
}

void ZAddressBookPage::on_copyZSendManyTo_clicked()
{
QModelIndexList selection = GUIUtil::getEntryData(ui->tableView, ZAddressTableModel::Address);
if(!selection.isEmpty())
{
QString commandTemplate;
commandTemplate = QString("z_sendmany %1 '[{\"address\":\"%2\",\"amount\":\"%3\"}]'").arg(QString("YOUR_Z_OR_T_ADDRESS_FROM"),selection.at(0).data(Qt::DisplayRole).toString(),QString::number(0,'f',8));
GUIUtil::setClipboard(commandTemplate);
}
}

void ZAddressBookPage::on_copyAddress_clicked()
{
GUIUtil::copyEntryData(ui->tableView, ZAddressTableModel::Address);
Expand Down
4 changes: 4 additions & 0 deletions src/qt/zaddressbookpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ private Q_SLOTS:
void on_deleteAddress_clicked();
/** Create a new address for receiving coins and / or add a new address book entry */
void on_newAddress_clicked();
/** Copy z_sendmany template to send funds to selected address entry to clipboard */
void on_copyZSendManyTo_clicked();
/** Copy z_sendmany template to send funds from selected address entry to clipboard */
void on_copyZSendManyFrom_clicked();
/** Copy address of currently selected address entry to clipboard */
void on_copyAddress_clicked();
/** Copy label of currently selected address entry to clipboard (no button) */
Expand Down

0 comments on commit 9c191ed

Please sign in to comment.