mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-10 11:52:05 +02:00
Transfer: fix Send button state not being updated properly
This commit is contained in:
parent
43f378b7d2
commit
148c1b9816
@ -51,7 +51,33 @@ Rectangle {
|
|||||||
property alias transferHeight2: advancedLayout.height
|
property alias transferHeight2: advancedLayout.height
|
||||||
property int mixin: 10 // (ring size 11)
|
property int mixin: 10 // (ring size 11)
|
||||||
property string warningContent: ""
|
property string warningContent: ""
|
||||||
property string sendButtonWarning: ""
|
property string sendButtonWarning: {
|
||||||
|
// Currently opened wallet is not view-only
|
||||||
|
if (appWindow.viewOnly) {
|
||||||
|
return qsTr("Wallet is view-only and sends are not possible. Unless key images are imported, " +
|
||||||
|
"the balance reflects only incoming but not outgoing transactions.") + translationManager.emptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
// There are sufficient unlocked funds available
|
||||||
|
if (walletManager.amountFromString(amountLine.text) > appWindow.getUnlockedBalance()) {
|
||||||
|
return qsTr("Amount is more than unlocked balance.") + translationManager.emptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addressLine.text)
|
||||||
|
{
|
||||||
|
// Address is valid
|
||||||
|
if (!TxUtils.checkAddress(addressLine.text, appWindow.persistentSettings.nettype)) {
|
||||||
|
return qsTr("Address is invalid.") + translationManager.emptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Amount is nonzero
|
||||||
|
if (!amountLine.text || parseFloat(amountLine.text) <= 0) {
|
||||||
|
return qsTr("Enter an amount.") + translationManager.emptyString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
property string startLinkText: qsTr("<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>") + translationManager.emptyString
|
property string startLinkText: qsTr("<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>") + translationManager.emptyString
|
||||||
property bool warningLongPidDescription: descriptionLine.text.match(/^[0-9a-f]{64}$/i)
|
property bool warningLongPidDescription: descriptionLine.text.match(/^[0-9a-f]{64}$/i)
|
||||||
|
|
||||||
@ -88,7 +114,6 @@ Rectangle {
|
|||||||
addressLine.text = ""
|
addressLine.text = ""
|
||||||
setPaymentId("");
|
setPaymentId("");
|
||||||
amountLine.text = ""
|
amountLine.text = ""
|
||||||
root.sendButtonWarning = ""
|
|
||||||
setDescription("");
|
setDescription("");
|
||||||
priorityDropdown.currentIndex = 0
|
priorityDropdown.currentIndex = 0
|
||||||
updatePriorityDropdown()
|
updatePriorityDropdown()
|
||||||
@ -414,9 +439,7 @@ Rectangle {
|
|||||||
rightIconInactive: "qrc:///images/rightArrowInactive.png"
|
rightIconInactive: "qrc:///images/rightArrowInactive.png"
|
||||||
Layout.topMargin: 4
|
Layout.topMargin: 4
|
||||||
text: qsTr("Send") + translationManager.emptyString
|
text: qsTr("Send") + translationManager.emptyString
|
||||||
enabled: {
|
enabled: !sendButtonWarningBox.visible && !warningContent && addressLine.text && !paymentIdWarningBox.visible
|
||||||
updateSendButton()
|
|
||||||
}
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
console.log("Transfer: paymentClicked")
|
console.log("Transfer: paymentClicked")
|
||||||
var priority = priorityModelV5.get(priorityDropdown.currentIndex).priority
|
var priority = priorityModelV5.get(priorityDropdown.currentIndex).priority
|
||||||
@ -730,49 +753,4 @@ Rectangle {
|
|||||||
if(typeof amount !== 'undefined')
|
if(typeof amount !== 'undefined')
|
||||||
amountLine.text = amount;
|
amountLine.text = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSendButton(){
|
|
||||||
// reset message
|
|
||||||
root.sendButtonWarning = "";
|
|
||||||
|
|
||||||
// Currently opened wallet is not view-only
|
|
||||||
if(appWindow.viewOnly){
|
|
||||||
root.sendButtonWarning = qsTr("Wallet is view-only and sends are not possible. Unless key images are imported, " +
|
|
||||||
"the balance reflects only incoming but not outgoing transactions.") + translationManager.emptyString;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// There are sufficient unlocked funds available
|
|
||||||
if(walletManager.amountFromString(amountLine.text) > appWindow.getUnlockedBalance()){
|
|
||||||
root.sendButtonWarning = qsTr("Amount is more than unlocked balance.") + translationManager.emptyString;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is no warning box displayed
|
|
||||||
if(root.warningContent !== ""){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addressLine.text == "") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Address is valid
|
|
||||||
if(!TxUtils.checkAddress(addressLine.text, appWindow.persistentSettings.nettype)){
|
|
||||||
root.sendButtonWarning = qsTr("Address is invalid.") + translationManager.emptyString;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Amount is nonzero
|
|
||||||
if (!amountLine.text || parseFloat(amountLine.text) <= 0) {
|
|
||||||
root.sendButtonWarning = qsTr("Enter an amount.") + translationManager.emptyString;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paymentIdWarningBox.visible) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user