Redoing the Sign/Verify page

This commit is contained in:
Sander Ferdinand 2018-03-21 23:56:53 +01:00 committed by moneromooo-monero
parent 7c0f704fbd
commit 6e794e3c50
7 changed files with 194 additions and 265 deletions

View file

@ -136,7 +136,7 @@ Rectangle {
}, State { }, State {
name: "Sign" name: "Sign"
PropertyChanges { target: root; currentView: signView } PropertyChanges { target: root; currentView: signView }
PropertyChanges { target: mainFlickable; contentHeight: minHeight } PropertyChanges { target: mainFlickable; contentHeight: 1200 * scaleRatio }
}, State { }, State {
name: "Settings" name: "Settings"
PropertyChanges { target: root; currentView: settingsView } PropertyChanges { target: root; currentView: settingsView }

View file

@ -29,6 +29,7 @@
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import QtQuick 2.10 import QtQuick 2.10
import "../js/TxUtils.js" as TxUtils
import "." 1.0 import "." 1.0
@ -37,6 +38,7 @@ TextArea {
property bool addressValidation: false property bool addressValidation: false
property bool wrapAnywhere: true property bool wrapAnywhere: true
property int fontSize: 18 * scaleRatio property int fontSize: 18 * scaleRatio
id: textArea id: textArea
font.family: Style.fontRegular font.family: Style.fontRegular
font.pixelSize: fontSize font.pixelSize: fontSize
@ -56,6 +58,9 @@ TextArea {
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.testnet);
if(!address_ok) error = true;
else error = false;
TextArea.cursorPosition = textArea.text.length; TextArea.cursorPosition = textArea.text.length;
} }
} }

View file

@ -35,7 +35,7 @@ ColumnLayout {
id: lineditmulti id: lineditmulti
property alias text: multiLine.text property alias text: multiLine.text
property alias placeholderText: placeholderLabel.text property alias placeholderText: placeholderLabel.text
property alias inputLabelText: inputLabel.text property alias labelText: inputLabel.text
property alias error: multiLine.error property alias error: multiLine.error
property alias readOnly: multiLine.readOnly property alias readOnly: multiLine.readOnly
property alias addressValidation: multiLine.addressValidation property alias addressValidation: multiLine.addressValidation

View file

@ -65,6 +65,7 @@ ListView {
showingHeader: false showingHeader: false
showBorder: false showBorder: false
addressValidation: false
} }
IconButton { IconButton {

View file

@ -43,10 +43,6 @@ Rectangle {
Clipboard { id: clipboard } Clipboard { id: clipboard }
function checkAddress(address, nettype) {
return walletManager.addressValid(address, nettype)
}
MessageDialog { MessageDialog {
// dynamically change onclose handler // dynamically change onclose handler
property var onCloseCallback property var onCloseCallback
@ -88,302 +84,215 @@ Rectangle {
// sign / verify // sign / verify
ColumnLayout { ColumnLayout {
anchors.margins: 17 * scaleRatio anchors.top: parent.top
anchors.margins: 40 * scaleRatio
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
spacing: 20 * scaleRatio spacing: 20 * scaleRatio
// sign // sign
ColumnLayout { ColumnLayout {
id: signBox id: signBox
anchors.left: parent.left
RowLayout { anchors.right: parent.right
spacing: 20 * scaleRatio
Text {
text: qsTr("Sign a message or file contents with your address:") + translationManager.emptyString
wrapMode: Text.Wrap
Layout.fillWidth: true
font.family: Style.fontRegular
font.pixelSize: 16 * scaleRatio
color: Style.defaultFontColor
}
}
Label { Label {
id: signMessageLabel id: signTitleLabel
text: qsTr("Either message:") + translationManager.emptyString fontSize: 24 * scaleRatio
text: qsTr("Sign") + translationManager.emptyString
} }
RowLayout { Text {
text: qsTr("This page lets you sign/verify a message (or file contents) with your address.") + translationManager.emptyString
wrapMode: Text.Wrap
Layout.fillWidth: true
font.family: Style.fontRegular
font.pixelSize: 14 * scaleRatio
color: Style.defaultFontColor
}
ColumnLayout{
id: signMessageRow id: signMessageRow
anchors.topMargin: 17
anchors.left: parent.left
anchors.right: parent.right
LineEdit { RowLayout {
id: signMessageLine
anchors.left: parent.left
anchors.right: signMessageButton.left
placeholderText: qsTr("Message to sign") + translationManager.emptyString;
readOnly: false
onTextChanged: signSignatureLine.text = ""
IconButton {
imageSource: "../images/copyToClipboard.png"
onClicked: {
if (signMessageLine.text.length > 0) {
clipboard.setText(signMessageLine.text)
}
}
}
}
StandardButton {
id: signMessageButton
anchors.right: parent.right
text: qsTr("Sign") + translationManager.emptyString
enabled: true
onClicked: {
var signature = appWindow.currentWallet.signMessage(signMessageLine.text, false)
signSignatureLine.text = signature
}
}
}
Label {
id: signMessageFileLabel
text: qsTr("Or file:") + translationManager.emptyString
}
RowLayout {
id: signFileRow
anchors.topMargin: 17
anchors.left: parent.left
anchors.right: parent.right
FileDialog {
id: signFileDialog
title: qsTr("Please choose a file to sign") + translationManager.emptyString;
folder: "file://"
nameFilters: [ "*"]
onAccepted: {
signFileLine.text = walletManager.urlToLocalPath(signFileDialog.fileUrl)
}
}
StandardButton {
id: loadFileToSignButton
anchors.rightMargin: 17 * scaleRatio
text: qsTr("Select") + translationManager.emptyString
enabled: true
onClicked: {
signFileDialog.open()
}
}
LineEdit {
id: signFileLine
anchors.left: loadFileToSignButton.right
anchors.right: signFileButton.left
placeholderText: qsTr("Filename with message to sign") + translationManager.emptyString;
readOnly: false
Layout.fillWidth: true Layout.fillWidth: true
onTextChanged: signSignatureLine.text = ""
IconButton { LineEdit {
imageSource: "../images/copyToClipboard.png" id: signMessageLine
onClicked: { Layout.fillWidth: true
if (signFileLine.text.length > 0) { placeholderText: qsTr("Message to sign") + translationManager.emptyString;
clipboard.setText(signFileLine.text) labelText: qsTr("Message") + translationManager.emptyString;
} readOnly: false
} onTextChanged: signSignatureLine.text = ""
} }
} }
StandardButton { RowLayout{
id: signFileButton Layout.fillWidth: true
anchors.right: parent.right Layout.topMargin: 18
text: qsTr("Sign") + translationManager.emptyString
enabled: true StandardButton {
onClicked: { id: signMessageButton
var signature = appWindow.currentWallet.signMessage(signFileLine.text, true) text: qsTr("Sign") + translationManager.emptyString
signSignatureLine.text = signature enabled: signMessageLine.text !== ''
small: true
onClicked: {
var signature = appWindow.currentWallet.signMessage(signMessageLine.text, false)
signSignatureLine.text = signature
}
} }
} }
} }
ColumnLayout {
id: signFileRow
RowLayout {
LineEdit {
id: signFileLine
labelText: "Message from file"
placeholderText: qsTr("Path to file") + translationManager.emptyString;
readOnly: false
Layout.fillWidth: true
onTextChanged: signSignatureLine.text = ""
}
}
RowLayout {
Layout.fillWidth: true
Layout.topMargin: 18
StandardButton {
id: loadFileToSignButton
small: true
text: qsTr("Browse") + translationManager.emptyString
enabled: true
onClicked: {
signFileDialog.open();
}
}
StandardButton {
id: signFileButton
small: true
anchors.left: loadFileToSignButton.right
anchors.leftMargin: 20
text: qsTr("Sign") + translationManager.emptyString
enabled: signFileLine.text !== ''
onClicked: {
var signature = appWindow.currentWallet.signMessage(signFileLine.text, true);
signSignatureLine.text = signature;
}
}
}
}
ColumnLayout { ColumnLayout {
id: signSignatureRow id: signSignatureRow
anchors.topMargin: 17 * scaleRatio
Label { RowLayout {
id: signSignatureLabel LineEdit {
text: qsTr("Signature") + translationManager.emptyString id: signSignatureLine
} labelText: qsTr("Signature")
placeholderText: qsTr("Signature") + translationManager.emptyString;
LineEdit { readOnly: true
id: signSignatureLine Layout.fillWidth: true
placeholderText: qsTr("Signature") + translationManager.emptyString; copyButton: true
readOnly: true
Layout.fillWidth: true
IconButton {
imageSource: "../images/copyToClipboard.png"
onClicked: {
if (signSignatureLine.text.length > 0) {
clipboard.setText(signSignatureLine.text)
}
}
}
}
}
}
// verify
ColumnLayout {
id: verifyBox
RowLayout {
Text {
text: qsTr("Verify a message or file signature from an address:") + translationManager.emptyString
wrapMode: Text.Wrap
Layout.fillWidth: true
font.family: Style.fontRegular
font.pixelSize: 16 * scaleRatio
color: Style.defaultFontColor
}
}
Label {
id: verifyMessageLabel
text: qsTr("Either message:") + translationManager.emptyString
}
RowLayout {
id: verifyMessageRow
anchors.topMargin: 17 * scaleRatio
anchors.left: parent.left
anchors.right: parent.right
LineEdit {
id: verifyMessageLine
anchors.left: parent.left
anchors.right: verifyMessageButton.left
placeholderText: qsTr("Message to verify") + translationManager.emptyString;
readOnly: false
Layout.fillWidth: true
IconButton {
imageSource: "../images/copyToClipboard.png"
onClicked: {
if (verifyMessageLine.text.length > 0) {
clipboard.setText(verifyMessageLine.text)
}
}
}
}
StandardButton {
id: verifyMessageButton
anchors.right: parent.right
text: qsTr("Verify") + translationManager.emptyString
enabled: true
onClicked: {
var verified = appWindow.currentWallet.verifySignedMessage(verifyMessageLine.text, verifyAddressLine.text, verifySignatureLine.text, false)
displayVerificationResult(verified)
} }
} }
} }
Label { Label {
id: verifyMessageFileLabel id: verifyTitleLabel
text: qsTr("Or file:") + translationManager.emptyString fontSize: 24 * scaleRatio
Layout.topMargin: 40
text: qsTr("Verify") + translationManager.emptyString
} }
RowLayout { ColumnLayout {
id: verifyFileRow RowLayout {
anchors.topMargin: 17 * scaleRatio id: verifyMessageRow
anchors.left: parent.left
anchors.right: parent.right
FileDialog { LineEdit {
id: verifyFileDialog id: verifyMessageLine
title: qsTr("Please choose a file to verify") + translationManager.emptyString; Layout.fillWidth: true
folder: "file://" labelText: qsTr("Verify message")
nameFilters: [ "*"] placeholderText: qsTr("Message to verify") + translationManager.emptyString;
readOnly: false
onAccepted: {
verifyFileLine.text = walletManager.urlToLocalPath(verifyFileDialog.fileUrl)
} }
} }
StandardButton { RowLayout{
id: loadFileToVerifyButton
anchors.rightMargin: 17 * scaleRatio
text: qsTr("Select") + translationManager.emptyString
enabled: true
onClicked: {
verifyFileDialog.open()
}
}
LineEdit {
id: verifyFileLine
anchors.left: loadFileToVerifyButton.right
anchors.right: verifyFileButton.left
placeholderText: qsTr("Filename with message to verify") + translationManager.emptyString;
readOnly: false
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: 18
IconButton { StandardButton {
imageSource: "../images/copyToClipboard.png" id: verifyMessageButton
small: true
text: qsTr("Verify") + translationManager.emptyString
enabled: true
onClicked: { onClicked: {
if (verifyFileLine.text.length > 0) { var verified = appWindow.currentWallet.verifySignedMessage(verifyMessageLine.text, verifyAddressLine.text, verifySignatureLine.text, false)
clipboard.setText(verifyFileLine.text) displayVerificationResult(verified)
}
} }
} }
} }
}
StandardButton { ColumnLayout {
id: verifyFileButton RowLayout {
anchors.right: parent.right LineEdit {
text: qsTr("Verify") + translationManager.emptyString id: verifyFileLine
enabled: true labelText: qsTr("Verify file")
onClicked: { placeholderText: qsTr("Filename with message to verify") + translationManager.emptyString;
var verified = appWindow.currentWallet.verifySignedMessage(verifyFileLine.text, verifyAddressLine.text, verifySignatureLine.text, true) readOnly: false
displayVerificationResult(verified) Layout.fillWidth: true
}
}
RowLayout{
Layout.fillWidth: true
Layout.topMargin: 18
StandardButton {
id: loadFileToVerifyButton
small: true
text: qsTr("Browse") + translationManager.emptyString
enabled: true
onClicked: {
verifyFileDialog.open()
}
}
StandardButton {
id: verifyFileButton
small: true
anchors.left: loadFileToVerifyButton.right
anchors.leftMargin: 20
text: qsTr("Verify") + translationManager.emptyString
enabled: true
onClicked: {
var verified = appWindow.currentWallet.verifySignedMessage(verifyFileLine.text, verifyAddressLine.text, verifySignatureLine.text, true)
displayVerificationResult(verified)
}
} }
} }
} }
Text { ColumnLayout {
id: verifyAddressLabel RowLayout{
text: "<style type='text/css'>a {text-decoration: none; color: #FF6C3C; font-size: " + (16 * scaleRatio) + "px;}</style>" +
qsTr("Signing address") +
"<font size='" + (2 * scaleRatio) + "'> ( " +
qsTr("Paste in or select from <a href='#'>Address book</a>") +
" )</font>" +
translationManager.emptyString
wrapMode: Text.Wrap
font.pixelSize: 16 * scaleRatio
Layout.fillWidth: true
textFormat: Text.RichText
onLinkActivated: appWindow.showPageRequest("AddressBook")
}
LineEdit { LineEditMulti {
id: verifyAddressLine id: verifyAddressLine
anchors.left: parent.left Layout.fillWidth: true
anchors.right: parent.right labelText: qsTr("Address")
anchors.top: verifyAddressLabel.bottom addressValidation: true
anchors.topMargin: 5 * scaleRatio anchors.topMargin: 5 * scaleRatio
placeholderText: "4..." placeholderText: "4..."
// validator: RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g } }
}
} }
ColumnLayout { ColumnLayout {
@ -399,18 +308,33 @@ Rectangle {
id: verifySignatureLine id: verifySignatureLine
placeholderText: qsTr("Signature") + translationManager.emptyString; placeholderText: qsTr("Signature") + translationManager.emptyString;
Layout.fillWidth: true Layout.fillWidth: true
copyButton: true
IconButton {
imageSource: "../images/copyToClipboard.png"
onClicked: {
if (verifySignatureLine.text.length > 0) {
clipboard.setText(verifySignatureLine.text)
}
}
}
} }
} }
} }
FileDialog {
id: signFileDialog
title: qsTr("Please choose a file to sign") + translationManager.emptyString;
folder: "file://"
nameFilters: [ "*"]
onAccepted: {
signFileLine.text = walletManager.urlToLocalPath(signFileDialog.fileUrl)
}
}
FileDialog {
id: verifyFileDialog
title: qsTr("Please choose a file to verify") + translationManager.emptyString;
folder: "file://"
nameFilters: [ "*"]
onAccepted: {
verifyFileLine.text = walletManager.urlToLocalPath(verifyFileDialog.fileUrl)
}
}
} }
function onPageCompleted() { function onPageCompleted() {

View file

@ -205,7 +205,7 @@ Rectangle {
LineEditMulti { LineEditMulti {
id: addressLine id: addressLine
spacing: 0 spacing: 0
inputLabelText: qsTr("<style type='text/css'>a {text-decoration: none; color: #858585; font-size: 14px;}</style>\ labelText: qsTr("<style type='text/css'>a {text-decoration: none; color: #858585; font-size: 14px;}</style>\
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

View file

@ -132,7 +132,6 @@ Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
anchors.bottomMargin: 3 * scaleRatio anchors.bottomMargin: 3 * scaleRatio
} }
Label { Label {