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 {
name: "Sign"
PropertyChanges { target: root; currentView: signView }
PropertyChanges { target: mainFlickable; contentHeight: minHeight }
PropertyChanges { target: mainFlickable; contentHeight: 1200 * scaleRatio }
}, State {
name: "Settings"
PropertyChanges { target: root; currentView: settingsView }

View file

@ -29,6 +29,7 @@
import QtQuick.Controls 2.2
import QtQuick 2.10
import "../js/TxUtils.js" as TxUtils
import "." 1.0
@ -37,6 +38,7 @@ TextArea {
property bool addressValidation: false
property bool wrapAnywhere: true
property int fontSize: 18 * scaleRatio
id: textArea
font.family: Style.fontRegular
font.pixelSize: fontSize
@ -56,6 +58,9 @@ TextArea {
if(addressValidation){
// js replacement for `RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }`
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;
}
}

View file

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

View file

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

View file

@ -43,10 +43,6 @@ Rectangle {
Clipboard { id: clipboard }
function checkAddress(address, nettype) {
return walletManager.addressValid(address, nettype)
}
MessageDialog {
// dynamically change onclose handler
property var onCloseCallback
@ -88,209 +84,153 @@ Rectangle {
// sign / verify
ColumnLayout {
anchors.margins: 17 * scaleRatio
anchors.top: parent.top
anchors.margins: 40 * scaleRatio
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
spacing: 20 * scaleRatio
// sign
ColumnLayout {
id: signBox
anchors.left: parent.left
anchors.right: parent.right
spacing: 20 * scaleRatio
RowLayout {
Label {
id: signTitleLabel
fontSize: 24 * scaleRatio
text: qsTr("Sign") + translationManager.emptyString
}
Text {
text: qsTr("Sign a message or file contents with your address:") + translationManager.emptyString
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: 16 * scaleRatio
font.pixelSize: 14 * scaleRatio
color: Style.defaultFontColor
}
}
Label {
id: signMessageLabel
text: qsTr("Either message:") + translationManager.emptyString
}
ColumnLayout{
id: signMessageRow
RowLayout {
id: signMessageRow
anchors.topMargin: 17
anchors.left: parent.left
anchors.right: parent.right
Layout.fillWidth: true
LineEdit {
id: signMessageLine
anchors.left: parent.left
anchors.right: signMessageButton.left
Layout.fillWidth: true
placeholderText: qsTr("Message to sign") + translationManager.emptyString;
labelText: qsTr("Message") + translationManager.emptyString;
readOnly: false
onTextChanged: signSignatureLine.text = ""
}
}
IconButton {
imageSource: "../images/copyToClipboard.png"
onClicked: {
if (signMessageLine.text.length > 0) {
clipboard.setText(signMessageLine.text)
}
}
}
}
RowLayout{
Layout.fillWidth: true
Layout.topMargin: 18
StandardButton {
id: signMessageButton
anchors.right: parent.right
text: qsTr("Sign") + translationManager.emptyString
enabled: true
enabled: signMessageLine.text !== ''
small: true
onClicked: {
var signature = appWindow.currentWallet.signMessage(signMessageLine.text, false)
signSignatureLine.text = signature
}
}
}
Label {
id: signMessageFileLabel
text: qsTr("Or file:") + translationManager.emptyString
}
ColumnLayout {
id: signFileRow
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;
labelText: "Message from file"
placeholderText: qsTr("Path to file") + translationManager.emptyString;
readOnly: false
Layout.fillWidth: true
onTextChanged: signSignatureLine.text = ""
}
}
IconButton {
imageSource: "../images/copyToClipboard.png"
RowLayout {
Layout.fillWidth: true
Layout.topMargin: 18
StandardButton {
id: loadFileToSignButton
small: true
text: qsTr("Browse") + translationManager.emptyString
enabled: true
onClicked: {
if (signFileLine.text.length > 0) {
clipboard.setText(signFileLine.text)
}
}
signFileDialog.open();
}
}
StandardButton {
id: signFileButton
anchors.right: parent.right
small: true
anchors.left: loadFileToSignButton.right
anchors.leftMargin: 20
text: qsTr("Sign") + translationManager.emptyString
enabled: true
enabled: signFileLine.text !== ''
onClicked: {
var signature = appWindow.currentWallet.signMessage(signFileLine.text, true)
signSignatureLine.text = signature
var signature = appWindow.currentWallet.signMessage(signFileLine.text, true);
signSignatureLine.text = signature;
}
}
}
}
ColumnLayout {
id: signSignatureRow
anchors.topMargin: 17 * scaleRatio
Label {
id: signSignatureLabel
text: qsTr("Signature") + translationManager.emptyString
}
RowLayout {
LineEdit {
id: signSignatureLine
labelText: qsTr("Signature")
placeholderText: qsTr("Signature") + translationManager.emptyString;
readOnly: true
Layout.fillWidth: true
IconButton {
imageSource: "../images/copyToClipboard.png"
onClicked: {
if (signSignatureLine.text.length > 0) {
clipboard.setText(signSignatureLine.text)
copyButton: true
}
}
}
}
}
}
// 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
id: verifyTitleLabel
fontSize: 24 * scaleRatio
Layout.topMargin: 40
text: qsTr("Verify") + translationManager.emptyString
}
ColumnLayout {
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
Layout.fillWidth: true
labelText: qsTr("Verify message")
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)
}
}
}
}
RowLayout{
Layout.fillWidth: true
Layout.topMargin: 18
StandardButton {
id: verifyMessageButton
anchors.right: parent.right
small: true
text: qsTr("Verify") + translationManager.emptyString
enabled: true
onClicked: {
@ -299,59 +239,38 @@ Rectangle {
}
}
}
}
Label {
id: verifyMessageFileLabel
text: qsTr("Or file:") + translationManager.emptyString
ColumnLayout {
RowLayout {
LineEdit {
id: verifyFileLine
labelText: qsTr("Verify file")
placeholderText: qsTr("Filename with message to verify") + translationManager.emptyString;
readOnly: false
Layout.fillWidth: true
}
}
RowLayout{
id: verifyFileRow
anchors.topMargin: 17 * scaleRatio
anchors.left: parent.left
anchors.right: parent.right
FileDialog {
id: verifyFileDialog
title: qsTr("Please choose a file to verify") + translationManager.emptyString;
folder: "file://"
nameFilters: [ "*"]
onAccepted: {
verifyFileLine.text = walletManager.urlToLocalPath(verifyFileDialog.fileUrl)
}
}
Layout.fillWidth: true
Layout.topMargin: 18
StandardButton {
id: loadFileToVerifyButton
anchors.rightMargin: 17 * scaleRatio
text: qsTr("Select") + translationManager.emptyString
small: true
text: qsTr("Browse") + 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
IconButton {
imageSource: "../images/copyToClipboard.png"
onClicked: {
if (verifyFileLine.text.length > 0) {
clipboard.setText(verifyFileLine.text)
}
}
}
}
StandardButton {
id: verifyFileButton
anchors.right: parent.right
small: true
anchors.left: loadFileToVerifyButton.right
anchors.leftMargin: 20
text: qsTr("Verify") + translationManager.emptyString
enabled: true
onClicked: {
@ -360,30 +279,20 @@ Rectangle {
}
}
}
Text {
id: verifyAddressLabel
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 {
ColumnLayout {
RowLayout{
LineEditMulti {
id: verifyAddressLine
anchors.left: parent.left
anchors.right: parent.right
anchors.top: verifyAddressLabel.bottom
Layout.fillWidth: true
labelText: qsTr("Address")
addressValidation: true
anchors.topMargin: 5 * scaleRatio
placeholderText: "4..."
// validator: RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }
}
}
}
ColumnLayout {
@ -399,16 +308,31 @@ Rectangle {
id: verifySignatureLine
placeholderText: qsTr("Signature") + translationManager.emptyString;
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)
}
}
}

View file

@ -205,7 +205,7 @@ Rectangle {
LineEditMulti {
id: addressLine
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>")
+ translationManager.emptyString
labelButtonText: qsTr("Resolve") + translationManager.emptyString

View file

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