Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paste button in Open URI dialog #319

Merged
merged 1 commit into from
Nov 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ void BitcoinGUI::showHelpMessageClicked()
#ifdef ENABLE_WALLET
void BitcoinGUI::openClicked()
{
OpenURIDialog dlg(this);
OpenURIDialog dlg(platformStyle, this);
if(dlg.exec())
{
Q_EMIT receivedURI(dlg.getURI());
Expand Down
21 changes: 21 additions & 0 deletions src/qt/forms/openuridialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pasteButton">
<property name="toolTip">
<string extracomment="Tooltip text for button that allows you to paste an address that is in your clipboard.">Paste address from clipboard</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../bitcoin.qrc">
<normaloff>:/icons/editpaste</normaloff>:/icons/editpaste
</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
23 changes: 18 additions & 5 deletions src/qt/openuridialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
#include <qt/forms/ui_openuridialog.h>

#include <qt/guiutil.h>
#include <qt/platformstyle.h>
#include <qt/sendcoinsrecipient.h>

#include <QAbstractButton>
#include <QLineEdit>
#include <QUrl>

OpenURIDialog::OpenURIDialog(QWidget *parent) :
QDialog(parent, GUIUtil::dialog_flags),
ui(new Ui::OpenURIDialog)
OpenURIDialog::OpenURIDialog(const PlatformStyle* platformStyle, QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags),
ui(new Ui::OpenURIDialog),
m_platform_style(platformStyle)
{
ui->setupUi(this);
ui->pasteButton->setIcon(m_platform_style->SingleColorIcon(":/icons/editpaste"));
QObject::connect(ui->pasteButton, &QAbstractButton::clicked, ui->uriEdit, &QLineEdit::paste);

GUIUtil::handleCloseWindowShortcut(this);
}
Expand All @@ -32,11 +37,19 @@ QString OpenURIDialog::getURI()
void OpenURIDialog::accept()
{
SendCoinsRecipient rcp;
if(GUIUtil::parseBitcoinURI(getURI(), &rcp))
{
if (GUIUtil::parseBitcoinURI(getURI(), &rcp)) {
/* Only accept value URIs */
QDialog::accept();
} else {
ui->uriEdit->setValid(false);
}
}

void OpenURIDialog::changeEvent(QEvent* e)
{
if (e->type() == QEvent::PaletteChange) {
ui->pasteButton->setIcon(m_platform_style->SingleColorIcon(":/icons/editpaste"));
}

QDialog::changeEvent(e);
}
9 changes: 7 additions & 2 deletions src/qt/openuridialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <QDialog>

class PlatformStyle;

namespace Ui {
class OpenURIDialog;
}
Expand All @@ -16,16 +18,19 @@ class OpenURIDialog : public QDialog
Q_OBJECT

public:
explicit OpenURIDialog(QWidget *parent);
explicit OpenURIDialog(const PlatformStyle* platformStyle, QWidget* parent);
~OpenURIDialog();

QString getURI();

protected Q_SLOTS:
void accept() override;
void changeEvent(QEvent* e) override;

private:
Ui::OpenURIDialog *ui;
Ui::OpenURIDialog* ui;

const PlatformStyle* m_platform_style;
};

#endif // BITCOIN_QT_OPENURIDIALOG_H