diff --git a/harbour-fernschreiber.pro b/harbour-fernschreiber.pro
index f72d480..0c3a283 100644
--- a/harbour-fernschreiber.pro
+++ b/harbour-fernschreiber.pro
@@ -46,6 +46,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \
qml/components/LocationPreview.qml \
qml/components/MessageListViewItem.qml \
qml/components/MessageListViewItemSimple.qml \
+ qml/components/PinnedMessageItem.qml \
qml/components/PollPreview.qml \
qml/components/StickerPicker.qml \
qml/components/PhotoTextsListItem.qml \
diff --git a/qml/components/PinnedMessageItem.qml b/qml/components/PinnedMessageItem.qml
new file mode 100644
index 0000000..542e091
--- /dev/null
+++ b/qml/components/PinnedMessageItem.qml
@@ -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 .
+*/
+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;
+ }
+ }
+ }
+}
diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml
index 3232227..93ccf56 100644
--- a/qml/pages/ChatPage.qml
+++ b/qml/pages/ChatPage.qml
@@ -145,11 +145,15 @@ Page {
updateGroupStatusText();
}
if (stickerManager.needsReload()) {
- console.log("Stickers will be reloaded!");
+ console.log("[ChatPage] Stickers will be reloaded!");
tdLibWrapper.getRecentStickers();
tdLibWrapper.getInstalledStickerSets();
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) {
@@ -359,6 +363,12 @@ Page {
onErrorReceived: {
Functions.handleErrorMessage(code, message);
}
+ onReceivedMessage: {
+ if (messageId === chatInformation.pinned_message_id.toString()) {
+ console.log("[ChatPage] Received pinned message");
+ pinnedMessageItem.pinnedMessage = message;
+ }
+ }
}
Connections {
@@ -535,6 +545,7 @@ Page {
}
}
}
+
Column {
id: chatColumn
width: parent.width
@@ -589,10 +600,14 @@ Page {
}
}
+ PinnedMessageItem {
+ id: pinnedMessageItem
+ }
+
Item {
id: chatViewItem
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;
@@ -1256,7 +1271,6 @@ Page {
}
}
}
-
}
}
diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts
index 413c482..bc09134 100644
--- a/translations/harbour-fernschreiber-de.ts
+++ b/translations/harbour-fernschreiber-de.ts
@@ -897,6 +897,13 @@
Sie haben noch keine Chats.
+
+ PinnedMessageItem
+
+
+ Sie
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts
index f99c38d..f38d398 100644
--- a/translations/harbour-fernschreiber-en.ts
+++ b/translations/harbour-fernschreiber-en.ts
@@ -897,6 +897,13 @@
You don't have any chats yet.
+
+ PinnedMessageItem
+
+
+ You
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts
index b8e0b40..5565c05 100644
--- a/translations/harbour-fernschreiber-es.ts
+++ b/translations/harbour-fernschreiber-es.ts
@@ -893,6 +893,13 @@
No hay todavía ninguna charla.
+
+ PinnedMessageItem
+
+
+ Usted
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts
index fa067be..44f9ecb 100644
--- a/translations/harbour-fernschreiber-fi.ts
+++ b/translations/harbour-fernschreiber-fi.ts
@@ -898,6 +898,13 @@
Sinulla ei ole vielä keskusteluja.
+
+ PinnedMessageItem
+
+
+ Sinä
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts
index be6c998..a378d47 100644
--- a/translations/harbour-fernschreiber-hu.ts
+++ b/translations/harbour-fernschreiber-hu.ts
@@ -893,6 +893,13 @@
+
+ PinnedMessageItem
+
+
+ Te
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts
index 64e6d4f..6bbd72a 100644
--- a/translations/harbour-fernschreiber-it.ts
+++ b/translations/harbour-fernschreiber-it.ts
@@ -897,6 +897,13 @@
Carica lista chat...
+
+ PinnedMessageItem
+
+
+ Tu
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts
index 61e474e..c084f44 100644
--- a/translations/harbour-fernschreiber-pl.ts
+++ b/translations/harbour-fernschreiber-pl.ts
@@ -901,6 +901,13 @@
Nie masz jeszcze żadnych czatów.
+
+ PinnedMessageItem
+
+
+ Ty
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts
index 2872909..1cd53b4 100644
--- a/translations/harbour-fernschreiber-ru.ts
+++ b/translations/harbour-fernschreiber-ru.ts
@@ -901,6 +901,13 @@
Тут пока ничего нет
+
+ PinnedMessageItem
+
+
+ Вы
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts
index 8379e51..e7cd308 100644
--- a/translations/harbour-fernschreiber-sv.ts
+++ b/translations/harbour-fernschreiber-sv.ts
@@ -897,6 +897,13 @@
Du har inga chattar än.
+
+ PinnedMessageItem
+
+
+ Du
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts
index 05c9911..0e2ee11 100644
--- a/translations/harbour-fernschreiber-zh_CN.ts
+++ b/translations/harbour-fernschreiber-zh_CN.ts
@@ -893,6 +893,13 @@
你还没有任何对话。
+
+ PinnedMessageItem
+
+
+ 你
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts
index 4996468..46ab50b 100644
--- a/translations/harbour-fernschreiber.ts
+++ b/translations/harbour-fernschreiber.ts
@@ -893,6 +893,13 @@
+
+ PinnedMessageItem
+
+
+
+
+
PollCreationPage