Skip to content

Commit

Permalink
merge bitcoin-core/gui#319: Paste button in Open URI dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Feb 5, 2025
1 parent 3db335f commit c02483c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
20 changes: 19 additions & 1 deletion src/qt/forms/openuridialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@
</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="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -64,7 +80,9 @@
<header>qt/qvalidatedlineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<resources>
<include location="../dash.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
Expand Down
23 changes: 17 additions & 6 deletions src/qt/openuridialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
#include <qt/guiutil.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(QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags),
ui(new Ui::OpenURIDialog)
{
ui->setupUi(this);
GUIUtil::setIcon(ui->pasteButton, "editpaste");
QObject::connect(ui->pasteButton, &QAbstractButton::clicked, ui->uriEdit, &QLineEdit::paste);

GUIUtil::updateFonts();
GUIUtil::disableMacFocusRect(this);

GUIUtil::handleCloseWindowShortcut(this);
}

Expand All @@ -35,11 +38,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)
{
QDialog::changeEvent(e);
if (e->type() == QEvent::StyleChange) {
// Adjust button icon colors on theme changes
GUIUtil::setIcon(ui->pasteButton, "editpaste");
}
}
5 changes: 3 additions & 2 deletions src/qt/openuridialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ class OpenURIDialog : public QDialog
Q_OBJECT

public:
explicit OpenURIDialog(QWidget *parent);
explicit OpenURIDialog(QWidget* parent);
~OpenURIDialog();

QString getURI();

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

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

#endif // BITCOIN_QT_OPENURIDIALOG_H
7 changes: 7 additions & 0 deletions src/qt/res/css/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,13 @@ QDialog#OpenURIDialog {
QDialog#OpenURIDialog QLabel#label { /* URI Label */
}

QDialog#OpenURIDialog .QToolButton { /* General Settings for Pay To Icons */
background-color: #00000000;
margin-left: 5px;
margin-right: 5px;
border: 0;
}

/******************************************************
OptionsDialog
******************************************************/
Expand Down

0 comments on commit c02483c

Please sign in to comment.