mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-22 19:49:34 +00:00
qml: use libwalletqt make_uri function
This commit is contained in:
parent
dcc16a44be
commit
f327d20deb
3 changed files with 7 additions and 35 deletions
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue