2020-08-28 18:40:25 +03:00
|
|
|
/*
|
2020-10-19 20:34:47 +03:00
|
|
|
Copyright (C) 2020 Sebastian J. Wolf and other contributors
|
2020-08-28 18:40:25 +03:00
|
|
|
|
|
|
|
This file is part of Fernschreiber.
|
|
|
|
|
|
|
|
Fernschreiber is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Fernschreiber is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-10-31 22:49:03 +03:00
|
|
|
import QtQuick 2.6
|
2020-08-28 18:40:25 +03:00
|
|
|
import Sailfish.Silica 1.0
|
|
|
|
import "../components"
|
|
|
|
import "../js/functions.js" as Functions
|
|
|
|
import "../js/twemoji.js" as Emoji
|
|
|
|
|
|
|
|
Row {
|
|
|
|
id: inReplyToRow
|
|
|
|
spacing: Theme.paddingSmall
|
|
|
|
width: parent.width
|
2020-10-13 22:37:06 +03:00
|
|
|
height: inReplyToMessageColumn.height
|
2020-08-28 18:40:25 +03:00
|
|
|
|
2020-08-29 12:22:18 +03:00
|
|
|
property string myUserId;
|
2020-11-06 01:23:37 +03:00
|
|
|
property var inReplyToMessage;
|
2020-10-18 22:54:15 +03:00
|
|
|
property bool editable: false;
|
2021-02-10 00:35:19 +03:00
|
|
|
property bool inReplyToMessageDeleted: false;
|
2020-10-18 22:54:15 +03:00
|
|
|
|
|
|
|
signal clearRequested()
|
2020-08-28 18:40:25 +03:00
|
|
|
|
2020-08-29 12:22:18 +03:00
|
|
|
onInReplyToMessageChanged: {
|
2020-08-29 17:58:48 +03:00
|
|
|
if (inReplyToMessage) {
|
2022-01-07 21:18:04 +03:00
|
|
|
inReplyToUserText.text = (inReplyToMessage.sender_id["@type"] === "messageSenderChat" ? page.chatInformation.title : (inReplyToRow.inReplyToMessage.sender_id.user_id !== inReplyToRow.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(inReplyToRow.inReplyToMessage.sender_id.user_id)), inReplyToUserText.font.pixelSize) : qsTr("You"));
|
2020-12-29 18:32:39 +03:00
|
|
|
inReplyToMessageText.text = Emoji.emojify(Functions.getMessageText(inReplyToRow.inReplyToMessage, true, inReplyToRow.myUserId, false), inReplyToMessageText.font.pixelSize);
|
2020-08-28 18:40:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-10 00:35:19 +03:00
|
|
|
onInReplyToMessageDeletedChanged: {
|
|
|
|
if (inReplyToMessageDeleted) {
|
|
|
|
inReplyToUserText.text = qsTr("Unknown")
|
|
|
|
inReplyToMessageText.text = "<i>" + qsTr("This message was deleted") + "</i>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-28 18:40:25 +03:00
|
|
|
Rectangle {
|
|
|
|
id: inReplyToMessageRectangle
|
|
|
|
height: inReplyToMessageColumn.height
|
|
|
|
width: Theme.paddingSmall
|
|
|
|
color: Theme.secondaryHighlightColor
|
|
|
|
border.width: 0
|
|
|
|
}
|
|
|
|
|
2020-10-18 22:54:15 +03:00
|
|
|
Row {
|
2020-08-28 18:40:25 +03:00
|
|
|
width: parent.width - Theme.paddingSmall - inReplyToMessageRectangle.width
|
2020-10-18 22:54:15 +03:00
|
|
|
spacing: Theme.paddingSmall
|
2020-08-28 18:40:25 +03:00
|
|
|
|
2020-10-18 22:54:15 +03:00
|
|
|
Column {
|
|
|
|
id: inReplyToMessageColumn
|
|
|
|
spacing: Theme.paddingSmall
|
|
|
|
width: parent.width - ( inReplyToRow.editable ? ( Theme.paddingSmall + removeInReplyToIconButton.width ) : 0 )
|
|
|
|
|
2020-11-22 02:39:49 +03:00
|
|
|
Label {
|
2020-10-18 22:54:15 +03:00
|
|
|
id: inReplyToUserText
|
2020-08-28 18:40:25 +03:00
|
|
|
|
2020-10-18 22:54:15 +03:00
|
|
|
width: parent.width
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
font.weight: Font.ExtraBold
|
|
|
|
maximumLineCount: 1
|
2020-11-22 02:39:49 +03:00
|
|
|
truncationMode: TruncationMode.Fade
|
2020-10-18 22:54:15 +03:00
|
|
|
textFormat: Text.StyledText
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
}
|
|
|
|
|
2020-11-22 02:39:49 +03:00
|
|
|
Label {
|
2020-10-18 22:54:15 +03:00
|
|
|
id: inReplyToMessageText
|
|
|
|
font.pixelSize: Theme.fontSizeExtraSmall
|
|
|
|
width: parent.width
|
|
|
|
textFormat: Text.StyledText
|
2020-11-22 02:39:49 +03:00
|
|
|
truncationMode: TruncationMode.Fade
|
2020-12-01 23:17:13 +03:00
|
|
|
maximumLineCount: 1
|
2020-12-08 01:30:46 +03:00
|
|
|
linkColor: Theme.highlightColor
|
|
|
|
onLinkActivated: {
|
|
|
|
Functions.handleLink(link);
|
|
|
|
}
|
2020-08-28 18:40:25 +03:00
|
|
|
}
|
|
|
|
}
|
2020-10-18 22:54:15 +03:00
|
|
|
|
|
|
|
IconButton {
|
|
|
|
id: removeInReplyToIconButton
|
|
|
|
icon.source: "image://theme/icon-m-clear"
|
|
|
|
visible: inReplyToRow.editable
|
|
|
|
onClicked: {
|
|
|
|
inReplyToRow.clearRequested();
|
|
|
|
}
|
|
|
|
}
|
2020-08-28 18:40:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|