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