2021-04-13 20:01:49 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2021-04-15 18:44:58 +03:00
|
|
|
import "./delegates/"
|
2021-04-13 20:01:49 +03:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.3
|
|
|
|
import im.nheko 1.0
|
|
|
|
|
2021-04-15 18:44:58 +03:00
|
|
|
Dialog {
|
2021-04-13 20:01:49 +03:00
|
|
|
id: forwardMessagePopup
|
2021-04-15 18:44:58 +03:00
|
|
|
title: qsTr("Forward Message")
|
2021-04-13 20:01:49 +03:00
|
|
|
x: 400
|
|
|
|
y: 400
|
|
|
|
|
|
|
|
width: 200
|
2021-04-15 18:44:58 +03:00
|
|
|
height: replyPreview.height + roomTextInput.height + completerPopup.height + implicitFooterHeight + implicitHeaderHeight
|
2021-04-13 20:01:49 +03:00
|
|
|
|
|
|
|
property var mid
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
completerPopup.open();
|
|
|
|
roomTextInput.forceActiveFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
completerPopup.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
function setMessageEventId(mid_in) {
|
|
|
|
mid = mid_in;
|
|
|
|
}
|
|
|
|
|
2021-04-15 18:44:58 +03:00
|
|
|
Reply {
|
|
|
|
id: replyPreview
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: parent.top
|
|
|
|
modelData: TimelineManager.timeline ? TimelineManager.timeline.getDump(mid, "") : {
|
|
|
|
}
|
|
|
|
userColor: TimelineManager.userColor(modelData.userId, colors.window)
|
|
|
|
}
|
|
|
|
|
2021-04-13 20:01:49 +03:00
|
|
|
MatrixTextField {
|
|
|
|
id: roomTextInput
|
|
|
|
|
|
|
|
width: forwardMessagePopup.width - forwardMessagePopup.leftPadding * 2
|
|
|
|
|
2021-04-15 18:44:58 +03:00
|
|
|
anchors.top: replyPreview.bottom
|
|
|
|
|
2021-04-13 20:01:49 +03:00
|
|
|
color: colors.text
|
|
|
|
onTextEdited: {
|
|
|
|
completerPopup.completer.searchString = text;
|
|
|
|
}
|
|
|
|
Keys.onPressed: {
|
|
|
|
if (event.key == Qt.Key_Up && completerPopup.opened) {
|
|
|
|
event.accepted = true;
|
|
|
|
completerPopup.up();
|
|
|
|
} else if (event.key == Qt.Key_Down && completerPopup.opened) {
|
|
|
|
event.accepted = true;
|
|
|
|
completerPopup.down();
|
|
|
|
} else if (event.matches(StandardKey.InsertParagraphSeparator)) {
|
|
|
|
completerPopup.finishCompletion();
|
|
|
|
event.accepted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Completer {
|
|
|
|
id: completerPopup
|
|
|
|
|
2021-04-15 18:44:58 +03:00
|
|
|
y: replyPreview.height + roomTextInput.height + roomTextInput.bottomPadding
|
|
|
|
|
2021-04-13 20:01:49 +03:00
|
|
|
width: forwardMessagePopup.width - forwardMessagePopup.leftPadding * 2
|
|
|
|
completerName: "room"
|
|
|
|
avatarHeight: 24
|
|
|
|
avatarWidth: 24
|
|
|
|
bottomToTop: false
|
|
|
|
closePolicy: Popup.NoAutoClose
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
onCompletionSelected: {
|
|
|
|
TimelineManager.timeline.forwardMessage(messageContextMenu.eventId, id);
|
|
|
|
forwardMessagePopup.close();
|
|
|
|
}
|
|
|
|
onCountChanged: {
|
|
|
|
if (completerPopup.count > 0 && (completerPopup.currentIndex < 0 || completerPopup.currentIndex >= completerPopup.count))
|
|
|
|
completerPopup.currentIndex = 0;
|
|
|
|
}
|
|
|
|
target: completerPopup
|
|
|
|
}
|
|
|
|
}
|