diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-05-06 09:40:01 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-05-06 10:04:33 +0200 |
commit | 9bbaac73bb1f2a3836ed64b82b27360c427d1e4c (patch) | |
tree | 1032cdf0a1f52e1c7c3236fcd59a017f007137b5 /src/qt/qrimagewidget.h | |
parent | d7d7d315060620446bd363ca50f95f79d3260db7 (diff) | |
parent | fc929842c20ac81869a33edce765e389a46e6c0c (diff) | |
download | bitcoin-9bbaac73bb1f2a3836ed64b82b27360c427d1e4c.tar.xz |
Merge #15928: GUI: Move QRImageWidget to its own file-pair
fc929842c20ac81869a33edce765e389a46e6c0c GUI: Move QRImageWidget to its own file-pair (Luke Dashjr)
77851ab682bf94f78874a245919bcc4b79dc054e GUI: Refactor actual QR code rendering into new QRImageWidget::setQR (Luke Dashjr)
Pull request description:
For at least QR-code based pairing of mobile wallets with nodes, it will be desirable to render QR codes even without wallet support.
Therefore, this prepares by moving the QRImageWidget out of a wallet-specific file into its own `qrencoder` file-pair.
ACKs for commit fc9298:
laanwj:
utACK fc929842c20ac81869a33edce765e389a46e6c0c
jonasschnelli:
utACK fc929842c20ac81869a33edce765e389a46e6c0c
Tree-SHA512: 95529a38c0573a4b3f1253fb5f11ca07a5b3a9840ec24acc7d87270212f3c9f7c5b186d9274d297517a3b80494f38a57574fb9730b1574db01688539b987bd91
Diffstat (limited to 'src/qt/qrimagewidget.h')
-rw-r--r-- | src/qt/qrimagewidget.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/qt/qrimagewidget.h b/src/qt/qrimagewidget.h new file mode 100644 index 0000000000..2a219ac101 --- /dev/null +++ b/src/qt/qrimagewidget.h @@ -0,0 +1,45 @@ +// Copyright (c) 2011-2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_QRIMAGEWIDGET_H +#define BITCOIN_QT_QRIMAGEWIDGET_H + +#include <QImage> +#include <QLabel> + +/* Maximum allowed URI length */ +static const int MAX_URI_LENGTH = 255; + +/* Size of exported QR Code image */ +static const int QR_IMAGE_SIZE = 300; + +QT_BEGIN_NAMESPACE +class QMenu; +QT_END_NAMESPACE + +/* Label widget for QR code. This image can be dragged, dropped, copied and saved + * to disk. + */ +class QRImageWidget : public QLabel +{ + Q_OBJECT + +public: + explicit QRImageWidget(QWidget *parent = nullptr); + bool setQR(const QString& data, const QString& text = ""); + QImage exportImage(); + +public Q_SLOTS: + void saveImage(); + void copyImage(); + +protected: + virtual void mousePressEvent(QMouseEvent *event); + virtual void contextMenuEvent(QContextMenuEvent *event); + +private: + QMenu *contextMenu; +}; + +#endif // BITCOIN_QT_QRIMAGEWIDGET_H |