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,209 +84,153 @@ 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
anchors.right: parent.right
spacing: 20 * scaleRatio
RowLayout { Label {
id: signTitleLabel
fontSize: 24 * scaleRatio
text: qsTr("Sign") + translationManager.emptyString
}
Text { 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 wrapMode: Text.Wrap
Layout.fillWidth: true Layout.fillWidth: true
font.family: Style.fontRegular font.family: Style.fontRegular
font.pixelSize: 16 * scaleRatio font.pixelSize: 14 * scaleRatio
color: Style.defaultFontColor color: Style.defaultFontColor
} }
}
Label { ColumnLayout{
id: signMessageLabel id: signMessageRow
text: qsTr("Either message:") + translationManager.emptyString
}
RowLayout { RowLayout {
id: signMessageRow Layout.fillWidth: true
anchors.topMargin: 17
anchors.left: parent.left
anchors.right: parent.right
LineEdit { LineEdit {
id: signMessageLine id: signMessageLine
anchors.left: parent.left Layout.fillWidth: true
anchors.right: signMessageButton.left
placeholderText: qsTr("Message to sign") + translationManager.emptyString; placeholderText: qsTr("Message to sign") + translationManager.emptyString;
labelText: qsTr("Message") + translationManager.emptyString;
readOnly: false readOnly: false
onTextChanged: signSignatureLine.text = "" onTextChanged: signSignatureLine.text = ""
}
}
IconButton { RowLayout{
imageSource: "../images/copyToClipboard.png" Layout.fillWidth: true
onClicked: { Layout.topMargin: 18
if (signMessageLine.text.length > 0) {
clipboard.setText(signMessageLine.text)
}
}
}
}
StandardButton { StandardButton {
id: signMessageButton id: signMessageButton
anchors.right: parent.right
text: qsTr("Sign") + translationManager.emptyString text: qsTr("Sign") + translationManager.emptyString
enabled: true enabled: signMessageLine.text !== ''
small: true
onClicked: { onClicked: {
var signature = appWindow.currentWallet.signMessage(signMessageLine.text, false) var signature = appWindow.currentWallet.signMessage(signMessageLine.text, false)
signSignatureLine.text = signature signSignatureLine.text = signature
} }
} }
} }
Label {
id: signMessageFileLabel
text: qsTr("Or file:") + translationManager.emptyString
} }
ColumnLayout {
id: signFileRow
RowLayout { 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 { LineEdit {
id: signFileLine id: signFileLine
anchors.left: loadFileToSignButton.right labelText: "Message from file"
anchors.right: signFileButton.left placeholderText: qsTr("Path to file") + translationManager.emptyString;
placeholderText: qsTr("Filename with message to sign") + translationManager.emptyString;
readOnly: false readOnly: false
Layout.fillWidth: true Layout.fillWidth: true
onTextChanged: signSignatureLine.text = "" onTextChanged: signSignatureLine.text = ""
}
}
IconButton { RowLayout {
imageSource: "../images/copyToClipboard.png" Layout.fillWidth: true
Layout.topMargin: 18
StandardButton {
id: loadFileToSignButton
small: true
text: qsTr("Browse") + translationManager.emptyString
enabled: true
onClicked: { onClicked: {
if (signFileLine.text.length > 0) { signFileDialog.open();
clipboard.setText(signFileLine.text)
}
}
} }
} }
StandardButton { StandardButton {
id: signFileButton id: signFileButton
anchors.right: parent.right small: true
anchors.left: loadFileToSignButton.right
anchors.leftMargin: 20
text: qsTr("Sign") + translationManager.emptyString text: qsTr("Sign") + translationManager.emptyString
enabled: true enabled: signFileLine.text !== ''
onClicked: { onClicked: {
var signature = appWindow.currentWallet.signMessage(signFileLine.text, true) var signature = appWindow.currentWallet.signMessage(signFileLine.text, true);
signSignatureLine.text = signature signSignatureLine.text = signature;
} }
} }
} }
}
ColumnLayout { ColumnLayout {
id: signSignatureRow id: signSignatureRow
anchors.topMargin: 17 * scaleRatio
Label {
id: signSignatureLabel
text: qsTr("Signature") + translationManager.emptyString
}
RowLayout {
LineEdit { LineEdit {
id: signSignatureLine id: signSignatureLine
labelText: qsTr("Signature")
placeholderText: qsTr("Signature") + translationManager.emptyString; placeholderText: qsTr("Signature") + translationManager.emptyString;
readOnly: true readOnly: true
Layout.fillWidth: true Layout.fillWidth: true
copyButton: 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 { Label {
id: verifyMessageLabel id: verifyTitleLabel
text: qsTr("Either message:") + translationManager.emptyString fontSize: 24 * scaleRatio
Layout.topMargin: 40
text: qsTr("Verify") + translationManager.emptyString
} }
ColumnLayout {
RowLayout { RowLayout {
id: verifyMessageRow id: verifyMessageRow
anchors.topMargin: 17 * scaleRatio
anchors.left: parent.left
anchors.right: parent.right
LineEdit { LineEdit {
id: verifyMessageLine id: verifyMessageLine
anchors.left: parent.left Layout.fillWidth: true
anchors.right: verifyMessageButton.left labelText: qsTr("Verify message")
placeholderText: qsTr("Message to verify") + translationManager.emptyString; placeholderText: qsTr("Message to verify") + translationManager.emptyString;
readOnly: false readOnly: false
Layout.fillWidth: true }
}
IconButton { RowLayout{
imageSource: "../images/copyToClipboard.png" Layout.fillWidth: true
onClicked: { Layout.topMargin: 18
if (verifyMessageLine.text.length > 0) {
clipboard.setText(verifyMessageLine.text)
}
}
}
}
StandardButton { StandardButton {
id: verifyMessageButton id: verifyMessageButton
anchors.right: parent.right small: true
text: qsTr("Verify") + translationManager.emptyString text: qsTr("Verify") + translationManager.emptyString
enabled: true enabled: true
onClicked: { onClicked: {
@ -299,59 +239,38 @@ Rectangle {
} }
} }
} }
}
Label { ColumnLayout {
id: verifyMessageFileLabel RowLayout {
text: qsTr("Or file:") + translationManager.emptyString LineEdit {
id: verifyFileLine
labelText: qsTr("Verify file")
placeholderText: qsTr("Filename with message to verify") + translationManager.emptyString;
readOnly: false
Layout.fillWidth: true
}
} }
RowLayout{ RowLayout{
id: verifyFileRow Layout.fillWidth: true
anchors.topMargin: 17 * scaleRatio Layout.topMargin: 18
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)
}
}
StandardButton { StandardButton {
id: loadFileToVerifyButton id: loadFileToVerifyButton
anchors.rightMargin: 17 * scaleRatio small: true
text: qsTr("Select") + translationManager.emptyString text: qsTr("Browse") + translationManager.emptyString
enabled: true enabled: true
onClicked: { onClicked: {
verifyFileDialog.open() 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 { StandardButton {
id: verifyFileButton id: verifyFileButton
anchors.right: parent.right small: true
anchors.left: loadFileToVerifyButton.right
anchors.leftMargin: 20
text: qsTr("Verify") + translationManager.emptyString text: qsTr("Verify") + translationManager.emptyString
enabled: true enabled: true
onClicked: { 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 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,16 +308,31 @@ 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" FileDialog {
onClicked: { id: signFileDialog
if (verifySignatureLine.text.length > 0) { title: qsTr("Please choose a file to sign") + translationManager.emptyString;
clipboard.setText(verifySignatureLine.text) 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 { 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 {