2023-02-21 23:48:49 +01:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2021-03-14 02:45:20 +01:00
|
|
|
//
|
2021-03-05 00:35:15 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-07-15 20:37:52 +02:00
|
|
|
import "./emoji"
|
2020-12-30 21:03:07 +01:00
|
|
|
import "./voip"
|
2023-02-25 17:03:30 +01:00
|
|
|
import "./ui"
|
2021-02-21 02:11:50 +01:00
|
|
|
import QtQuick 2.12
|
2020-10-26 14:57:54 +01:00
|
|
|
import QtQuick.Controls 2.3
|
2021-01-12 15:03:39 +01:00
|
|
|
import QtQuick.Layouts 1.2
|
2021-08-04 02:27:50 +02:00
|
|
|
import QtQuick.Window 2.13
|
2020-10-31 23:24:07 +01:00
|
|
|
import im.nheko 1.0
|
|
|
|
|
2020-10-26 14:57:54 +01:00
|
|
|
Rectangle {
|
2021-02-21 02:11:50 +01:00
|
|
|
id: inputBar
|
|
|
|
|
2023-06-02 01:45:24 +02:00
|
|
|
property bool showAllButtons: width > 450 || (messageInput.length == 0 && !messageInput.inputMethodComposing)
|
2023-02-24 03:57:53 +01:00
|
|
|
readonly property string text: messageInput.text
|
|
|
|
|
2020-10-26 14:57:54 +01:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.minimumHeight: 40
|
2023-06-02 01:45:24 +02:00
|
|
|
Layout.preferredHeight: row.implicitHeight
|
|
|
|
color: palette.window
|
2020-10-26 14:57:54 +01:00
|
|
|
|
2020-12-18 18:49:24 +01:00
|
|
|
Component {
|
|
|
|
id: placeCallDialog
|
|
|
|
|
|
|
|
PlaceCall {
|
|
|
|
}
|
|
|
|
}
|
2022-03-10 20:42:12 +01:00
|
|
|
Component {
|
|
|
|
id: screenShareDialog
|
|
|
|
|
|
|
|
ScreenShare {
|
|
|
|
}
|
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
RowLayout {
|
2021-02-21 02:11:50 +01:00
|
|
|
id: row
|
2020-10-26 14:57:54 +01:00
|
|
|
|
|
|
|
anchors.fill: parent
|
2022-02-14 22:56:35 +01:00
|
|
|
spacing: 0
|
2023-06-02 01:45:24 +02:00
|
|
|
visible: room ? room.permissions.canSend(MtxEvent.TextMessage) : false
|
2020-10-26 14:57:54 +01:00
|
|
|
|
|
|
|
ImageButton {
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
2023-06-02 01:45:24 +02:00
|
|
|
Layout.margins: 8
|
|
|
|
ToolTip.text: CallManager.isOnCall ? qsTr("Hang up") : (CallManager.isOnCallOnOtherDevice ? qsTr("Already on a call") : qsTr("Place a call"))
|
|
|
|
ToolTip.visible: hovered
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredHeight: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
hoverEnabled: true
|
2021-11-14 02:23:10 +01:00
|
|
|
image: CallManager.isOnCall ? ":/icons/icons/ui/end-call.svg" : ":/icons/icons/ui/place-call.svg"
|
2023-06-02 01:45:24 +02:00
|
|
|
opacity: (CallManager.haveCallInvite || CallManager.isOnCallOnOtherDevice) ? 0.3 : 1
|
|
|
|
visible: CallManager.callsSupported && showAllButtons
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredWidth: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
|
2020-12-18 18:49:24 +01:00
|
|
|
onClicked: {
|
2021-05-28 22:14:59 +02:00
|
|
|
if (room) {
|
2020-12-18 18:49:24 +01:00
|
|
|
if (CallManager.haveCallInvite) {
|
2023-06-02 01:45:24 +02:00
|
|
|
return;
|
2021-01-11 23:51:39 +01:00
|
|
|
} else if (CallManager.isOnCall) {
|
2020-12-18 18:49:24 +01:00
|
|
|
CallManager.hangUp();
|
2023-06-02 01:45:24 +02:00
|
|
|
} else if (CallManager.isOnCallOnOtherDevice) {
|
2022-10-14 15:49:05 +02:00
|
|
|
return;
|
2023-06-02 01:45:24 +02:00
|
|
|
} else {
|
2020-12-18 18:49:24 +01:00
|
|
|
var dialog = placeCallDialog.createObject(timelineRoot);
|
2020-12-30 21:03:07 +01:00
|
|
|
dialog.open();
|
2022-02-21 05:01:01 +01:00
|
|
|
timelineRoot.destroyOnClose(dialog);
|
2020-12-18 18:49:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
ImageButton {
|
|
|
|
Layout.alignment: Qt.AlignBottom
|
2023-06-02 01:45:24 +02:00
|
|
|
Layout.margins: 8
|
|
|
|
ToolTip.text: qsTr("Send a file")
|
|
|
|
ToolTip.visible: hovered
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredHeight: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
hoverEnabled: true
|
2021-11-14 02:23:10 +01:00
|
|
|
image: ":/icons/icons/ui/attach.svg"
|
2023-06-02 01:45:24 +02:00
|
|
|
visible: showAllButtons
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredWidth: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
|
2021-05-28 22:14:59 +02:00
|
|
|
onClicked: room.input.openFileSelection()
|
2020-11-15 04:52:49 +01:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
2023-06-02 01:29:05 +02:00
|
|
|
color: palette.window
|
2021-05-28 22:14:59 +02:00
|
|
|
visible: room && room.input.uploading
|
2020-11-15 04:52:49 +01:00
|
|
|
|
2023-02-25 17:03:30 +01:00
|
|
|
Spinner {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
height: parent.height / 2
|
2020-11-15 04:52:49 +01:00
|
|
|
running: parent.visible
|
|
|
|
}
|
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
2021-02-21 02:11:50 +01:00
|
|
|
ScrollView {
|
2020-10-26 14:57:54 +01:00
|
|
|
id: textInput
|
|
|
|
|
2021-12-12 00:03:00 +01:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-06-02 01:45:24 +02:00
|
|
|
Layout.fillWidth: true
|
2020-10-26 14:57:54 +01:00
|
|
|
Layout.maximumHeight: Window.height / 4
|
2022-02-14 22:56:35 +01:00
|
|
|
Layout.minimumHeight: fontMetrics.lineSpacing
|
|
|
|
Layout.preferredHeight: contentHeight
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
contentWidth: availableWidth
|
2020-10-26 14:57:54 +01:00
|
|
|
|
|
|
|
TextArea {
|
2021-01-25 16:17:14 +01:00
|
|
|
id: messageInput
|
2020-10-31 23:24:07 +01:00
|
|
|
|
2021-08-21 06:01:10 +02:00
|
|
|
property int completerTriggeredAt: 0
|
2023-06-02 01:45:24 +02:00
|
|
|
property string lastChar
|
2020-11-20 01:22:36 +01:00
|
|
|
|
2020-11-24 17:32:45 +01:00
|
|
|
function insertCompletion(completion) {
|
2021-01-25 16:17:14 +01:00
|
|
|
messageInput.remove(completerTriggeredAt, cursorPosition);
|
|
|
|
messageInput.insert(cursorPosition, completion);
|
2020-11-24 17:32:45 +01:00
|
|
|
}
|
2020-11-25 19:03:22 +01:00
|
|
|
function openCompleter(pos, type) {
|
2023-06-02 01:45:24 +02:00
|
|
|
if (popup.opened)
|
|
|
|
return;
|
2020-11-25 19:03:22 +01:00
|
|
|
completerTriggeredAt = pos;
|
2022-02-21 04:06:49 +01:00
|
|
|
completer.completerName = type;
|
2020-11-25 19:03:22 +01:00
|
|
|
popup.open();
|
2023-06-02 01:45:24 +02:00
|
|
|
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition) + messageInput.preeditText);
|
2020-11-25 19:03:22 +01:00
|
|
|
}
|
2021-04-15 23:21:50 +02:00
|
|
|
function positionCursorAtEnd() {
|
|
|
|
cursorPosition = messageInput.length;
|
|
|
|
}
|
|
|
|
function positionCursorAtStart() {
|
|
|
|
cursorPosition = 0;
|
|
|
|
}
|
|
|
|
|
2023-06-02 01:45:24 +02:00
|
|
|
background: null
|
|
|
|
bottomPadding: 8
|
|
|
|
color: palette.text
|
|
|
|
focus: true
|
|
|
|
leftPadding: inputBar.showAllButtons ? 0 : 8
|
|
|
|
padding: 0
|
2020-10-26 14:57:54 +01:00
|
|
|
placeholderText: qsTr("Write a message...")
|
2023-06-02 01:29:05 +02:00
|
|
|
placeholderTextColor: palette.buttonText
|
2023-06-02 01:45:24 +02:00
|
|
|
selectByMouse: true
|
|
|
|
topPadding: 8
|
2021-12-12 00:03:00 +01:00
|
|
|
verticalAlignment: TextEdit.AlignVCenter
|
2023-06-02 01:45:24 +02:00
|
|
|
width: textInput.width
|
2020-10-26 14:57:54 +01:00
|
|
|
wrapMode: TextEdit.Wrap
|
2021-08-28 00:38:33 +02:00
|
|
|
|
2023-06-02 01:45:24 +02:00
|
|
|
Keys.onPressed: event => {
|
2020-10-31 23:24:07 +01:00
|
|
|
if (event.matches(StandardKey.Paste)) {
|
2022-06-13 13:16:49 +02:00
|
|
|
event.accepted = room.input.tryPasteAttachment(false);
|
2021-01-27 19:19:21 +01:00
|
|
|
} else if (event.key == Qt.Key_Space) {
|
2021-02-05 17:22:49 +01:00
|
|
|
// close popup if user enters space after colon
|
2021-02-10 14:32:16 +01:00
|
|
|
if (cursorPosition == completerTriggeredAt + 1)
|
2021-02-05 17:22:49 +01:00
|
|
|
popup.close();
|
2022-03-01 01:59:06 +01:00
|
|
|
if (popup.opened && completer.count <= 0)
|
2021-01-27 19:36:53 +01:00
|
|
|
popup.close();
|
2020-11-20 01:22:36 +01:00
|
|
|
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_U) {
|
2021-01-25 16:17:14 +01:00
|
|
|
messageInput.clear();
|
2020-11-20 01:22:36 +01:00
|
|
|
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_P) {
|
2021-05-28 22:14:59 +02:00
|
|
|
messageInput.text = room.input.previousText();
|
2020-11-20 01:22:36 +01:00
|
|
|
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) {
|
2021-05-28 22:14:59 +02:00
|
|
|
messageInput.text = room.input.nextText();
|
2020-11-20 01:22:36 +01:00
|
|
|
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
2022-02-21 04:06:49 +01:00
|
|
|
completer.completerName = "";
|
2021-08-21 05:29:27 +02:00
|
|
|
popup.close();
|
2020-11-20 01:22:36 +01:00
|
|
|
event.accepted = true;
|
2021-08-21 05:29:27 +02:00
|
|
|
} else if (event.matches(StandardKey.SelectAll) && popup.opened) {
|
2022-02-21 04:06:49 +01:00
|
|
|
completer.completerName = "";
|
2020-11-20 01:22:36 +01:00
|
|
|
popup.close();
|
2022-03-01 01:59:06 +01:00
|
|
|
} else if (event.matches(StandardKey.InsertLineSeparator)) {
|
2023-06-02 01:45:24 +02:00
|
|
|
if (popup.opened)
|
|
|
|
popup.close();
|
2022-12-29 00:51:30 +01:00
|
|
|
if (Settings.invertEnterKey && (!Qt.inputMethod.visible || Qt.platform.os === "windows")) {
|
2022-11-04 23:42:35 +01:00
|
|
|
room.input.send();
|
|
|
|
event.accepted = true;
|
|
|
|
}
|
2020-11-25 02:20:42 +01:00
|
|
|
} else if (event.matches(StandardKey.InsertParagraphSeparator)) {
|
|
|
|
if (popup.opened) {
|
2022-02-21 04:06:49 +01:00
|
|
|
var currentCompletion = completer.currentCompletion();
|
|
|
|
completer.completerName = "";
|
2020-11-25 02:20:42 +01:00
|
|
|
popup.close();
|
|
|
|
if (currentCompletion) {
|
2021-01-25 16:17:14 +01:00
|
|
|
messageInput.insertCompletion(currentCompletion);
|
2020-11-25 02:20:42 +01:00
|
|
|
event.accepted = true;
|
2022-03-01 01:59:06 +01:00
|
|
|
return;
|
2020-11-25 02:20:42 +01:00
|
|
|
}
|
2020-11-20 01:22:36 +01:00
|
|
|
}
|
2022-12-29 00:51:30 +01:00
|
|
|
if (!Settings.invertEnterKey && (!Qt.inputMethod.visible || Qt.platform.os === "windows")) {
|
2022-03-20 22:17:25 +01:00
|
|
|
room.input.send();
|
|
|
|
event.accepted = true;
|
|
|
|
}
|
2022-01-09 00:28:03 +01:00
|
|
|
} else if (event.key == Qt.Key_Tab && (event.modifiers == Qt.NoModifier || event.modifiers == Qt.ShiftModifier)) {
|
2020-11-20 01:22:36 +01:00
|
|
|
event.accepted = true;
|
2020-11-25 19:03:22 +01:00
|
|
|
if (popup.opened) {
|
2021-08-28 00:38:33 +02:00
|
|
|
if (event.modifiers & Qt.ShiftModifier)
|
2022-02-21 04:06:49 +01:00
|
|
|
completer.down();
|
2021-08-28 00:38:33 +02:00
|
|
|
else
|
2022-02-21 04:06:49 +01:00
|
|
|
completer.up();
|
2020-11-25 19:03:22 +01:00
|
|
|
} else {
|
|
|
|
var pos = cursorPosition - 1;
|
|
|
|
while (pos > -1) {
|
2021-01-25 16:17:14 +01:00
|
|
|
var t = messageInput.getText(pos, pos + 1);
|
2020-11-25 19:03:22 +01:00
|
|
|
console.log('"' + t + '"');
|
2021-01-27 20:26:54 +01:00
|
|
|
if (t == '@') {
|
2021-01-25 16:17:14 +01:00
|
|
|
messageInput.openCompleter(pos, "user");
|
2023-06-02 01:45:24 +02:00
|
|
|
return;
|
2021-01-27 20:26:54 +01:00
|
|
|
} else if (t == ' ' || t == '\t') {
|
|
|
|
messageInput.openCompleter(pos + 1, "user");
|
2023-06-02 01:45:24 +02:00
|
|
|
return;
|
2020-11-25 19:03:22 +01:00
|
|
|
} else if (t == ':') {
|
2021-01-25 16:17:14 +01:00
|
|
|
messageInput.openCompleter(pos, "emoji");
|
2023-06-02 01:45:24 +02:00
|
|
|
return;
|
2021-12-27 06:23:36 +01:00
|
|
|
} else if (t == '~') {
|
|
|
|
messageInput.openCompleter(pos, "customEmoji");
|
2023-06-02 01:45:24 +02:00
|
|
|
return;
|
2020-11-25 19:03:22 +01:00
|
|
|
}
|
|
|
|
pos = pos - 1;
|
|
|
|
}
|
|
|
|
// At start of input
|
2021-01-25 16:17:14 +01:00
|
|
|
messageInput.openCompleter(0, "user");
|
2020-11-25 19:03:22 +01:00
|
|
|
}
|
2020-11-20 01:22:36 +01:00
|
|
|
} else if (event.key == Qt.Key_Up && popup.opened) {
|
|
|
|
event.accepted = true;
|
2022-02-21 04:06:49 +01:00
|
|
|
completer.up();
|
2021-08-22 18:02:26 +02:00
|
|
|
} else if ((event.key == Qt.Key_Down || event.key == Qt.Key_Backtab) && popup.opened) {
|
2020-11-20 01:22:36 +01:00
|
|
|
event.accepted = true;
|
2022-02-21 04:06:49 +01:00
|
|
|
completer.down();
|
2021-02-25 14:54:50 +01:00
|
|
|
} else if (event.key == Qt.Key_Up && event.modifiers == Qt.NoModifier) {
|
2021-02-24 23:51:05 +01:00
|
|
|
if (cursorPosition == 0) {
|
|
|
|
event.accepted = true;
|
2021-05-28 22:14:59 +02:00
|
|
|
var idx = room.edit ? room.idToIndex(room.edit) + 1 : 0;
|
2021-02-24 23:51:05 +01:00
|
|
|
while (true) {
|
2021-05-28 22:14:59 +02:00
|
|
|
var id = room.indexToId(idx);
|
|
|
|
if (!id || room.getDump(id, "").isEditable) {
|
|
|
|
room.edit = id;
|
2021-02-24 23:51:05 +01:00
|
|
|
cursorPosition = 0;
|
2021-04-15 23:21:50 +02:00
|
|
|
Qt.callLater(positionCursorAtEnd);
|
2021-02-24 23:51:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
idx++;
|
|
|
|
}
|
2022-06-13 09:22:09 +02:00
|
|
|
} else if (positionAt(0, cursorRectangle.y + cursorRectangle.height / 2) === 0) {
|
2021-02-24 23:51:05 +01:00
|
|
|
event.accepted = true;
|
2021-04-15 23:21:50 +02:00
|
|
|
positionCursorAtStart();
|
2021-02-24 23:51:05 +01:00
|
|
|
}
|
2021-02-25 14:54:50 +01:00
|
|
|
} else if (event.key == Qt.Key_Down && event.modifiers == Qt.NoModifier) {
|
2021-05-28 22:14:59 +02:00
|
|
|
if (cursorPosition == messageInput.length && room.edit) {
|
2021-02-24 23:51:05 +01:00
|
|
|
event.accepted = true;
|
2021-05-28 22:14:59 +02:00
|
|
|
var idx = room.idToIndex(room.edit) - 1;
|
2021-02-24 23:51:05 +01:00
|
|
|
while (true) {
|
2021-05-28 22:14:59 +02:00
|
|
|
var id = room.indexToId(idx);
|
|
|
|
if (!id || room.getDump(id, "").isEditable) {
|
|
|
|
room.edit = id;
|
2021-04-15 23:21:50 +02:00
|
|
|
Qt.callLater(positionCursorAtStart);
|
2021-02-24 23:51:05 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
idx--;
|
|
|
|
}
|
2022-06-13 09:22:09 +02:00
|
|
|
} else if (positionAt(width, cursorRectangle.y + cursorRectangle.height / 2) === messageInput.length) {
|
2021-04-15 23:21:50 +02:00
|
|
|
event.accepted = true;
|
|
|
|
positionCursorAtEnd();
|
2021-02-24 23:51:05 +01:00
|
|
|
}
|
2020-11-20 01:22:36 +01:00
|
|
|
}
|
|
|
|
}
|
2023-06-02 01:45:24 +02:00
|
|
|
// Ensure that we get escape key press events first.
|
|
|
|
Keys.onShortcutOverride: event => event.accepted = (popup.opened && (event.key === Qt.Key_Escape || event.key === Qt.Key_Tab || event.key === Qt.Key_Enter || event.key === Qt.Key_Space))
|
|
|
|
onCursorPositionChanged: {
|
|
|
|
if (!room)
|
|
|
|
return;
|
|
|
|
room.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
|
|
|
|
if (popup.opened && cursorPosition <= completerTriggeredAt)
|
|
|
|
popup.close();
|
|
|
|
if (popup.opened)
|
|
|
|
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition) + messageInput.preeditText);
|
|
|
|
}
|
|
|
|
onPreeditTextChanged: {
|
|
|
|
if (popup.opened)
|
|
|
|
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition) + messageInput.preeditText);
|
|
|
|
}
|
|
|
|
onSelectionEndChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
|
|
|
|
onSelectionStartChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
|
|
|
|
onTextChanged: {
|
|
|
|
if (room)
|
|
|
|
room.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
|
|
|
|
forceActiveFocus();
|
|
|
|
if (cursorPosition > 0)
|
|
|
|
lastChar = text.charAt(cursorPosition - 1);
|
|
|
|
else
|
|
|
|
lastChar = '';
|
|
|
|
if (lastChar == '@') {
|
|
|
|
messageInput.openCompleter(selectionStart - 1, "user");
|
|
|
|
} else if (lastChar == ':') {
|
|
|
|
messageInput.openCompleter(selectionStart - 1, "emoji");
|
|
|
|
} else if (lastChar == '#') {
|
|
|
|
messageInput.openCompleter(selectionStart - 1, "roomAliases");
|
|
|
|
} else if (lastChar == "/" && cursorPosition == 1) {
|
|
|
|
messageInput.openCompleter(selectionStart - 1, "command");
|
|
|
|
}
|
|
|
|
}
|
2020-11-20 01:22:36 +01:00
|
|
|
|
2020-11-20 02:38:08 +01:00
|
|
|
Connections {
|
2021-07-27 22:35:38 +02:00
|
|
|
function onRoomChanged() {
|
2021-01-25 16:17:14 +01:00
|
|
|
messageInput.clear();
|
2021-07-27 22:35:38 +02:00
|
|
|
if (room)
|
2021-09-02 03:15:07 +02:00
|
|
|
messageInput.append(room.input.text);
|
2022-02-21 04:06:49 +01:00
|
|
|
completer.completerName = "";
|
2021-01-25 16:17:14 +01:00
|
|
|
messageInput.forceActiveFocus();
|
2020-11-20 02:38:08 +01:00
|
|
|
}
|
2021-07-27 22:35:38 +02:00
|
|
|
|
2021-05-28 22:14:59 +02:00
|
|
|
target: timelineView
|
2020-11-20 02:38:08 +01:00
|
|
|
}
|
2020-11-24 17:32:45 +01:00
|
|
|
Connections {
|
2021-07-27 22:35:38 +02:00
|
|
|
function onCompletionClicked(completion) {
|
|
|
|
messageInput.insertCompletion(completion);
|
|
|
|
}
|
|
|
|
|
2022-02-21 04:06:49 +01:00
|
|
|
target: completer
|
2020-11-24 17:32:45 +01:00
|
|
|
}
|
2022-02-21 04:06:49 +01:00
|
|
|
Popup {
|
2020-11-20 01:22:36 +01:00
|
|
|
id: popup
|
|
|
|
|
2022-02-21 04:06:49 +01:00
|
|
|
background: null
|
2022-03-01 01:59:06 +01:00
|
|
|
padding: 0
|
2023-06-02 01:45:24 +02:00
|
|
|
x: messageInput.positionToRectangle(messageInput.completerTriggeredAt).x
|
|
|
|
y: messageInput.positionToRectangle(messageInput.completerTriggeredAt).y - height
|
2022-02-21 04:06:49 +01:00
|
|
|
|
|
|
|
enter: Transition {
|
|
|
|
NumberAnimation {
|
2023-06-02 01:45:24 +02:00
|
|
|
duration: 100
|
2022-02-21 04:06:49 +01:00
|
|
|
from: 0
|
2023-06-02 01:45:24 +02:00
|
|
|
property: "opacity"
|
2022-02-21 04:06:49 +01:00
|
|
|
to: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit: Transition {
|
|
|
|
NumberAnimation {
|
2023-06-02 01:45:24 +02:00
|
|
|
duration: 100
|
2022-02-21 04:06:49 +01:00
|
|
|
from: 1
|
2023-06-02 01:45:24 +02:00
|
|
|
property: "opacity"
|
2022-02-21 04:06:49 +01:00
|
|
|
to: 0
|
|
|
|
}
|
|
|
|
}
|
2020-11-15 04:52:49 +01:00
|
|
|
|
2023-06-02 01:45:24 +02:00
|
|
|
Completer {
|
|
|
|
id: completer
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
rowMargin: 2
|
|
|
|
rowSpacing: 0
|
|
|
|
}
|
|
|
|
}
|
2020-11-15 04:52:49 +01:00
|
|
|
Connections {
|
2021-07-27 22:35:38 +02:00
|
|
|
function onTextChanged(newText) {
|
2021-02-01 02:22:53 +01:00
|
|
|
messageInput.text = newText;
|
|
|
|
messageInput.cursorPosition = newText.length;
|
|
|
|
}
|
2021-07-27 22:35:38 +02:00
|
|
|
|
|
|
|
ignoreUnknownSignals: true
|
2021-05-28 22:14:59 +02:00
|
|
|
target: room ? room.input : null
|
2020-10-31 23:24:07 +01:00
|
|
|
}
|
2021-01-25 16:17:14 +01:00
|
|
|
Connections {
|
2023-06-02 01:45:24 +02:00
|
|
|
function onEditChanged() {
|
2021-07-27 22:35:38 +02:00
|
|
|
messageInput.forceActiveFocus();
|
|
|
|
}
|
2023-06-02 01:45:24 +02:00
|
|
|
function onReplyChanged() {
|
2021-07-27 22:35:38 +02:00
|
|
|
messageInput.forceActiveFocus();
|
|
|
|
}
|
2022-09-30 03:27:05 +02:00
|
|
|
function onThreadChanged() {
|
|
|
|
messageInput.forceActiveFocus();
|
|
|
|
}
|
|
|
|
|
2021-01-25 16:17:14 +01:00
|
|
|
ignoreUnknownSignals: true
|
2021-05-28 22:14:59 +02:00
|
|
|
target: room
|
2021-01-25 16:17:14 +01:00
|
|
|
}
|
2021-02-05 18:12:08 +01:00
|
|
|
Connections {
|
2021-07-27 22:35:38 +02:00
|
|
|
function onFocusInput() {
|
|
|
|
messageInput.forceActiveFocus();
|
|
|
|
}
|
|
|
|
|
2021-02-05 18:12:08 +01:00
|
|
|
target: TimelineManager
|
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
MouseArea {
|
2023-06-02 01:45:24 +02:00
|
|
|
acceptedButtons: Qt.MiddleButton
|
2020-10-26 14:57:54 +01:00
|
|
|
// workaround for wrong cursor shape on some platforms
|
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.IBeamCursor
|
2021-02-03 03:12:08 +01:00
|
|
|
|
2023-06-02 01:45:24 +02:00
|
|
|
onPressed: mouse => mouse.accepted = room.input.tryPasteAttachment(true)
|
|
|
|
}
|
2021-01-17 04:05:02 +01:00
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
2021-07-15 20:37:52 +02:00
|
|
|
ImageButton {
|
|
|
|
id: stickerButton
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
|
|
|
Layout.margins: 8
|
2023-06-02 01:45:24 +02:00
|
|
|
ToolTip.text: qsTr("Stickers")
|
|
|
|
ToolTip.visible: hovered
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredHeight: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
hoverEnabled: true
|
2021-07-15 20:37:52 +02:00
|
|
|
image: ":/icons/icons/ui/sticky-note-solid.svg"
|
2023-06-02 01:45:24 +02:00
|
|
|
visible: showAllButtons
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredWidth: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
|
|
|
|
onClicked: stickerPopup.visible ? stickerPopup.close() : stickerPopup.show(stickerButton, room.roomId, function (row) {
|
|
|
|
room.input.sticker(row);
|
|
|
|
TimelineManager.focusMessageInput();
|
|
|
|
})
|
2021-07-15 20:37:52 +02:00
|
|
|
|
|
|
|
StickerPicker {
|
|
|
|
id: stickerPopup
|
|
|
|
|
2023-05-25 19:07:13 +02:00
|
|
|
emoji: false
|
2021-07-15 20:37:52 +02:00
|
|
|
}
|
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
ImageButton {
|
2020-11-16 18:41:29 +01:00
|
|
|
id: emojiButton
|
|
|
|
|
2020-10-26 14:57:54 +01:00
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
2021-02-21 02:11:50 +01:00
|
|
|
Layout.margins: 8
|
2023-06-02 01:45:24 +02:00
|
|
|
ToolTip.text: qsTr("Emoji")
|
|
|
|
ToolTip.visible: hovered
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredHeight: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
hoverEnabled: true
|
2021-11-14 02:23:10 +01:00
|
|
|
image: ":/icons/icons/ui/smile.svg"
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredWidth: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
|
|
|
|
onClicked: emojiPopup.visible ? emojiPopup.close() : emojiPopup.show(emojiButton, room.roomId, function (plaintext, markdown) {
|
|
|
|
messageInput.insert(messageInput.cursorPosition, markdown);
|
|
|
|
TimelineManager.focusMessageInput();
|
|
|
|
})
|
2023-05-25 19:07:13 +02:00
|
|
|
|
|
|
|
StickerPicker {
|
2023-05-25 19:20:25 +02:00
|
|
|
id: emojiPopup
|
2023-05-25 19:07:13 +02:00
|
|
|
|
|
|
|
emoji: true
|
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
ImageButton {
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
|
2021-02-21 02:11:50 +01:00
|
|
|
Layout.margins: 8
|
2022-03-19 22:30:35 +01:00
|
|
|
Layout.rightMargin: 8
|
2020-11-15 23:14:47 +01:00
|
|
|
ToolTip.text: qsTr("Send")
|
2023-06-02 01:45:24 +02:00
|
|
|
ToolTip.visible: hovered
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredHeight: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
hoverEnabled: true
|
|
|
|
image: ":/icons/icons/ui/send.svg"
|
2023-10-26 16:43:09 +02:00
|
|
|
Layout.preferredWidth: 22
|
2023-06-02 01:45:24 +02:00
|
|
|
|
2020-11-15 04:52:49 +01:00
|
|
|
onClicked: {
|
2021-05-28 22:14:59 +02:00
|
|
|
room.input.send();
|
2020-11-15 04:52:49 +01:00
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|
|
|
|
}
|
2023-07-08 22:55:44 +02:00
|
|
|
Label {
|
2021-05-02 18:01:18 +02:00
|
|
|
anchors.centerIn: parent
|
2023-07-08 22:55:44 +02:00
|
|
|
color: palette.placeholderText
|
2021-05-02 18:01:18 +02:00
|
|
|
text: qsTr("You don't have permission to send messages in this room")
|
2023-06-02 01:45:24 +02:00
|
|
|
visible: room ? (!room.permissions.canSend(MtxEvent.TextMessage)) : false
|
2021-05-02 18:01:18 +02:00
|
|
|
}
|
2020-10-26 14:57:54 +01:00
|
|
|
}
|