Transfer: display estimated amount when clicking "Send all" button

This commit is contained in:
rating89us 2021-07-27 19:43:13 +02:00 committed by rating89us
parent 51828babbb
commit f06e002ef7
3 changed files with 116 additions and 10 deletions

View File

@ -13,6 +13,7 @@ Text {
property string themeTransitionBlackColor: ""
property string themeTransitionWhiteColor: ""
property alias tooltip: tooltip.text
property alias tooltipExitAnimationDuration: tooltip.tooltipExitAnimationDuration
property alias tooltipLeft: tooltip.tooltipLeft
property alias tooltipIconVisible: tooltip.tooltipIconVisible
property alias tooltipPopup: tooltip.tooltipPopup

View File

@ -39,6 +39,7 @@ Rectangle {
property bool tooltipIconVisible: false
property bool tooltipLeft: false
property bool tooltipBottom: tooltipIconVisible ? false : true
property int tooltipExitAnimationDuration: 150
color: "transparent"
height: tooltipIconVisible ? icon.height : parent.height
@ -90,7 +91,7 @@ Rectangle {
}
exit: Transition {
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 150 }
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: tooltipExitAnimationDuration }
}
delay: 200

View File

@ -53,6 +53,7 @@ Rectangle {
property alias transferHeight2: advancedLayout.height
property int mixin: 10 // (ring size 11)
property string warningContent: ""
property bool isSendAll: false
property string sendButtonWarning: {
// Currently opened wallet is not view-only
if (appWindow.viewOnly) {
@ -334,13 +335,17 @@ Rectangle {
}
MoneroComponents.InlineButton {
enabled: root.warningContent == ""
fontFamily: FontAwesome.fontFamilySolid
fontStyleName: "Solid"
fontPixelSize: 16
text: FontAwesome.infinity
visible: recipientModel.count == 1
tooltip: qsTr("Send all unlocked balance of this account") + translationManager.emptyString
onClicked: recipientRepeater.itemAt(0).children[1].children[2].text = "(all)";
onClicked: {
root.isSendAll = true;
recipientRepeater.itemAt(0).children[1].children[3].text = "(all)";
}
}
Item {
@ -374,8 +379,8 @@ Rectangle {
spacing: 0
MoneroComponents.LineEditMulti {
KeyNavigation.backtab: index > 0 ? recipientRepeater.itemAt(index - 1).children[1].children[2] : sendButton
KeyNavigation.tab: parent.children[2]
KeyNavigation.backtab: index > 0 ? recipientRepeater.itemAt(index - 1).children[1].children[3] : sendButton
KeyNavigation.tab: parent.children[3]
Layout.alignment: Qt.AlignVCenter
Layout.topMargin: index > 0 ? 0 : 1
Layout.bottomMargin: 2
@ -460,12 +465,103 @@ Rectangle {
Layout.topMargin: index > 0 ? 0 : 1
Layout.bottomMargin: 1
Layout.leftMargin: recipientLayout.colSpacing / 2 - width
Layout.rightMargin: recipientLayout.colSpacing / 2
Layout.rightMargin: amountAll.visible ? 0 : recipientLayout.colSpacing / 2
color: MoneroComponents.Style.inputBorderColorInActive
width: 1
}
Rectangle {
id: amountAll
Layout.fillHeight: true
Layout.minimumHeight: 40
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
Layout.topMargin: 1
Layout.bottomMargin: 1
Layout.rightMargin: -4
Layout.preferredWidth: 139
Layout.maximumWidth: 139
color: MoneroComponents.Style.buttonInlineBackgroundColor
visible: index == 0 && recipientModel.get(0).amount == "(all)"
border.color: "transparent"
border.width: 0
onVisibleChanged: {
if (index == 0 && amountAll.visible) {
root.isSendAll = true;
} else if (index == 0 && !amountAll.visible) {
root.isSendAll = false;
}
}
RowLayout {
id: rowAmountAll
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.rightMargin: 4
anchors.right: parent.right
spacing: 8
MoneroComponents.TextPlain {
id: amountEstimate
Layout.leftMargin: 4
font.family: feeLabel.estimatedFee ? MoneroComponents.Style.fontMonoRegular.name : MoneroComponents.Style.fontRegular.name
font.pixelSize: 14
color: MoneroComponents.Style.inlineButtonTextColor
text: {
if (!feeLabel.estimatedFee) {
return qsTr("Estimating") + "..." + translationManager.emptyString;
} else {
return "~" + (leftPanel.balanceUnlockedString - feeLabel.estimatedFee).toFixed(10);
}
}
visible: index == 0 && recipientModel.get(0).amount == "(all)"
tooltip: qsTr("Estimated amount") + translationManager.emptyString;
MouseArea {
anchors.fill: parent
cursorShape: Qt.IBeamCursor
hoverEnabled: true
onEntered: parent.tooltipPopup.open()
onExited: parent.tooltipPopup.close()
onClicked: {
parent.tooltipPopup.close()
amountField.text = "";
root.isSendAll = false;
}
}
}
MoneroComponents.TextPlain {
Layout.alignment: Qt.AlignRight
Layout.rightMargin: 6
font.family: FontAwesome.fontFamily
font.bold: true
color: MoneroComponents.Style.defaultFontColor
text: FontAwesome.times
opacity: cleanSendAllAmountMouseArea.containsMouse ? 1 : 0.85
tooltip: qsTr("Clean amount") + translationManager.emptyString
tooltipExitAnimationDuration: 0
MouseArea {
id: cleanSendAllAmountMouseArea
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onEntered: parent.tooltipPopup.open()
onExited: parent.tooltipPopup.close()
onClicked: {
parent.tooltipPopup.close()
amountField.text = "";
root.isSendAll = false;
}
}
}
}
}
MoneroComponents.LineEdit {
id: amountField
visible: !amountEstimate.visible
KeyNavigation.backtab: parent.children[0]
KeyNavigation.tab: index + 1 < recipientRepeater.count ? recipientRepeater.itemAt(index + 1).children[1].children[0] : sendButton
Layout.alignment: Qt.AlignVCenter
@ -598,7 +694,7 @@ Rectangle {
Layout.topMargin: recipientModel.count > 1 ? 0 : -1
Layout.maximumWidth: recipientLayout.secondRowWidth
borderDisabled: true
fontFamily: MoneroComponents.Style.fontMonoRegular.name
fontFamily: root.isSendAll && !feeLabel.estimatedFee ? MoneroComponents.Style.fontRegular.name : MoneroComponents.Style.fontMonoRegular.name
fontSize: 14
inputHeight: 30
inputPaddingLeft: 0
@ -628,7 +724,7 @@ Rectangle {
Layout.topMargin: recipientModel.count > 1 ? 0 : -1
Layout.maximumWidth: recipientLayout.secondRowWidth
borderDisabled: true
fontFamily: MoneroComponents.Style.fontMonoRegular.name
fontFamily: root.isSendAll && !feeLabel.estimatedFee ? MoneroComponents.Style.fontRegular.name : MoneroComponents.Style.fontMonoRegular.name
fontSize: 14
inputHeight: 30
inputPaddingLeft: 0
@ -637,7 +733,15 @@ Rectangle {
inputPaddingBottom: 0
opacity: 0.7
readOnly: true
text: fiatApiConvertToFiat(walletManager.displayAmount(recipientModel.getAmountTotal()))
text: {
if (root.isSendAll && !feeLabel.estimatedFee) {
return qsTr("Estimating") + "..." + translationManager.emptyString;
} else if (root.isSendAll && feeLabel.estimatedFee) {
return "~" + fiatApiConvertToFiat(leftPanel.balanceUnlockedString - feeLabel.estimatedFee);
} else {
return fiatApiConvertToFiat(walletManager.displayAmount(recipientModel.getAmountTotal()));
}
}
visible: persistentSettings.fiatPriceEnabled
}
@ -726,7 +830,7 @@ Rectangle {
property var fee: {
estimatedFee = null;
estimating = sendButton.enabled;
if (!sendButton.enabled || !currentWallet) {
if (!currentWallet) {
return;
}
var addresses = [];
@ -748,7 +852,7 @@ Rectangle {
});
}
text: {
if (!sendButton.enabled || estimatedFee == null) {
if (estimatedFee == null) {
return ""
}
return "~%1 XMR%2 %3".arg(estimatedFee)