Check the 'to receive amount' with the transaction tracker

This commit is contained in:
Sander Ferdinand 2018-04-28 02:54:12 +02:00
parent 9018ae3afe
commit dc1d5e9e0a

View File

@ -48,13 +48,14 @@ Rectangle {
property var model property var model
property var current_address property var current_address
property int current_subaddress_table_index: 0 property int current_subaddress_table_index: 0
property alias receiveHeight: mainLayout.height
property alias addressText : pageReceive.current_address property alias addressText : pageReceive.current_address
function makeQRCodeString() { function makeQRCodeString() {
var s = "monero:" var s = "monero:"
var nfields = 0 var nfields = 0
s += current_address; s += current_address;
var amount = amountLine.text.trim() var amount = amountToReceiveLine.text.trim()
if (amount !== "") { if (amount !== "") {
s += (nfields++ ? "&" : "?") s += (nfields++ ? "&" : "?")
s += "tx_amount=" + amount s += "tx_amount=" + amount
@ -65,10 +66,12 @@ Rectangle {
function update() { function update() {
if (!appWindow.currentWallet || !trackingEnabled.checked) { if (!appWindow.currentWallet || !trackingEnabled.checked) {
trackingLineText.text = ""; trackingLineText.text = "";
trackingModel.clear();
return return
} }
if (appWindow.currentWallet.connected() == Wallet.ConnectionStatus_Disconnected) { if (appWindow.currentWallet.connected() == Wallet.ConnectionStatus_Disconnected) {
trackingLineText.text = qsTr("WARNING: no connection to daemon"); trackingLineText.text = qsTr("WARNING: no connection to daemon");
trackingModel.clear();
return return
} }
@ -121,22 +124,21 @@ Rectangle {
return return
} }
else if(nTransactions === 1){ else if(nTransactions === 1){
trackingLineText.text = qsTr("Transaction found") + translationManager.emptyString; trackingLineText.text = qsTr("Transaction found") + ":" + translationManager.emptyString;
} else { } else {
trackingLineText.text = qsTr("%1 transactions found").arg(nTransactions) + translationManager.emptyString trackingLineText.text = qsTr("%1 transactions found").arg(nTransactions) + ":" + translationManager.emptyString
} }
var max_tracking = 3; var max_tracking = 3;
toReceiveSatisfiedLine.text = "";
var expectedAmount = walletManager.amountFromString(amountLine.text) var expectedAmount = walletManager.amountFromString(amountToReceiveLine.text)
if (expectedAmount && expectedAmount != amount) { if (expectedAmount && expectedAmount != amount) {
var displayTotalAmount = walletManager.displayAmount(totalAmount) var displayTotalAmount = walletManager.displayAmount(totalAmount)
if (amount > expectedAmount) { if (amount > expectedAmount) toReceiveSatisfiedLine.text += qsTr("With more Monero");
else if (amount < expectedAmount) toReceiveSatisfiedLine.text = qsTr("With not enough Monero")
text += qsTr(" with more money (%1)").arg(displayTotalAmount) + translationManager.emptyString toReceiveSatisfiedLine.text += ": " + "<br>" +
} else if (amount < expectedAmount) { qsTr("Expected") + ": " + amountToReceiveLine.text + "<br>" +
text += qsTr(" with not enough money (%1)").arg(displayTotalAmount) + translationManager.emptyString qsTr("Total received") + ": " + displayTotalAmount + translationManager.emptyString;
}
} }
trackingModel.clear(); trackingModel.clear();
@ -434,7 +436,7 @@ Rectangle {
Layout.maximumWidth: mainLayout.qrCodeSize Layout.maximumWidth: mainLayout.qrCodeSize
LineEdit { LineEdit {
id: amountLine id: amountToReceiveLine
Layout.fillWidth: true Layout.fillWidth: true
labelText: qsTr("Amount") + translationManager.emptyString labelText: qsTr("Amount") + translationManager.emptyString
placeholderText: qsTr("Amount to receive") + translationManager.emptyString placeholderText: qsTr("Amount to receive") + translationManager.emptyString
@ -626,7 +628,6 @@ Rectangle {
} }
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 4
anchors.top: undefined anchors.top: undefined
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
@ -635,9 +636,26 @@ Rectangle {
} }
RowLayout { RowLayout {
Layout.topMargin: 32 * scaleRatio visible: trackingTableRow.visible && x.text !== "" && amountToReceiveLine.text !== ""
Layout.topMargin: 14 * scaleRatio
Layout.fillWidth: true
Layout.preferredHeight: 40 * scaleRatio
Label {
id: toReceiveSatisfiedLine
color: "white"
fontFamily: Style.fontLight.name
fontSize: 14 * scaleRatio
textFormat: Text.RichText
text: ""
height: 40 * scaleRatio
}
}
RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: 200 Layout.minimumWidth: 200
Layout.topMargin: trackingTableRow.visible ? 20 * scaleRatio : 32 * scaleRatio
CheckBox { CheckBox {
id: trackingEnabled id: trackingEnabled
@ -695,5 +713,7 @@ Rectangle {
function onPageClosed() { function onPageClosed() {
timer.running = false timer.running = false
trackingEnabled.checked = false
trackingModel.clear()
} }
} }