mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-14 04:16:33 +02:00
commit
d4a40499ac
@ -358,6 +358,32 @@ Rectangle {
|
||||
standardButtons: StandardButton.Ok
|
||||
}
|
||||
|
||||
FileDialog {
|
||||
id: qrFileDialog
|
||||
title: "Please choose a name"
|
||||
folder: shortcuts.pictures
|
||||
selectExisting: false
|
||||
nameFilters: [ "Image (*.png)"]
|
||||
onAccepted: {
|
||||
if( ! walletManager.saveQrCode(makeQRCodeString(), walletManager.urlToLocalPath(fileUrl))) {
|
||||
console.log("Failed to save QrCode to file " + walletManager.urlToLocalPath(fileUrl) )
|
||||
trackingHowToUseDialog.title = qsTr("Save QrCode") + translationManager.emptyString;
|
||||
trackingHowToUseDialog.text = qsTr("Failed to save QrCode to ") + walletManager.urlToLocalPath(fileUrl) + translationManager.emptyString;
|
||||
trackingHowToUseDialog.icon = StandardIcon.Error
|
||||
trackingHowToUseDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: qrMenu
|
||||
title: "QrCode"
|
||||
MenuItem {
|
||||
text: qsTr("Save As")
|
||||
onTriggered: qrFileDialog.open()
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: qrCode
|
||||
anchors.margins: 50
|
||||
@ -367,6 +393,15 @@ Rectangle {
|
||||
smooth: false
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: "image://qrcode/" + makeQRCodeString()
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
onClicked: {
|
||||
if (mouse.button == Qt.RightButton)
|
||||
qrMenu.popup()
|
||||
}
|
||||
onPressAndHold: qrFileDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user