diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml
index 3e2b5fd..f30454b 100644
--- a/qml/components/MessageListViewItem.qml
+++ b/qml/components/MessageListViewItem.qml
@@ -102,34 +102,11 @@ ListItem {
text: qsTr("Select Message")
}
MenuItem {
-
- function amIVisible() {
- console.log("Is pin message menu visible?");
- if (page.isPrivateChat) {
- console.log("Private Chat: No!");
- return false;
- }
- if (page.chatGroupInformation.status["@type"] === "chatMemberStatusCreator") {
- console.log("Creator of this chat: Yes!");
- return true;
- }
- if (page.chatInformation.permissions.can_pin_messages) {
- console.log("All people can pin: Yes!");
- return true;
- }
- if (page.chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator") {
- console.log("Admin with privileges? " + page.chatGroupInformation.status.can_pin_messages);
- return page.chatGroupInformation.status.can_pin_messages;
- }
- console.log("Something else: No!");
- return false;
- }
-
onClicked: {
tdLibWrapper.pinMessage(page.chatInformation.id, myMessage.id);
}
text: qsTr("Pin Message")
- visible: amIVisible()
+ visible: canPinMessages()
}
MenuItem {
onClicked: {
diff --git a/qml/components/MessageOverlayFlickable.qml b/qml/components/MessageOverlayFlickable.qml
index 3197121..c70f8a1 100644
--- a/qml/components/MessageOverlayFlickable.qml
+++ b/qml/components/MessageOverlayFlickable.qml
@@ -38,14 +38,15 @@ Flickable {
signal requestClose;
function getOriginalAuthor(forwardInformation, fontSize) {
- if (forwardInformation.origin["@type"] === "messageForwardOriginChannel") {
- var otherChatInformation = tdLibWrapper.getChat(forwardInformation.origin.chat_id);
- return Emoji.emojify(otherChatInformation.title, fontSize);
- } else if (forwardInformation.origin["@type"] === "messageForwardOriginUser") {
- var otherUserInformation = tdLibWrapper.getUserInformation(forwardInformation.origin.sender_user_id);
- return Emoji.emojify(Functions.getUserName(otherUserInformation), fontSize);
- } else {
- return Emoji.emojify(forwardInformation.origin.sender_name, fontSize);
+ switch (forwardInformation.origin["@type"]) {
+ case "messageForwardOriginChannel":
+ var otherChatInformation = tdLibWrapper.getChat(forwardInformation.origin.chat_id);
+ return Emoji.emojify(otherChatInformation.title, fontSize);
+ case "messageForwardOriginUser":
+ var otherUserInformation = tdLibWrapper.getUserInformation(forwardInformation.origin.sender_user_id);
+ return Emoji.emojify(Functions.getUserName(otherUserInformation), fontSize);
+ default:
+ return Emoji.emojify(forwardInformation.origin.sender_name, fontSize);
}
}
@@ -77,7 +78,8 @@ Flickable {
Rectangle {
id: messageContentBackground
- color: (Theme.colorScheme === Theme.LightOnDark) ? Theme.darkSecondaryColor : Theme.lightSecondaryColor
+ color: Theme.overlayBackgroundColor
+ opacity: 0.7
width: parent.width
height: messageContentColumn.height >= messageOverlayFlickable.height ? messageContentColumn.height : messageOverlayFlickable.height
MouseArea {
diff --git a/qml/components/PinnedMessageItem.qml b/qml/components/PinnedMessageItem.qml
index 64f042a..9040a8a 100644
--- a/qml/components/PinnedMessageItem.qml
+++ b/qml/components/PinnedMessageItem.qml
@@ -27,6 +27,7 @@ Item {
property var pinnedMessage;
signal requestShowMessage;
+ signal requestCloseMessage;
onPinnedMessageChanged: {
if (pinnedMessage) {
@@ -43,7 +44,7 @@ Item {
visible: false
anchors.left: parent.left
anchors.right: parent.right
- height: pinnedMessageRow.height
+ height: visible ? pinnedMessageRow.height : 0
Rectangle {
id: pinnedMessageBackground
@@ -68,7 +69,7 @@ Item {
}
Item {
- width: parent.width - pinnedMessageButton.width - removePinnedMessageIconButton.width
+ width: parent.width - pinnedMessageButton.width - unpinMessageIconLoader.width - removePinnedMessageIconButton.width
height: pinnedMessageColumn.height
anchors.verticalCenter: parent.verticalCenter
Column {
@@ -108,11 +109,33 @@ Item {
}
}
+ Loader {
+ id: unpinMessageIconLoader
+ asynchronous: true
+ active: canPinMessages()
+ Behavior on opacity { FadeAnimation {} }
+ width: active ? item.width : 0
+ height: active ? item.height : 0
+ anchors.verticalCenter: parent.verticalCenter
+ sourceComponent: Component {
+ IconButton {
+ id: unpinMessageIconButton
+ icon.source: "image://theme/icon-m-remove"
+ onClicked: {
+ Remorse.itemAction(pinnedMessageRow, qsTr("Message unpinned"), function() { tdLibWrapper.unpinMessage(chatPage.chatInformation.id);
+ pinnedMessageItem.requestCloseMessage(); });
+
+ }
+ }
+ }
+ }
+
IconButton {
id: removePinnedMessageIconButton
icon.source: "image://theme/icon-m-clear"
anchors.verticalCenter: parent.verticalCenter
onClicked: {
+ pinnedMessageItem.requestCloseMessage();
pinnedMessage = undefined;
}
}
diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml
index dca402a..1e85c51 100644
--- a/qml/pages/ChatPage.qml
+++ b/qml/pages/ChatPage.qml
@@ -17,6 +17,7 @@
along with Fernschreiber. If not, see .
*/
import QtQuick 2.6
+import QtGraphicalEffects 1.0
import Sailfish.Silica 1.0
import Sailfish.Pickers 1.0
import Nemo.Thumbnailer 1.0
@@ -282,6 +283,31 @@ Page {
|| groupStatusType === "chatMemberStatusCreator"
|| (groupStatusType === "chatMemberStatusRestricted" && groupStatus.permissions[privilege])
}
+ function canPinMessages() {
+ console.log("Can we pin messages?");
+ if (chatPage.isPrivateChat) {
+ console.log("Private Chat: No!");
+ return false;
+ }
+ if (chatPage.chatGroupInformation.status["@type"] === "chatMemberStatusCreator") {
+ console.log("Creator of this chat: Yes!");
+ return true;
+ }
+ if (chatPage.chatInformation.permissions.can_pin_messages) {
+ console.log("All people can pin: Yes!");
+ return true;
+ }
+ if (chatPage.chatGroupInformation.status["@type"] === "chatMemberStatusAdministrator") {
+ console.log("Admin with privileges? " + chatPage.chatGroupInformation.status.can_pin_messages);
+ return chatPage.chatGroupInformation.status.can_pin_messages;
+ }
+ if (chatPage.chatGroupInformation.status["@type"] === "chatMemberStatusRestricted") {
+ console.log("Restricted, but can pin messages? " + chatPage.chatGroupInformation.status.permissions.can_pin_messages);
+ return chatPage.chatGroupInformation.status.permissions.can_pin_messages;
+ }
+ console.log("Something else: No!");
+ return false;
+ }
Timer {
id: forwardMessagesTimer
@@ -613,14 +639,18 @@ Page {
id: pinnedMessageItem
onRequestShowMessage: {
messageOverlayLoader.overlayMessage = pinnedMessageItem.pinnedMessage;
- messageOverlayLoader.active = !messageOverlayLoader.active;
+ messageOverlayLoader.active = true;
+ }
+ onRequestCloseMessage: {
+ messageOverlayLoader.overlayMessage = undefined;
+ messageOverlayLoader.active = false;
}
}
Item {
id: chatViewItem
width: parent.width
- height: parent.height - headerRow.height - ( pinnedMessageItem.visible ? pinnedMessageItem.height : 0 ) - newMessageColumn.height - selectedMessagesActions.height
+ height: parent.height - headerRow.height - pinnedMessageItem.height - newMessageColumn.height - selectedMessagesActions.height
property int previousHeight;
@@ -645,10 +675,24 @@ Page {
}
}
+ Loader {
+ asynchronous: true
+ active: chatView.blurred
+ anchors.fill: chatView
+ sourceComponent: Component {
+ FastBlur {
+ source: chatView
+ radius: Theme.paddingLarge
+ }
+ }
+ }
SilicaListView {
id: chatView
+ visible: !blurred
+ property bool blurred: messageOverlayLoader.item
+
anchors.fill: parent
opacity: chatPage.loading ? 0 : 1
Behavior on opacity { FadeAnimation {} }
@@ -1208,6 +1252,7 @@ Page {
}
}
}
+
Loader {
id: selectedMessagesActions
asynchronous: true
diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp
index 800bef2..293dbfa 100644
--- a/src/tdlibwrapper.cpp
+++ b/src/tdlibwrapper.cpp
@@ -303,6 +303,15 @@ void TDLibWrapper::pinMessage(const QString &chatId, const QString &messageId, b
this->sendRequest(requestObject);
}
+void TDLibWrapper::unpinMessage(const QString &chatId)
+{
+ LOG("Unpin message from chat" << chatId);
+ QVariantMap requestObject;
+ requestObject.insert(_TYPE, "unpinChatMessage");
+ requestObject.insert("chat_id", chatId);
+ this->sendRequest(requestObject);
+}
+
void TDLibWrapper::sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId)
{
LOG("Sending text message" << chatId << message << replyToMessageId);
diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h
index fc6ad80..0f02595 100644
--- a/src/tdlibwrapper.h
+++ b/src/tdlibwrapper.h
@@ -123,6 +123,7 @@ public:
Q_INVOKABLE void getChatHistory(qlonglong chatId, const qlonglong &fromMessageId = 0, int offset = 0, int limit = 50, bool onlyLocal = false);
Q_INVOKABLE void viewMessage(const QString &chatId, const QString &messageId, bool force);
Q_INVOKABLE void pinMessage(const QString &chatId, const QString &messageId, bool disableNotification = false);
+ Q_INVOKABLE void unpinMessage(const QString &chatId);
Q_INVOKABLE void sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendPhotoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendVideoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts
index c5e6cb3..df94a10 100644
--- a/translations/harbour-fernschreiber-de.ts
+++ b/translations/harbour-fernschreiber-de.ts
@@ -922,6 +922,10 @@
Angeheftete Nachricht
+
+
+ Nachricht losgeheftet
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts
index 3a0487b..c8b04f9 100644
--- a/translations/harbour-fernschreiber-en.ts
+++ b/translations/harbour-fernschreiber-en.ts
@@ -922,6 +922,10 @@
+
+
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts
index 7bc6d35..bf46684 100644
--- a/translations/harbour-fernschreiber-es.ts
+++ b/translations/harbour-fernschreiber-es.ts
@@ -918,6 +918,10 @@
+
+
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts
index 5ec3674..4aea0ae 100644
--- a/translations/harbour-fernschreiber-fi.ts
+++ b/translations/harbour-fernschreiber-fi.ts
@@ -923,6 +923,10 @@
+
+
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts
index 18ca9f1..82da38a 100644
--- a/translations/harbour-fernschreiber-hu.ts
+++ b/translations/harbour-fernschreiber-hu.ts
@@ -918,6 +918,10 @@
+
+
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts
index 393401f..5b72241 100644
--- a/translations/harbour-fernschreiber-it.ts
+++ b/translations/harbour-fernschreiber-it.ts
@@ -922,6 +922,10 @@
+
+
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts
index 9925848..03223e9 100644
--- a/translations/harbour-fernschreiber-pl.ts
+++ b/translations/harbour-fernschreiber-pl.ts
@@ -926,6 +926,10 @@
+
+
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts
index 719fdb9..427270e 100644
--- a/translations/harbour-fernschreiber-ru.ts
+++ b/translations/harbour-fernschreiber-ru.ts
@@ -926,6 +926,10 @@
+
+
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts
index c270c90..2d1c91b 100644
--- a/translations/harbour-fernschreiber-sv.ts
+++ b/translations/harbour-fernschreiber-sv.ts
@@ -922,6 +922,10 @@
+
+
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts
index 95c6435..39899b4 100644
--- a/translations/harbour-fernschreiber-zh_CN.ts
+++ b/translations/harbour-fernschreiber-zh_CN.ts
@@ -918,6 +918,10 @@
+
+
+
+
PollCreationPage
diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts
index 9f19869..8414ccd 100644
--- a/translations/harbour-fernschreiber.ts
+++ b/translations/harbour-fernschreiber.ts
@@ -918,6 +918,10 @@
+
+
+
+
PollCreationPage