Transfer: hide advanced options

This commit is contained in:
Jaquee 2017-02-27 22:05:28 +01:00
parent 573b284017
commit 30f87a1019
2 changed files with 309 additions and 297 deletions

View file

@ -829,6 +829,7 @@ ApplicationWindow {
property string logCategories: "" property string logCategories: ""
property string daemonUsername: "" property string daemonUsername: ""
property string daemonPassword: "" property string daemonPassword: ""
property bool transferShowAdvanced: false
} }
// Information dialog // Information dialog

View file

@ -42,6 +42,7 @@ Rectangle {
color: "#F0EEEE" color: "#F0EEEE"
property string startLinkText: "<style type='text/css'>a {text-decoration: none; color: #FF6C3C; font-size: 14px;}</style><font size='2'> (</font><a href='#'>Start daemon</a><font size='2'>)</font>" property string startLinkText: "<style type='text/css'>a {text-decoration: none; color: #FF6C3C; font-size: 14px;}</style><font size='2'> (</font><a href='#'>Start daemon</a><font size='2'>)</font>"
property bool showAdvanced: false
function scaleValueToMixinCount(scaleValue) { function scaleValueToMixinCount(scaleValue) {
var scaleToMixinCount = [4,5,6,7,8,9,10,11,12,13,14,15,20,25]; var scaleToMixinCount = [4,5,6,7,8,9,10,11,12,13,14,15,20,25];
@ -111,328 +112,293 @@ Rectangle {
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height:550 height: 400
Label {
id: amountLabel
anchors.left: parent.left
anchors.top: parent.top
anchors.leftMargin: 17
anchors.rightMargin: 17
anchors.topMargin: 17
text: qsTr("Amount") + translationManager.emptyString
fontSize: 14
}
Label { Label {
id: transactionPriority id: amountLabel
anchors.top: parent.top anchors.left: parent.left
anchors.topMargin: 17 anchors.top: parent.top
fontSize: 14 anchors.leftMargin: 17
x: (parent.width - 17) / 2 + 17 anchors.rightMargin: 17
text: qsTr("Transaction priority") + translationManager.emptyString anchors.topMargin: 17
} text: qsTr("Amount") + translationManager.emptyString
fontSize: 14
}
Row { Label {
id: amountRow id: transactionPriority
anchors.top: amountLabel.bottom anchors.top: parent.top
anchors.topMargin: 5 anchors.topMargin: 17
anchors.left: parent.left fontSize: 14
anchors.leftMargin: 7 x: (parent.width - 17) / 2 + 17
width: (parent.width - 17) / 2 + 10 text: qsTr("Transaction priority") + translationManager.emptyString
Item { }
width: 37
height: 37
Image {
anchors.centerIn: parent
source: "../images/moneroIcon.png"
}
}
// Amount input
LineEdit {
id: amountLine
placeholderText: qsTr("") + translationManager.emptyString
width: parent.width - 37 - 17 - 60
validator: DoubleValidator {
bottom: 0.0
top: 18446744.073709551615
decimals: 12
notation: DoubleValidator.StandardNotation
locale: "C"
}
}
StandardButton { Row {
id: amountAllButton id: amountRow
//anchors.left: amountLine.right anchors.top: amountLabel.bottom
//anchors.top: amountLine.top anchors.topMargin: 5
//anchors.bottom: amountLine.bottom anchors.left: parent.left
width: 60 anchors.leftMargin: 7
text: qsTr("All") + translationManager.emptyString width: (parent.width - 17) / 2 + 10
shadowReleasedColor: "#FF4304" Item {
shadowPressedColor: "#B32D00" width: 37
releasedColor: "#FF6C3C" height: 37
pressedColor: "#FF4304"
enabled : true
onClicked: amountLine.text = "(all)"
}
}
ListModel { Image {
id: priorityModel anchors.centerIn: parent
// ListElement: cannot use script for property value, so source: "../images/moneroIcon.png"
// code like this wont work: }
// ListElement { column1: qsTr("Low") + translationManager.emptyString ; column2: ""; priority: PendingTransaction.Priority_Low } }
// Amount input
LineEdit {
id: amountLine
placeholderText: qsTr("") + translationManager.emptyString
width: parent.width - 37 - 17 - 60
validator: DoubleValidator {
bottom: 0.0
top: 18446744.073709551615
decimals: 12
notation: DoubleValidator.StandardNotation
locale: "C"
}
}
ListElement { column1: qsTr("Low (x1 fee)") ; column2: ""; priority: PendingTransaction.Priority_Low } StandardButton {
ListElement { column1: qsTr("Medium (x20 fee)") ; column2: ""; priority: PendingTransaction.Priority_Medium } id: amountAllButton
ListElement { column1: qsTr("High (x166 fee)") ; column2: ""; priority: PendingTransaction.Priority_High } //anchors.left: amountLine.right
} //anchors.top: amountLine.top
//anchors.bottom: amountLine.bottom
StandardDropdown { width: 60
id: priorityDropdown text: qsTr("all") + translationManager.emptyString
anchors.top: transactionPriority.bottom shadowReleasedColor: "#FF4304"
anchors.right: parent.right shadowPressedColor: "#B32D00"
anchors.rightMargin: 17 releasedColor: "#FF6C3C"
anchors.topMargin: 5 pressedColor: "#FF4304"
anchors.left: transactionPriority.left enabled : true
shadowReleasedColor: "#FF4304" onClicked: amountLine.text = "(all)"
shadowPressedColor: "#B32D00" }
releasedColor: "#FF6C3C" }
pressedColor: "#FF4304"
dataModel: priorityModel
z: 1
}
Label { ListModel {
id: privacyLabel id: priorityModel
anchors.left: parent.left // ListElement: cannot use script for property value, so
anchors.right: parent.right // code like this wont work:
anchors.top: amountRow.bottom // ListElement { column1: qsTr("LOW") + translationManager.emptyString ; column2: ""; priority: PendingTransaction.Priority_Low }
anchors.leftMargin: 17
anchors.rightMargin: 17
anchors.topMargin: 30
fontSize: 14
text: ""
}
PrivacyLevel { ListElement { column1: qsTr("Low (x1 fee)") ; column2: ""; priority: PendingTransaction.Priority_Low }
id: privacyLevelItem ListElement { column1: qsTr("Medium (x20 fee)") ; column2: ""; priority: PendingTransaction.Priority_Medium }
anchors.left: parent.left ListElement { column1: qsTr("High (x166 fee)") ; column2: ""; priority: PendingTransaction.Priority_High }
anchors.right: parent.right }
anchors.top: privacyLabel.bottom
anchors.leftMargin: 17
anchors.rightMargin: 17
anchors.topMargin: 5
onFillLevelChanged: updateMixin()
}
StandardDropdown {
id: priorityDropdown
anchors.top: transactionPriority.bottom
anchors.right: parent.right
anchors.rightMargin: 17
anchors.topMargin: 5
anchors.left: transactionPriority.left
shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
dataModel: priorityModel
z: 1
}
Label { Label {
id: costLabel id: addressLabel
anchors.right: parent.right anchors.left: parent.left
anchors.top: amountRow.bottom anchors.right: parent.right
anchors.leftMargin: 17 anchors.top: amountRow.bottom
anchors.rightMargin: 17 anchors.leftMargin: 17
anchors.topMargin: 30 anchors.rightMargin: 17
fontSize: 14 anchors.topMargin: 30
text: qsTr("Transaction cost") fontSize: 14
} textFormat: Text.RichText
text: qsTr("<style type='text/css'>a {text-decoration: none; color: #FF6C3C; font-size: 14px;}</style>\
Address <font size='2'> ( Paste in or select from </font> <a href='#'>Address book</a><font size='2'> )</font>")
+ translationManager.emptyString
onLinkActivated: appWindow.showPageRequest("AddressBook")
}
// recipient address input
RowLayout {
id: addressLineRow
anchors.left: parent.left
anchors.right: parent.right
anchors.top: addressLabel.bottom
Label { StandardButton {
id: addressLabel id: qrfinderButton
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.leftMargin: 17
anchors.top: privacyLevelItem.bottom anchors.topMargin: 5
anchors.leftMargin: 17 text: qsTr("QR Code") + translationManager.emptyString
anchors.rightMargin: 17 shadowReleasedColor: "#FF4304"
anchors.topMargin: 30 shadowPressedColor: "#B32D00"
fontSize: 14 releasedColor: "#FF6C3C"
textFormat: Text.RichText pressedColor: "#FF4304"
text: qsTr("<style type='text/css'>a {text-decoration: none; color: #FF6C3C; font-size: 14px;}</style>\ visible : appWindow.qrScannerEnabled
Address <font size='2'> ( Paste in or select from </font> <a href='#'>Address book</a><font size='2'> )</font>") enabled : visible
+ translationManager.emptyString width: visible ? 60 : 0
onClicked: {
cameraUi.state = "Capture"
cameraUi.qrcode_decoded.connect(updateFromQrCode)
}
}
LineEdit {
id: addressLine
anchors.left: qrfinderButton.right
anchors.right: resolveButton.left
//anchors.leftMargin: 17
anchors.topMargin: 5
placeholderText: "4..."
// validator: RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }
}
onLinkActivated: appWindow.showPageRequest("AddressBook") StandardButton {
} id: resolveButton
// recipient address input anchors.right: parent.right
RowLayout { anchors.leftMargin: 17
id: addressLineRow anchors.topMargin: 17
anchors.left: parent.left anchors.rightMargin: 17
anchors.right: parent.right width: 60
anchors.top: addressLabel.bottom text: qsTr("Resolve") + translationManager.emptyString
shadowReleasedColor: "#FF4304"
StandardButton { shadowPressedColor: "#B32D00"
id: qrfinderButton releasedColor: "#FF6C3C"
anchors.left: parent.left pressedColor: "#FF4304"
anchors.leftMargin: 17 enabled : isValidOpenAliasAddress(addressLine.text)
anchors.topMargin: 5 onClicked: {
text: qsTr("QRCODE") + translationManager.emptyString var result = walletManager.resolveOpenAlias(addressLine.text)
shadowReleasedColor: "#FF4304" if (result) {
shadowPressedColor: "#B32D00" var parts = result.split("|")
releasedColor: "#FF6C3C" if (parts.length == 2) {
pressedColor: "#FF4304" var address_ok = walletManager.addressValid(parts[1], appWindow.persistentSettings.testnet)
visible : appWindow.qrScannerEnabled if (parts[0] === "true") {
enabled : visible if (address_ok) {
width: visible ? 60 : 0 addressLine.text = parts[1]
onClicked: { addressLine.cursorPosition = 0
cameraUi.state = "Capture" }
cameraUi.qrcode_decoded.connect(updateFromQrCode) else
} oa_message(qsTr("No valid address found at this OpenAlias address"))
} } else if (parts[0] === "false") {
LineEdit { if (address_ok) {
id: addressLine addressLine.text = parts[1]
anchors.left: qrfinderButton.right addressLine.cursorPosition = 0
anchors.right: resolveButton.left oa_message(qsTr("Address found, but the DNSSEC signatures could not be verified, so this address may be spoofed"))
//anchors.leftMargin: 17 } else {
anchors.topMargin: 5 oa_message(qsTr("No valid address found at this OpenAlias address, but the DNSSEC signatures could not be verified, so this may be spoofed"))
placeholderText: "4..." }
// validator: RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }
}
StandardButton {
id: resolveButton
anchors.right: parent.right
anchors.leftMargin: 17
anchors.topMargin: 17
anchors.rightMargin: 17
width: 60
text: qsTr("Resolve") + translationManager.emptyString
shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C"
pressedColor: "#FF4304"
enabled : isValidOpenAliasAddress(addressLine.text)
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.testnet)
if (parts[0] === "true") {
if (address_ok) {
addressLine.text = parts[1]
addressLine.cursorPosition = 0
}
else
oa_message(qsTr("No valid address found at this OpenAlias address"))
} else if (parts[0] === "false") {
if (address_ok) {
addressLine.text = parts[1]
addressLine.cursorPosition = 0
oa_message(qsTr("Address found, but the DNSSEC signatures could not be verified, so this address may be spoofed"))
} else { } 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")) oa_message(qsTr("Internal error"))
} }
} else { } else {
oa_message(qsTr("Internal error")) oa_message(qsTr("Internal error"))
} }
} else { } else {
oa_message(qsTr("Internal error")) oa_message(qsTr("No address found"))
} }
} else { }
oa_message(qsTr("No address found")) }
} }
}
}
}
Label { Label {
id: paymentIdLabel id: paymentIdLabel
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: addressLineRow.bottom anchors.top: addressLineRow.bottom
anchors.leftMargin: 17 anchors.leftMargin: 17
anchors.rightMargin: 17 anchors.rightMargin: 17
anchors.topMargin: 17 anchors.topMargin: 17
fontSize: 14 fontSize: 14
text: qsTr("Payment ID <font size='2'>( Optional )</font>") + translationManager.emptyString text: qsTr("Payment ID <font size='2'>( Optional )</font>") + translationManager.emptyString
} }
// payment id input // payment id input
LineEdit { LineEdit {
id: paymentIdLine id: paymentIdLine
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: paymentIdLabel.bottom anchors.top: paymentIdLabel.bottom
anchors.leftMargin: 17 anchors.leftMargin: 17
anchors.rightMargin: 17 anchors.rightMargin: 17
anchors.topMargin: 5 anchors.topMargin: 5
placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString
// validator: DoubleValidator { top: 0.0 } // validator: DoubleValidator { top: 0.0 }
} }
Label { Label {
id: descriptionLabel id: descriptionLabel
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: paymentIdLine.bottom anchors.top: paymentIdLine.bottom
anchors.leftMargin: 17 anchors.leftMargin: 17
anchors.rightMargin: 17 anchors.rightMargin: 17
anchors.topMargin: 17 anchors.topMargin: 17
fontSize: 14 fontSize: 14
text: qsTr("Description <font size='2'>( Optional )</font>") text: qsTr("Description <font size='2'>( Optional )</font>")
+ translationManager.emptyString + translationManager.emptyString
} }
LineEdit { LineEdit {
id: descriptionLine id: descriptionLine
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: descriptionLabel.bottom anchors.top: descriptionLabel.bottom
anchors.leftMargin: 17 anchors.leftMargin: 17
anchors.rightMargin: 17 anchors.rightMargin: 17
anchors.topMargin: 5 anchors.topMargin: 5
placeholderText: qsTr("Saved to local wallet history") + translationManager.emptyString placeholderText: qsTr("Saved to local wallet history") + translationManager.emptyString
} }
function checkInformation(amount, address, payment_id, testnet) { function checkInformation(amount, address, payment_id, testnet) {
address = address.trim() address = address.trim()
payment_id = payment_id.trim() payment_id = payment_id.trim()
var amount_ok = amount.length > 0 var amount_ok = amount.length > 0
var address_ok = walletManager.addressValid(address, testnet) var address_ok = walletManager.addressValid(address, testnet)
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, testnet) var ipid = walletManager.paymentIdFromAddress(address, testnet)
if (ipid.length > 0 && payment_id.length > 0) if (ipid.length > 0 && payment_id.length > 0)
payment_id_ok = false payment_id_ok = false
addressLine.error = !address_ok addressLine.error = !address_ok
amountLine.error = !amount_ok amountLine.error = !amount_ok
paymentIdLine.error = !payment_id_ok paymentIdLine.error = !payment_id_ok
return amount_ok && address_ok && payment_id_ok return amount_ok && address_ok && payment_id_ok
} }
StandardButton { StandardButton {
id: sendButton id: sendButton
anchors.left: parent.left anchors.left: parent.left
anchors.top: descriptionLine.bottom anchors.top: descriptionLine.bottom
anchors.leftMargin: 17 anchors.leftMargin: 17
anchors.topMargin: 17 anchors.topMargin: 17
width: 60 width: 60
text: qsTr("Send") + translationManager.emptyString text: qsTr("Send") + translationManager.emptyString
shadowReleasedColor: "#FF4304" shadowReleasedColor: "#FF4304"
shadowPressedColor: "#B32D00" shadowPressedColor: "#B32D00"
releasedColor: "#FF6C3C" releasedColor: "#FF6C3C"
pressedColor: "#FF4304" pressedColor: "#FF4304"
enabled : !appWindow.viewOnly && pageRoot.checkInformation(amountLine.text, addressLine.text, paymentIdLine.text, appWindow.persistentSettings.testnet) enabled : !appWindow.viewOnly && pageRoot.checkInformation(amountLine.text, addressLine.text, paymentIdLine.text, appWindow.persistentSettings.testnet)
onClicked: { onClicked: {
console.log("Transfer: paymentClicked") console.log("Transfer: paymentClicked")
var priority = priorityModel.get(priorityDropdown.currentIndex).priority var priority = priorityModel.get(priorityDropdown.currentIndex).priority
console.log("priority: " + priority) console.log("priority: " + priority)
console.log("amount: " + amountLine.text) console.log("amount: " + amountLine.text)
addressLine.text = addressLine.text.trim() addressLine.text = addressLine.text.trim()
paymentIdLine.text = paymentIdLine.text.trim() paymentIdLine.text = paymentIdLine.text.trim()
root.paymentClicked(addressLine.text, paymentIdLine.text, amountLine.text, scaleValueToMixinCount(privacyLevelItem.fillLevel), root.paymentClicked(addressLine.text, paymentIdLine.text, amountLine.text, scaleValueToMixinCount(privacyLevelItem.fillLevel),
priority, descriptionLine.text) priority, descriptionLine.text)
}
}
}
}
} // pageRoot } // pageRoot
Rectangle { Rectangle {
@ -452,23 +418,68 @@ Rectangle {
enabled: !viewOnly || pageRoot.enabled enabled: !viewOnly || pageRoot.enabled
RowLayout { RowLayout {
Label { // Label {
id: manageWalletLabel // id: manageWalletLabel
Layout.fillWidth: true // Layout.fillWidth: true
color: "#4A4949" // color: "#4A4949"
text: qsTr("Advanced") + translationManager.emptyString // text: qsTr("Advanced options") + translationManager.emptyString
fontSize: 16 // fontSize: 16
Layout.topMargin: 20 // Layout.topMargin: 20
// }
CheckBox {
id: showAdvancedCheckbox
checked: persistentSettings.transferShowAdvanced
onClicked: {
persistentSettings.transferShowAdvanced = !persistentSettings.transferShowAdvanced
}
text: qsTr("Show advanced options") + translationManager.emptyString
checkedIcon: "../images/checkedVioletIcon.png"
uncheckedIcon: "../images/uncheckedIcon.png"
} }
} }
Rectangle { Rectangle {
visible: persistentSettings.transferShowAdvanced
Layout.fillWidth: true Layout.fillWidth: true
height: 1 height: 1
color: "#DEDEDE" color: "#DEDEDE"
Layout.bottomMargin: 30
} }
RowLayout { RowLayout {
visible: persistentSettings.transferShowAdvanced
anchors.left: parent.left
anchors.right: parent.right
Label {
id: privacyLabel
fontSize: 14
text: ""
}
Label {
id: costLabel
fontSize: 14
text: qsTr("Transaction cost")
anchors.right: parent.right
}
}
PrivacyLevel {
visible: persistentSettings.transferShowAdvanced
id: privacyLevelItem
anchors.left: parent.left
anchors.right: parent.right
onFillLevelChanged: updateMixin()
}
RowLayout {
visible: persistentSettings.transferShowAdvanced
Layout.topMargin: 50
StandardButton { StandardButton {
id: sweepUnmixableButton id: sweepUnmixableButton
text: qsTr("Sweep Unmixable") + translationManager.emptyString text: qsTr("Sweep Unmixable") + translationManager.emptyString