aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-04-18 15:21:57 +0300
committerJarol Rodriguez <jarolrod@tutanota.com>2021-05-17 14:01:00 -0400
commita2e122f0fe72d695762db2b83905e246f451300c (patch)
treefdd3597de977b512ae070a1c61a8160ec6d8e9c3 /src/qt
parent4ee9ee72363d46c5ba0c71b8d8283d9c5621e3ed (diff)
qt: Add GUIUtil::AddButtonShortcut
Co-authored-by: Jarol Rodriguez <jarolrod@tutanota.com>
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/guiutil.cpp6
-rw-r--r--src/qt/guiutil.h10
2 files changed, 16 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index b4afdbcc22..15146cfac4 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -29,6 +29,7 @@
#include <shlwapi.h>
#endif
+#include <QAbstractButton>
#include <QAbstractItemView>
#include <QApplication>
#include <QClipboard>
@@ -119,6 +120,11 @@ void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
widget->setCheckValidator(new BitcoinAddressCheckValidator(parent));
}
+void AddButtonShortcut(QAbstractButton* button, const QKeySequence& shortcut)
+{
+ QObject::connect(new QShortcut(shortcut, button), &QShortcut::activated, [button]() { button->animateClick(); });
+}
+
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
{
// return if URI is not valid or is no bitcoin: URI
diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h
index 6395ec6abd..972d6348fc 100644
--- a/src/qt/guiutil.h
+++ b/src/qt/guiutil.h
@@ -31,10 +31,12 @@ namespace interfaces
}
QT_BEGIN_NAMESPACE
+class QAbstractButton;
class QAbstractItemView;
class QAction;
class QDateTime;
class QFont;
+class QKeySequence;
class QLineEdit;
class QMenu;
class QPoint;
@@ -60,6 +62,14 @@ namespace GUIUtil
// Set up widget for address
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent);
+ /**
+ * Connects an additional shortcut to a QAbstractButton. Works around the
+ * one shortcut limitation of the button's shortcut property.
+ * @param[in] button QAbstractButton to assign shortcut to
+ * @param[in] shortcut QKeySequence to use as shortcut
+ */
+ void AddButtonShortcut(QAbstractButton* button, const QKeySequence& shortcut);
+
// Parse "bitcoin:" URI into recipient object, return true on successful parsing
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out);
bool parseBitcoinURI(QString uri, SendCoinsRecipient *out);