Display pinned message in chat
This commit is contained in:
parent
f6b42eb3cb
commit
15be3862f6
14 changed files with 215 additions and 3 deletions
|
@ -46,6 +46,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \
|
||||||
qml/components/LocationPreview.qml \
|
qml/components/LocationPreview.qml \
|
||||||
qml/components/MessageListViewItem.qml \
|
qml/components/MessageListViewItem.qml \
|
||||||
qml/components/MessageListViewItemSimple.qml \
|
qml/components/MessageListViewItemSimple.qml \
|
||||||
|
qml/components/PinnedMessageItem.qml \
|
||||||
qml/components/PollPreview.qml \
|
qml/components/PollPreview.qml \
|
||||||
qml/components/StickerPicker.qml \
|
qml/components/StickerPicker.qml \
|
||||||
qml/components/PhotoTextsListItem.qml \
|
qml/components/PhotoTextsListItem.qml \
|
||||||
|
|
120
qml/components/PinnedMessageItem.qml
Normal file
120
qml/components/PinnedMessageItem.qml
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2020 Sebastian J. Wolf and other contributors
|
||||||
|
|
||||||
|
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/>.
|
||||||
|
*/
|
||||||
|
import QtQuick 2.6
|
||||||
|
import Sailfish.Silica 1.0
|
||||||
|
import "../components"
|
||||||
|
import "../js/functions.js" as Functions
|
||||||
|
import "../js/twemoji.js" as Emoji
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: pinnedMessageItem
|
||||||
|
|
||||||
|
property var pinnedMessage;
|
||||||
|
|
||||||
|
onPinnedMessageChanged: {
|
||||||
|
if (pinnedMessage) {
|
||||||
|
console.log("[ChatPage] Activating pinned message");
|
||||||
|
pinnedMessageUserText.text = (pinnedMessage.sender_user_id !== chatPage.myUserId) ? Emoji.emojify(Functions.getUserName(tdLibWrapper.getUserInformation(pinnedMessage.sender_user_id)), pinnedMessageUserText.font.pixelSize) : qsTr("You");
|
||||||
|
pinnedMessageText.text = Emoji.emojify(Functions.getMessageText(pinnedMessage, true, pinnedMessage.sender_user_id === chatPage.myUserId), pinnedMessageText.font.pixelSize);
|
||||||
|
pinnedMessageItem.visible = true;
|
||||||
|
} else {
|
||||||
|
pinnedMessageItem.visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
visible: false
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
height: pinnedMessageRow.height
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: pinnedMessageBackground
|
||||||
|
anchors.fill: parent
|
||||||
|
opacity: 0.1
|
||||||
|
color: Theme.secondaryColor
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: pinnedMessageRow
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
IconButton {
|
||||||
|
id: pinnedMessageButton
|
||||||
|
width: Theme.itemSizeLarge
|
||||||
|
height: Theme.itemSizeLarge
|
||||||
|
icon.source: "image://theme/icon-m-mark-unread"
|
||||||
|
onClicked: {
|
||||||
|
console.log("Opening pinned message");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: pinnedMessageColumn
|
||||||
|
spacing: Theme.paddingSmall
|
||||||
|
width: parent.width - pinnedMessageButton.width - removePinnedMessageIconButton.width
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: pinnedMessageUserText
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
font.pixelSize: Theme.fontSizeExtraSmall
|
||||||
|
font.weight: Font.ExtraBold
|
||||||
|
color: Theme.primaryColor
|
||||||
|
maximumLineCount: 1
|
||||||
|
elide: Text.ElideRight
|
||||||
|
textFormat: Text.StyledText
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
console.log("Opening pinned message");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: pinnedMessageText
|
||||||
|
|
||||||
|
font.pixelSize: Theme.fontSizeExtraSmall
|
||||||
|
color: Theme.primaryColor
|
||||||
|
width: parent.width
|
||||||
|
elide: Text.ElideRight
|
||||||
|
maximumLineCount: 1
|
||||||
|
textFormat: Text.StyledText
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
console.log("Opening pinned message");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IconButton {
|
||||||
|
id: removePinnedMessageIconButton
|
||||||
|
icon.source: "image://theme/icon-m-clear"
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
onClicked: {
|
||||||
|
pinnedMessage = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -145,11 +145,15 @@ Page {
|
||||||
updateGroupStatusText();
|
updateGroupStatusText();
|
||||||
}
|
}
|
||||||
if (stickerManager.needsReload()) {
|
if (stickerManager.needsReload()) {
|
||||||
console.log("Stickers will be reloaded!");
|
console.log("[ChatPage] Stickers will be reloaded!");
|
||||||
tdLibWrapper.getRecentStickers();
|
tdLibWrapper.getRecentStickers();
|
||||||
tdLibWrapper.getInstalledStickerSets();
|
tdLibWrapper.getInstalledStickerSets();
|
||||||
stickerManager.setNeedsReload(false);
|
stickerManager.setNeedsReload(false);
|
||||||
}
|
}
|
||||||
|
if (chatInformation.pinned_message_id.toString() !== "0") {
|
||||||
|
console.log("[ChatPage] Loading pinned message " + chatInformation.pinned_message_id);
|
||||||
|
tdLibWrapper.getMessage(chatInformation.id, chatInformation.pinned_message_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMessageStatusText(message, listItemIndex, lastReadSentIndex, useElapsed) {
|
function getMessageStatusText(message, listItemIndex, lastReadSentIndex, useElapsed) {
|
||||||
|
@ -359,6 +363,12 @@ Page {
|
||||||
onErrorReceived: {
|
onErrorReceived: {
|
||||||
Functions.handleErrorMessage(code, message);
|
Functions.handleErrorMessage(code, message);
|
||||||
}
|
}
|
||||||
|
onReceivedMessage: {
|
||||||
|
if (messageId === chatInformation.pinned_message_id.toString()) {
|
||||||
|
console.log("[ChatPage] Received pinned message");
|
||||||
|
pinnedMessageItem.pinnedMessage = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
@ -535,6 +545,7 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: chatColumn
|
id: chatColumn
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -589,10 +600,14 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PinnedMessageItem {
|
||||||
|
id: pinnedMessageItem
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: chatViewItem
|
id: chatViewItem
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height - headerRow.height - newMessageColumn.height - selectedMessagesActions.height
|
height: parent.height - headerRow.height - ( pinnedMessageItem.visible ? pinnedMessageItem.height : 0 ) - newMessageColumn.height - selectedMessagesActions.height
|
||||||
|
|
||||||
property int previousHeight;
|
property int previousHeight;
|
||||||
|
|
||||||
|
@ -1256,7 +1271,6 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -897,6 +897,13 @@
|
||||||
<translation>Sie haben noch keine Chats.</translation>
|
<translation>Sie haben noch keine Chats.</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">Sie</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -897,6 +897,13 @@
|
||||||
<translation>You don't have any chats yet.</translation>
|
<translation>You don't have any chats yet.</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">You</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -893,6 +893,13 @@
|
||||||
<translation>No hay todavía ninguna charla.</translation>
|
<translation>No hay todavía ninguna charla.</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">Usted</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -898,6 +898,13 @@
|
||||||
<translation>Sinulla ei ole vielä keskusteluja.</translation>
|
<translation>Sinulla ei ole vielä keskusteluja.</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">Sinä</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -893,6 +893,13 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">Te</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -897,6 +897,13 @@
|
||||||
<translation>Carica lista chat...</translation>
|
<translation>Carica lista chat...</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">Tu</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -901,6 +901,13 @@
|
||||||
<translation>Nie masz jeszcze żadnych czatów.</translation>
|
<translation>Nie masz jeszcze żadnych czatów.</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">Ty</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -901,6 +901,13 @@
|
||||||
<translation>Тут пока ничего нет</translation>
|
<translation>Тут пока ничего нет</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">Вы</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -897,6 +897,13 @@
|
||||||
<translation>Du har inga chattar än.</translation>
|
<translation>Du har inga chattar än.</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">Du</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -893,6 +893,13 @@
|
||||||
<translation>你还没有任何对话。</translation>
|
<translation>你还没有任何对话。</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished">你</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
|
@ -893,6 +893,13 @@
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>PinnedMessageItem</name>
|
||||||
|
<message>
|
||||||
|
<source>You</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
<message>
|
<message>
|
||||||
|
|
Loading…
Reference in a new issue