Some improvements as suggested by @jgibbon, add unpin feature
This commit is contained in:
parent
b35d268b12
commit
af47ae2c72
17 changed files with 138 additions and 37 deletions
|
@ -102,34 +102,11 @@ ListItem {
|
||||||
text: qsTr("Select Message")
|
text: qsTr("Select Message")
|
||||||
}
|
}
|
||||||
MenuItem {
|
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: {
|
onClicked: {
|
||||||
tdLibWrapper.pinMessage(page.chatInformation.id, myMessage.id);
|
tdLibWrapper.pinMessage(page.chatInformation.id, myMessage.id);
|
||||||
}
|
}
|
||||||
text: qsTr("Pin Message")
|
text: qsTr("Pin Message")
|
||||||
visible: amIVisible()
|
visible: canPinMessages()
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|
|
@ -38,14 +38,15 @@ Flickable {
|
||||||
signal requestClose;
|
signal requestClose;
|
||||||
|
|
||||||
function getOriginalAuthor(forwardInformation, fontSize) {
|
function getOriginalAuthor(forwardInformation, fontSize) {
|
||||||
if (forwardInformation.origin["@type"] === "messageForwardOriginChannel") {
|
switch (forwardInformation.origin["@type"]) {
|
||||||
var otherChatInformation = tdLibWrapper.getChat(forwardInformation.origin.chat_id);
|
case "messageForwardOriginChannel":
|
||||||
return Emoji.emojify(otherChatInformation.title, fontSize);
|
var otherChatInformation = tdLibWrapper.getChat(forwardInformation.origin.chat_id);
|
||||||
} else if (forwardInformation.origin["@type"] === "messageForwardOriginUser") {
|
return Emoji.emojify(otherChatInformation.title, fontSize);
|
||||||
var otherUserInformation = tdLibWrapper.getUserInformation(forwardInformation.origin.sender_user_id);
|
case "messageForwardOriginUser":
|
||||||
return Emoji.emojify(Functions.getUserName(otherUserInformation), fontSize);
|
var otherUserInformation = tdLibWrapper.getUserInformation(forwardInformation.origin.sender_user_id);
|
||||||
} else {
|
return Emoji.emojify(Functions.getUserName(otherUserInformation), fontSize);
|
||||||
return Emoji.emojify(forwardInformation.origin.sender_name, fontSize);
|
default:
|
||||||
|
return Emoji.emojify(forwardInformation.origin.sender_name, fontSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +78,8 @@ Flickable {
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: messageContentBackground
|
id: messageContentBackground
|
||||||
color: (Theme.colorScheme === Theme.LightOnDark) ? Theme.darkSecondaryColor : Theme.lightSecondaryColor
|
color: Theme.overlayBackgroundColor
|
||||||
|
opacity: 0.7
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: messageContentColumn.height >= messageOverlayFlickable.height ? messageContentColumn.height : messageOverlayFlickable.height
|
height: messageContentColumn.height >= messageOverlayFlickable.height ? messageContentColumn.height : messageOverlayFlickable.height
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
|
@ -27,6 +27,7 @@ Item {
|
||||||
|
|
||||||
property var pinnedMessage;
|
property var pinnedMessage;
|
||||||
signal requestShowMessage;
|
signal requestShowMessage;
|
||||||
|
signal requestCloseMessage;
|
||||||
|
|
||||||
onPinnedMessageChanged: {
|
onPinnedMessageChanged: {
|
||||||
if (pinnedMessage) {
|
if (pinnedMessage) {
|
||||||
|
@ -43,7 +44,7 @@ Item {
|
||||||
visible: false
|
visible: false
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
height: pinnedMessageRow.height
|
height: visible ? pinnedMessageRow.height : 0
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: pinnedMessageBackground
|
id: pinnedMessageBackground
|
||||||
|
@ -68,7 +69,7 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
width: parent.width - pinnedMessageButton.width - removePinnedMessageIconButton.width
|
width: parent.width - pinnedMessageButton.width - unpinMessageIconLoader.width - removePinnedMessageIconButton.width
|
||||||
height: pinnedMessageColumn.height
|
height: pinnedMessageColumn.height
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
Column {
|
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 {
|
IconButton {
|
||||||
id: removePinnedMessageIconButton
|
id: removePinnedMessageIconButton
|
||||||
icon.source: "image://theme/icon-m-clear"
|
icon.source: "image://theme/icon-m-clear"
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
pinnedMessageItem.requestCloseMessage();
|
||||||
pinnedMessage = undefined;
|
pinnedMessage = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
along with Fernschreiber. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import QtQuick 2.6
|
import QtQuick 2.6
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
import Sailfish.Pickers 1.0
|
import Sailfish.Pickers 1.0
|
||||||
import Nemo.Thumbnailer 1.0
|
import Nemo.Thumbnailer 1.0
|
||||||
|
@ -282,6 +283,31 @@ Page {
|
||||||
|| groupStatusType === "chatMemberStatusCreator"
|
|| groupStatusType === "chatMemberStatusCreator"
|
||||||
|| (groupStatusType === "chatMemberStatusRestricted" && groupStatus.permissions[privilege])
|
|| (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 {
|
Timer {
|
||||||
id: forwardMessagesTimer
|
id: forwardMessagesTimer
|
||||||
|
@ -613,14 +639,18 @@ Page {
|
||||||
id: pinnedMessageItem
|
id: pinnedMessageItem
|
||||||
onRequestShowMessage: {
|
onRequestShowMessage: {
|
||||||
messageOverlayLoader.overlayMessage = pinnedMessageItem.pinnedMessage;
|
messageOverlayLoader.overlayMessage = pinnedMessageItem.pinnedMessage;
|
||||||
messageOverlayLoader.active = !messageOverlayLoader.active;
|
messageOverlayLoader.active = true;
|
||||||
|
}
|
||||||
|
onRequestCloseMessage: {
|
||||||
|
messageOverlayLoader.overlayMessage = undefined;
|
||||||
|
messageOverlayLoader.active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: chatViewItem
|
id: chatViewItem
|
||||||
width: parent.width
|
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;
|
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 {
|
SilicaListView {
|
||||||
id: chatView
|
id: chatView
|
||||||
|
|
||||||
|
visible: !blurred
|
||||||
|
property bool blurred: messageOverlayLoader.item
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
opacity: chatPage.loading ? 0 : 1
|
opacity: chatPage.loading ? 0 : 1
|
||||||
Behavior on opacity { FadeAnimation {} }
|
Behavior on opacity { FadeAnimation {} }
|
||||||
|
@ -1208,6 +1252,7 @@ Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: selectedMessagesActions
|
id: selectedMessagesActions
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
|
|
|
@ -303,6 +303,15 @@ void TDLibWrapper::pinMessage(const QString &chatId, const QString &messageId, b
|
||||||
this->sendRequest(requestObject);
|
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)
|
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);
|
||||||
|
|
|
@ -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 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 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 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");
|
||||||
|
|
|
@ -922,6 +922,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation>Angeheftete Nachricht</translation>
|
<translation>Angeheftete Nachricht</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation>Nachricht losgeheftet</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -922,6 +922,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -918,6 +918,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -923,6 +923,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -918,6 +918,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -922,6 +922,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -926,6 +926,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -926,6 +926,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -922,6 +922,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -918,6 +918,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
|
@ -918,6 +918,10 @@
|
||||||
<source>Pinned Message</source>
|
<source>Pinned Message</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Message unpinned</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>PollCreationPage</name>
|
<name>PollCreationPage</name>
|
||||||
|
|
Loading…
Reference in a new issue