mirror of
https://github.com/monero-project/monero-gui.git
synced 2026-04-05 07:37:25 -04:00
save qrcode to file
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "QRCodeImageProvider.h"
|
||||
|
||||
QImage QRCodeImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
|
||||
QImage QRCodeImageProvider::genQrImage(const QString &id, QSize *size)
|
||||
{
|
||||
using namespace qrcodegen;
|
||||
|
||||
@@ -15,3 +15,8 @@ QImage QRCodeImageProvider::requestImage(const QString &id, QSize *size, const Q
|
||||
*size = QSize(qrcode.size, qrcode.size);
|
||||
return img;
|
||||
}
|
||||
|
||||
QImage QRCodeImageProvider::requestImage(const QString &id, QSize *size, const QSize &/* requestedSize */)
|
||||
{
|
||||
return genQrImage(id, size);
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ public:
|
||||
QRCodeImageProvider(): QQuickImageProvider(QQuickImageProvider::Image) {}
|
||||
|
||||
QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize);
|
||||
static QImage genQrImage(const QString &id, QSize *size);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Wallet.h"
|
||||
#include "wallet/wallet2_api.h"
|
||||
#include "zxcvbn-c/zxcvbn.h"
|
||||
#include "QRCodeImageProvider.h"
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
@@ -291,6 +292,13 @@ double WalletManager::getPasswordStrength(const QString &password) const
|
||||
return e;
|
||||
}
|
||||
|
||||
bool WalletManager::saveQrCode(const QString &code, const QString &path) const
|
||||
{
|
||||
QSize size;
|
||||
// 240 <=> mainLayout.qrCodeSize (Receive.qml)
|
||||
return QRCodeImageProvider::genQrImage(code, &size).scaled(size.expandedTo(QSize(240, 240)), Qt::KeepAspectRatio).save(path, "PNG", 100);
|
||||
}
|
||||
|
||||
WalletManager::WalletManager(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_pimpl = Monero::WalletManagerFactory::getWalletManager();
|
||||
|
||||
@@ -123,6 +123,7 @@ public:
|
||||
|
||||
Q_INVOKABLE QString resolveOpenAlias(const QString &address) const;
|
||||
Q_INVOKABLE bool parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector<QString> &unknown_parameters, QString &error);
|
||||
Q_INVOKABLE bool saveQrCode(const QString &, const QString &) const;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user