2018-01-02 18:12:05 +01:00
|
|
|
// Copyright (c) 2011-2017 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-06 15:08:56 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2017-11-10 01:57:53 +01:00
|
|
|
#include <qt/openuridialog.h>
|
2017-08-15 17:31:26 +02:00
|
|
|
#include <qt/forms/ui_openuridialog.h>
|
2013-11-06 15:08:56 +01:00
|
|
|
|
2017-11-10 01:57:53 +01:00
|
|
|
#include <qt/guiutil.h>
|
|
|
|
#include <qt/walletmodel.h>
|
2013-11-06 15:08:56 +01:00
|
|
|
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
OpenURIDialog::OpenURIDialog(QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::OpenURIDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
#if QT_VERSION >= 0x040700
|
|
|
|
ui->uriEdit->setPlaceholderText("bitcoin:");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
OpenURIDialog::~OpenURIDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString OpenURIDialog::getURI()
|
|
|
|
{
|
|
|
|
return ui->uriEdit->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenURIDialog::accept()
|
|
|
|
{
|
|
|
|
SendCoinsRecipient rcp;
|
|
|
|
if(GUIUtil::parseBitcoinURI(getURI(), &rcp))
|
|
|
|
{
|
|
|
|
/* Only accept value URIs */
|
|
|
|
QDialog::accept();
|
|
|
|
} else {
|
|
|
|
ui->uriEdit->setValid(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenURIDialog::on_selectFileButton_clicked()
|
|
|
|
{
|
2017-08-07 07:36:37 +02:00
|
|
|
QString filename = GUIUtil::getOpenFileName(this, tr("Select payment request file to open"), "", "", nullptr);
|
2013-11-06 15:08:56 +01:00
|
|
|
if(filename.isEmpty())
|
|
|
|
return;
|
|
|
|
QUrl fileUri = QUrl::fromLocalFile(filename);
|
2013-12-04 04:18:09 +01:00
|
|
|
ui->uriEdit->setText("bitcoin:?r=" + QUrl::toPercentEncoding(fileUri.toString()));
|
2013-11-06 15:08:56 +01:00
|
|
|
}
|