mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-18 09:37:59 +00:00
implement emoji handler that replaces text 😂 with text
This commit is contained in:
parent
0b6643ac2d
commit
1cc43c15e7
@ -16,6 +16,8 @@ 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)
|
||||||
|
|
||||||
|
property bool emojiEvent: false;
|
||||||
|
|
||||||
Audio {
|
Audio {
|
||||||
id: sendMessageSound
|
id: sendMessageSound
|
||||||
source: "../../../../sounds/send_message.wav"
|
source: "../../../../sounds/send_message.wav"
|
||||||
@ -53,6 +55,62 @@ Rectangle {
|
|||||||
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)) {
|
||||||
sendMsg(event);
|
sendMsg(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emojiEvent = emojiHandler(emojiEvent, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function emojiHandler(emojiEvent, event) {
|
||||||
|
|
||||||
|
var msg = chatsModel.plainText(Emoji.deparse(txtData.text).trim());
|
||||||
|
|
||||||
|
if (emojiEvent == false && event.key == Qt.Key_Colon) {
|
||||||
|
if (isSpace(msg.charAt(msg.length - 1)) == true) {
|
||||||
|
console.log('emoji event');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else if (emojiEvent == true && isKeyValid(event.key) == true) {
|
||||||
|
console.log('popup');
|
||||||
|
return true;
|
||||||
|
} else if (emojiEvent == true && event.key == Qt.Key_Colon) {
|
||||||
|
var index = msg.indexOf(':', 0);
|
||||||
|
txtData.remove(index - 1, txtData.length);
|
||||||
|
txtData.insert(txtData.length, " EMOJI");
|
||||||
|
|
||||||
|
if (event) event.accepted = true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else if (emojiEvent == true && isKeyValid(event.key) == false) {
|
||||||
|
console.log('emoji event stopped');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isKeyValid(key) {
|
||||||
|
if (isKeyAlpha(key) == true || isKeyDigit(key) == true || key == Qt.Key_Underscore || key == Qt.Key_Shift)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSpace(c) {
|
||||||
|
if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
function isKeyAlpha(key) {
|
||||||
|
if (key >= Qt.Key_A && key <= Qt.Key_Z)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isKeyDigit(key) {
|
||||||
|
if (key >= Qt.Key_0 && key <= Qt.Key_9)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDialog {
|
FileDialog {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user