Now able to pin messages and show in-reply-to messages in overlay
This commit is contained in:
parent
541036d796
commit
b35d268b12
15 changed files with 138 additions and 43 deletions
|
@ -101,6 +101,36 @@ ListItem {
|
||||||
}
|
}
|
||||||
text: qsTr("Select Message")
|
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()
|
||||||
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
var chatId = page.chatInformation.id;
|
var chatId = page.chatInformation.id;
|
||||||
|
@ -277,11 +307,22 @@ ListItem {
|
||||||
height: active ? precalculatedValues.messageInReplyToHeight : 0
|
height: active ? precalculatedValues.messageInReplyToHeight : 0
|
||||||
property var inReplyToMessage;
|
property var inReplyToMessage;
|
||||||
sourceComponent: Component {
|
sourceComponent: Component {
|
||||||
InReplyToRow {
|
Item {
|
||||||
id: messageInReplyToRow
|
width: messageInReplyToRow.width
|
||||||
myUserId: page.myUserId
|
height: messageInReplyToRow.height
|
||||||
visible: true
|
InReplyToRow {
|
||||||
inReplyToMessage: messageInReplyToLoader.inReplyToMessage
|
id: messageInReplyToRow
|
||||||
|
myUserId: page.myUserId
|
||||||
|
visible: true
|
||||||
|
inReplyToMessage: messageInReplyToLoader.inReplyToMessage
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
messageOverlayLoader.overlayMessage = messageInReplyToRow.inReplyToMessage;
|
||||||
|
messageOverlayLoader.active = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,45 +67,43 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Item {
|
||||||
id: pinnedMessageColumn
|
|
||||||
spacing: Theme.paddingSmall
|
|
||||||
width: parent.width - pinnedMessageButton.width - removePinnedMessageIconButton.width
|
width: parent.width - pinnedMessageButton.width - removePinnedMessageIconButton.width
|
||||||
|
height: pinnedMessageColumn.height
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
Column {
|
||||||
Text {
|
id: pinnedMessageColumn
|
||||||
id: pinnedMessageUserText
|
spacing: Theme.paddingSmall
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
font.pixelSize: Theme.fontSizeExtraSmall
|
|
||||||
font.weight: Font.ExtraBold
|
Text {
|
||||||
color: Theme.primaryColor
|
id: pinnedMessageUserText
|
||||||
maximumLineCount: 1
|
|
||||||
elide: Text.ElideRight
|
width: parent.width
|
||||||
textFormat: Text.StyledText
|
font.pixelSize: Theme.fontSizeExtraSmall
|
||||||
horizontalAlignment: Text.AlignLeft
|
font.weight: Font.ExtraBold
|
||||||
MouseArea {
|
color: Theme.primaryColor
|
||||||
anchors.fill: parent
|
maximumLineCount: 1
|
||||||
onClicked: {
|
elide: Text.ElideRight
|
||||||
pinnedMessageItem.requestShowMessage();
|
textFormat: Text.StyledText
|
||||||
}
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: pinnedMessageText
|
||||||
|
|
||||||
|
font.pixelSize: Theme.fontSizeExtraSmall
|
||||||
|
color: Theme.primaryColor
|
||||||
|
width: parent.width
|
||||||
|
elide: Text.ElideRight
|
||||||
|
maximumLineCount: 1
|
||||||
|
textFormat: Text.StyledText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MouseArea {
|
||||||
Text {
|
anchors.fill: parent
|
||||||
id: pinnedMessageText
|
onClicked: {
|
||||||
|
pinnedMessageItem.requestShowMessage();
|
||||||
font.pixelSize: Theme.fontSizeExtraSmall
|
|
||||||
color: Theme.primaryColor
|
|
||||||
width: parent.width
|
|
||||||
elide: Text.ElideRight
|
|
||||||
maximumLineCount: 1
|
|
||||||
textFormat: Text.StyledText
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: {
|
|
||||||
pinnedMessageItem.requestShowMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,6 +292,17 @@ void TDLibWrapper::viewMessage(const QString &chatId, const QString &messageId,
|
||||||
this->sendRequest(requestObject);
|
this->sendRequest(requestObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TDLibWrapper::pinMessage(const QString &chatId, const QString &messageId, bool disableNotification)
|
||||||
|
{
|
||||||
|
LOG("Pin message to chat" << chatId << messageId << disableNotification);
|
||||||
|
QVariantMap requestObject;
|
||||||
|
requestObject.insert(_TYPE, "pinChatMessage");
|
||||||
|
requestObject.insert("chat_id", chatId);
|
||||||
|
requestObject.insert("message_id", messageId);
|
||||||
|
requestObject.insert("disable_notification", disableNotification);
|
||||||
|
this->sendRequest(requestObject);
|
||||||
|
}
|
||||||
|
|
||||||
void TDLibWrapper::sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId)
|
void TDLibWrapper::sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId)
|
||||||
{
|
{
|
||||||
LOG("Sending text message" << chatId << message << replyToMessageId);
|
LOG("Sending text message" << chatId << message << replyToMessageId);
|
||||||
|
|
|
@ -122,6 +122,7 @@ public:
|
||||||
Q_INVOKABLE void leaveChat(const QString &chatId);
|
Q_INVOKABLE void leaveChat(const QString &chatId);
|
||||||
Q_INVOKABLE void getChatHistory(qlonglong chatId, const qlonglong &fromMessageId = 0, int offset = 0, int limit = 50, bool onlyLocal = false);
|
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 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 sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId = "0");
|
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 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");
|
Q_INVOKABLE void sendVideoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
|
||||||
|
|
|
@ -839,6 +839,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation>Nachricht auswählen</translation>
|
<translation>Nachricht auswählen</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation>Nachricht anheften</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
@ -851,11 +855,11 @@
|
||||||
<name>MessageOverlayFlickable</name>
|
<name>MessageOverlayFlickable</name>
|
||||||
<message>
|
<message>
|
||||||
<source>You</source>
|
<source>You</source>
|
||||||
<translation type="unfinished">Sie</translation>
|
<translation>Sie</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>This message was forwarded. Original author: %1</source>
|
<source>This message was forwarded. Original author: %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation>Diese Nachricht wurde weitergeleitet. Ursprünglicher Autor: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
|
@ -912,11 +916,11 @@
|
||||||
<name>PinnedMessageItem</name>
|
<name>PinnedMessageItem</name>
|
||||||
<message>
|
<message>
|
||||||
<source>You</source>
|
<source>You</source>
|
||||||
<translation type="unfinished">Sie</translation>
|
<translation>Sie</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation>Angeheftete Nachricht</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
|
|
|
@ -839,6 +839,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation>Select Message</translation>
|
<translation>Select Message</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
|
@ -835,6 +835,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation>Seleccionar mensaje</translation>
|
<translation>Seleccionar mensaje</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
|
@ -840,6 +840,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
|
@ -835,6 +835,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
|
@ -839,6 +839,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
|
@ -843,6 +843,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation>Wybierz wiadomość</translation>
|
<translation>Wybierz wiadomość</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
|
@ -843,6 +843,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
|
@ -839,6 +839,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation>Välj meddelande</translation>
|
<translation>Välj meddelande</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
|
@ -835,6 +835,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation>选择消息</translation>
|
<translation>选择消息</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
|
@ -835,6 +835,10 @@
|
||||||
<source>Select Message</source>
|
<source>Select Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Pin Message</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>MessageListViewItemSimple</name>
|
<name>MessageListViewItemSimple</name>
|
||||||
|
|
Loading…
Reference in a new issue