play sounds when a message is sent or an error occurs

This commit is contained in:
Iuri Matias 2020-06-30 16:01:37 -04:00
parent 63d9ee7201
commit 9935d349c4
16 changed files with 99 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import QtMultimedia 5.13
import "../components" import "../components"
import "../../../../shared" import "../../../../shared"
import "../../../../imports" import "../../../../imports"
@ -10,12 +11,19 @@ Rectangle {
visible: chatsModel.activeChannel.chatType != Constants.chatTypePrivateGroupChat || chatsModel.activeChannel.isMember(profileModel.profile.pubKey) visible: chatsModel.activeChannel.chatType != Constants.chatTypePrivateGroupChat || chatsModel.activeChannel.isMember(profileModel.profile.pubKey)
Audio {
id: sendMessageSound
source: "../../../../sounds/send_message.wav"
}
function onEnter(event){ function onEnter(event){
if (event.modifiers == Qt.NoModifier && (event.key == Qt.Key_Enter || event.key == Qt.Key_Return)) { if (event.modifiers == Qt.NoModifier && (event.key == Qt.Key_Enter || event.key == Qt.Key_Return)) {
if(txtData.text.trim().length > 0){ if(txtData.text.trim().length > 0){
chatsModel.sendMessage(txtData.text.trim()); chatsModel.sendMessage(txtData.text.trim());
txtData.text = ""; txtData.text = "";
event.accepted = true; event.accepted = true;
sendMessageSound.stop()
Qt.callLater(sendMessageSound.play);
} }
} }
} }

View File

@ -4,6 +4,7 @@ import QtQuick.Layouts 1.13
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import "../../../imports" import "../../../imports"
import "../../../shared" import "../../../shared"
import "../../../sounds"
ModalPopup { ModalPopup {
property var currentAccount: walletModel.currentAccount property var currentAccount: walletModel.currentAccount
@ -31,6 +32,12 @@ ModalPopup {
accountNameInput.forceActiveFocus(Qt.MouseFocusReason) accountNameInput.forceActiveFocus(Qt.MouseFocusReason)
} }
Item {
ErrorSound {
id: errorSound
}
}
Input { Input {
id: accountNameInput id: accountNameInput
placeholderText: qsTr("Enter an account name...") placeholderText: qsTr("Enter an account name...")
@ -126,6 +133,7 @@ ModalPopup {
onAccepted: { onAccepted: {
const error = walletModel.deleteAccount(currentAccount.address); const error = walletModel.deleteAccount(currentAccount.address);
if (error) { if (error) {
errorSound.play()
deleteError.text = error deleteError.text = error
deleteError.open() deleteError.open()
return return
@ -165,6 +173,7 @@ ModalPopup {
const error = walletModel.changeAccountSettings(currentAccount.address, accountNameInput.text, selectedColor); const error = walletModel.changeAccountSettings(currentAccount.address, accountNameInput.text, selectedColor);
if (error) { if (error) {
errorSound.play()
changeError.text = error changeError.text = error
changeError.open() changeError.open()
return return

View File

@ -3,6 +3,7 @@ import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import "../../../imports" import "../../../imports"
import "../../../shared" import "../../../shared"
import "../../../sounds"
ModalPopup { ModalPopup {
id: popup id: popup
@ -15,6 +16,12 @@ ModalPopup {
accountNameInput.forceActiveFocus(Qt.MouseFocusReason) accountNameInput.forceActiveFocus(Qt.MouseFocusReason)
} }
Item {
ErrorSound {
id: errorSound
}
}
Input { Input {
id: addressInput id: addressInput
placeholderText: qsTr("Enter contract address...") placeholderText: qsTr("Enter contract address...")
@ -61,6 +68,7 @@ ModalPopup {
const error = walletModel.addCustomToken(addressInput.text, nameInput.text, symbolInput.text, decimalsInput.text); const error = walletModel.addCustomToken(addressInput.text, nameInput.text, symbolInput.text, decimalsInput.text);
if (error) { if (error) {
errorSound.play()
changeError.text = error changeError.text = error
changeError.open() changeError.open()
return return

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import "../../../../imports" import "../../../../imports"
import "../../../../shared" import "../../../../shared"
import "../../../../sounds"
ModalPopup { ModalPopup {
id: popup id: popup
@ -46,6 +47,12 @@ ModalPopup {
passwordInput.forceActiveFocus(Qt.MouseFocusReason) passwordInput.forceActiveFocus(Qt.MouseFocusReason)
} }
Item {
ErrorSound {
id: errorSound
}
}
Input { Input {
id: passwordInput id: passwordInput
placeholderText: qsTr("Enter your password…") placeholderText: qsTr("Enter your password…")
@ -117,6 +124,7 @@ ModalPopup {
const error = walletModel.addAccountsFromPrivateKey(accountPKeyInput.text, passwordInput.text, accountNameInput.text, selectedColor) const error = walletModel.addAccountsFromPrivateKey(accountPKeyInput.text, passwordInput.text, accountNameInput.text, selectedColor)
loading = false loading = false
if (error) { if (error) {
errorSound.play()
accountError.text = error accountError.text = error
return accountError.open() return accountError.open()
} }

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import "../../../../imports" import "../../../../imports"
import "../../../../shared" import "../../../../shared"
import "../../../../sounds"
ModalPopup { ModalPopup {
id: popup id: popup
@ -47,6 +48,12 @@ ModalPopup {
title: qsTr("Add account with a seed phrase") title: qsTr("Add account with a seed phrase")
Item {
ErrorSound {
id: errorSound
}
}
Input { Input {
id: passwordInput id: passwordInput
placeholderText: qsTr("Enter your password…") placeholderText: qsTr("Enter your password…")
@ -112,12 +119,14 @@ ModalPopup {
// TODO the loaidng doesn't work because the function freezes th eview. Might need to use threads // TODO the loaidng doesn't work because the function freezes th eview. Might need to use threads
loading = true loading = true
if (!validate()) { if (!validate()) {
errorSound.play()
return loading = false return loading = false
} }
const error = walletModel.addAccountsFromSeed(accountSeedInput.text, passwordInput.text, accountNameInput.text, selectedColor) const error = walletModel.addAccountsFromSeed(accountSeedInput.text, passwordInput.text, accountNameInput.text, selectedColor)
loading = false loading = false
if (error) { if (error) {
errorSound.play()
accountError.text = error accountError.text = error
return accountError.open() return accountError.open()
} }

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import "../../../../imports" import "../../../../imports"
import "../../../../shared" import "../../../../shared"
import "../../../../sounds"
ModalPopup { ModalPopup {
id: popup id: popup
@ -36,6 +37,12 @@ ModalPopup {
addressInput.forceActiveFocus(Qt.MouseFocusReason) addressInput.forceActiveFocus(Qt.MouseFocusReason)
} }
Item {
ErrorSound {
id: errorSound
}
}
Input { Input {
id: addressInput id: addressInput
// TODO add QR code reader for the address // TODO add QR code reader for the address
@ -90,12 +97,14 @@ ModalPopup {
// TODO the loaidng doesn't work because the function freezes th eview. Might need to use threads // TODO the loaidng doesn't work because the function freezes th eview. Might need to use threads
loading = true loading = true
if (!validate()) { if (!validate()) {
errorSound.play()
return loading = false return loading = false
} }
const error = walletModel.addWatchOnlyAccount(addressInput.text, accountNameInput.text, selectedColor); const error = walletModel.addWatchOnlyAccount(addressInput.text, accountNameInput.text, selectedColor);
loading = false loading = false
if (error) { if (error) {
errorSound.play()
accountError.text = error accountError.text = error
return accountError.open() return accountError.open()
} }

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import "../../../../imports" import "../../../../imports"
import "../../../../shared" import "../../../../shared"
import "../../../../sounds"
ModalPopup { ModalPopup {
id: popup id: popup
@ -36,6 +37,12 @@ ModalPopup {
passwordInput.forceActiveFocus(Qt.MouseFocusReason) passwordInput.forceActiveFocus(Qt.MouseFocusReason)
} }
Item {
ErrorSound {
id: errorSound
}
}
Input { Input {
id: passwordInput id: passwordInput
placeholderText: qsTr("Enter your password…") placeholderText: qsTr("Enter your password…")
@ -90,12 +97,14 @@ ModalPopup {
// TODO the loaidng doesn't work because the function freezes th eview. Might need to use threads // TODO the loaidng doesn't work because the function freezes th eview. Might need to use threads
loading = true loading = true
if (!validate()) { if (!validate()) {
errorSound.play()
return loading = false return loading = false
} }
const error = walletModel.generateNewAccount(passwordInput.text, accountNameInput.text, selectedColor) const error = walletModel.generateNewAccount(passwordInput.text, accountNameInput.text, selectedColor)
loading = false loading = false
if (error) { if (error) {
errorSound.play()
accountError.text = error accountError.text = error
return accountError.open() return accountError.open()
} }

View File

@ -224,4 +224,5 @@ DISTFILES += \
shared/TextWithLabel.qml \ shared/TextWithLabel.qml \
shared/img/close.svg \ shared/img/close.svg \
shared/img/status-logo.png \ shared/img/status-logo.png \
shared/qmldir shared/qmldir \
sounds/ErrorSound.qml

View File

@ -3,6 +3,7 @@ import QtQuick.Controls 2.13
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import "../imports" import "../imports"
import "../shared" import "../shared"
import "../sounds"
ModalPopup { ModalPopup {
property bool loading: false property bool loading: false
@ -38,6 +39,12 @@ ModalPopup {
firstPasswordField.forceActiveFocus(Qt.MouseFocusReason) firstPasswordField.forceActiveFocus(Qt.MouseFocusReason)
} }
Item {
ErrorSound {
id: errorSound
}
}
Input { Input {
id: firstPasswordField id: firstPasswordField
anchors.rightMargin: 56 anchors.rightMargin: 56
@ -143,6 +150,7 @@ ModalPopup {
ignoreUnknownSignals: true ignoreUnknownSignals: true
onLoginResponseChanged: { onLoginResponseChanged: {
if (error) { if (error) {
errorSound.play()
loading = false loading = false
importLoginError.open() importLoginError.open()
} }
@ -151,6 +159,7 @@ ModalPopup {
onClicked: { onClicked: {
if (!validate()) { if (!validate()) {
errorSound.play()
return return
} }
// TODO this doesn't seem to work because the function freezes the view // TODO this doesn't seem to work because the function freezes the view
@ -160,6 +169,7 @@ ModalPopup {
const result = onboardingModel.storeDerivedAndLogin(repeatPasswordField.text); const result = onboardingModel.storeDerivedAndLogin(repeatPasswordField.text);
const error = JSON.parse(result).error const error = JSON.parse(result).error
if (error) { if (error) {
errorSound.play()
importError.text += error importError.text += error
return importError.open() return importError.open()
} }

View File

@ -1,5 +1,6 @@
import QtQuick 2.13 import QtQuick 2.13
import QtQuick.Controls 2.13 import QtQuick.Controls 2.13
import "../sounds"
Item { Item {
property var onClosed: function () {} property var onClosed: function () {}
@ -10,12 +11,17 @@ Item {
enterSeedPhraseModal.open() enterSeedPhraseModal.open()
} }
ErrorSound {
id: errorSound
}
EnterSeedPhraseModal { EnterSeedPhraseModal {
property bool wentNext: false property bool wentNext: false
id: enterSeedPhraseModal id: enterSeedPhraseModal
onConfirmSeedClick: function (mnemonic) { onConfirmSeedClick: function (mnemonic) {
let error = onboardingModel.validateMnemonic(mnemonic) let error = onboardingModel.validateMnemonic(mnemonic)
if (error != "") { if (error != "") {
errorSound.play()
invalidSeedPhraseModal.error = error invalidSeedPhraseModal.error = error
invalidSeedPhraseModal.open() invalidSeedPhraseModal.open()
} else { } else {

View File

@ -5,6 +5,7 @@ import QtQuick.Dialogs 1.3
import QtGraphicalEffects 1.13 import QtGraphicalEffects 1.13
import "../shared" import "../shared"
import "../imports" import "../imports"
import "../sounds"
import "./Login" import "./Login"
Item { Item {
@ -23,6 +24,11 @@ Item {
Component.onCompleted: { Component.onCompleted: {
txtPassword.forceActiveFocus(Qt.MouseFocusReason) txtPassword.forceActiveFocus(Qt.MouseFocusReason)
} }
ErrorSound {
id: errorSound
}
Item { Item {
id: element id: element
width: 360 width: 360
@ -216,6 +222,7 @@ Item {
ignoreUnknownSignals: true ignoreUnknownSignals: true
onLoginResponseChanged: { onLoginResponseChanged: {
if (error) { if (error) {
errorSound.play()
loginError.open() loginError.open()
} }
} }

13
ui/sounds/ErrorSound.qml Normal file
View File

@ -0,0 +1,13 @@
import QtQuick 2.13
import QtMultimedia 5.13
Audio {
id: errorSound
source: "./error.mp3"
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/

BIN
ui/sounds/error.mp3 Normal file

Binary file not shown.

BIN
ui/sounds/notification.wav Normal file

Binary file not shown.

1
ui/sounds/qmldir Normal file
View File

@ -0,0 +1 @@
ErrorSound 1.0 ErrorSound.qml

BIN
ui/sounds/send_message.wav Normal file

Binary file not shown.