Skip to content

Commit c02483c

Browse files
committed
merge bitcoin-core/gui#319: Paste button in Open URI dialog
1 parent 3db335f commit c02483c

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

src/qt/forms/openuridialog.ui

+19-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@
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="iconSize">
42+
<size>
43+
<width>22</width>
44+
<height>22</height>
45+
</size>
46+
</property>
47+
</widget>
48+
</item>
3349
</layout>
3450
</item>
3551
<item>
@@ -64,7 +80,9 @@
6480
<header>qt/qvalidatedlineedit.h</header>
6581
</customwidget>
6682
</customwidgets>
67-
<resources/>
83+
<resources>
84+
<include location="../dash.qrc"/>
85+
</resources>
6886
<connections>
6987
<connection>
7088
<sender>buttonBox</sender>

src/qt/openuridialog.cpp

+17-6
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@
99
#include <qt/guiutil.h>
1010
#include <qt/sendcoinsrecipient.h>
1111

12+
#include <QAbstractButton>
13+
#include <QLineEdit>
1214
#include <QUrl>
1315

14-
OpenURIDialog::OpenURIDialog(QWidget *parent) :
15-
QDialog(parent, GUIUtil::dialog_flags),
16-
ui(new Ui::OpenURIDialog)
16+
OpenURIDialog::OpenURIDialog(QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags),
17+
ui(new Ui::OpenURIDialog)
1718
{
1819
ui->setupUi(this);
20+
GUIUtil::setIcon(ui->pasteButton, "editpaste");
21+
QObject::connect(ui->pasteButton, &QAbstractButton::clicked, ui->uriEdit, &QLineEdit::paste);
22+
1923
GUIUtil::updateFonts();
2024
GUIUtil::disableMacFocusRect(this);
21-
2225
GUIUtil::handleCloseWindowShortcut(this);
2326
}
2427

@@ -35,11 +38,19 @@ QString OpenURIDialog::getURI()
3538
void OpenURIDialog::accept()
3639
{
3740
SendCoinsRecipient rcp;
38-
if(GUIUtil::parseBitcoinURI(getURI(), &rcp))
39-
{
41+
if (GUIUtil::parseBitcoinURI(getURI(), &rcp)) {
4042
/* Only accept value URIs */
4143
QDialog::accept();
4244
} else {
4345
ui->uriEdit->setValid(false);
4446
}
4547
}
48+
49+
void OpenURIDialog::changeEvent(QEvent* e)
50+
{
51+
QDialog::changeEvent(e);
52+
if (e->type() == QEvent::StyleChange) {
53+
// Adjust button icon colors on theme changes
54+
GUIUtil::setIcon(ui->pasteButton, "editpaste");
55+
}
56+
}

src/qt/openuridialog.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ class OpenURIDialog : public QDialog
1616
Q_OBJECT
1717

1818
public:
19-
explicit OpenURIDialog(QWidget *parent);
19+
explicit OpenURIDialog(QWidget* parent);
2020
~OpenURIDialog();
2121

2222
QString getURI();
2323

2424
protected Q_SLOTS:
2525
void accept() override;
26+
void changeEvent(QEvent* e) override;
2627

2728
private:
28-
Ui::OpenURIDialog *ui;
29+
Ui::OpenURIDialog* ui;
2930
};
3031

3132
#endif // BITCOIN_QT_OPENURIDIALOG_H

src/qt/res/css/general.css

+7
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,13 @@ QDialog#OpenURIDialog {
12591259
QDialog#OpenURIDialog QLabel#label { /* URI Label */
12601260
}
12611261

1262+
QDialog#OpenURIDialog .QToolButton { /* General Settings for Pay To Icons */
1263+
background-color: #00000000;
1264+
margin-left: 5px;
1265+
margin-right: 5px;
1266+
border: 0;
1267+
}
1268+
12621269
/******************************************************
12631270
OptionsDialog
12641271
******************************************************/

0 commit comments

Comments
 (0)