qt: Add GUIUtil::AddButtonShortcut

Co-authored-by: Jarol Rodriguez <jarolrod@tutanota.com>
This commit is contained in:
Hennadii Stepanov 2021-04-18 15:21:57 +03:00 committed by Jarol Rodriguez
parent 4ee9ee7236
commit a2e122f0fe
2 changed files with 16 additions and 0 deletions

View file

@ -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

View file

@ -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);