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.Controls 2.13
import QtQuick.Layouts 1.13
import QtMultimedia 5.13
import "../components"
import "../../../../shared"
import "../../../../imports"
@ -10,12 +11,19 @@ Rectangle {
visible: chatsModel.activeChannel.chatType != Constants.chatTypePrivateGroupChat || chatsModel.activeChannel.isMember(profileModel.profile.pubKey)
Audio {
id: sendMessageSound
source: "../../../../sounds/send_message.wav"
}
function onEnter(event){
if (event.modifiers == Qt.NoModifier && (event.key == Qt.Key_Enter || event.key == Qt.Key_Return)) {
if(txtData.text.trim().length > 0){
chatsModel.sendMessage(txtData.text.trim());
txtData.text = "";
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 "../../../imports"
import "../../../shared"
import "../../../sounds"
ModalPopup {
property var currentAccount: walletModel.currentAccount
@ -31,6 +32,12 @@ ModalPopup {
accountNameInput.forceActiveFocus(Qt.MouseFocusReason)
}
Item {
ErrorSound {
id: errorSound
}
}
Input {
id: accountNameInput
placeholderText: qsTr("Enter an account name...")
@ -126,6 +133,7 @@ ModalPopup {
onAccepted: {
const error = walletModel.deleteAccount(currentAccount.address);
if (error) {
errorSound.play()
deleteError.text = error
deleteError.open()
return
@ -165,6 +173,7 @@ ModalPopup {
const error = walletModel.changeAccountSettings(currentAccount.address, accountNameInput.text, selectedColor);
if (error) {
errorSound.play()
changeError.text = error
changeError.open()
return

View File

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

View File

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

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtQuick.Dialogs 1.3
import "../../../../imports"
import "../../../../shared"
import "../../../../sounds"
ModalPopup {
id: popup
@ -47,6 +48,12 @@ ModalPopup {
title: qsTr("Add account with a seed phrase")
Item {
ErrorSound {
id: errorSound
}
}
Input {
id: passwordInput
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
loading = true
if (!validate()) {
errorSound.play()
return loading = false
}
const error = walletModel.addAccountsFromSeed(accountSeedInput.text, passwordInput.text, accountNameInput.text, selectedColor)
loading = false
if (error) {
errorSound.play()
accountError.text = error
return accountError.open()
}

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtQuick.Dialogs 1.3
import "../../../../imports"
import "../../../../shared"
import "../../../../sounds"
ModalPopup {
id: popup
@ -36,6 +37,12 @@ ModalPopup {
addressInput.forceActiveFocus(Qt.MouseFocusReason)
}
Item {
ErrorSound {
id: errorSound
}
}
Input {
id: addressInput
// 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
loading = true
if (!validate()) {
errorSound.play()
return loading = false
}
const error = walletModel.addWatchOnlyAccount(addressInput.text, accountNameInput.text, selectedColor);
loading = false
if (error) {
errorSound.play()
accountError.text = error
return accountError.open()
}

View File

@ -2,6 +2,7 @@ import QtQuick 2.13
import QtQuick.Dialogs 1.3
import "../../../../imports"
import "../../../../shared"
import "../../../../sounds"
ModalPopup {
id: popup
@ -36,6 +37,12 @@ ModalPopup {
passwordInput.forceActiveFocus(Qt.MouseFocusReason)
}
Item {
ErrorSound {
id: errorSound
}
}
Input {
id: passwordInput
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
loading = true
if (!validate()) {
errorSound.play()
return loading = false
}
const error = walletModel.generateNewAccount(passwordInput.text, accountNameInput.text, selectedColor)
loading = false
if (error) {
errorSound.play()
accountError.text = error
return accountError.open()
}

View File

@ -224,4 +224,5 @@ DISTFILES += \
shared/TextWithLabel.qml \
shared/img/close.svg \
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 "../imports"
import "../shared"
import "../sounds"
ModalPopup {
property bool loading: false
@ -38,6 +39,12 @@ ModalPopup {
firstPasswordField.forceActiveFocus(Qt.MouseFocusReason)
}
Item {
ErrorSound {
id: errorSound
}
}
Input {
id: firstPasswordField
anchors.rightMargin: 56
@ -143,6 +150,7 @@ ModalPopup {
ignoreUnknownSignals: true
onLoginResponseChanged: {
if (error) {
errorSound.play()
loading = false
importLoginError.open()
}
@ -151,6 +159,7 @@ ModalPopup {
onClicked: {
if (!validate()) {
errorSound.play()
return
}
// 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 error = JSON.parse(result).error
if (error) {
errorSound.play()
importError.text += error
return importError.open()
}

View File

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

View File

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