mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-09 20:40:27 +00:00
openalias: usuability improvements on addressbook/transfer page
This commit is contained in:
parent
ed760cfc82
commit
d36904096d
3 changed files with 92 additions and 5 deletions
|
@ -54,7 +54,7 @@ TextArea {
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
if(addressValidation){
|
if(addressValidation){
|
||||||
// js replacement for `RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }`
|
// js replacement for `RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }`
|
||||||
textArea.text = textArea.text.replace(/[^a-z0-9.@]/gi,'');
|
textArea.text = textArea.text.replace(/[^a-z0-9.@\-]/gi,'');
|
||||||
var address_ok = TxUtils.checkAddress(textArea.text, appWindow.persistentSettings.nettype) || TxUtils.isValidOpenAliasAddress(textArea.text);
|
var address_ok = TxUtils.checkAddress(textArea.text, appWindow.persistentSettings.nettype) || TxUtils.isValidOpenAliasAddress(textArea.text);
|
||||||
if(!address_ok) error = true;
|
if(!address_ok) error = true;
|
||||||
else error = false;
|
else error = false;
|
||||||
|
|
|
@ -28,7 +28,9 @@
|
||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
|
import QtQuick.Dialogs 1.2
|
||||||
import "../components" as MoneroComponents
|
import "../components" as MoneroComponents
|
||||||
|
import "../js/TxUtils.js" as TxUtils
|
||||||
import moneroComponents.AddressBook 1.0
|
import moneroComponents.AddressBook 1.0
|
||||||
import moneroComponents.AddressBookModel 1.0
|
import moneroComponents.AddressBookModel 1.0
|
||||||
import moneroComponents.Clipboard 1.0
|
import moneroComponents.Clipboard 1.0
|
||||||
|
@ -51,9 +53,20 @@ ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
fontBold: true
|
fontBold: true
|
||||||
labelText: qsTr("Address") + translationManager.emptyString
|
labelText: qsTr("Address") + translationManager.emptyString
|
||||||
placeholderText: qsTr("4.. / 8..") + translationManager.emptyString
|
placeholderText: qsTr("4.. / 8.. / OpenAlias") + translationManager.emptyString
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
addressValidation: true
|
addressValidation: true
|
||||||
|
pasteButton: true
|
||||||
|
onPaste: function(clipboardText) {
|
||||||
|
const parsed = walletManager.parse_uri_to_object(clipboardText);
|
||||||
|
if (!parsed.error) {
|
||||||
|
addressLine.text = parsed.address;
|
||||||
|
setPaymentId(parsed.payment_id);
|
||||||
|
setDescription(parsed.tx_description);
|
||||||
|
} else {
|
||||||
|
addressLine.text = clipboardText;
|
||||||
|
}
|
||||||
|
}
|
||||||
inlineButton.icon: "../images/qr.png"
|
inlineButton.icon: "../images/qr.png"
|
||||||
inlineButton.buttonColor: MoneroComponents.Style.orange
|
inlineButton.buttonColor: MoneroComponents.Style.orange
|
||||||
inlineButton.onClicked: {
|
inlineButton.onClicked: {
|
||||||
|
@ -63,6 +76,50 @@ ColumnLayout {
|
||||||
inlineButtonVisible : appWindow.qrScannerEnabled && !addressLine.text
|
inlineButtonVisible : appWindow.qrScannerEnabled && !addressLine.text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoneroComponents.StandardButton {
|
||||||
|
id: resolveButton
|
||||||
|
text: qsTr("Resolve") + translationManager.emptyString
|
||||||
|
visible: TxUtils.isValidOpenAliasAddress(addressLine.text)
|
||||||
|
enabled : visible
|
||||||
|
onClicked: {
|
||||||
|
var result = walletManager.resolveOpenAlias(addressLine.text)
|
||||||
|
if (result) {
|
||||||
|
var parts = result.split("|")
|
||||||
|
if (parts.length === 2) {
|
||||||
|
var address_ok = walletManager.addressValid(parts[1], appWindow.persistentSettings.nettype)
|
||||||
|
if (parts[0] === "true") {
|
||||||
|
if (address_ok) {
|
||||||
|
// prepend openalias to description
|
||||||
|
descriptionLine.text = descriptionLine.text ? addressLine.text + " " + descriptionLine.text : addressLine.text
|
||||||
|
addressLine.text = parts[1]
|
||||||
|
}
|
||||||
|
else
|
||||||
|
oa_message(qsTr("No valid address found at this OpenAlias address"))
|
||||||
|
}
|
||||||
|
else if (parts[0] === "false") {
|
||||||
|
if (address_ok) {
|
||||||
|
addressLine.text = parts[1]
|
||||||
|
oa_message(qsTr("Address found, but the DNSSEC signatures could not be verified, so this address may be spoofed"))
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oa_message(qsTr("No valid address found at this OpenAlias address, but the DNSSEC signatures could not be verified, so this may be spoofed"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
oa_message(qsTr("Internal error"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
oa_message(qsTr("Internal error"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
oa_message(qsTr("No address found"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MoneroComponents.LineEditMulti {
|
MoneroComponents.LineEditMulti {
|
||||||
id: paymentIdLine
|
id: paymentIdLine
|
||||||
visible: appWindow.persistentSettings.showPid
|
visible: appWindow.persistentSettings.showPid
|
||||||
|
@ -82,7 +139,6 @@ ColumnLayout {
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: addButton
|
id: addButton
|
||||||
Layout.bottomMargin: 17 * scaleRatio
|
Layout.bottomMargin: 17 * scaleRatio
|
||||||
|
@ -150,7 +206,7 @@ ColumnLayout {
|
||||||
payment_id = payment_id.trim()
|
payment_id = payment_id.trim()
|
||||||
|
|
||||||
var address_ok = walletManager.addressValid(address, nettype)
|
var address_ok = walletManager.addressValid(address, nettype)
|
||||||
var payment_id_ok = payment_id.length == 0 || walletManager.paymentIdValid(payment_id)
|
var payment_id_ok = payment_id.length === 0 || walletManager.paymentIdValid(payment_id)
|
||||||
var ipid = walletManager.paymentIdFromAddress(address, nettype)
|
var ipid = walletManager.paymentIdFromAddress(address, nettype)
|
||||||
if (ipid.length > 0 && payment_id.length > 0)
|
if (ipid.length > 0 && payment_id.length > 0)
|
||||||
payment_id_ok = false
|
payment_id_ok = false
|
||||||
|
@ -178,9 +234,37 @@ ColumnLayout {
|
||||||
cameraUi.qrcode_decoded.disconnect(updateFromQrCode)
|
cameraUi.qrcode_decoded.disconnect(updateFromQrCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setDescription(value) {
|
||||||
|
descriptionLine.text = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPaymentId(value) {
|
||||||
|
paymentIdLine.text = value;
|
||||||
|
}
|
||||||
|
|
||||||
function clearFields() {
|
function clearFields() {
|
||||||
addressLine.text = "";
|
addressLine.text = "";
|
||||||
paymentIdLine.text = "";
|
paymentIdLine.text = "";
|
||||||
descriptionLine.text = "";
|
descriptionLine.text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function oa_message(text) {
|
||||||
|
oaPopup.title = qsTr("OpenAlias error") + translationManager.emptyString
|
||||||
|
oaPopup.text = text
|
||||||
|
oaPopup.icon = StandardIcon.Information
|
||||||
|
oaPopup.onCloseCallback = null
|
||||||
|
oaPopup.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
MoneroComponents.StandardDialog {
|
||||||
|
// dynamically change onclose handler
|
||||||
|
property var onCloseCallback
|
||||||
|
id: oaPopup
|
||||||
|
cancelVisible: false
|
||||||
|
onAccepted: {
|
||||||
|
if (onCloseCallback) {
|
||||||
|
onCloseCallback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ Rectangle {
|
||||||
Address <font size='2'> ( </font> <a href='#'>Address book</a><font size='2'> )</font>")
|
Address <font size='2'> ( </font> <a href='#'>Address book</a><font size='2'> )</font>")
|
||||||
+ translationManager.emptyString
|
+ translationManager.emptyString
|
||||||
labelButtonText: qsTr("Resolve") + translationManager.emptyString
|
labelButtonText: qsTr("Resolve") + translationManager.emptyString
|
||||||
placeholderText: "4.. / 8.."
|
placeholderText: "4.. / 8.. / OpenAlias"
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
addressValidation: true
|
addressValidation: true
|
||||||
onInputLabelLinkActivated: {
|
onInputLabelLinkActivated: {
|
||||||
|
@ -259,6 +259,9 @@ Rectangle {
|
||||||
var address_ok = walletManager.addressValid(parts[1], appWindow.persistentSettings.nettype)
|
var address_ok = walletManager.addressValid(parts[1], appWindow.persistentSettings.nettype)
|
||||||
if (parts[0] === "true") {
|
if (parts[0] === "true") {
|
||||||
if (address_ok) {
|
if (address_ok) {
|
||||||
|
// prepend openalias to description
|
||||||
|
descriptionLine.text = descriptionLine.text ? addressLine.text + " " + descriptionLine.text : addressLine.text
|
||||||
|
descriptionCheckbox.checked = true
|
||||||
addressLine.text = parts[1]
|
addressLine.text = parts[1]
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue