Changeset View
Changeset View
Standalone View
Standalone View
src/qt/openuridialog.cpp
// Copyright (c) 2011-2014 The Bitcoin Core developers | // Copyright (c) 2011-2014 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <qt/forms/ui_openuridialog.h> | #include <qt/forms/ui_openuridialog.h> | ||||
#include <qt/openuridialog.h> | #include <qt/openuridialog.h> | ||||
#include <chainparams.h> | |||||
#include <qt/guiutil.h> | #include <qt/guiutil.h> | ||||
#include <qt/walletmodel.h> | #include <qt/walletmodel.h> | ||||
#include <QUrl> | #include <QUrl> | ||||
OpenURIDialog::OpenURIDialog(const Config *configIn, QWidget *parent) | OpenURIDialog::OpenURIDialog(const CChainParams ¶ms, QWidget *parent) | ||||
: QDialog(parent), ui(new Ui::OpenURIDialog), config(configIn) { | : QDialog(parent), ui(new Ui::OpenURIDialog), | ||||
uriScheme(QString::fromStdString(params.CashAddrPrefix())) { | |||||
ui->setupUi(this); | ui->setupUi(this); | ||||
ui->uriEdit->setPlaceholderText(GUIUtil::bitcoinURIScheme(*config) + ":"); | ui->uriEdit->setPlaceholderText(uriScheme + ":"); | ||||
} | } | ||||
OpenURIDialog::~OpenURIDialog() { | OpenURIDialog::~OpenURIDialog() { | ||||
delete ui; | delete ui; | ||||
} | } | ||||
QString OpenURIDialog::getURI() { | QString OpenURIDialog::getURI() { | ||||
return ui->uriEdit->text(); | return ui->uriEdit->text(); | ||||
} | } | ||||
void OpenURIDialog::accept() { | void OpenURIDialog::accept() { | ||||
SendCoinsRecipient rcp; | SendCoinsRecipient rcp; | ||||
QString uriScheme = GUIUtil::bitcoinURIScheme(*config); | |||||
if (GUIUtil::parseBitcoinURI(uriScheme, getURI(), &rcp)) { | if (GUIUtil::parseBitcoinURI(uriScheme, getURI(), &rcp)) { | ||||
/* Only accept value URIs */ | /* Only accept value URIs */ | ||||
QDialog::accept(); | QDialog::accept(); | ||||
} else { | } else { | ||||
ui->uriEdit->setValid(false); | ui->uriEdit->setValid(false); | ||||
} | } | ||||
} | } | ||||
void OpenURIDialog::on_selectFileButton_clicked() { | void OpenURIDialog::on_selectFileButton_clicked() { | ||||
QString filename = GUIUtil::getOpenFileName( | QString filename = GUIUtil::getOpenFileName( | ||||
this, tr("Select payment request file to open"), "", "", nullptr); | this, tr("Select payment request file to open"), "", "", nullptr); | ||||
if (filename.isEmpty()) return; | if (filename.isEmpty()) { | ||||
return; | |||||
} | |||||
QUrl fileUri = QUrl::fromLocalFile(filename); | QUrl fileUri = QUrl::fromLocalFile(filename); | ||||
ui->uriEdit->setText(GUIUtil::bitcoinURIScheme(*config) + | ui->uriEdit->setText(uriScheme + | ||||
":?r=" + QUrl::toPercentEncoding(fileUri.toString())); | ":?r=" + QUrl::toPercentEncoding(fileUri.toString())); | ||||
} | } |