qml: use libwalletqt make_uri function

This commit is contained in:
selsta 2021-09-05 05:48:50 +02:00
parent dcc16a44be
commit f327d20deb
No known key found for this signature in database
GPG key ID: 2EA0A99A8B07AE5E
3 changed files with 7 additions and 35 deletions

View file

@ -73,30 +73,3 @@ function isValidOpenAliasAddress(address) {
// we can get an awful lot of valid domains, including non ASCII chars... accept anything // we can get an awful lot of valid domains, including non ASCII chars... accept anything
return true return true
} }
function makeQRCodeString(addr, amount, txDescription, recipientName) {
var XMR_URI_SCHEME = "monero:"
var XMR_AMOUNT = "tx_amount"
var XMR_RECIPIENT_NAME = "recipient_name"
var XMR_TX_DESCRIPTION = "tx_description"
var qrCodeString =""
qrCodeString += (XMR_URI_SCHEME + addr)
if (amount !== undefined && amount !== ""){
qrCodeString += ("?" + XMR_AMOUNT + "=" + amount)
}
if (txDescription !== undefined && txDescription !== ""){
if (amount == ""){
qrCodeString += ("?" + XMR_TX_DESCRIPTION + "=" + encodeURI(txDescription))
} else {
qrCodeString += ("&" + XMR_TX_DESCRIPTION + "=" + encodeURI(txDescription))
}
}
if (recipientName !== undefined && recipientName !== ""){
if (amount == "" && txDescription == ""){
qrCodeString += ("?" + XMR_RECIPIENT_NAME + "=" + encodeURI(recipientName))
} else {
qrCodeString += ("&" + XMR_RECIPIENT_NAME + "=" + encodeURI(recipientName))
}
}
return qrCodeString
}

View file

@ -63,12 +63,11 @@ Rectangle {
function generateQRCodeString() { function generateQRCodeString() {
if (pageReceive.state == "PaymentRequest") { if (pageReceive.state == "PaymentRequest") {
return TxUtils.makeQRCodeString(appWindow.current_address, return walletManager.make_uri(appWindow.current_address,
(amountToReceiveXMR.text != "" && parseFloat(amountToReceiveXMR.text) != 0 ? amountToReceiveXMR.text : ""), walletManager.amountFromString(amountToReceiveXMR.text),
(txDescriptionInput.text != "" ? txDescriptionInput.text : ""), txDescriptionInput.text, receiverNameInput.text);
(receiverNameInput.text != "" ? receiverNameInput.text : ""));
} else { } else {
return TxUtils.makeQRCodeString(appWindow.current_address); return walletManager.make_uri(appWindow.current_address);
} }
} }

View file

@ -211,7 +211,7 @@ Item {
smooth: false smooth: false
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
source: "image://qrcode/" + TxUtils.makeQRCodeString(appWindow.current_address, amountToReceive.text) source: "image://qrcode/" + walletManager.make_uri(appWindow.current_address, walletManager.amountFromString(amountToReceive.text))
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
@ -400,7 +400,7 @@ Item {
font.pixelSize: 12 font.pixelSize: 12
font.bold: true font.bold: true
color: _color color: _color
text: TxUtils.makeQRCodeString(appWindow.current_address, amountToReceive.text) text: walletManager.make_uri(appWindow.current_address, walletManager.amountFromString(amountToReceive.text))
themeTransition: false themeTransition: false
MouseArea { MouseArea {
@ -685,7 +685,7 @@ Item {
selectExisting: false selectExisting: false
nameFilters: ["Image (*.png)"] nameFilters: ["Image (*.png)"]
onAccepted: { onAccepted: {
if(!walletManager.saveQrCode(TxUtils.makeQRCodeString(appWindow.current_address, amountToReceive.text), walletManager.urlToLocalPath(fileUrl))) { if (!walletManager.saveQrCode(walletManager.make_uri(appWindow.current_address, walletManager.amountFromString(amountToReceive.text)), walletManager.urlToLocalPath(fileUrl))) {
console.log("Failed to save QrCode to file " + walletManager.urlToLocalPath(fileUrl) ) console.log("Failed to save QrCode to file " + walletManager.urlToLocalPath(fileUrl) )
receivePageDialog.title = qsTr("Save QrCode") + translationManager.emptyString; receivePageDialog.title = qsTr("Save QrCode") + translationManager.emptyString;
receivePageDialog.text = qsTr("Failed to save QrCode to ") + walletManager.urlToLocalPath(fileUrl) + translationManager.emptyString; receivePageDialog.text = qsTr("Failed to save QrCode to ") + walletManager.urlToLocalPath(fileUrl) + translationManager.emptyString;