mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-13 11:25:02 -05:00
Merge bitcoin-core/gui#319: Paste button in Open URI dialog
dbde0558ce
gui: Paste button in Open URI dialog (Kristaps Kaupe) Pull request description: Picking up https://github.com/bitcoin/bitcoin/pull/17955, with some review comments addressed. ACKs for top commit: shaavan: tACKdbde055
jarolrod: ACKdbde055
promag: Tested ACKdbde0558ce
. Tree-SHA512: db47f19673aff6becd6d1f938cd2aa5dc2291d6e80150d2b99f435674330a5eae678b20e42ef327ea9b05c44925a941fc251e622c73b3585018fc7c1d245edb5
This commit is contained in:
commit
79e64a053d
4 changed files with 47 additions and 8 deletions
|
@ -870,7 +870,7 @@ void BitcoinGUI::showHelpMessageClicked()
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
void BitcoinGUI::openClicked()
|
void BitcoinGUI::openClicked()
|
||||||
{
|
{
|
||||||
OpenURIDialog dlg(this);
|
OpenURIDialog dlg(platformStyle, this);
|
||||||
if(dlg.exec())
|
if(dlg.exec())
|
||||||
{
|
{
|
||||||
Q_EMIT receivedURI(dlg.getURI());
|
Q_EMIT receivedURI(dlg.getURI());
|
||||||
|
|
|
@ -30,6 +30,27 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -6,15 +6,20 @@
|
||||||
#include <qt/forms/ui_openuridialog.h>
|
#include <qt/forms/ui_openuridialog.h>
|
||||||
|
|
||||||
#include <qt/guiutil.h>
|
#include <qt/guiutil.h>
|
||||||
|
#include <qt/platformstyle.h>
|
||||||
#include <qt/sendcoinsrecipient.h>
|
#include <qt/sendcoinsrecipient.h>
|
||||||
|
|
||||||
|
#include <QAbstractButton>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
OpenURIDialog::OpenURIDialog(QWidget *parent) :
|
OpenURIDialog::OpenURIDialog(const PlatformStyle* platformStyle, QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags),
|
||||||
QDialog(parent, GUIUtil::dialog_flags),
|
ui(new Ui::OpenURIDialog),
|
||||||
ui(new Ui::OpenURIDialog)
|
m_platform_style(platformStyle)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
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);
|
GUIUtil::handleCloseWindowShortcut(this);
|
||||||
}
|
}
|
||||||
|
@ -32,11 +37,19 @@ QString OpenURIDialog::getURI()
|
||||||
void OpenURIDialog::accept()
|
void OpenURIDialog::accept()
|
||||||
{
|
{
|
||||||
SendCoinsRecipient rcp;
|
SendCoinsRecipient rcp;
|
||||||
if(GUIUtil::parseBitcoinURI(getURI(), &rcp))
|
if (GUIUtil::parseBitcoinURI(getURI(), &rcp)) {
|
||||||
{
|
|
||||||
/* Only accept value URIs */
|
/* Only accept value URIs */
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
} else {
|
} else {
|
||||||
ui->uriEdit->setValid(false);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
class PlatformStyle;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class OpenURIDialog;
|
class OpenURIDialog;
|
||||||
}
|
}
|
||||||
|
@ -16,16 +18,19 @@ class OpenURIDialog : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit OpenURIDialog(QWidget *parent);
|
explicit OpenURIDialog(const PlatformStyle* platformStyle, QWidget* parent);
|
||||||
~OpenURIDialog();
|
~OpenURIDialog();
|
||||||
|
|
||||||
QString getURI();
|
QString getURI();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
|
void changeEvent(QEvent* e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::OpenURIDialog *ui;
|
Ui::OpenURIDialog* ui;
|
||||||
|
|
||||||
|
const PlatformStyle* m_platform_style;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_QT_OPENURIDIALOG_H
|
#endif // BITCOIN_QT_OPENURIDIALOG_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue