You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

openuridialog.cpp 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (c) 2011-2014 The Starwels developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #include "openuridialog.h"
  5. #include "ui_openuridialog.h"
  6. #include "guiutil.h"
  7. #include "walletmodel.h"
  8. #include <QUrl>
  9. OpenURIDialog::OpenURIDialog(QWidget *parent) :
  10. QDialog(parent),
  11. ui(new Ui::OpenURIDialog)
  12. {
  13. ui->setupUi(this);
  14. #if QT_VERSION >= 0x040700
  15. ui->uriEdit->setPlaceholderText("starwels:");
  16. #endif
  17. }
  18. OpenURIDialog::~OpenURIDialog()
  19. {
  20. delete ui;
  21. }
  22. QString OpenURIDialog::getURI()
  23. {
  24. return ui->uriEdit->text();
  25. }
  26. void OpenURIDialog::accept()
  27. {
  28. SendCoinsRecipient rcp;
  29. if(GUIUtil::parseStarwelsURI(getURI(), &rcp))
  30. {
  31. /* Only accept value URIs */
  32. QDialog::accept();
  33. } else {
  34. ui->uriEdit->setValid(false);
  35. }
  36. }
  37. void OpenURIDialog::on_selectFileButton_clicked()
  38. {
  39. QString filename = GUIUtil::getOpenFileName(this, tr("Select payment request file to open"), "", "", nullptr);
  40. if(filename.isEmpty())
  41. return;
  42. QUrl fileUri = QUrl::fromLocalFile(filename);
  43. ui->uriEdit->setText("starwels:?r=" + QUrl::toPercentEncoding(fileUri.toString()));
  44. }