Add CashAddr Address Format
Ported from Bitcoin Unlimited, Bitcoin ABC
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "addressbookpage.h"
|
||||
#include "addresstablemodel.h"
|
||||
#include "bitcoinunits.h"
|
||||
#include "config.h"
|
||||
#include "guiutil.h"
|
||||
#include "optionsmodel.h"
|
||||
#include "platformstyle.h"
|
||||
@@ -22,12 +23,13 @@
|
||||
#include <QScrollBar>
|
||||
#include <QTextDocument>
|
||||
|
||||
ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent) :
|
||||
ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *platformStyle, const Config *cfg, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ReceiveCoinsDialog),
|
||||
columnResizingFixer(0),
|
||||
model(0),
|
||||
platformStyle(platformStyle)
|
||||
platformStyle(platformStyle),
|
||||
cfg(cfg)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -44,18 +46,21 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidg
|
||||
}
|
||||
|
||||
// context menu actions
|
||||
QAction *copyURIAction = new QAction(tr("Copy URI"), this);
|
||||
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
|
||||
QAction *copyMessageAction = new QAction(tr("Copy message"), this);
|
||||
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
|
||||
|
||||
// context menu
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->addAction(copyURIAction);
|
||||
contextMenu->addAction(copyLabelAction);
|
||||
contextMenu->addAction(copyMessageAction);
|
||||
contextMenu->addAction(copyAmountAction);
|
||||
|
||||
// context menu signals
|
||||
connect(ui->recentRequestsView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint)));
|
||||
connect(copyURIAction, SIGNAL(triggered()), this, SLOT(copyURI()));
|
||||
connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel()));
|
||||
connect(copyMessageAction, SIGNAL(triggered()), this, SLOT(copyMessage()));
|
||||
connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount()));
|
||||
@@ -153,7 +158,7 @@ void ReceiveCoinsDialog::on_receiveButton_clicked()
|
||||
}
|
||||
SendCoinsRecipient info(address, label,
|
||||
ui->reqAmount->value(), ui->reqMessage->text());
|
||||
ReceiveRequestDialog *dialog = new ReceiveRequestDialog(this);
|
||||
ReceiveRequestDialog *dialog = new ReceiveRequestDialog(cfg, this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->setModel(model->getOptionsModel());
|
||||
dialog->setInfo(info);
|
||||
@@ -167,7 +172,7 @@ void ReceiveCoinsDialog::on_receiveButton_clicked()
|
||||
void ReceiveCoinsDialog::on_recentRequestsView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
const RecentRequestsTableModel *submodel = model->getRecentRequestsTableModel();
|
||||
ReceiveRequestDialog *dialog = new ReceiveRequestDialog(this);
|
||||
ReceiveRequestDialog *dialog = new ReceiveRequestDialog(cfg, this);
|
||||
dialog->setModel(model->getOptionsModel());
|
||||
dialog->setInfo(submodel->entry(index.row()).recipient);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
@@ -229,30 +234,55 @@ void ReceiveCoinsDialog::keyPressEvent(QKeyEvent *event)
|
||||
this->QDialog::keyPressEvent(event);
|
||||
}
|
||||
|
||||
QModelIndex ReceiveCoinsDialog::selectedRow()
|
||||
{
|
||||
if (!model || !model->getRecentRequestsTableModel() || !ui->recentRequestsView->selectionModel())
|
||||
return QModelIndex();
|
||||
QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows();
|
||||
if (selection.empty())
|
||||
return QModelIndex();
|
||||
// correct for selection mode ContiguousSelection
|
||||
QModelIndex firstIndex = selection.at(0);
|
||||
return firstIndex;
|
||||
}
|
||||
|
||||
// copy column of selected row to clipboard
|
||||
void ReceiveCoinsDialog::copyColumnToClipboard(int column)
|
||||
{
|
||||
if(!model || !model->getRecentRequestsTableModel() || !ui->recentRequestsView->selectionModel())
|
||||
QModelIndex firstIndex = selectedRow();
|
||||
if (!firstIndex.isValid())
|
||||
{
|
||||
return;
|
||||
QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows();
|
||||
if(selection.empty())
|
||||
return;
|
||||
// correct for selection mode ContiguousSelection
|
||||
QModelIndex firstIndex = selection.at(0);
|
||||
GUIUtil::setClipboard(model->getRecentRequestsTableModel()->data(firstIndex.child(firstIndex.row(), column), Qt::EditRole).toString());
|
||||
}
|
||||
GUIUtil::setClipboard(model->getRecentRequestsTableModel()
|
||||
->data(firstIndex.child(firstIndex.row(), column), Qt::EditRole)
|
||||
.toString());
|
||||
}
|
||||
|
||||
// context menu
|
||||
void ReceiveCoinsDialog::showMenu(const QPoint &point)
|
||||
{
|
||||
if(!model || !model->getRecentRequestsTableModel() || !ui->recentRequestsView->selectionModel())
|
||||
return;
|
||||
QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows();
|
||||
if(selection.empty())
|
||||
if (!selectedRow().isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
contextMenu->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
// context menu action: copy URI
|
||||
void ReceiveCoinsDialog::copyURI()
|
||||
{
|
||||
QModelIndex sel = selectedRow();
|
||||
if (!sel.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const RecentRequestsTableModel *const submodel = model->getRecentRequestsTableModel();
|
||||
const QString uri = GUIUtil::formatBitcoinURI(*cfg, submodel->entry(sel.row()).recipient);
|
||||
GUIUtil::setClipboard(uri);
|
||||
}
|
||||
|
||||
// context menu action: copy label
|
||||
void ReceiveCoinsDialog::copyLabel()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user