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 "openuridialog.h" | #include "openuridialog.h" | ||||
#include "ui_openuridialog.h" | #include "ui_openuridialog.h" | ||||
#include "guiutil.h" | #include "guiutil.h" | ||||
#include "walletmodel.h" | #include "walletmodel.h" | ||||
#include <QUrl> | #include <QUrl> | ||||
OpenURIDialog::OpenURIDialog(const Config &cfg, QWidget *parent) | OpenURIDialog::OpenURIDialog(const Config &cfg, QWidget *parent) | ||||
: QDialog(parent), ui(new Ui::OpenURIDialog), cfg(cfg) { | : QDialog(parent), ui(new Ui::OpenURIDialog), cfg(cfg) { | ||||
ui->setupUi(this); | ui->setupUi(this); | ||||
#if QT_VERSION >= 0x040700 | #if QT_VERSION >= 0x040700 | ||||
ui->uriEdit->setPlaceholderText(GUIUtil::URI_SCHEME + ":"); | ui->uriEdit->setPlaceholderText(GUIUtil::bitcoinURIScheme(cfg) + ":"); | ||||
#endif | #endif | ||||
} | } | ||||
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; | ||||
if (GUIUtil::parseBitcoinURI(getURI(), &rcp)) { | QString uriScheme = GUIUtil::bitcoinURIScheme(cfg); | ||||
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::URI_SCHEME + ":?r=" + | ui->uriEdit->setText(GUIUtil::bitcoinURIScheme(cfg) + ":?r=" + | ||||
QUrl::toPercentEncoding(fileUri.toString())); | QUrl::toPercentEncoding(fileUri.toString())); | ||||
} | } |