2020-06-17 19:18:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
2020-06-30 20:01:37 +00:00
|
|
|
import QtMultimedia 5.13
|
2020-06-24 03:23:49 +00:00
|
|
|
import "../components"
|
2020-05-27 23:06:41 +00:00
|
|
|
import "../../../../shared"
|
|
|
|
import "../../../../imports"
|
|
|
|
|
|
|
|
Rectangle {
|
2020-07-09 19:10:28 +00:00
|
|
|
id: rectangle
|
2020-05-27 23:06:41 +00:00
|
|
|
border.width: 0
|
2020-07-09 19:10:28 +00:00
|
|
|
height: 52
|
2020-07-13 18:45:54 +00:00
|
|
|
color: Style.current.transparent
|
2020-05-27 23:06:41 +00:00
|
|
|
|
2020-07-02 18:49:02 +00:00
|
|
|
visible: chatsModel.activeChannel.chatType !== Constants.chatTypePrivateGroupChat || chatsModel.activeChannel.isMember(profileModel.profile.pubKey)
|
2020-06-15 17:41:19 +00:00
|
|
|
|
2020-07-10 19:02:57 +00:00
|
|
|
Audio {
|
|
|
|
id: sendMessageSound
|
|
|
|
source: "../../../../sounds/send_message.wav"
|
|
|
|
}
|
|
|
|
|
|
|
|
function interpretMessage(msg) {
|
|
|
|
if (msg === "/shrug") {
|
|
|
|
return "¯\\\\\\_(ツ)\\_/¯"
|
|
|
|
}
|
|
|
|
if (msg === "/tableflip") {
|
|
|
|
return "(╯°□°)╯︵ ┻━┻"
|
|
|
|
}
|
|
|
|
|
|
|
|
return msg
|
|
|
|
}
|
|
|
|
|
2020-06-25 02:01:13 +00:00
|
|
|
function onEnter(event){
|
2020-07-02 18:49:02 +00:00
|
|
|
if (event.modifiers === Qt.NoModifier && (event.key === Qt.Key_Enter || event.key === Qt.Key_Return)) {
|
2020-06-25 02:01:13 +00:00
|
|
|
if(txtData.text.trim().length > 0){
|
2020-07-10 19:02:57 +00:00
|
|
|
let msg = interpretMessage(txtData.text.trim())
|
2020-07-10 22:22:39 +00:00
|
|
|
chatsModel.sendMessage(msg, SelectedMessage.messageId);
|
2020-06-25 02:01:13 +00:00
|
|
|
txtData.text = "";
|
2020-06-26 03:07:34 +00:00
|
|
|
event.accepted = true;
|
2020-06-30 20:01:37 +00:00
|
|
|
sendMessageSound.stop()
|
|
|
|
Qt.callLater(sendMessageSound.play);
|
2020-06-25 02:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-27 23:06:41 +00:00
|
|
|
|
2020-06-24 03:23:49 +00:00
|
|
|
|
2020-07-09 19:10:28 +00:00
|
|
|
ScrollView {
|
|
|
|
id: scrollView
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: sendBtns.left
|
|
|
|
anchors.rightMargin: 0
|
2020-06-24 03:23:49 +00:00
|
|
|
|
2020-07-09 19:10:28 +00:00
|
|
|
StyledTArea {
|
|
|
|
textFormat: TextArea.PlainText
|
|
|
|
|
|
|
|
id: txtData
|
|
|
|
text: ""
|
|
|
|
selectByMouse: true
|
2020-06-24 03:23:49 +00:00
|
|
|
|
2020-07-09 19:10:28 +00:00
|
|
|
anchors.top: parent.top
|
|
|
|
// The normal padding doesn't work for some reason
|
|
|
|
topPadding: Style.current.padding + 9
|
|
|
|
leftPadding: 12
|
|
|
|
rightPadding: Style.current.padding
|
|
|
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
//% "Type a message..."
|
|
|
|
placeholderText: qsTrId("type-a-message")
|
|
|
|
Keys.onPressed: onEnter(event)
|
|
|
|
background: Rectangle {
|
|
|
|
color: "#00000000"
|
2020-07-02 18:49:02 +00:00
|
|
|
}
|
2020-06-24 03:23:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-09 19:10:28 +00:00
|
|
|
ChatButtons {
|
|
|
|
id: sendBtns
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.right: parent.right
|
|
|
|
addToChat: function (text) {
|
|
|
|
txtData.insert(txtData.length, text)
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 19:41:31 +00:00
|
|
|
}
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
2020-07-09 19:10:28 +00:00
|
|
|
D{i:0;formeditorColor:"#ffffff";formeditorZoom:1.25}
|
2020-05-28 19:41:31 +00:00
|
|
|
}
|
|
|
|
##^##*/
|