2020-09-29 09:06:57 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
2021-02-11 15:50:59 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2020-09-29 09:06:57 +00:00
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtMultimedia 5.13
|
|
|
|
import QtQuick.Dialogs 1.3
|
2021-07-23 09:53:43 +00:00
|
|
|
import DotherSide 0.1
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
2021-10-28 09:45:21 +00:00
|
|
|
import shared.popups 1.0
|
2021-12-08 21:20:43 +00:00
|
|
|
import shared.stores 1.0
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2021-10-27 21:27:49 +00:00
|
|
|
//TODO remove this dependency
|
|
|
|
import "../../../app/AppLayouts/Chat/panels"
|
2021-10-29 11:58:07 +00:00
|
|
|
import "./emojiList.js" as EmojiJSON
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2021-07-28 11:08:32 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-20 22:47:23 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-18 10:34:16 +00:00
|
|
|
import StatusQ.Controls 0.1 as StatusQ
|
2021-07-28 11:08:32 +00:00
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
Rectangle {
|
|
|
|
id: control
|
|
|
|
signal sendTransactionCommandButtonClicked()
|
|
|
|
signal receiveTransactionCommandButtonClicked()
|
|
|
|
signal stickerSelected(string hashId, string packId)
|
2020-12-07 14:59:24 +00:00
|
|
|
signal sendMessage(var event)
|
2020-09-29 09:06:57 +00:00
|
|
|
|
|
|
|
property bool emojiEvent: false;
|
|
|
|
property bool paste: false;
|
|
|
|
property bool isColonPressed: false;
|
|
|
|
property bool isReply: false
|
2022-01-12 12:55:26 +00:00
|
|
|
property string replyMessageId: replyArea.messageId
|
2021-08-17 13:28:10 +00:00
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
property bool isImage: false
|
2021-06-29 14:49:32 +00:00
|
|
|
property bool isEdit: false
|
2021-08-09 11:11:04 +00:00
|
|
|
property bool isContactBlocked: false
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2020-12-04 12:14:18 +00:00
|
|
|
property var recentStickers
|
|
|
|
property var stickerPackList
|
2020-09-29 09:06:57 +00:00
|
|
|
|
|
|
|
property int extraHeightFactor: calculateExtraHeightFactor()
|
2021-12-01 12:46:21 +00:00
|
|
|
property int messageLimit: control.isStatusUpdateInput ? 300 : 2000
|
|
|
|
property int messageLimitVisible: control.isStatusUpdateInput ? 50 : 200
|
2020-09-29 09:06:57 +00:00
|
|
|
|
|
|
|
property int chatType
|
|
|
|
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Type a message."
|
|
|
|
property string chatInputPlaceholder: qsTrId("type-a-message-")
|
2020-12-02 09:10:22 +00:00
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
property alias textInput: messageInputField
|
2021-12-09 12:53:40 +00:00
|
|
|
property bool isStatusUpdateInput: chatType === Constants.chatType.profile
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2020-12-07 14:59:24 +00:00
|
|
|
property var fileUrls: []
|
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
property var imageErrorMessageLocation: StatusChatInput.ImageErrorMessageLocation.Top
|
|
|
|
|
2021-08-24 09:10:26 +00:00
|
|
|
property alias suggestions: suggestionsBox
|
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
enum ImageErrorMessageLocation {
|
|
|
|
Top,
|
|
|
|
Bottom
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
height: {
|
|
|
|
if (extendedArea.visible) {
|
2021-12-01 12:46:21 +00:00
|
|
|
return messageInput.height + extendedArea.height + (control.isStatusUpdateInput ? 0 : Style.current.bigPadding)
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
if (messageInput.height > messageInput.defaultInputFieldHeight) {
|
|
|
|
if (messageInput.height >= messageInput.maxInputFieldHeight) {
|
2021-12-01 12:46:21 +00:00
|
|
|
return messageInput.maxInputFieldHeight + (control.isStatusUpdateInput ? 0 : Style.current.bigPadding)
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
2021-12-01 12:46:21 +00:00
|
|
|
return messageInput.height + (control.isStatusUpdateInput ? 0 : Style.current.bigPadding)
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
2021-12-01 12:46:21 +00:00
|
|
|
return control.isStatusUpdateInput ? 56 : 64
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
2021-06-29 14:49:32 +00:00
|
|
|
color: Style.current.transparent
|
2021-12-01 12:46:21 +00:00
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
function calculateExtraHeightFactor() {
|
|
|
|
const factor = (messageInputField.length / 500) + 1;
|
|
|
|
return (factor > 5) ? 5 : factor;
|
|
|
|
}
|
|
|
|
|
|
|
|
function insertInTextInput(start, text) {
|
|
|
|
// Repace new lines with entities because `insert` gets rid of them
|
|
|
|
messageInputField.insert(start, text.replace(/\n/g, "<br/>"));
|
|
|
|
}
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
function togglePopup(popup, btn) {
|
|
|
|
if (popup !== stickersPopup) {
|
|
|
|
stickersPopup.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (popup !== gifPopup) {
|
|
|
|
gifPopup.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (popup !== emojiPopup) {
|
|
|
|
emojiPopup.close()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (popup.opened) {
|
|
|
|
popup.close()
|
|
|
|
btn.highlighted = false
|
|
|
|
} else {
|
|
|
|
popup.open()
|
|
|
|
btn.highlighted = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-25 12:21:48 +00:00
|
|
|
function insertMention(aliasName, lastAtPosition, lastCursorPosition) {
|
|
|
|
const hasEmoji = Emoji.hasEmoji(messageInputField.text)
|
|
|
|
const spanPlusAlias = `${Constants.mentionSpanTag}@${aliasName}</span> `
|
|
|
|
|
|
|
|
let rightIndex = hasEmoji ? lastCursorPosition + 2 : lastCursorPosition
|
|
|
|
|
|
|
|
messageInputField.remove(lastAtPosition, rightIndex)
|
|
|
|
messageInputField.insert(lastAtPosition, spanPlusAlias)
|
|
|
|
messageInputField.cursorPosition = lastAtPosition + aliasName.length + 2
|
|
|
|
|
|
|
|
if (messageInputField.cursorPosition === 0) {
|
|
|
|
// It reset to 0 for some reason, go back to the end
|
|
|
|
messageInputField.cursorPosition = messageInputField.length
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-23 15:57:19 +00:00
|
|
|
property var interpretMessage: function (msg) {
|
2020-11-16 20:21:06 +00:00
|
|
|
if (msg.startsWith("/shrug")) {
|
|
|
|
return msg.replace("/shrug", "") + " ¯\\\\\\_(ツ)\\_/¯"
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
2020-11-16 20:21:06 +00:00
|
|
|
if (msg.startsWith("/tableflip")) {
|
|
|
|
return msg.replace("/tableflip", "") + " (╯°□°)╯︵ ┻━┻"
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return msg
|
|
|
|
}
|
|
|
|
|
2020-11-17 03:07:01 +00:00
|
|
|
function isUploadFilePressed(event) {
|
|
|
|
return (event.key === Qt.Key_U) && (event.modifiers & Qt.ControlModifier) && imageBtn.visible && !imageDialog.visible
|
|
|
|
}
|
|
|
|
|
2021-01-21 15:58:36 +00:00
|
|
|
function checkTextInsert() {
|
|
|
|
if (emojiSuggestions.visible) {
|
2021-12-08 21:20:43 +00:00
|
|
|
replaceWithEmoji(extrapolateCursorPosition(), emojiSuggestions.shortname, emojiSuggestions.unicode);
|
2021-01-21 15:58:36 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
if (suggestionsBox.visible) {
|
|
|
|
suggestionsBox.selectCurrentItem();
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-11-18 17:14:29 +00:00
|
|
|
function onKeyPress(event){
|
2020-09-29 09:06:57 +00:00
|
|
|
if (event.modifiers === Qt.NoModifier && (event.key === Qt.Key_Enter || event.key === Qt.Key_Return)) {
|
2021-01-21 15:58:36 +00:00
|
|
|
if (checkTextInsert()) {
|
2020-10-20 17:38:48 +00:00
|
|
|
event.accepted = true;
|
|
|
|
return
|
|
|
|
}
|
2021-12-01 12:46:21 +00:00
|
|
|
|
|
|
|
if (control.isStatusUpdateInput) {
|
|
|
|
return // Status update require the send button to be clicked
|
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
if (messageInputField.length < messageLimit) {
|
2020-12-07 14:59:24 +00:00
|
|
|
control.sendMessage(event)
|
|
|
|
control.hideExtendedArea();
|
2021-03-10 04:59:01 +00:00
|
|
|
event.accepted = true
|
2020-09-29 09:06:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(event) event.accepted = true
|
|
|
|
messageTooLongDialog.open()
|
|
|
|
}
|
|
|
|
|
2021-01-21 15:58:36 +00:00
|
|
|
if (event.key === Qt.Key_Tab) {
|
|
|
|
if (checkTextInsert()) {
|
|
|
|
event.accepted = true;
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-10 19:54:21 +00:00
|
|
|
const message = control.extrapolateCursorPosition();
|
|
|
|
|
2020-11-17 03:07:01 +00:00
|
|
|
// handle new line in blockquote
|
2020-12-10 19:54:21 +00:00
|
|
|
if ((event.key === Qt.Key_Enter || event.key === Qt.Key_Return) && (event.modifiers & Qt.ShiftModifier) && message.data.startsWith(">")) {
|
2020-11-17 03:07:01 +00:00
|
|
|
if(message.data.startsWith(">") && !message.data.endsWith("\n\n")) {
|
2021-04-01 17:07:26 +00:00
|
|
|
let newMessage1 = ""
|
2020-11-17 03:07:01 +00:00
|
|
|
if (message.data.endsWith("\n> ")) {
|
2021-04-01 17:07:26 +00:00
|
|
|
newMessage1 = message.data.substr(0, message.data.lastIndexOf("> ")) + "\n\n"
|
2020-11-17 03:07:01 +00:00
|
|
|
} else {
|
2021-04-01 17:07:26 +00:00
|
|
|
newMessage1 = message.data + "\n> ";
|
2020-11-17 03:07:01 +00:00
|
|
|
}
|
|
|
|
messageInputField.remove(0, messageInputField.cursorPosition);
|
2021-04-01 17:07:26 +00:00
|
|
|
insertInTextInput(0, Emoji.parse(newMessage1));
|
2020-11-17 03:07:01 +00:00
|
|
|
}
|
|
|
|
event.accepted = true
|
|
|
|
}
|
|
|
|
// handle backspace when entering an existing blockquote
|
|
|
|
if ((event.key === Qt.Key_Backspace || event.key === Qt.Key_Delete)) {
|
|
|
|
if(message.data.startsWith(">") && message.data.endsWith("\n\n")) {
|
|
|
|
const newMessage = message.data.substr(0, message.data.lastIndexOf("\n")) + "> ";
|
|
|
|
messageInputField.remove(0, messageInputField.cursorPosition);
|
|
|
|
insertInTextInput(0, Emoji.parse(newMessage));
|
|
|
|
event.accepted = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
if ((event.key === Qt.Key_V) && (event.modifiers & Qt.ControlModifier)) {
|
|
|
|
paste = true;
|
|
|
|
}
|
|
|
|
|
2020-11-17 03:07:01 +00:00
|
|
|
// ⌘⇧U
|
|
|
|
if (isUploadFilePressed(event)) {
|
|
|
|
imageBtn.clicked()
|
|
|
|
event.accepted = true
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
if (event.key === Qt.Key_Down) {
|
2020-10-20 17:38:48 +00:00
|
|
|
suggestionsBox.listView.incrementCurrentIndex()
|
2020-10-20 15:32:03 +00:00
|
|
|
return emojiSuggestions.listView.incrementCurrentIndex()
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
if (event.key === Qt.Key_Up) {
|
2020-10-20 17:38:48 +00:00
|
|
|
suggestionsBox.listView.decrementCurrentIndex()
|
2020-10-20 15:32:03 +00:00
|
|
|
return emojiSuggestions.listView.decrementCurrentIndex()
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
2020-11-18 17:14:29 +00:00
|
|
|
if (event.key === Qt.Key_Escape) {
|
|
|
|
suggestionsBox.hide()
|
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
|
|
|
|
isColonPressed = (event.key === Qt.Key_Colon) && (event.modifiers & Qt.ShiftModifier);
|
2021-08-25 12:21:48 +00:00
|
|
|
|
2021-12-01 12:46:21 +00:00
|
|
|
if (event.key === Qt.Key_Space && suggestionsBox.formattedPlainTextFilter.length > 1 && suggestionsBox.formattedPlainTextFilter.trim().split(" ").length === 1) {
|
|
|
|
let aliasName = suggestionsBox.formattedPlainTextFilter
|
|
|
|
let lastCursorPosition = suggestionsBox.suggestionFilter.cursorPosition
|
|
|
|
let lastAtPosition = suggestionsBox.suggestionFilter.lastAtPosition
|
|
|
|
insertMention(aliasName, lastAtPosition, lastCursorPosition)
|
2021-08-25 12:21:48 +00:00
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-17 03:07:01 +00:00
|
|
|
function wrapSelection(wrapWith) {
|
|
|
|
if (messageInputField.selectionStart - messageInputField.selectionEnd === 0) return
|
2021-05-06 20:29:22 +00:00
|
|
|
|
2021-08-24 16:34:24 +00:00
|
|
|
// calulate the new selection start and end positions
|
|
|
|
var newSelectionStart = messageInputField.selectionStart + wrapWith.length
|
|
|
|
var newSelectionEnd = messageInputField.selectionEnd - messageInputField.selectionStart + newSelectionStart
|
|
|
|
|
2021-04-22 15:55:11 +00:00
|
|
|
insertInTextInput(messageInputField.selectionStart, wrapWith);
|
|
|
|
insertInTextInput(messageInputField.selectionEnd, wrapWith);
|
2021-03-03 15:13:41 +00:00
|
|
|
|
2021-08-24 16:34:24 +00:00
|
|
|
messageInputField.select(newSelectionStart, newSelectionEnd)
|
2021-02-17 11:31:37 +00:00
|
|
|
}
|
2021-08-24 16:34:24 +00:00
|
|
|
|
2021-04-21 19:46:58 +00:00
|
|
|
function unwrapSelection(unwrapWith, selectedTextWithFormationChars) {
|
2021-08-24 16:34:24 +00:00
|
|
|
if (messageInputField.selectionStart - messageInputField.selectionEnd === 0) return
|
|
|
|
|
|
|
|
// calulate the new selection start and end positions
|
|
|
|
var newSelectionStart = messageInputField.selectionStart - unwrapWith.length
|
|
|
|
var newSelectionEnd = messageInputField.selectionEnd-messageInputField.selectionStart + newSelectionStart
|
|
|
|
|
|
|
|
selectedTextWithFormationChars = selectedTextWithFormationChars.trim()
|
|
|
|
// Check if the selectedTextWithFormationChars has formation chars and if so, calculate how many so we can adapt the start and end pos
|
|
|
|
const selectTextDiff = (selectedTextWithFormationChars.length - messageInputField.selectedText.length) / 2
|
2021-04-21 18:18:52 +00:00
|
|
|
|
2021-08-24 16:34:24 +00:00
|
|
|
// Remove the deselected option from the before and after the selected text
|
|
|
|
const prefixChars = messageInputField.getText((messageInputField.selectionStart - selectTextDiff), messageInputField.selectionStart)
|
|
|
|
const updatedPrefixChars = prefixChars.replace(unwrapWith, '')
|
|
|
|
const postfixChars = messageInputField.getText(messageInputField.selectionEnd, (messageInputField.selectionEnd + selectTextDiff))
|
|
|
|
const updatedPostfixChars = postfixChars.replace(unwrapWith, '')
|
2021-04-21 19:46:58 +00:00
|
|
|
|
2021-08-24 16:34:24 +00:00
|
|
|
// Create updated selected string with pre and post formatting characters
|
|
|
|
const updatedSelectedStringWithFormatChars = updatedPrefixChars + messageInputField.selectedText + updatedPostfixChars
|
2021-04-21 19:46:58 +00:00
|
|
|
|
2021-08-24 16:34:24 +00:00
|
|
|
messageInputField.remove(messageInputField.selectionStart - selectTextDiff, messageInputField.selectionEnd + selectTextDiff)
|
2021-04-21 19:46:58 +00:00
|
|
|
|
2021-08-24 16:34:24 +00:00
|
|
|
insertInTextInput(messageInputField.selectionStart, updatedSelectedStringWithFormatChars)
|
2021-04-21 18:18:52 +00:00
|
|
|
|
2021-08-24 16:34:24 +00:00
|
|
|
messageInputField.select(newSelectionStart, newSelectionEnd)
|
2021-04-21 18:18:52 +00:00
|
|
|
}
|
2021-02-17 11:31:37 +00:00
|
|
|
|
2021-03-19 20:13:12 +00:00
|
|
|
function getPlainText() {
|
|
|
|
const textWithoutMention = messageInputField.text.replace(/<span style="[ :#0-9a-z;\-\.,\(\)]+">(@([a-z\.]+(\ ?[a-z]+\ ?[a-z]+)?))<\/span>/ig, "\[\[mention\]\]$1\[\[mention\]\]")
|
|
|
|
|
|
|
|
const deparsedEmoji = Emoji.deparse(textWithoutMention);
|
|
|
|
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
return ""
|
2021-12-08 21:20:43 +00:00
|
|
|
//return RootStore.chatsModelInst.plainText(deparsedEmoji);
|
2021-03-19 20:13:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function removeMentions(currentText) {
|
|
|
|
return currentText.replace(/\[\[mention\]\]/g, '')
|
|
|
|
}
|
|
|
|
|
2021-05-06 20:29:22 +00:00
|
|
|
function parseMarkdown(markdownText) {
|
|
|
|
const htmlText = markdownText
|
2021-07-13 07:34:13 +00:00
|
|
|
.replace(/\~\~([^*]+)\~\~/gim, '~~<span style="text-decoration: line-through">$1</span>~~')
|
|
|
|
.replace(/\*\*([^*]+)\*\*/gim, ':asterisk::asterisk:<b>$1</b>:asterisk::asterisk:')
|
|
|
|
.replace(/\`([^*]+)\`/gim, '`<code>$1</code>`')
|
|
|
|
.replace(/\*([^*]+)\*/gim, ':asterisk:<i>$1</i>:asterisk:')
|
2021-05-06 20:29:22 +00:00
|
|
|
return htmlText.replace(/\:asterisk\:/gim, "*")
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFormattedText(start, end) {
|
|
|
|
start = start || 0
|
|
|
|
end = end || messageInputField.length
|
2021-03-19 20:13:12 +00:00
|
|
|
|
2021-05-06 20:29:22 +00:00
|
|
|
const oldFormattedText = messageInputField.getFormattedText(start, end)
|
|
|
|
|
|
|
|
const found = oldFormattedText.match(/<!--StartFragment-->([\w\W\s]*)<!--EndFragment-->/m);
|
|
|
|
|
|
|
|
return found[1]
|
|
|
|
}
|
|
|
|
|
|
|
|
function setFormatInInput(formationFunction, startTag, endTag, formationChar, numFormationChars) {
|
|
|
|
const inputText = getFormattedText()
|
|
|
|
const plainInputText = messageInputField.getText(0, messageInputField.length)
|
|
|
|
|
|
|
|
let lengthDifference
|
|
|
|
|
|
|
|
try {
|
|
|
|
const result = formationFunction(inputText)
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const parsed = JSON.parse(result)
|
|
|
|
|
|
|
|
let substring
|
|
|
|
let nbEmojis
|
|
|
|
parsed.forEach(function (match) {
|
|
|
|
match[1] += 1
|
|
|
|
const truncatedInputText = inputText.substring(0, match[1] + numFormationChars)
|
|
|
|
const truncatedPlainText = plainInputText.substring(0, messageInputField.cursorPosition)
|
|
|
|
|
|
|
|
const lengthDifference = truncatedInputText.length - truncatedPlainText.length
|
|
|
|
|
|
|
|
nbEmojis = Emoji.nbEmojis(truncatedInputText)
|
|
|
|
|
|
|
|
|
|
|
|
match[1] += (nbEmojis * -2)
|
|
|
|
match[0] += (nbEmojis * -2)
|
|
|
|
substring = inputText.substring(match[0], match[1])
|
|
|
|
|
|
|
|
if (plainInputText.charAt(match[0] - 1) !== formationChar) {
|
|
|
|
match[0] -= lengthDifference
|
|
|
|
match[1] -= lengthDifference
|
|
|
|
} else {
|
|
|
|
match[1] -= lengthDifference
|
|
|
|
}
|
|
|
|
|
|
|
|
messageInputField.remove(match[0], match[1])
|
|
|
|
insertInTextInput(match[0], `${startTag}${substring}${endTag}`)
|
|
|
|
})
|
|
|
|
} catch (e) {
|
|
|
|
//
|
|
|
|
}
|
2021-03-19 20:13:12 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
function onRelease(event) {
|
2021-03-03 16:04:03 +00:00
|
|
|
if (event.key === Qt.Key_Backspace && textFormatMenu.opened) {
|
|
|
|
textFormatMenu.close()
|
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
// the text doesn't get registered to the textarea fast enough
|
|
|
|
// we can only get it in the `released` event
|
|
|
|
if (paste) {
|
|
|
|
paste = false;
|
2021-08-27 14:15:59 +00:00
|
|
|
const plainText = messageInputField.getFormattedText(0, messageInputField.length);
|
2021-07-15 10:35:15 +00:00
|
|
|
messageInputField.remove(0, messageInputField.length);
|
|
|
|
insertInTextInput(0, plainText);
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-18 17:14:29 +00:00
|
|
|
if (event.key !== Qt.Key_Escape) {
|
|
|
|
emojiEvent = emojiHandler(event);
|
|
|
|
if (!emojiEvent) {
|
|
|
|
emojiSuggestions.close()
|
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// since emoji length is not 1 we need to match that position that TextArea returns
|
2021-05-06 20:29:22 +00:00
|
|
|
// to the actual position in the string.
|
2020-09-29 09:06:57 +00:00
|
|
|
function extrapolateCursorPosition() {
|
|
|
|
// we need only the message part to be html
|
2021-03-19 20:13:12 +00:00
|
|
|
const text = getPlainText()
|
|
|
|
const completelyPlainText = removeMentions(text)
|
2020-11-17 03:07:01 +00:00
|
|
|
const plainText = Emoji.parse(text);
|
2020-09-29 09:06:57 +00:00
|
|
|
|
|
|
|
var bracketEvent = false;
|
2021-03-19 20:13:12 +00:00
|
|
|
var almostMention = false;
|
|
|
|
var mentionEvent = false;
|
2020-09-29 09:06:57 +00:00
|
|
|
var length = 0;
|
|
|
|
|
2021-03-19 20:13:12 +00:00
|
|
|
// This loop calculates the cursor position inside the plain text which contains the image tags (<img>) and the mention tags ([[mention]])
|
|
|
|
const cursorPos = messageInputField.cursorPosition
|
2021-05-06 20:29:22 +00:00
|
|
|
let character = ""
|
|
|
|
for (var i = 0; i < plainText.length; i++) {
|
2021-03-19 20:13:12 +00:00
|
|
|
if (length >= cursorPos) break;
|
2020-09-29 09:06:57 +00:00
|
|
|
|
2021-05-06 20:29:22 +00:00
|
|
|
character = plainText.charAt(i)
|
|
|
|
if (!bracketEvent && character !== '<' && !mentionEvent && character !== '[') {
|
2020-09-29 09:06:57 +00:00
|
|
|
length++;
|
2021-05-06 20:29:22 +00:00
|
|
|
} else if (!bracketEvent && character === '<') {
|
2020-09-29 09:06:57 +00:00
|
|
|
bracketEvent = true;
|
2021-05-06 20:29:22 +00:00
|
|
|
} else if (bracketEvent && character === '>') {
|
2020-09-29 09:06:57 +00:00
|
|
|
bracketEvent = false;
|
|
|
|
length++;
|
2021-03-19 20:13:12 +00:00
|
|
|
} else if (!mentionEvent && almostMention && plainText.charAt(i) === '[') {
|
|
|
|
almostMention = false
|
|
|
|
mentionEvent = true
|
|
|
|
} else if (!mentionEvent && !almostMention && plainText.charAt(i) === '[') {
|
|
|
|
almostMention = true
|
|
|
|
} else if (!mentionEvent && almostMention && plainText.charAt(i) !== '[') {
|
|
|
|
almostMention = false
|
|
|
|
} else if (mentionEvent && !almostMention && plainText.charAt(i) === ']') {
|
|
|
|
almostMention = true
|
|
|
|
} else if (mentionEvent && almostMention && plainText.charAt(i) === ']') {
|
|
|
|
almostMention = false
|
|
|
|
mentionEvent = false
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let textBeforeCursor = Emoji.deparseFromParse(plainText.substr(0, i));
|
2021-03-19 20:13:12 +00:00
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
return {
|
2021-03-19 20:13:12 +00:00
|
|
|
cursor: countEmojiLengths(plainText.substr(0, i)) + messageInputField.cursorPosition + text.length - completelyPlainText.length,
|
|
|
|
data: textBeforeCursor,
|
2020-09-29 09:06:57 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function emojiHandler(event) {
|
|
|
|
let message = extrapolateCursorPosition();
|
|
|
|
pollEmojiEvent(message);
|
|
|
|
|
|
|
|
// state machine to handle different forms of the emoji event state
|
|
|
|
if (!emojiEvent && isColonPressed) {
|
|
|
|
return (message.data.length <= 1 || Utils.isSpace(message.data.charAt(message.cursor - 1))) ? true : false;
|
|
|
|
} else if (emojiEvent && isColonPressed) {
|
|
|
|
const index = message.data.lastIndexOf(':', message.cursor - 2);
|
|
|
|
if (index >= 0 && message.cursor > 0) {
|
|
|
|
const shortname = message.data.substr(index, message.cursor);
|
|
|
|
const codePoint = Emoji.getEmojiUnicode(shortname);
|
|
|
|
if (codePoint !== undefined) {
|
|
|
|
replaceWithEmoji(message, shortname, codePoint);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else if (emojiEvent && isKeyValid(event.key) && !isColonPressed) {
|
|
|
|
// popup
|
|
|
|
const index2 = message.data.lastIndexOf(':', message.cursor - 1);
|
|
|
|
if (index2 >= 0 && message.cursor > 0) {
|
|
|
|
const emojiPart = message.data.substr(index2, message.cursor);
|
|
|
|
if (emojiPart.length > 2) {
|
|
|
|
const emojis = EmojiJSON.emoji_json.filter(function (emoji) {
|
|
|
|
return emoji.name.includes(emojiPart) ||
|
|
|
|
emoji.shortname.includes(emojiPart) ||
|
|
|
|
emoji.aliases.some(a => a.includes(emojiPart))
|
|
|
|
})
|
|
|
|
|
|
|
|
emojiSuggestions.openPopup(emojis, emojiPart)
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else if (emojiEvent && !isKeyValid(event.key) && !isColonPressed) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function countEmojiLengths(value) {
|
|
|
|
const match = Emoji.getEmojis(value);
|
|
|
|
var length = 0;
|
|
|
|
|
|
|
|
if (match && match.length > 0) {
|
|
|
|
for (var i = 0; i < match.length; i++) {
|
|
|
|
length += Emoji.deparseFromParse(match[i]).length;
|
|
|
|
}
|
|
|
|
length = length - match.length;
|
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
function replaceWithEmoji(message, shortname, codePoint) {
|
|
|
|
const encodedCodePoint = Emoji.getEmojiCodepoint(codePoint)
|
2021-05-06 20:29:22 +00:00
|
|
|
messageInputField.remove(messageInputField.cursorPosition - shortname.length, messageInputField.cursorPosition);
|
|
|
|
insertInTextInput(messageInputField.cursorPosition, Emoji.parse(encodedCodePoint) + " ");
|
2020-09-29 09:06:57 +00:00
|
|
|
emojiSuggestions.close()
|
|
|
|
emojiEvent = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if user has placed cursor near valid emoji colon token
|
|
|
|
function pollEmojiEvent(message) {
|
|
|
|
const index = message.data.lastIndexOf(':', message.cursor);
|
|
|
|
if (index >= 0) {
|
|
|
|
emojiEvent = validSubstr(message.data.substr(index, message.cursor - index));
|
2021-05-05 17:54:35 +00:00
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function validSubstr(substr) {
|
|
|
|
for(var i = 0; i < substr.length; i++) {
|
|
|
|
var c = substr.charAt(i);
|
|
|
|
if (Utils.isSpace(c) === true || Utils.isPunct(c) === true)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isKeyValid(key) {
|
|
|
|
if (key === Qt.Key_Space || key === Qt.Key_Tab ||
|
2021-07-13 07:34:13 +00:00
|
|
|
(key >= Qt.Key_Exclam && key <= Qt.Key_Slash) ||
|
|
|
|
(key >= Qt.Key_Semicolon && key <= Qt.Key_Question) ||
|
|
|
|
(key >= Qt.Key_BracketLeft && key <= Qt.Key_hyphen))
|
2020-09-29 09:06:57 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideExtendedArea() {
|
|
|
|
isImage = false;
|
|
|
|
isReply = false;
|
2020-12-07 14:59:24 +00:00
|
|
|
control.fileUrls = []
|
2021-03-10 04:59:01 +00:00
|
|
|
imageArea.imageSource = [];
|
2020-09-29 09:06:57 +00:00
|
|
|
replyArea.userName = ""
|
|
|
|
replyArea.identicon = ""
|
|
|
|
replyArea.message = ""
|
2021-03-10 04:59:01 +00:00
|
|
|
for (let i=0; i<validators.children.length; i++) {
|
|
|
|
const validator = validators.children[i]
|
|
|
|
validator.images = []
|
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
function validateImages(imagePaths) {
|
|
|
|
// needed because imageArea.imageSource is not a normal js array
|
|
|
|
const existing = (imageArea.imageSource || []).map(x => x.toString())
|
|
|
|
let validImages = Utils.deduplicate(existing.concat(imagePaths))
|
|
|
|
for (let i=0; i<validators.children.length; i++) {
|
|
|
|
const validator = validators.children[i]
|
|
|
|
validator.images = validImages
|
|
|
|
validImages = validImages.filter(validImage => validator.validImages.includes(validImage))
|
|
|
|
}
|
|
|
|
return validImages
|
|
|
|
}
|
|
|
|
|
|
|
|
function showImageArea(imagePaths) {
|
2020-09-29 09:06:57 +00:00
|
|
|
isImage = true;
|
|
|
|
isReply = false;
|
2021-03-10 04:59:01 +00:00
|
|
|
imageArea.imageSource = imagePaths
|
|
|
|
control.fileUrls = imageArea.imageSource
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-12 12:55:26 +00:00
|
|
|
function showReplyArea(messageId, userName, message, identicon, contentType, image, sticker) {
|
2020-09-29 09:06:57 +00:00
|
|
|
isReply = true
|
|
|
|
replyArea.userName = userName
|
|
|
|
replyArea.message = message
|
|
|
|
replyArea.identicon = identicon
|
2021-08-30 12:42:11 +00:00
|
|
|
replyArea.contentType = contentType
|
|
|
|
replyArea.image = image
|
2021-11-09 16:46:18 +00:00
|
|
|
replyArea.stickerData = sticker
|
2022-01-12 12:55:26 +00:00
|
|
|
replyArea.messageId = messageId
|
2020-11-23 15:49:30 +00:00
|
|
|
messageInputField.forceActiveFocus();
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 17:14:21 +00:00
|
|
|
function forceInputActiveFocus() {
|
|
|
|
messageInputField.forceActiveFocus();
|
|
|
|
}
|
|
|
|
|
2021-03-10 04:59:01 +00:00
|
|
|
Connections {
|
2021-12-08 21:20:43 +00:00
|
|
|
target: Global.applicationWindow.dragAndDrop
|
2021-03-10 04:59:01 +00:00
|
|
|
onDroppedOnValidScreen: (drop) => {
|
2021-07-13 07:34:13 +00:00
|
|
|
let validImages = validateImages(drop.urls)
|
|
|
|
if (validImages.length > 0) {
|
|
|
|
showImageArea(validImages)
|
|
|
|
drop.acceptProposedAction()
|
|
|
|
}
|
|
|
|
}
|
2021-03-10 04:59:01 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
FileDialog {
|
|
|
|
id: imageDialog
|
|
|
|
//% "Please choose an image"
|
|
|
|
title: qsTrId("please-choose-an-image")
|
|
|
|
folder: shortcuts.pictures
|
2021-03-10 04:59:01 +00:00
|
|
|
selectMultiple: true
|
2020-09-29 09:06:57 +00:00
|
|
|
nameFilters: [
|
2021-07-16 20:22:50 +00:00
|
|
|
//% "Image files (%1)"
|
|
|
|
qsTrId("image-files---1-").arg(Constants.acceptedDragNDropImageExtensions.map(img => "*" + img).join(" "))
|
2020-09-29 09:06:57 +00:00
|
|
|
]
|
|
|
|
onAccepted: {
|
|
|
|
imageBtn.highlighted = false
|
2021-12-01 12:46:21 +00:00
|
|
|
imageBtn2.highlighted = false
|
2021-03-10 04:59:01 +00:00
|
|
|
let validImages = validateImages(imageDialog.fileUrls)
|
|
|
|
if (validImages.length > 0) {
|
|
|
|
control.showImageArea(validImages)
|
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
messageInputField.forceActiveFocus();
|
|
|
|
}
|
|
|
|
onRejected: {
|
|
|
|
imageBtn.highlighted = false
|
2021-12-01 12:46:21 +00:00
|
|
|
imageBtn2.highlighted = false
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
id: messageTooLongDialog
|
|
|
|
//% "Your message is too long."
|
|
|
|
title: qsTrId("your-message-is-too-long.")
|
|
|
|
icon: StandardIcon.Critical
|
|
|
|
//% "Please make your message shorter. We have set the limit to 2000 characters to be courteous of others."
|
|
|
|
text: qsTrId("please-make-your-message-shorter.-we-have-set-the-limit-to-2000-characters-to-be-courteous-of-others.")
|
|
|
|
standardButtons: StandardButton.Ok
|
|
|
|
}
|
|
|
|
|
2020-10-20 15:32:03 +00:00
|
|
|
StatusEmojiSuggestionPopup {
|
2020-09-29 09:06:57 +00:00
|
|
|
id: emojiSuggestions
|
2021-12-08 21:20:43 +00:00
|
|
|
messageInput: messageInput
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
2021-10-01 15:58:36 +00:00
|
|
|
SuggestionBoxPanel {
|
2020-10-20 17:38:48 +00:00
|
|
|
id: suggestionsBox
|
2021-12-08 21:20:43 +00:00
|
|
|
// Not Refactored Yet
|
2021-12-13 14:24:21 +00:00
|
|
|
// model: {
|
2021-12-08 21:20:43 +00:00
|
|
|
// if (RootStore.chatsModelInst.communities.activeCommunity.active) {
|
|
|
|
// return RootStore.chatsModelInst.communities.activeCommunity.members
|
2021-12-13 14:24:21 +00:00
|
|
|
// }
|
2021-12-08 21:20:43 +00:00
|
|
|
// return RootStore.chatsModelInst.messageView.messageList.userList
|
2021-12-13 14:24:21 +00:00
|
|
|
// }
|
2020-10-20 17:38:48 +00:00
|
|
|
x : messageInput.x
|
|
|
|
y: -height - Style.current.smallPadding
|
|
|
|
width: messageInput.width
|
|
|
|
filter: messageInputField.text
|
|
|
|
cursorPosition: messageInputField.cursorPosition
|
2021-08-24 09:10:26 +00:00
|
|
|
property: ["userName", "localName", "alias"]
|
2020-10-20 17:38:48 +00:00
|
|
|
onItemSelected: function (item, lastAtPosition, lastCursorPosition) {
|
2021-08-24 09:10:26 +00:00
|
|
|
const properties = "userName, alias"; // Ignore localName
|
2021-02-08 17:51:31 +00:00
|
|
|
let aliasName = item[properties.split(",").map(p => p.trim()).find(p => !!item[p])]
|
2021-08-25 12:21:48 +00:00
|
|
|
aliasName = aliasName.replace("@", "")
|
2020-11-18 16:57:02 +00:00
|
|
|
aliasName = aliasName.replace(/(\.stateofus)?\.eth/, "")
|
2021-05-06 20:29:22 +00:00
|
|
|
|
2021-08-25 12:21:48 +00:00
|
|
|
insertMention(aliasName, lastAtPosition, lastCursorPosition)
|
2020-10-20 17:38:48 +00:00
|
|
|
suggestionsBox.suggestionsModel.clear()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-28 09:45:21 +00:00
|
|
|
ChatCommandsPopup {
|
2020-09-29 09:06:57 +00:00
|
|
|
id: chatCommandsPopup
|
|
|
|
x: 8
|
|
|
|
y: -height
|
|
|
|
onSendTransactionCommandButtonClicked: {
|
|
|
|
control.sendTransactionCommandButtonClicked()
|
|
|
|
chatCommandsPopup.close()
|
|
|
|
}
|
|
|
|
onReceiveTransactionCommandButtonClicked: {
|
|
|
|
control.receiveTransactionCommandButtonClicked()
|
|
|
|
chatCommandsPopup.close()
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
chatCommandsBtn.highlighted = false
|
|
|
|
}
|
2021-09-27 10:31:40 +00:00
|
|
|
onOpened: {
|
|
|
|
chatCommandsBtn.highlighted = true
|
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
StatusGifPopup {
|
|
|
|
id: gifPopup
|
|
|
|
width: 360
|
|
|
|
height: 440
|
|
|
|
x: parent.width - width - Style.current.halfPadding
|
|
|
|
y: -height
|
|
|
|
gifSelected: function (event, url) {
|
|
|
|
messageInputField.text = url
|
|
|
|
control.sendMessage(event)
|
|
|
|
gifBtn.highlighted = false
|
|
|
|
messageInputField.forceActiveFocus();
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
gifBtn.highlighted = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
StatusEmojiPopup {
|
|
|
|
id: emojiPopup
|
|
|
|
width: 360
|
|
|
|
height: 440
|
|
|
|
x: parent.width - width - Style.current.halfPadding
|
|
|
|
y: -height
|
|
|
|
emojiSelected: function (text, atCursor) {
|
|
|
|
insertInTextInput(atCursor ? messageInputField.cursorPosition : messageInputField.length, text)
|
|
|
|
emojiBtn.highlighted = false
|
|
|
|
messageInputField.forceActiveFocus();
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
emojiBtn.highlighted = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusStickersPopup {
|
|
|
|
id: stickersPopup
|
|
|
|
x: parent.width - width - Style.current.halfPadding
|
|
|
|
y: -height
|
2020-12-04 12:14:18 +00:00
|
|
|
enabled: !!control.recentStickers && !!control.stickerPackList
|
2020-09-29 09:06:57 +00:00
|
|
|
recentStickers: control.recentStickers
|
|
|
|
stickerPackList: control.stickerPackList
|
|
|
|
onStickerSelected: {
|
|
|
|
control.stickerSelected(hashId, packId)
|
2021-08-17 13:28:10 +00:00
|
|
|
control.hideExtendedArea();
|
2020-09-29 09:06:57 +00:00
|
|
|
messageInputField.forceActiveFocus();
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
stickersBtn.highlighted = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 10:34:16 +00:00
|
|
|
StatusQ.StatusFlatRoundButton {
|
2020-09-29 09:06:57 +00:00
|
|
|
id: chatCommandsBtn
|
2021-10-18 10:34:16 +00:00
|
|
|
width: 32
|
|
|
|
height: 32
|
2020-09-29 09:06:57 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 4
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 16
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "chat-commands"
|
|
|
|
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
2021-12-09 12:53:40 +00:00
|
|
|
visible: !isEdit && control.chatType === Constants.chatType.oneToOne && !control.isStatusUpdateInput
|
2021-08-09 11:11:04 +00:00
|
|
|
enabled: !control.isContactBlocked
|
2020-09-29 09:06:57 +00:00
|
|
|
onClicked: {
|
2021-09-27 10:31:40 +00:00
|
|
|
chatCommandsPopup.opened ?
|
|
|
|
chatCommandsPopup.close() :
|
|
|
|
chatCommandsPopup.open()
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 10:34:16 +00:00
|
|
|
StatusQ.StatusFlatRoundButton {
|
2020-09-29 09:06:57 +00:00
|
|
|
id: imageBtn
|
2021-10-18 10:34:16 +00:00
|
|
|
width: 32
|
|
|
|
height: 32
|
2020-09-29 09:06:57 +00:00
|
|
|
anchors.left: chatCommandsBtn.visible ? chatCommandsBtn.right : parent.left
|
|
|
|
anchors.leftMargin: chatCommandsBtn.visible ? 2 : 4
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: 16
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "image"
|
|
|
|
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
2021-12-09 12:53:40 +00:00
|
|
|
visible: !isEdit && control.chatType !== Constants.chatType.publicChat && !control.isStatusUpdateInput
|
2021-08-09 11:11:04 +00:00
|
|
|
enabled: !control.isContactBlocked
|
2020-09-29 09:06:57 +00:00
|
|
|
onClicked: {
|
|
|
|
highlighted = true
|
|
|
|
imageDialog.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: messageInput
|
2021-08-09 11:11:04 +00:00
|
|
|
enabled: !control.isContactBlocked
|
2021-12-01 12:46:21 +00:00
|
|
|
property int maxInputFieldHeight: control.isStatusUpdateInput ? 124 : 112
|
|
|
|
property int defaultInputFieldHeight: control.isStatusUpdateInput ? 56 : 40
|
2020-09-29 09:06:57 +00:00
|
|
|
anchors.left: imageBtn.visible ? imageBtn.right : parent.left
|
|
|
|
anchors.leftMargin: imageBtn.visible ? 5 : Style.current.smallPadding
|
2021-12-01 12:46:21 +00:00
|
|
|
anchors.top: control.isStatusUpdateInput ? parent.top : undefined
|
|
|
|
anchors.bottom: !control.isStatusUpdateInput ? parent.bottom : undefined
|
|
|
|
anchors.bottomMargin: control.isStatusUpdateInput ? 0 : 12
|
2021-08-09 11:11:04 +00:00
|
|
|
anchors.right: unblockBtn.visible ? unblockBtn.left : parent.right
|
2020-09-29 09:06:57 +00:00
|
|
|
anchors.rightMargin: Style.current.smallPadding
|
2021-03-24 10:11:56 +00:00
|
|
|
height: {
|
|
|
|
if (messageInputField.implicitHeight <= messageInput.defaultInputFieldHeight) {
|
|
|
|
return messageInput.defaultInputFieldHeight
|
|
|
|
}
|
|
|
|
if (messageInputField.implicitHeight >= messageInput.maxInputFieldHeight) {
|
|
|
|
return messageInput.maxInputFieldHeight
|
|
|
|
}
|
|
|
|
return messageInputField.implicitHeight
|
|
|
|
}
|
|
|
|
|
2021-07-28 11:08:32 +00:00
|
|
|
color: isEdit ? Theme.palette.statusChatInput.secondaryBackgroundColor : Style.current.inputBackground
|
2021-12-01 12:46:21 +00:00
|
|
|
radius: control.isStatusUpdateInput ? 36 :
|
|
|
|
height > defaultInputFieldHeight + 1 || extendedArea.visible ? 16 : 32
|
2021-07-13 07:34:13 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: validators
|
|
|
|
anchors.bottom: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Top ? extendedArea.top : undefined
|
|
|
|
anchors.bottomMargin: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Top ? -4 : undefined
|
|
|
|
anchors.top: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Bottom ? extendedArea.bottom : undefined
|
|
|
|
anchors.topMargin: control.imageErrorMessageLocation === StatusChatInput.ImageErrorMessageLocation.Bottom ? (isImage ? -4 : 4) : undefined
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: parent.width
|
|
|
|
z: 1
|
|
|
|
StatusChatImageExtensionValidator {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
}
|
|
|
|
StatusChatImageSizeValidator {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
}
|
|
|
|
StatusChatImageQtyValidator {
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
}
|
2021-03-10 04:59:01 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
Rectangle {
|
2020-12-04 11:11:49 +00:00
|
|
|
id: extendedArea
|
|
|
|
visible: isImage || isReply
|
|
|
|
height: {
|
2021-07-13 07:34:13 +00:00
|
|
|
if (visible) {
|
|
|
|
if (isImage) {
|
|
|
|
return imageArea.height
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isReply) {
|
|
|
|
return replyArea.height + replyArea.anchors.topMargin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0
|
2020-12-04 11:11:49 +00:00
|
|
|
}
|
|
|
|
anchors.left: messageInput.left
|
|
|
|
anchors.right: messageInput.right
|
2021-12-01 12:46:21 +00:00
|
|
|
anchors.bottom: control.isStatusUpdateInput ? undefined : messageInput.top
|
|
|
|
anchors.top: control.isStatusUpdateInput ? messageInput.bottom : undefined
|
|
|
|
anchors.topMargin: control.isStatusUpdateInput ? -Style.current.halfPadding : 0
|
2021-07-08 16:11:55 +00:00
|
|
|
color: isEdit ? Style.current.secondaryInputBackground : Style.current.inputBackground
|
2021-12-01 12:46:21 +00:00
|
|
|
radius: control.isStatusUpdateInput ? 36 : 16
|
2020-12-04 11:11:49 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: parent.color
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
2021-12-01 12:46:21 +00:00
|
|
|
height: control.isStatusUpdateInput ? 64 : 30
|
|
|
|
anchors.top: control.isStatusUpdateInput ? parent.top : undefined
|
|
|
|
anchors.topMargin: control.isStatusUpdateInput ? -24 : 0
|
|
|
|
anchors.bottom: control.isStatusUpdateInput ? undefined : parent.bottom
|
|
|
|
anchors.bottomMargin: control.isStatusUpdateInput ? 0 : -height/2
|
2020-12-04 11:11:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusChatInputImageArea {
|
|
|
|
id: imageArea
|
|
|
|
anchors.left: parent.left
|
2021-12-01 12:46:21 +00:00
|
|
|
anchors.leftMargin: control.isStatusUpdateInput ? profileImage.width + Style.current.padding : Style.current.halfPadding
|
2020-12-04 11:11:49 +00:00
|
|
|
anchors.right: parent.right
|
2021-12-01 12:46:21 +00:00
|
|
|
anchors.rightMargin: control.isStatusUpdateInput ? actions.width + 2* Style.current.padding : Style.current.halfPadding
|
2020-12-04 11:11:49 +00:00
|
|
|
anchors.top: parent.top
|
2021-07-13 07:34:13 +00:00
|
|
|
anchors.topMargin: Style.current.halfPadding
|
2020-12-04 11:11:49 +00:00
|
|
|
visible: isImage
|
2021-03-10 04:59:01 +00:00
|
|
|
width: messageInputField.width - actions.width
|
2020-12-04 11:11:49 +00:00
|
|
|
onImageRemoved: {
|
2021-03-10 04:59:01 +00:00
|
|
|
if (control.fileUrls.length > index && control.fileUrls[index]) {
|
|
|
|
control.fileUrls.splice(index, 1)
|
|
|
|
}
|
|
|
|
isImage = control.fileUrls.length > 0
|
|
|
|
validateImages(control.fileUrls)
|
2020-12-04 11:11:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusChatInputReplyArea {
|
|
|
|
id: replyArea
|
|
|
|
visible: isReply
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 2
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 2
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 2
|
2022-01-11 23:16:17 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// stickerData: sticker
|
2020-12-04 11:11:49 +00:00
|
|
|
onCloseButtonClicked: {
|
|
|
|
isReply = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-01 12:46:21 +00:00
|
|
|
StatusSmartIdenticon {
|
|
|
|
id: profileImage
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: Style.current.halfPadding
|
|
|
|
image.source: userProfile.icon
|
|
|
|
image.isIdenticon: userProfile.isIdenticon
|
|
|
|
visible: control.isStatusUpdateInput
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
ScrollView {
|
|
|
|
id: scrollView
|
2021-03-24 10:11:56 +00:00
|
|
|
anchors.top: parent.top
|
2020-09-29 09:06:57 +00:00
|
|
|
anchors.bottom: parent.bottom
|
2021-12-01 12:46:21 +00:00
|
|
|
anchors.left: profileImage.visible ? profileImage.right : parent.left
|
2020-09-29 09:06:57 +00:00
|
|
|
anchors.leftMargin: Style.current.smallPadding
|
|
|
|
anchors.right: actions.left
|
2020-12-04 11:11:49 +00:00
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
2020-09-29 09:06:57 +00:00
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
TextArea {
|
|
|
|
id: messageInputField
|
2021-07-23 09:53:43 +00:00
|
|
|
property var lastClick: 0
|
2020-09-29 09:06:57 +00:00
|
|
|
textFormat: Text.RichText
|
|
|
|
font.pixelSize: 15
|
|
|
|
font.family: Style.current.fontRegular.name
|
|
|
|
wrapMode: TextArea.Wrap
|
2021-08-09 11:11:04 +00:00
|
|
|
placeholderText: control.chatInputPlaceholder
|
2020-09-29 09:06:57 +00:00
|
|
|
placeholderTextColor: Style.current.secondaryText
|
|
|
|
selectByMouse: true
|
2021-07-28 11:08:32 +00:00
|
|
|
color: isEdit ? Theme.palette.directColor1 : Style.current.textColor
|
2021-12-01 12:46:21 +00:00
|
|
|
topPadding: control.isStatusUpdateInput ? 18 : Style.current.smallPadding
|
|
|
|
bottomPadding: control.isStatusUpdateInput ? 14 : 12
|
2020-11-18 17:14:29 +00:00
|
|
|
Keys.onPressed: onKeyPress(event)
|
2020-09-29 09:06:57 +00:00
|
|
|
Keys.onReleased: onRelease(event) // gives much more up to date cursorPosition
|
2020-11-17 03:07:01 +00:00
|
|
|
Keys.onShortcutOverride: event.accepted = isUploadFilePressed(event)
|
2020-09-29 09:06:57 +00:00
|
|
|
leftPadding: 0
|
2021-01-22 19:44:01 +00:00
|
|
|
selectionColor: Style.current.primarySelectionColor
|
2021-02-11 15:50:59 +00:00
|
|
|
persistentSelection: true
|
2021-07-09 16:11:17 +00:00
|
|
|
onTextChanged: {
|
|
|
|
var symbols = ":='xX><0O;*dB8-D#%\\";
|
2021-08-17 11:10:59 +00:00
|
|
|
if ((length > 1) && (symbols.indexOf(getText((cursorPosition - 2), (cursorPosition - 1))) !== -1)
|
|
|
|
&& (!getText((cursorPosition - 7), cursorPosition).includes("http"))) {
|
2021-07-09 16:11:17 +00:00
|
|
|
const emojis = EmojiJSON.emoji_json.filter(function (emoji) {
|
|
|
|
if (emoji.aliases_ascii.includes(getText((cursorPosition - 2), cursorPosition)) ||
|
|
|
|
emoji.aliases_ascii.includes(getText((cursorPosition - 3), cursorPosition))) {
|
|
|
|
var has2Chars = emoji.aliases_ascii.includes(getText((cursorPosition - 2), cursorPosition));
|
|
|
|
replaceWithEmoji("", getText(cursorPosition - (has2Chars ? 2 : 3), cursorPosition), emoji.unicode);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-11 15:50:59 +00:00
|
|
|
onReleased: function (event) {
|
2021-04-01 20:00:30 +00:00
|
|
|
const now = Date.now()
|
2021-02-11 15:50:59 +00:00
|
|
|
if (messageInputField.selectedText.trim() !== "") {
|
2021-04-01 20:00:30 +00:00
|
|
|
// If it's a double click, just check the mouse position
|
|
|
|
// If it's a mouse select, use the start and end position average)
|
|
|
|
let x = now < messageInputField.lastClick + 500 ? x = event.x :
|
2021-07-13 07:34:13 +00:00
|
|
|
(messageInputField.cursorRectangle.x + event.x) / 2
|
2021-04-01 20:00:30 +00:00
|
|
|
x -= textFormatMenu.width / 2
|
|
|
|
|
2021-02-11 15:50:59 +00:00
|
|
|
textFormatMenu.popup(x, -messageInputField.height-2)
|
2021-02-15 12:45:08 +00:00
|
|
|
messageInputField.forceActiveFocus();
|
2021-02-11 15:50:59 +00:00
|
|
|
}
|
2021-04-01 20:00:30 +00:00
|
|
|
lastClick = now
|
2021-02-11 15:50:59 +00:00
|
|
|
}
|
|
|
|
|
2021-08-19 13:45:43 +00:00
|
|
|
StatusSyntaxHighlighter {
|
|
|
|
quickTextDocument: messageInputField.textDocument
|
|
|
|
}
|
|
|
|
|
2021-02-11 15:50:59 +00:00
|
|
|
StatusTextFormatMenu {
|
|
|
|
id: textFormatMenu
|
2021-04-21 19:46:58 +00:00
|
|
|
|
2021-04-21 18:18:52 +00:00
|
|
|
StatusChatInputTextFormationAction {
|
|
|
|
wrapper: "**"
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "bold"
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Bold"
|
|
|
|
text: qsTrId("bold")
|
2022-01-11 23:16:17 +00:00
|
|
|
selectedTextWithFormationChars: RootStore.getSelectedTextWithFormationChars(messageInputField)
|
2021-12-08 21:20:43 +00:00
|
|
|
onActionTriggered: checked ?
|
|
|
|
unwrapSelection(wrapper, RootStore.getSelectedTextWithFormationChars(messageInputField)) :
|
|
|
|
wrapSelection(wrapper)
|
2021-02-11 15:50:59 +00:00
|
|
|
}
|
2021-04-21 18:18:52 +00:00
|
|
|
StatusChatInputTextFormationAction {
|
|
|
|
wrapper: "*"
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "italic"
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Italic"
|
|
|
|
text: qsTrId("italic")
|
2022-01-11 23:16:17 +00:00
|
|
|
selectedTextWithFormationChars: RootStore.getSelectedTextWithFormationChars(messageInputField)
|
2021-12-08 21:20:43 +00:00
|
|
|
checked: (surroundedBy("*") && !surroundedBy("**")) || surroundedBy("***")
|
|
|
|
onActionTriggered: checked ?
|
|
|
|
unwrapSelection(wrapper, RootStore.getSelectedTextWithFormationChars(messageInputField)) :
|
|
|
|
wrapSelection(wrapper)
|
2021-02-11 15:50:59 +00:00
|
|
|
}
|
2021-04-21 18:18:52 +00:00
|
|
|
StatusChatInputTextFormationAction {
|
|
|
|
wrapper: "~~"
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "strikethrough"
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Strikethrough"
|
|
|
|
text: qsTrId("strikethrough")
|
2022-01-11 23:16:17 +00:00
|
|
|
selectedTextWithFormationChars: RootStore.getSelectedTextWithFormationChars(messageInputField)
|
2021-12-08 21:20:43 +00:00
|
|
|
onActionTriggered: checked ?
|
|
|
|
unwrapSelection(wrapper, RootStore.getSelectedTextWithFormationChars(messageInputField)) :
|
|
|
|
wrapSelection(wrapper)
|
2021-02-11 15:50:59 +00:00
|
|
|
}
|
2021-04-21 18:18:52 +00:00
|
|
|
StatusChatInputTextFormationAction {
|
|
|
|
wrapper: "`"
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "code"
|
2021-02-18 16:36:05 +00:00
|
|
|
//% "Code"
|
|
|
|
text: qsTrId("code")
|
2022-01-11 23:16:17 +00:00
|
|
|
selectedTextWithFormationChars: RootStore.getSelectedTextWithFormationChars(messageInputField)
|
2021-12-08 21:20:43 +00:00
|
|
|
onActionTriggered: checked ?
|
|
|
|
unwrapSelection(wrapper, RootStore.getSelectedTextWithFormationChars(messageInputField)) :
|
|
|
|
wrapSelection(wrapper)
|
|
|
|
}
|
|
|
|
onClosed: {
|
|
|
|
messageInputField.deselect();
|
2021-02-11 15:50:59 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
2021-02-15 12:45:08 +00:00
|
|
|
|
|
|
|
Shortcut {
|
|
|
|
enabled: messageInputField.activeFocus
|
|
|
|
sequence: StandardKey.Bold
|
|
|
|
onActivated: wrapSelection("**")
|
2020-11-17 03:07:01 +00:00
|
|
|
}
|
2021-02-15 12:45:08 +00:00
|
|
|
Shortcut {
|
|
|
|
enabled: messageInputField.activeFocus
|
|
|
|
sequence: StandardKey.Italic
|
|
|
|
onActivated: wrapSelection("*")
|
2020-11-17 03:07:01 +00:00
|
|
|
}
|
2021-02-15 12:45:08 +00:00
|
|
|
Shortcut {
|
|
|
|
enabled: messageInputField.activeFocus
|
|
|
|
sequence: "Ctrl+Shift+Alt+C"
|
|
|
|
onActivated: wrapSelection("```")
|
2020-11-17 03:07:01 +00:00
|
|
|
}
|
2021-02-15 12:45:08 +00:00
|
|
|
Shortcut {
|
|
|
|
enabled: messageInputField.activeFocus
|
|
|
|
sequence: "Ctrl+Shift+C"
|
|
|
|
onActivated: wrapSelection("`")
|
2020-11-17 03:07:01 +00:00
|
|
|
}
|
2021-02-15 12:45:08 +00:00
|
|
|
Shortcut {
|
|
|
|
enabled: messageInputField.activeFocus
|
|
|
|
sequence: "Ctrl+Alt+-"
|
|
|
|
onActivated: wrapSelection("~~")
|
2020-11-17 03:07:01 +00:00
|
|
|
}
|
2021-02-15 12:45:08 +00:00
|
|
|
Shortcut {
|
|
|
|
enabled: messageInputField.activeFocus
|
|
|
|
sequence: "Ctrl+Shift+X"
|
|
|
|
onActivated: wrapSelection("~~")
|
2020-11-17 03:07:01 +00:00
|
|
|
}
|
2021-02-15 12:45:08 +00:00
|
|
|
Shortcut {
|
|
|
|
enabled: messageInputField.activeFocus
|
|
|
|
sequence: "Ctrl+Meta+Space"
|
|
|
|
onActivated: emojiBtn.clicked()
|
2020-11-17 03:07:01 +00:00
|
|
|
}
|
2021-02-15 12:45:08 +00:00
|
|
|
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: parent.color
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.right: parent.right
|
2021-12-01 12:46:21 +00:00
|
|
|
visible: !control.isStatusUpdateInput
|
2020-09-29 09:06:57 +00:00
|
|
|
height: parent.height / 2
|
|
|
|
width: 32
|
|
|
|
radius: Style.current.radius
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: messageLengthLimit
|
|
|
|
property int remainingChars: messageLimit - messageInputField.length
|
|
|
|
text: remainingChars.toString()
|
|
|
|
visible: remainingChars <= control.messageLimitVisible
|
|
|
|
color: (remainingChars <= 0) ? Style.current.danger : Style.current.textColor
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: actions.top
|
2021-12-01 12:46:21 +00:00
|
|
|
anchors.rightMargin: control.isStatusUpdateInput ? Style.current.padding : Style.current.radius
|
2020-09-29 09:06:57 +00:00
|
|
|
leftPadding: Style.current.halfPadding
|
|
|
|
rightPadding: Style.current.halfPadding
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: actions
|
2021-12-01 12:46:21 +00:00
|
|
|
width: control.isStatusUpdateInput ?
|
|
|
|
imageBtn2.width + sendBtn.anchors.leftMargin + sendBtn.width :
|
|
|
|
emojiBtn.width + stickersBtn.anchors.leftMargin + stickersBtn.width
|
|
|
|
anchors.bottom: control.isStatusUpdateInput && extendedArea.visible ? extendedArea.bottom : parent.bottom
|
|
|
|
anchors.bottomMargin: control.isStatusUpdateInput ? Style.current.smallPadding+2: 4
|
2020-09-29 09:06:57 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.radius
|
|
|
|
height: emojiBtn.height
|
|
|
|
|
2021-12-01 12:46:21 +00:00
|
|
|
StatusQ.StatusFlatRoundButton {
|
|
|
|
id: imageBtn2
|
|
|
|
implicitHeight: 32
|
|
|
|
implicitWidth: 32
|
|
|
|
anchors.right: sendBtn.left
|
|
|
|
anchors.rightMargin: 2
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
icon.name: "image"
|
|
|
|
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
|
|
|
visible: control.isStatusUpdateInput
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
highlighted = true
|
|
|
|
imageDialog.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusQ.StatusFlatButton {
|
|
|
|
id: sendBtn
|
|
|
|
icon.name: "send"
|
|
|
|
text: qsTr("Send")
|
|
|
|
size: StatusQ.StatusBaseButton.Size.Small
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
visible: imageBtn2.visible
|
2021-12-08 21:20:43 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// enabled: (RootStore.chatsModelInst.plainText(Emoji.deparse(messageInputField.text)).length > 0 || isImage) && messageInputField.length < messageLimit
|
2021-12-01 12:46:21 +00:00
|
|
|
onClicked: function (event) {
|
|
|
|
control.sendMessage(event)
|
|
|
|
control.hideExtendedArea();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 10:34:16 +00:00
|
|
|
StatusQ.StatusFlatRoundButton {
|
2020-09-29 09:06:57 +00:00
|
|
|
id: emojiBtn
|
2021-10-18 10:34:16 +00:00
|
|
|
implicitHeight: 32
|
|
|
|
implicitWidth: 32
|
2020-09-29 09:06:57 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.bottom: parent.bottom
|
2021-12-01 12:46:21 +00:00
|
|
|
visible: !imageBtn2.visible
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "emojis"
|
|
|
|
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
|
|
|
color: "transparent"
|
2021-07-21 08:26:31 +00:00
|
|
|
onClicked: togglePopup(emojiPopup, emojiBtn)
|
|
|
|
}
|
|
|
|
|
2021-10-18 10:34:16 +00:00
|
|
|
StatusQ.StatusFlatRoundButton {
|
2021-07-21 08:26:31 +00:00
|
|
|
id: gifBtn
|
2021-10-18 10:34:16 +00:00
|
|
|
implicitHeight: 32
|
|
|
|
implicitWidth: 32
|
2021-07-21 08:26:31 +00:00
|
|
|
anchors.right: emojiBtn.left
|
|
|
|
anchors.rightMargin: 2
|
|
|
|
anchors.bottom: parent.bottom
|
2021-12-08 21:20:43 +00:00
|
|
|
visible: !isEdit && RootStore.isGifWidgetEnabled
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "gif"
|
|
|
|
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
|
|
|
color: "transparent"
|
2021-08-02 07:11:28 +00:00
|
|
|
onClicked: togglePopup(gifPopup, gifBtn)
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 10:34:16 +00:00
|
|
|
StatusQ.StatusFlatRoundButton {
|
2020-09-29 09:06:57 +00:00
|
|
|
id: stickersBtn
|
2021-10-18 10:34:16 +00:00
|
|
|
implicitHeight: 32
|
|
|
|
implicitWidth: 32
|
|
|
|
width: visible ? 32 : 0
|
2020-09-29 09:06:57 +00:00
|
|
|
anchors.left: emojiBtn.right
|
|
|
|
anchors.leftMargin: 2
|
|
|
|
anchors.bottom: parent.bottom
|
2021-10-18 10:34:16 +00:00
|
|
|
icon.name: "stickers"
|
|
|
|
type: StatusQ.StatusFlatRoundButton.Type.Tertiary
|
2021-12-08 21:20:43 +00:00
|
|
|
visible: !isEdit && Global.networkGuarded && emojiBtn.visible
|
2021-10-18 10:34:16 +00:00
|
|
|
color: "transparent"
|
2021-07-21 08:26:31 +00:00
|
|
|
onClicked: togglePopup(stickersPopup, stickersBtn)
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-09 11:11:04 +00:00
|
|
|
|
2021-10-21 15:07:13 +00:00
|
|
|
StatusQ.StatusButton {
|
2021-08-09 11:11:04 +00:00
|
|
|
id: unblockBtn
|
|
|
|
visible: control.isContactBlocked
|
|
|
|
height: messageInput.height - Style.current.halfPadding
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: Style.current.halfPadding
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
anchors.bottomMargin: Style.current.padding
|
|
|
|
text: qsTr("Unblock")
|
2021-10-21 15:07:13 +00:00
|
|
|
type: StatusQ.StatusBaseButton.Type.Danger
|
2021-08-09 11:11:04 +00:00
|
|
|
onClicked: function (event) {
|
2021-12-08 21:20:43 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// RootStore.contactsModuleInst.unblockContact(RootStore.chatsModelInst.channelView.activeChannel.id)
|
2021-08-09 11:11:04 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-29 09:06:57 +00:00
|
|
|
}
|