diff options
author | Kristaps Kaupe <kristaps@blogiem.lv> | 2021-05-05 14:39:38 +0300 |
---|---|---|
committer | Kristaps Kaupe <kristaps@blogiem.lv> | 2021-09-26 03:32:43 +0300 |
commit | dbde0558ce73db4c901dbaa2eddc634701fa1d0d (patch) | |
tree | 23ddcc3f6f93d88bea43882f8be2ede6e6ad4293 /src/qt | |
parent | 16ccb3a1cd9125eb24a5b45a98099ff98660767a (diff) |
gui: Paste button in Open URI dialog
Co-authored-by: Emil Engler <me@emilengler.com>
Co-authored-by: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= <joao.paulo.barbosa@gmail.com>
Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
Co-authored-by: Jarol Rodriguez <jarolrod@tutanota.com>
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/bitcoingui.cpp | 2 | ||||
-rw-r--r-- | src/qt/forms/openuridialog.ui | 21 | ||||
-rw-r--r-- | src/qt/openuridialog.cpp | 23 | ||||
-rw-r--r-- | src/qt/openuridialog.h | 9 |
4 files changed, 47 insertions, 8 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 862bdd3bfe..b4dedd0bd5 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -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()); diff --git a/src/qt/forms/openuridialog.ui b/src/qt/forms/openuridialog.ui index 1b7291ab9d..97399e59a2 100644 --- a/src/qt/forms/openuridialog.ui +++ b/src/qt/forms/openuridialog.ui @@ -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> diff --git a/src/qt/openuridialog.cpp b/src/qt/openuridialog.cpp index 10bf82d532..a68eee718e 100644 --- a/src/qt/openuridialog.cpp +++ b/src/qt/openuridialog.cpp @@ -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); } @@ -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); +} diff --git a/src/qt/openuridialog.h b/src/qt/openuridialog.h index efe4b86f37..f3a8b0ba22 100644 --- a/src/qt/openuridialog.h +++ b/src/qt/openuridialog.h @@ -7,6 +7,8 @@ #include <QDialog> +class PlatformStyle; + namespace Ui { class OpenURIDialog; } @@ -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 |