diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2013-11-06 15:08:56 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2013-11-11 14:29:49 +0100 |
commit | 4c6035860448656c67fa60fef6b020aafbb2e208 (patch) | |
tree | d293e815b23f69b3f9555840af61ddf1d6c8fe79 /src/qt/openuridialog.cpp | |
parent | 3a8915d9a85b37f6c58a512fc11457eaa3d3570e (diff) |
qt: add Open URI dialog
Diffstat (limited to 'src/qt/openuridialog.cpp')
-rw-r--r-- | src/qt/openuridialog.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/qt/openuridialog.cpp b/src/qt/openuridialog.cpp new file mode 100644 index 0000000000..803a3c9ddb --- /dev/null +++ b/src/qt/openuridialog.cpp @@ -0,0 +1,52 @@ +// Copyright (c) 2011-2013 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "openuridialog.h" +#include "ui_openuridialog.h" + +#include "guiutil.h" +#include "walletmodel.h" + +#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() +{ + QString filename = GUIUtil::getOpenFileName(this, tr("Select payment request file to open"), "", "", NULL); + if(filename.isEmpty()) + return; + QUrl fileUri = QUrl::fromLocalFile(filename); + ui->uriEdit->setText("bitcoin:?request=" + QUrl::toPercentEncoding(fileUri.toString())); +} |