Bitcoin Core  22.99.0
P2P Digital Currency
openuridialog.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <qt/openuridialog.h>
6 #include <qt/forms/ui_openuridialog.h>
7 
8 #include <qt/guiutil.h>
9 #include <qt/platformstyle.h>
10 #include <qt/sendcoinsrecipient.h>
11 
12 #include <QAbstractButton>
13 #include <QLineEdit>
14 #include <QUrl>
15 
16 OpenURIDialog::OpenURIDialog(const PlatformStyle* platformStyle, QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags),
17  ui(new Ui::OpenURIDialog),
18  m_platform_style(platformStyle)
19 {
20  ui->setupUi(this);
21  ui->pasteButton->setIcon(m_platform_style->SingleColorIcon(":/icons/editpaste"));
22  QObject::connect(ui->pasteButton, &QAbstractButton::clicked, ui->uriEdit, &QLineEdit::paste);
23 
25 }
26 
28 {
29  delete ui;
30 }
31 
33 {
34  return ui->uriEdit->text();
35 }
36 
38 {
40  if (GUIUtil::parseBitcoinURI(getURI(), &rcp)) {
41  /* Only accept value URIs */
42  QDialog::accept();
43  } else {
44  ui->uriEdit->setValid(false);
45  }
46 }
47 
49 {
50  if (e->type() == QEvent::PaletteChange) {
51  ui->pasteButton->setIcon(m_platform_style->SingleColorIcon(":/icons/editpaste"));
52  }
53 
54  QDialog::changeEvent(e);
55 }
OpenURIDialog
Definition: openuridialog.h:16
OpenURIDialog::~OpenURIDialog
~OpenURIDialog()
Definition: openuridialog.cpp:27
PlatformStyle::SingleColorIcon
QIcon SingleColorIcon(const QString &filename) const
Colorize an icon (given filename) with the icon color.
Definition: platformstyle.cpp:105
OpenURIDialog::m_platform_style
const PlatformStyle * m_platform_style
Definition: openuridialog.h:33
GUIUtil
Utility functions used by the Bitcoin Qt UI.
Definition: bitcoingui.h:59
GUIUtil::parseBitcoinURI
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
Definition: guiutil.cpp:138
GUIUtil::dialog_flags
constexpr auto dialog_flags
Definition: guiutil.h:60
SendCoinsRecipient
Definition: sendcoinsrecipient.h:19
OpenURIDialog::ui
Ui::OpenURIDialog * ui
Definition: openuridialog.h:31
guiutil.h
OpenURIDialog::accept
void accept() override
Definition: openuridialog.cpp:37
platformstyle.h
Ui
Definition: addressbookpage.h:14
OpenURIDialog::OpenURIDialog
OpenURIDialog(const PlatformStyle *platformStyle, QWidget *parent)
Definition: openuridialog.cpp:16
OpenURIDialog::getURI
QString getURI()
Definition: openuridialog.cpp:32
GUIUtil::handleCloseWindowShortcut
void handleCloseWindowShortcut(QWidget *w)
Definition: guiutil.cpp:415
PlatformStyle
Definition: platformstyle.h:13
openuridialog.h
OpenURIDialog::changeEvent
void changeEvent(QEvent *e) override
Definition: openuridialog.cpp:48
sendcoinsrecipient.h