LeftPanel: display notification in account card when balance changes

This commit is contained in:
rating89us 2021-12-11 17:51:51 +01:00
parent bddb9b0050
commit 1742e2a394
6 changed files with 81 additions and 1 deletions

View file

@ -33,6 +33,7 @@ import moneroComponents.Wallet 1.0
import moneroComponents.NetworkType 1.0
import moneroComponents.Clipboard 1.0
import FontAwesome 1.0
import QtMultimedia 5.15
import "components" as MoneroComponents
import "components/effects/" as MoneroEffects
@ -42,6 +43,7 @@ Rectangle {
property int currentAccountIndex
property alias currentAccountLabel: accountLabel.text
property string previousBalanceString: balanceString
property string balanceString: "?.??"
property string balanceUnlockedString: "?.??"
property string balanceFiatString: "?.??"
@ -63,6 +65,30 @@ Rectangle {
signal addressBookClicked()
signal accountClicked()
onBalanceStringChanged: {
if (middlePanel.accountView.isChangingAccount) {
middlePanel.accountView.isChangingAccount = false;
return;
}
if (previousBalanceString != "?.??" && balanceString != "?.??") {
var differenceInBalance = parseFloat(balanceString) - parseFloat(previousBalanceString)
if (persistentSettings.fiatPriceEnabled && persistentSettings.fiatPriceToggle) {
differenceInBalance = fiatApiConvertToFiat(differenceInBalance);
}
newBalanceNotification.text = (differenceInBalance.toFixed(12) > 0 ? "+" : "") + differenceInBalance.toFixed(12);
newBalanceNotification.color = (differenceInBalance.toFixed(12) > 0 ? (MoneroComponents.Style.blackTheme ? "lime" : "green") : "red")
showNewBalanceNotificationAnimation.running = true;
newBalanceNotificationTimer.running = false;
hideNewBalanceNotificationAnimation.running = false;
if (differenceInBalance.toFixed(12) > 0 && persistentSettings.playSounds) incomingCoinsSound.play()
}
}
SoundEffect {
id: incomingCoinsSound
source: "media/moneybag.wav"
}
function selectItem(pos) {
menuColumn.previousButton.checked = false
if(pos === "History") menuColumn.previousButton = historyButton
@ -312,6 +338,47 @@ Rectangle {
}
}
MoneroComponents.TextPlain {
id: newBalanceNotification
opacity: 0
themeTransition: false
anchors.top: balancePart2.bottom
anchors.topMargin: -2
anchors.right: balancePart2.right
anchors.leftMargin: 0
color: balancePart1.color
font.pixelSize: 16
NumberAnimation {
id: showNewBalanceNotificationAnimation
target: newBalanceNotification
running: false
property: "opacity"
duration: 400
from: 0
to: 1
onStopped: {
newBalanceNotificationTimer.start()
}
}
Timer {
id: newBalanceNotificationTimer
interval: 2000; running: false; repeat: false
onTriggered: hideNewBalanceNotificationAnimation.running = true
}
NumberAnimation {
id: hideNewBalanceNotificationAnimation
target: newBalanceNotification
property: "opacity"
running: false
duration: 3000
from: 1
to: 0
}
}
Item { //separator
anchors.left: parent.left
anchors.right: parent.right

View file

@ -1417,6 +1417,7 @@ ApplicationWindow {
property bool autosave: true
property int autosaveMinutes: 10
property bool pruneBlockchain: false
property bool playSounds: true
property bool fiatPriceEnabled: false
property bool fiatPriceToggle: false

BIN
media/moneybag.wav Normal file

Binary file not shown.

View file

@ -51,6 +51,7 @@ Rectangle {
property alias balanceAllText: balanceAll.text
property alias unlockedBalanceAllText: unlockedBalanceAll.text
property bool selectAndSend: false
property bool isChangingAccount: false
property int currentAccountIndex
function renameSubaddressAccountLabel(_index){
@ -319,6 +320,7 @@ Rectangle {
anchors.fill: parent
hoverEnabled: true
onClicked: {
pageAccount.isChangingAccount = true;
appWindow.currentWallet.switchSubaddressAccount(index);
if (selectAndSend)
appWindow.showPageRequest("Transfer");

View file

@ -91,7 +91,16 @@ Rectangle {
MoneroComponents.Style.blackTheme = !MoneroComponents.Style.blackTheme;
}
}
MoneroComponents.CheckBox {
id: playSoundsCheckbox
checked: persistentSettings.playSounds
text: qsTr("Play sounds") + translationManager.emptyString
onClicked: {
persistentSettings.playSounds = !persistentSettings.playSounds
}
}
MoneroComponents.CheckBox {
checked: persistentSettings.askPasswordBeforeSending
text: qsTr("Ask for password before sending a transaction") + translationManager.emptyString

View file

@ -264,5 +264,6 @@
<file>images/ledgerNanoX.png</file>
<file>images/trezor.png</file>
<file>images/trezor@2x.png</file>
<file>media/moneybag.wav</file>
</qresource>
</RCC>