Skip to content

Commit 79e64a0

Browse files
committed
Merge #319: Paste button in Open URI dialog
dbde055 gui: Paste button in Open URI dialog (Kristaps Kaupe) Pull request description: Picking up bitcoin/bitcoin#17955, with some review comments addressed. ACKs for top commit: shaavan: tACK dbde055 jarolrod: ACK dbde055 promag: Tested ACK dbde055. Tree-SHA512: db47f19673aff6becd6d1f938cd2aa5dc2291d6e80150d2b99f435674330a5eae678b20e42ef327ea9b05c44925a941fc251e622c73b3585018fc7c1d245edb5
2 parents 06782cf + dbde055 commit 79e64a0

File tree

4 files changed

+47
-8
lines changed

4 files changed

+47
-8
lines changed

src/qt/bitcoingui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ void BitcoinGUI::showHelpMessageClicked()
870870
#ifdef ENABLE_WALLET
871871
void BitcoinGUI::openClicked()
872872
{
873-
OpenURIDialog dlg(this);
873+
OpenURIDialog dlg(platformStyle, this);
874874
if(dlg.exec())
875875
{
876876
Q_EMIT receivedURI(dlg.getURI());

src/qt/forms/openuridialog.ui

+21
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@
3030
</property>
3131
</widget>
3232
</item>
33+
<item>
34+
<widget class="QToolButton" name="pasteButton">
35+
<property name="toolTip">
36+
<string extracomment="Tooltip text for button that allows you to paste an address that is in your clipboard.">Paste address from clipboard</string>
37+
</property>
38+
<property name="text">
39+
<string/>
40+
</property>
41+
<property name="icon">
42+
<iconset resource="../bitcoin.qrc">
43+
<normaloff>:/icons/editpaste</normaloff>:/icons/editpaste
44+
</iconset>
45+
</property>
46+
<property name="iconSize">
47+
<size>
48+
<width>22</width>
49+
<height>22</height>
50+
</size>
51+
</property>
52+
</widget>
53+
</item>
3354
</layout>
3455
</item>
3556
<item>

src/qt/openuridialog.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
#include <qt/forms/ui_openuridialog.h>
77

88
#include <qt/guiutil.h>
9+
#include <qt/platformstyle.h>
910
#include <qt/sendcoinsrecipient.h>
1011

12+
#include <QAbstractButton>
13+
#include <QLineEdit>
1114
#include <QUrl>
1215

13-
OpenURIDialog::OpenURIDialog(QWidget *parent) :
14-
QDialog(parent, GUIUtil::dialog_flags),
15-
ui(new Ui::OpenURIDialog)
16+
OpenURIDialog::OpenURIDialog(const PlatformStyle* platformStyle, QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags),
17+
ui(new Ui::OpenURIDialog),
18+
m_platform_style(platformStyle)
1619
{
1720
ui->setupUi(this);
21+
ui->pasteButton->setIcon(m_platform_style->SingleColorIcon(":/icons/editpaste"));
22+
QObject::connect(ui->pasteButton, &QAbstractButton::clicked, ui->uriEdit, &QLineEdit::paste);
1823

1924
GUIUtil::handleCloseWindowShortcut(this);
2025
}
@@ -32,11 +37,19 @@ QString OpenURIDialog::getURI()
3237
void OpenURIDialog::accept()
3338
{
3439
SendCoinsRecipient rcp;
35-
if(GUIUtil::parseBitcoinURI(getURI(), &rcp))
36-
{
40+
if (GUIUtil::parseBitcoinURI(getURI(), &rcp)) {
3741
/* Only accept value URIs */
3842
QDialog::accept();
3943
} else {
4044
ui->uriEdit->setValid(false);
4145
}
4246
}
47+
48+
void OpenURIDialog::changeEvent(QEvent* e)
49+
{
50+
if (e->type() == QEvent::PaletteChange) {
51+
ui->pasteButton->setIcon(m_platform_style->SingleColorIcon(":/icons/editpaste"));
52+
}
53+
54+
QDialog::changeEvent(e);
55+
}

src/qt/openuridialog.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <QDialog>
99

10+
class PlatformStyle;
11+
1012
namespace Ui {
1113
class OpenURIDialog;
1214
}
@@ -16,16 +18,19 @@ class OpenURIDialog : public QDialog
1618
Q_OBJECT
1719

1820
public:
19-
explicit OpenURIDialog(QWidget *parent);
21+
explicit OpenURIDialog(const PlatformStyle* platformStyle, QWidget* parent);
2022
~OpenURIDialog();
2123

2224
QString getURI();
2325

2426
protected Q_SLOTS:
2527
void accept() override;
28+
void changeEvent(QEvent* e) override;
2629

2730
private:
28-
Ui::OpenURIDialog *ui;
31+
Ui::OpenURIDialog* ui;
32+
33+
const PlatformStyle* m_platform_style;
2934
};
3035

3136
#endif // BITCOIN_QT_OPENURIDIALOG_H

0 commit comments

Comments
 (0)