From 1ee8d134bcec5914a921be4ca49331cf79599cab Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sat, 18 Nov 2023 15:45:22 +0200 Subject: [PATCH 01/75] Adapt to changes in TdLib (#524) * Adapt setTdlibParameters for TdLib > 1.8.5 For some reason tdlibParameters were inlined between 1.8.5 and 1.8.6 See https://github.com/tdlib/td/commit/f6a2ecd * sponsoredMessage => sponsoredMessages in TdLib 1.8.8 See https://github.com/tdlib/td/commit/ec1310a * Support another variant of messageReaction The reaction field has changed from string to ReactionType somewhere between 1.8.5 and 1.8.6 See https://github.com/tdlib/td/commit/b14708f * Add support for new message reactions API It has changed between 1.8.5 and 1.8.6 https://github.com/tdlib/td/commit/b14708f (ReactionType) https://github.com/tdlib/td/commit/0b8e143 (ChatAvailableReactions) https://github.com/tdlib/td/commit/6b2f6b4 (addMessageReaction) https://github.com/tdlib/td/commit/d29d367 (updateActiveEmojiReactions) etc. * Highlight chosen reaction * Support username in the new format username attribute has been replaced with usernames in 1.8.8 and now looks like this: "usernames": { "@type": "usernames", "active_usernames": [ "whatever" ], "disabled_usernames": [ ], "editable_username": "whatever" } See https://github.com/tdlib/td/commit/897032e * Support new reply_to message attribute Since 1.8.15 it replaces reply_to_message_id and reply_in_chat_id. Looks like this: "reply_to": { "@type": "messageReplyToMessage", "chat_id": -1001234567890, "is_quote_manual": false, "message_id": 234567890, "origin_send_date": 0 }, See https://github.com/tdlib/td/commit/6116573 * Added support for MessageOrigin values All of a sudden MessageForwardOrigin has been renamed into MessageOrigin in TdLib 1.8.20 just because why not: https://github.com/tdlib/td/commit/10c9e40 --- qml/components/MessageListViewItem.qml | 26 ++- qml/components/MessageOverlayFlickable.qml | 2 + .../ChatInformationTabItemMembersGroups.qml | 5 +- qml/pages/ChatPage.qml | 4 +- src/tdlibreceiver.cpp | 69 ++++++- src/tdlibreceiver.h | 3 + src/tdlibwrapper.cpp | 179 +++++++++++++----- src/tdlibwrapper.h | 8 +- 8 files changed, 235 insertions(+), 61 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 88ab301..b01a39a 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -64,6 +64,7 @@ ListItem { readonly property bool showForwardMessageMenuItem: (baseContextMenuItemCount + 2) <= maxContextMenuItemCount // And don't count "More Options..." for "Delete Message" if "Delete Message" is the only extra option readonly property bool haveSpaceForDeleteMessageMenuItem: (baseContextMenuItemCount + 3 - (deleteMessageIsOnlyExtraOption ? 1 : 0)) <= maxContextMenuItemCount + property var chatReactions property var messageReactions highlighted: (down || isSelected || additionalOptionsOpened) && !menuOpen @@ -94,15 +95,21 @@ ListItem { } } - function getInteractionText(viewCount, reactions) { + function getInteractionText(viewCount, reactions, size, highlightColor) { var interactionText = ""; if (viewCount > 0) { - interactionText = Emoji.emojify("👁️", Theme.fontSizeTiny) + Functions.getShortenedCount(viewCount); + interactionText = Emoji.emojify("👁️ ", size) + Functions.getShortenedCount(viewCount); } for (var i = 0; i < reactions.length; i++) { - interactionText += ( " " + Emoji.emojify(reactions[i].reaction, Theme.fontSizeTiny) ); - if (!chatPage.isPrivateChat) { - interactionText += ( " " + Functions.getShortenedCount(reactions[i].total_count) ); + var reaction = reactions[i] + var reactionText = reaction.reaction ? reaction.reaction : (reaction.type && reaction.type.emoji) ? reaction.type.emoji : "" + if (reactionText) { + interactionText += ( " " + Emoji.emojify(reactionText, size) ); + if (!chatPage.isPrivateChat) { + var count = Functions.getShortenedCount(reaction.total_count) + interactionText += " " + interactionText += (reaction.is_chosen ? ( "" + count + "" ) : count) + } } } return interactionText; @@ -125,6 +132,8 @@ ListItem { if (messageListItem.messageReactions) { messageListItem.messageReactions = null; + } else if (messageListItem.chatReactions) { + messageListItem.messageReactions = chatReactions } else { tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); } @@ -467,11 +476,12 @@ ListItem { width: parent.width Component.onCompleted: { - if (myMessage.forward_info.origin["@type"] === "messageForwardOriginChannel") { + var originType = myMessage.forward_info.origin["@type"] + if (originType === "messageOriginChannel" || originType === "messageForwardOriginChannel") { var otherChatInformation = tdLibWrapper.getChat(myMessage.forward_info.origin.chat_id); forwardedThumbnail.photoData = (typeof otherChatInformation.photo !== "undefined") ? otherChatInformation.photo.small : {}; forwardedChannelText.text = Emoji.emojify(otherChatInformation.title, Theme.fontSizeExtraSmall); - } else if (myMessage.forward_info.origin["@type"] === "messageForwardOriginUser") { + } else if (originType === "messageOriginUser" || originType === "messageForwardOriginUser") { var otherUserInformation = tdLibWrapper.getUserInformation(myMessage.forward_info.origin.sender_user_id); forwardedThumbnail.photoData = (typeof otherUserInformation.profile_photo !== "undefined") ? otherUserInformation.profile_photo.small : {}; forwardedChannelText.text = Emoji.emojify(Functions.getUserName(otherUserInformation), Theme.fontSizeExtraSmall); @@ -625,7 +635,7 @@ ListItem { height: ( ( chatPage.isChannel && messageViewCount > 0 ) || reactions.length > 0 ) ? ( Theme.fontSizeExtraSmall + Theme.paddingSmall ) : 0 sourceComponent: Component { Label { - text: getInteractionText(messageViewCount, reactions) + text: getInteractionText(messageViewCount, reactions, font.pixelSize, Theme.highlightColor) width: parent.width font.pixelSize: Theme.fontSizeTiny color: messageListItem.isOwnMessage ? Theme.secondaryHighlightColor : Theme.secondaryColor diff --git a/qml/components/MessageOverlayFlickable.qml b/qml/components/MessageOverlayFlickable.qml index 274a284..b5d8915 100644 --- a/qml/components/MessageOverlayFlickable.qml +++ b/qml/components/MessageOverlayFlickable.qml @@ -40,9 +40,11 @@ Flickable { function getOriginalAuthor(forwardInformation, fontSize) { switch (forwardInformation.origin["@type"]) { + case "messageOriginChannel": case "messageForwardOriginChannel": var otherChatInformation = tdLibWrapper.getChat(forwardInformation.origin.chat_id); return Emoji.emojify(otherChatInformation.title, fontSize); + case "messageOriginUser": case "messageForwardOriginUser": var otherUserInformation = tdLibWrapper.getUserInformation(forwardInformation.origin.sender_id.user_id); return Emoji.emojify(Functions.getUserName(otherUserInformation), fontSize); diff --git a/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml b/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml index b4280b5..2b12c6f 100644 --- a/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml +++ b/qml/components/chatInformationPage/ChatInformationTabItemMembersGroups.qml @@ -79,7 +79,7 @@ ChatInformationTabItemBase { // chat title primaryText.text: Emoji.emojify(Functions.getUserName(user), primaryText.font.pixelSize) // last user - prologSecondaryText.text: "@"+(user.username !== "" ? user.username : member_id.user_id) + (member_id.user_id === chatInformationPage.myUserId ? " " + qsTr("You") : "") + prologSecondaryText.text: "@"+(user.username ? user.username : member_id.user_id) + (member_id.user_id === chatInformationPage.myUserId ? " " + qsTr("You") : "") secondaryText { horizontalAlignment: Text.AlignRight property string statusText: Functions.getChatMemberStatusText(model.status["@type"]) @@ -180,6 +180,9 @@ ChatInformationTabItemBase { for(var memberIndex in members) { var memberData = members[memberIndex]; var userInfo = tdLibWrapper.getUserInformation(memberData.member_id.user_id) || {user:{}, bot_info:{}}; + if (!userInfo.username && userInfo.usernames && userInfo.usernames.active_usernames) { + userInfo.username = userInfo.usernames.active_usernames[0] + } memberData.user = userInfo; memberData.bot_info = memberData.bot_info || {}; pageContent.membersList.append(memberData); diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index acfec79..c4bb440 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -66,6 +66,7 @@ Page { readonly property bool canSendMessages: hasSendPrivilege("can_send_messages") property bool doSendBotStartMessage property string sendBotStartMessageParameter + property var availableReactions states: [ State { @@ -184,7 +185,7 @@ Page { } tdLibWrapper.getChatPinnedMessage(chatInformation.id); tdLibWrapper.toggleChatIsMarkedAsUnread(chatInformation.id, false); - + availableReactions = tdLibWrapper.getChatReactions(chatInformation.id); } function getMessageStatusText(message, listItemIndex, lastReadSentIndex, useElapsed) { @@ -1348,6 +1349,7 @@ Page { messageId: model.message_id messageViewCount: model.view_count reactions: model.reactions + chatReactions: availableReactions messageIndex: model.index hasContentComponent: !!myMessage.content && chatView.delegateMessagesContent.indexOf(model.content_type) > -1 canReplyToMessage: chatPage.canSendMessages diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index 985e7b7..ba035e9 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -60,6 +60,10 @@ namespace { const QString CONTENT("content"); const QString NEW_CONTENT("new_content"); const QString SETS("sets"); + const QString EMOJIS("emojis"); + const QString REPLY_TO("reply_to"); + const QString REPLY_IN_CHAT_ID("reply_in_chat_id"); + const QString REPLY_TO_MESSAGE_ID("reply_to_message_id"); const QString _TYPE("@type"); const QString _EXTRA("@extra"); @@ -70,6 +74,7 @@ namespace { const QString TYPE_MESSAGE("message"); const QString TYPE_STICKER("sticker"); const QString TYPE_MESSAGE_STICKER("messageSticker"); + const QString TYPE_MESSAGE_REPLY_TO_MESSAGE("messageReplyToMessage"); const QString TYPE_MESSAGE_ANIMATED_EMOJI("messageAnimatedEmoji"); const QString TYPE_ANIMATED_EMOJI("animatedEmoji"); } @@ -119,7 +124,8 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("updateSupergroup", &TDLibReceiver::processUpdateSuperGroup); handlers.insert("updateChatOnlineMemberCount", &TDLibReceiver::processChatOnlineMemberCountUpdated); handlers.insert("messages", &TDLibReceiver::processMessages); - handlers.insert("sponsoredMessage", &TDLibReceiver::processSponsoredMessage); + handlers.insert("sponsoredMessage", &TDLibReceiver::processSponsoredMessage); // TdLib <= 1.8.7 + handlers.insert("sponsoredMessages", &TDLibReceiver::processSponsoredMessages); // TdLib >= 1.8.8 handlers.insert("updateNewMessage", &TDLibReceiver::processUpdateNewMessage); handlers.insert("message", &TDLibReceiver::processMessage); handlers.insert("messageLinkInfo", &TDLibReceiver::processMessageLinkInfo); @@ -167,6 +173,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("availableReactions", &TDLibReceiver::processAvailableReactions); handlers.insert("updateChatUnreadMentionCount", &TDLibReceiver::processUpdateChatUnreadMentionCount); handlers.insert("updateChatUnreadReactionCount", &TDLibReceiver::processUpdateChatUnreadReactionCount); + handlers.insert("updateActiveEmojiReactions", &TDLibReceiver::processUpdateActiveEmojiReactions); } void TDLibReceiver::setActive(bool active) @@ -382,11 +389,24 @@ void TDLibReceiver::processMessages(const QVariantMap &receivedInformation) void TDLibReceiver::processSponsoredMessage(const QVariantMap &receivedInformation) { + // TdLib <= 1.8.7 const qlonglong chatId = receivedInformation.value(_EXTRA).toLongLong(); // See TDLibWrapper::getChatSponsoredMessage LOG("Received sponsored message for chat" << chatId); emit sponsoredMessageReceived(chatId, receivedInformation); } +void TDLibReceiver::processSponsoredMessages(const QVariantMap &receivedInformation) +{ + // TdLib >= 1.8.8 + const qlonglong chatId = receivedInformation.value(_EXTRA).toLongLong(); // See TDLibWrapper::getChatSponsoredMessage + const QVariantList messages(receivedInformation.value(MESSAGES).toList()); + LOG("Received" << messages.count() << "sponsored messages for chat" << chatId); + QListIterator it(messages); + while (it.hasNext()) { + emit sponsoredMessageReceived(chatId, it.next().toMap()); + } +} + void TDLibReceiver::processUpdateNewMessage(const QVariantMap &receivedInformation) { const QVariantMap message = receivedInformation.value(MESSAGE).toMap(); @@ -400,7 +420,7 @@ void TDLibReceiver::processMessage(const QVariantMap &receivedInformation) const qlonglong chatId = receivedInformation.value(CHAT_ID).toLongLong(); const qlonglong messageId = receivedInformation.value(ID).toLongLong(); LOG("Received message " << chatId << messageId); - emit messageInformation(chatId, messageId, receivedInformation); + emit messageInformation(chatId, messageId, cleanupMap(receivedInformation)); } void TDLibReceiver::processMessageLinkInfo(const QVariantMap &receivedInformation) @@ -718,6 +738,13 @@ void TDLibReceiver::processUpdateChatUnreadReactionCount(const QVariantMap &rece emit chatUnreadReactionCountUpdated(chatId, unreadReactionCount); } +void TDLibReceiver::processUpdateActiveEmojiReactions(const QVariantMap &receivedInformation) +{ + // updateActiveEmojiReactions was introduced between 1.8.5 and 1.8.6 + // See https://github.com/tdlib/td/commit/d29d367 + emit activeEmojiReactionsUpdated(receivedInformation.value(EMOJIS).toStringList()); +} + // Recursively removes (some) unused entries from QVariantMaps to reduce // memory usage. QStrings allocated by QVariantMaps are the top consumers // of memory. The biggest saving is achieved by removing "outline" from @@ -747,12 +774,42 @@ const QVariantMap TDLibReceiver::cleanupMap(const QVariantMap& map, bool *update return animated_emoji; } } else if (type == TYPE_MESSAGE) { - bool cleaned = false; - const QVariantMap content(cleanupMap(map.value(CONTENT).toMap(), &cleaned)); - if (cleaned) { - QVariantMap message(map); + QVariantMap message(map); + bool messageChanged = false; + const QVariantMap content(cleanupMap(map.value(CONTENT).toMap(), &messageChanged)); + if (messageChanged) { message.remove(CONTENT); message.insert(CONTENT, content); + } + if (map.contains(REPLY_TO)) { + // In TdLib 1.8.15 reply_to_message_id and reply_in_chat_id attributes + // had been replaced with reply_to structure, e.g: + // + // "reply_to": { + // "@type": "messageReplyToMessage", + // "chat_id": -1001234567890, + // "is_quote_manual": false, + // "message_id": 234567890, + // "origin_send_date": 0 + // } + // + QVariantMap reply_to(message.value(REPLY_TO).toMap()); + if (reply_to.value(_TYPE).toString() == TYPE_MESSAGE_REPLY_TO_MESSAGE) { + if (reply_to.contains(MESSAGE_ID) && + !message.contains(REPLY_TO_MESSAGE_ID)) { + message.insert(REPLY_TO_MESSAGE_ID, reply_to.value(MESSAGE_ID)); + } + if (reply_to.contains(CHAT_ID) && + !message.contains(REPLY_IN_CHAT_ID)) { + message.insert(REPLY_IN_CHAT_ID, reply_to.value(CHAT_ID)); + } + reply_to.remove(_TYPE); + reply_to.insert(_TYPE, TYPE_MESSAGE_REPLY_TO_MESSAGE); + message.insert(REPLY_TO, reply_to); + messageChanged = true; + } + } + if (messageChanged) { message.remove(_TYPE); message.insert(_TYPE, TYPE_MESSAGE); // Replace with a shared value if (updated) *updated = true; diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index b033d9d..a13ae04 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -105,6 +105,7 @@ signals: void availableReactionsReceived(qlonglong messageId, const QStringList &reactions); void chatUnreadMentionCountUpdated(qlonglong chatId, int unreadMentionCount); void chatUnreadReactionCountUpdated(qlonglong chatId, int unreadReactionCount); + void activeEmojiReactionsUpdated(const QStringList& emojis); private: typedef void (TDLibReceiver::*Handler)(const QVariantMap &); @@ -139,6 +140,7 @@ private: void processChatOnlineMemberCountUpdated(const QVariantMap &receivedInformation); void processMessages(const QVariantMap &receivedInformation); void processSponsoredMessage(const QVariantMap &receivedInformation); + void processSponsoredMessages(const QVariantMap &receivedInformation); void processUpdateNewMessage(const QVariantMap &receivedInformation); void processMessage(const QVariantMap &receivedInformation); void processMessageLinkInfo(const QVariantMap &receivedInformation); @@ -186,6 +188,7 @@ private: void processAvailableReactions(const QVariantMap &receivedInformation); void processUpdateChatUnreadMentionCount(const QVariantMap &receivedInformation); void processUpdateChatUnreadReactionCount(const QVariantMap &receivedInformation); + void processUpdateActiveEmojiReactions(const QVariantMap &receivedInformation); }; #endif // TDLIBRECEIVER_H diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 53be644..6cedc4d 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -36,6 +36,9 @@ #define DEBUG_MODULE TDLibWrapper #include "debuglog.h" +#define VERSION_NUMBER(x,y,z) \ + ((((x) & 0x3ff) << 20) | (((y) & 0x3ff) << 10) | ((z) & 0x3ff)) + namespace { const QString STATUS("status"); const QString ID("id"); @@ -51,20 +54,28 @@ namespace { const QString _TYPE("@type"); const QString _EXTRA("@extra"); const QString CHAT_LIST_MAIN("chatListMain"); + const QString CHAT_AVAILABLE_REACTIONS("available_reactions"); + const QString CHAT_AVAILABLE_REACTIONS_ALL("chatAvailableReactionsAll"); + const QString CHAT_AVAILABLE_REACTIONS_SOME("chatAvailableReactionsSome"); + const QString REACTIONS("reactions"); + const QString REACTION_TYPE("reaction_type"); + const QString REACTION_TYPE_EMOJI("reactionTypeEmoji"); + const QString EMOJI("emoji"); } -TDLibWrapper::TDLibWrapper(AppSettings *appSettings, MceInterface *mceInterface, QObject *parent) +TDLibWrapper::TDLibWrapper(AppSettings *settings, MceInterface *mce, QObject *parent) : QObject(parent) + , tdLibClient(td_json_client_create()) , manager(new QNetworkAccessManager(this)) , networkConfigurationManager(new QNetworkConfigurationManager(this)) + , appSettings(settings) + , mceInterface(mce) + , authorizationState(AuthorizationState::Closed) + , versionNumber(0) , joinChatRequested(false) + , isLoggingOut(false) { LOG("Initializing TD Lib..."); - this->appSettings = appSettings; - this->mceInterface = mceInterface; - this->tdLibClient = td_json_client_create(); - this->authorizationState = AuthorizationState::Closed; - this->isLoggingOut = false; initializeTDLibReceiver(); @@ -174,6 +185,7 @@ void TDLibWrapper::initializeTDLibReceiver() { connect(this->tdLibReceiver, SIGNAL(availableReactionsReceived(qlonglong, QStringList)), this, SIGNAL(availableReactionsReceived(qlonglong, QStringList))); connect(this->tdLibReceiver, SIGNAL(chatUnreadMentionCountUpdated(qlonglong, int)), this, SIGNAL(chatUnreadMentionCountUpdated(qlonglong, int))); connect(this->tdLibReceiver, SIGNAL(chatUnreadReactionCountUpdated(qlonglong, int)), this, SIGNAL(chatUnreadReactionCountUpdated(qlonglong, int))); + connect(this->tdLibReceiver, SIGNAL(activeEmojiReactionsUpdated(QStringList)), this, SLOT(handleActiveEmojiReactionsUpdated(QStringList))); this->tdLibReceiver->start(); } @@ -192,7 +204,7 @@ void TDLibWrapper::sendRequest(const QVariantMap &requestObject) QString TDLibWrapper::getVersion() { - return this->version; + return this->versionString; } TDLibWrapper::AuthorizationState TDLibWrapper::getAuthorizationState() @@ -255,7 +267,7 @@ void TDLibWrapper::logout() { LOG("Logging out"); QVariantMap requestObject; - requestObject.insert("@type", "logOut"); + requestObject.insert(_TYPE, "logOut"); this->sendRequest(requestObject); this->isLoggingOut = true; @@ -436,7 +448,7 @@ void TDLibWrapper::sendTextMessage(const QString &chatId, const QString &message QVariantMap entityType; entityType.insert(_TYPE, "textEntityTypeMentionName"); entityType.insert("user_id", nextReplacement.value("userId").toString()); - entity.insert("type", entityType); + entity.insert(TYPE, entityType); entities.append(entity); offsetCorrection += replacementLength - replacementPlainText.length(); } @@ -586,7 +598,7 @@ void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &file QVariantMap stickerInputFile; stickerInputFile.insert(_TYPE, "inputFileRemote"); - stickerInputFile.insert("id", fileId); + stickerInputFile.insert(ID, fileId); inputMessageContent.insert("sticker", stickerInputFile); @@ -620,7 +632,7 @@ void TDLibWrapper::sendPollMessage(const QString &chatId, const QString &questio pollType.insert("allow_multiple_answers", multiple); } - inputMessageContent.insert("type", pollType); + inputMessageContent.insert(TYPE, pollType); inputMessageContent.insert("question", question); inputMessageContent.insert("options", options); inputMessageContent.insert("is_anonymous", anonymous); @@ -709,7 +721,11 @@ void TDLibWrapper::getChatSponsoredMessage(qlonglong chatId) { LOG("Retrieving sponsored message" << chatId); QVariantMap requestObject; - requestObject.insert(_TYPE, "getChatSponsoredMessage"); + // getChatSponsoredMessage has been replaced with getChatSponsoredMessages + // between 1.8.7 and 1.8.8 + // See https://github.com/tdlib/td/commit/ec1310a + requestObject.insert(_TYPE, QString((versionNumber > VERSION_NUMBER(1,8,7)) ? + "getChatSponsoredMessages" : "getChatSponsoredMessage")); requestObject.insert(CHAT_ID, chatId); requestObject.insert(_EXTRA, chatId); // see TDLibReceiver::processSponsoredMessage this->sendRequest(requestObject); @@ -1433,8 +1449,8 @@ void TDLibWrapper::getMessageAvailableReactions(qlonglong chatId, qlonglong mess QVariantMap requestObject; requestObject.insert(_TYPE, "getMessageAvailableReactions"); requestObject.insert(_EXTRA, QString::number(messageId)); - requestObject.insert("chat_id", chatId); - requestObject.insert("message_id", messageId); + requestObject.insert(CHAT_ID, chatId); + requestObject.insert(MESSAGE_ID, messageId); this->sendRequest(requestObject); } @@ -1457,11 +1473,23 @@ void TDLibWrapper::setMessageReaction(qlonglong chatId, qlonglong messageId, con { LOG("Set message reaction" << chatId << messageId << reaction); QVariantMap requestObject; - requestObject.insert(_TYPE, "setMessageReaction"); - requestObject.insert("chat_id", chatId); - requestObject.insert("message_id", messageId); - requestObject.insert("reaction", reaction); + requestObject.insert(CHAT_ID, chatId); + requestObject.insert(MESSAGE_ID, messageId); requestObject.insert("is_big", false); + if (versionNumber > VERSION_NUMBER(1,8,5)) { + // "reaction_type": { + // "@type": "reactionTypeEmoji", + // "emoji": "..." + // } + QVariantMap reactionType; + reactionType.insert(_TYPE, REACTION_TYPE_EMOJI); + reactionType.insert(EMOJI, reaction); + requestObject.insert(REACTION_TYPE, reactionType); + requestObject.insert(_TYPE, "addMessageReaction"); + } else { + requestObject.insert("reaction", reaction); + requestObject.insert(_TYPE, "setMessageReaction"); + } this->sendRequest(requestObject); } @@ -1494,7 +1522,7 @@ void TDLibWrapper::setNetworkType(NetworkType networkType) break; } - requestObject.insert("type", networkTypeObject); + requestObject.insert(TYPE, networkTypeObject); this->sendRequest(requestObject); } @@ -1575,6 +1603,43 @@ QVariantMap TDLibWrapper::getChat(const QString &chatId) return this->chats.value(chatId).toMap(); } +QStringList TDLibWrapper::getChatReactions(const QString &chatId) +{ + const QVariant available_reactions(chats.value(chatId).toMap().value(CHAT_AVAILABLE_REACTIONS)); + const QVariantMap map(available_reactions.toMap()); + const QString reactions_type(map.value(_TYPE).toString()); + if (reactions_type == CHAT_AVAILABLE_REACTIONS_ALL) { + return activeEmojiReactions; + } else if (reactions_type == CHAT_AVAILABLE_REACTIONS_SOME) { + const QVariantList reactions(map.value(REACTIONS).toList()); + const int n = reactions.count(); + QStringList emojis; + + // "available_reactions": { + // "@type": "chatAvailableReactionsSome", + // "reactions": [ + // { + // "@type": "reactionTypeEmoji", + // "emoji": "..." + // }, + emojis.reserve(n); + for (int i = 0; i < n; i++) { + const QVariantMap reaction(reactions.at(i).toMap()); + if (reaction.value(_TYPE).toString() == REACTION_TYPE_EMOJI) { + const QString emoji(reaction.value(EMOJI).toString()); + if (!emoji.isEmpty()) { + emojis.append(emoji); + } + } + } + return emojis; + } else if (reactions_type.isEmpty()) { + return available_reactions.toStringList(); + } else { + return QStringList(); + } +} + QVariantMap TDLibWrapper::getSecretChatFromCache(qlonglong secretChatId) { return this->secretChats.value(secretChatId); @@ -1645,7 +1710,16 @@ DBusAdaptor *TDLibWrapper::getDBusAdaptor() void TDLibWrapper::handleVersionDetected(const QString &version) { - this->version = version; + this->versionString = version; + const QStringList parts(version.split('.')); + uint major, minor, release; + bool ok; + if (parts.count() >= 3 && + (major = parts.at(0).toInt(&ok), ok) && + (minor = parts.at(1).toInt(&ok), ok) && + (release = parts.at(2).toInt(&ok), ok)) { + versionNumber = VERSION_NUMBER(major, minor, release); + } emit versionDetected(version); } @@ -1758,7 +1832,7 @@ void TDLibWrapper::handleConnectionStateChanged(const QString &connectionState) void TDLibWrapper::handleUserUpdated(const QVariantMap &userInformation) { - QString updatedUserId = userInformation.value("id").toString(); + QString updatedUserId = userInformation.value(ID).toString(); if (updatedUserId == this->options.value("my_id").toString()) { LOG("Own user information updated :)"); this->userInformation = userInformation; @@ -1774,11 +1848,11 @@ void TDLibWrapper::handleUserStatusUpdated(const QString &userId, const QVariant { if (userId == this->options.value("my_id").toString()) { LOG("Own user status information updated :)"); - this->userInformation.insert("status", userStatusInformation); + this->userInformation.insert(STATUS, userStatusInformation); } LOG("User status information updated:" << userId << userStatusInformation.value(_TYPE).toString()); QVariantMap updatedUserInformation = this->allUsers.value(userId).toMap(); - updatedUserInformation.insert("status", userStatusInformation); + updatedUserInformation.insert(STATUS, userStatusInformation); this->allUsers.insert(userId, updatedUserInformation); this->allUserNames.insert(userInformation.value(USERNAME).toString(), userInformation); emit userUpdated(userId, updatedUserInformation); @@ -1786,12 +1860,12 @@ void TDLibWrapper::handleUserStatusUpdated(const QString &userId, const QVariant void TDLibWrapper::handleFileUpdated(const QVariantMap &fileInformation) { - emit fileUpdated(fileInformation.value("id").toInt(), fileInformation); + emit fileUpdated(fileInformation.value(ID).toInt(), fileInformation); } void TDLibWrapper::handleNewChatDiscovered(const QVariantMap &chatInformation) { - QString chatId = chatInformation.value("id").toString(); + QString chatId = chatInformation.value(ID).toString(); this->chats.insert(chatId, chatInformation); emit newChatDiscovered(chatId, chatInformation); } @@ -1856,7 +1930,7 @@ void TDLibWrapper::handleStickerSets(const QVariantList &stickerSets) QListIterator stickerSetIterator(stickerSets); while (stickerSetIterator.hasNext()) { QVariantMap stickerSet = stickerSetIterator.next().toMap(); - this->getStickerSet(stickerSet.value("id").toString()); + this->getStickerSet(stickerSet.value(ID).toString()); } emit this->stickerSetsReceived(stickerSets); } @@ -1988,6 +2062,13 @@ void TDLibWrapper::handleSponsoredMessage(qlonglong chatId, const QVariantMap &m } } +void TDLibWrapper::handleActiveEmojiReactionsUpdated(const QStringList& emojis) +{ + if (activeEmojiReactions != emojis) { + activeEmojiReactions = emojis; + LOG(emojis.count() << "reaction(s) available"); + } +} void TDLibWrapper::handleNetworkConfigurationChanged(const QNetworkConfiguration &config) { @@ -2077,28 +2158,40 @@ void TDLibWrapper::handleGetPageSourceFinished() } } +QVariantMap& TDLibWrapper::fillTdlibParameters(QVariantMap& parameters) +{ + parameters.insert("api_id", TDLIB_API_ID); + parameters.insert("api_hash", TDLIB_API_HASH); + parameters.insert("database_directory", QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/tdlib"); + bool onlineOnlyMode = this->appSettings->onlineOnlyMode(); + parameters.insert("use_file_database", !onlineOnlyMode); + parameters.insert("use_chat_info_database", !onlineOnlyMode); + parameters.insert("use_message_database", !onlineOnlyMode); + parameters.insert("use_secret_chats", true); + parameters.insert("system_language_code", QLocale::system().name()); + QSettings hardwareSettings("/etc/hw-release", QSettings::NativeFormat); + parameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString()); + parameters.insert("system_version", QSysInfo::prettyProductName()); + parameters.insert("application_version", "0.17"); + parameters.insert("enable_storage_optimizer", appSettings->storageOptimizer()); + // parameters.insert("use_test_dc", true); + return parameters; +} + void TDLibWrapper::setInitialParameters() { LOG("Sending initial parameters to TD Lib"); QVariantMap requestObject; requestObject.insert(_TYPE, "setTdlibParameters"); - QVariantMap initialParameters; - initialParameters.insert("api_id", TDLIB_API_ID); - initialParameters.insert("api_hash", TDLIB_API_HASH); - initialParameters.insert("database_directory", QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/tdlib"); - bool onlineOnlyMode = this->appSettings->onlineOnlyMode(); - initialParameters.insert("use_file_database", !onlineOnlyMode); - initialParameters.insert("use_chat_info_database", !onlineOnlyMode); - initialParameters.insert("use_message_database", !onlineOnlyMode); - initialParameters.insert("use_secret_chats", true); - initialParameters.insert("system_language_code", QLocale::system().name()); - QSettings hardwareSettings("/etc/hw-release", QSettings::NativeFormat); - initialParameters.insert("device_model", hardwareSettings.value("NAME", "Unknown Mobile Device").toString()); - initialParameters.insert("system_version", QSysInfo::prettyProductName()); - initialParameters.insert("application_version", "0.17"); - initialParameters.insert("enable_storage_optimizer", appSettings->storageOptimizer()); - // initialParameters.insert("use_test_dc", true); - requestObject.insert("parameters", initialParameters); + // tdlibParameters were inlined between 1.8.5 and 1.8.6 + // See https://github.com/tdlib/td/commit/f6a2ecd + if (versionNumber > VERSION_NUMBER(1,8,5)) { + fillTdlibParameters(requestObject); + } else { + QVariantMap initialParameters; + fillTdlibParameters(initialParameters); + requestObject.insert("parameters", initialParameters); + } this->sendRequest(requestObject); } diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 1d1ec6d..4caff11 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -148,6 +148,7 @@ public: Q_INVOKABLE QVariantMap getSuperGroup(qlonglong groupId) const; Q_INVOKABLE QVariantMap getChat(const QString &chatId); Q_INVOKABLE QVariantMap getSecretChatFromCache(qlonglong secretChatId); + Q_INVOKABLE QStringList getChatReactions(const QString &chatId); Q_INVOKABLE QString getOptionString(const QString &optionName); Q_INVOKABLE void copyFileToDownloads(const QString &filePath, bool openAfterCopy = false); Q_INVOKABLE void openFileOnDevice(const QString &filePath); @@ -364,7 +365,7 @@ public slots: void handleUpdatedUserPrivacySettingRules(const QVariantMap &updatedRules); void handleSponsoredMessage(qlonglong chatId, const QVariantMap &message); void handleNetworkConfigurationChanged(const QNetworkConfiguration &config); - + void handleActiveEmojiReactionsUpdated(const QStringList& emojis); void handleGetPageSourceFinished(); private: @@ -372,6 +373,7 @@ private: void setInitialParameters(); void setEncryptionKey(); void setLogVerbosityLevel(); + QVariantMap &fillTdlibParameters(QVariantMap ¶meters); const Group *updateGroup(qlonglong groupId, const QVariantMap &groupInfo, QHash *groups); void initializeTDLibReceiver(); @@ -383,7 +385,7 @@ private: MceInterface *mceInterface; TDLibReceiver *tdLibReceiver; DBusInterface *dbusInterface; - QString version; + QString versionString; TDLibWrapper::AuthorizationState authorizationState; QVariantMap authorizationStateData; TDLibWrapper::ConnectionState connectionState; @@ -399,7 +401,9 @@ private: QHash basicGroups; QHash superGroups; EmojiSearchWorker emojiSearchWorker; + QStringList activeEmojiReactions; + int versionNumber; QString activeChatSearchName; bool joinChatRequested; bool isLoggingOut; -- 2.43.0 From 2b5140574352f841b873c1110a13578f2a2cfc05 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 18 Nov 2023 15:35:02 +0100 Subject: [PATCH 02/75] Only expect chat partner information in private chats --- qml/pages/ChatPage.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index c4bb440..8363c35 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -563,12 +563,12 @@ Page { } } onUserFullInfoReceived: { - if(userFullInfo["@extra"] === chatPartnerInformation.id.toString()) { + if ((isPrivateChat || isSecretChat) && userFullInfo["@extra"] === chatPartnerInformation.id.toString()) { chatPage.botInformation = userFullInfo; } } onUserFullInfoUpdated: { - if(userId === chatPartnerInformation.id) { + if ((isPrivateChat || isSecretChat) && userId === chatPartnerInformation.id) { chatPage.botInformation = userFullInfo; } } -- 2.43.0 From 527b2c3c9a5534d1f75b6d707c47384b83bbbe00 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sat, 18 Nov 2023 23:14:59 +0200 Subject: [PATCH 03/75] Adapt to changes in reply message info (#525) 1.8.14: https://github.com/tdlib/td/commit/fa94aba 1.8.21: https://github.com/tdlib/td/commit/811a7c6 https://github.com/tdlib/td/commit/5216ea1 --- qml/pages/ChatPage.qml | 3 +- src/tdlibreceiver.cpp | 25 ++++++++- src/tdlibwrapper.cpp | 116 ++++++++++++++++++++--------------------- src/tdlibwrapper.h | 17 +++--- 4 files changed, 92 insertions(+), 69 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 8363c35..e126281 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -440,7 +440,8 @@ Page { Component.onDestruction: { if (chatPage.canSendMessages && !chatPage.isDeletedUser) { - tdLibWrapper.setChatDraftMessage(chatInformation.id, 0, newMessageColumn.replyToMessageId, newMessageTextField.text); + tdLibWrapper.setChatDraftMessage(chatInformation.id, 0, newMessageColumn.replyToMessageId, newMessageTextField.text, + newMessageInReplyToRow.inReplyToMessage ? newMessageInReplyToRow.inReplyToMessage.id : 0); } fernschreiberUtils.stopGeoLocationUpdates(); tdLibWrapper.closeChat(chatInformation.id); diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index ba035e9..11a46dc 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -64,6 +64,7 @@ namespace { const QString REPLY_TO("reply_to"); const QString REPLY_IN_CHAT_ID("reply_in_chat_id"); const QString REPLY_TO_MESSAGE_ID("reply_to_message_id"); + const QString DRAFT_MESSAGE("draft_message"); const QString _TYPE("@type"); const QString _EXTRA("@extra"); @@ -77,6 +78,8 @@ namespace { const QString TYPE_MESSAGE_REPLY_TO_MESSAGE("messageReplyToMessage"); const QString TYPE_MESSAGE_ANIMATED_EMOJI("messageAnimatedEmoji"); const QString TYPE_ANIMATED_EMOJI("animatedEmoji"); + const QString TYPE_INPUT_MESSAGE_REPLY_TO_MESSAGE("inputMessageReplyToMessage"); + const QString TYPE_DRAFT_MESSAGE("draftMessage"); } static QString getChatPositionOrder(const QVariantMap &position) @@ -445,7 +448,7 @@ void TDLibReceiver::processMessageSendSucceeded(const QVariantMap &receivedInfor const QVariantMap message = receivedInformation.value(MESSAGE).toMap(); const qlonglong messageId = message.value(ID).toLongLong(); LOG("Message send succeeded" << messageId << oldMessageId); - emit messageSendSucceeded(messageId, oldMessageId, message); + emit messageSendSucceeded(messageId, oldMessageId, cleanupMap(message)); } void TDLibReceiver::processUpdateActiveNotifications(const QVariantMap &receivedInformation) @@ -672,7 +675,7 @@ void TDLibReceiver::processUpdateChatIsMarkedAsUnread(const QVariantMap &receive void TDLibReceiver::processUpdateChatDraftMessage(const QVariantMap &receivedInformation) { LOG("Draft message was updated"); - emit chatDraftMessageUpdated(receivedInformation.value(CHAT_ID).toLongLong(), receivedInformation.value("draft_message").toMap(), findChatPositionOrder(receivedInformation.value(POSITIONS).toList())); + emit chatDraftMessageUpdated(receivedInformation.value(CHAT_ID).toLongLong(), cleanupMap(receivedInformation.value(DRAFT_MESSAGE).toMap()), findChatPositionOrder(receivedInformation.value(POSITIONS).toList())); } void TDLibReceiver::processInlineQueryResults(const QVariantMap &receivedInformation) @@ -815,6 +818,24 @@ const QVariantMap TDLibReceiver::cleanupMap(const QVariantMap& map, bool *update if (updated) *updated = true; return message; } + } else if (type == TYPE_DRAFT_MESSAGE) { + QVariantMap draftMessage(map); + QVariantMap reply_to(draftMessage.value(REPLY_TO).toMap()); + // In TdLib 1.8.21 reply_to_message_id has been replaced with reply_to + if (reply_to.value(_TYPE).toString() == TYPE_INPUT_MESSAGE_REPLY_TO_MESSAGE) { + if (reply_to.contains(MESSAGE_ID) && + !draftMessage.contains(REPLY_TO_MESSAGE_ID)) { + // reply_to_message_id is what QML (still) expects + draftMessage.insert(REPLY_TO_MESSAGE_ID, reply_to.value(MESSAGE_ID)); + } + reply_to.remove(_TYPE); + reply_to.insert(_TYPE, TYPE_INPUT_MESSAGE_REPLY_TO_MESSAGE); // Shared value + draftMessage.insert(REPLY_TO, reply_to); + draftMessage.remove(_TYPE); + draftMessage.insert(_TYPE, DRAFT_MESSAGE); // Shared value + if (updated) *updated = true; + return draftMessage; + } } else if (type == TYPE_MESSAGE_STICKER) { bool cleaned = false; const QVariantMap content(cleanupMap(map.value(CONTENT).toMap(), &cleaned)); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 6cedc4d..509e7cc 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -51,6 +51,8 @@ namespace { const QString THREAD_ID("thread_id"); const QString VALUE("value"); const QString CHAT_LIST_TYPE("chat_list_type"); + const QString REPLY_TO_MESSAGE_ID("reply_to_message_id"); + const QString REPLY_TO("reply_to"); const QString _TYPE("@type"); const QString _EXTRA("@extra"); const QString CHAT_LIST_MAIN("chatListMain"); @@ -61,6 +63,8 @@ namespace { const QString REACTION_TYPE("reaction_type"); const QString REACTION_TYPE_EMOJI("reactionTypeEmoji"); const QString EMOJI("emoji"); + const QString TYPE_MESSAGE_REPLY_TO_MESSAGE("messageReplyToMessage"); + const QString TYPE_INPUT_MESSAGE_REPLY_TO_MESSAGE("inputMessageReplyToMessage"); } TDLibWrapper::TDLibWrapper(AppSettings *settings, MceInterface *mce, QObject *parent) @@ -401,15 +405,33 @@ static bool compareReplacements(const QVariant &replacement1, const QVariant &re } } -void TDLibWrapper::sendTextMessage(const QString &chatId, const QString &message, const QString &replyToMessageId) +QVariantMap TDLibWrapper::newSendMessageRequest(qlonglong chatId, qlonglong replyToMessageId) +{ + QVariantMap request; + request.insert(_TYPE, "sendMessage"); + request.insert(CHAT_ID, chatId); + if (replyToMessageId) { + if (versionNumber > VERSION_NUMBER(1,8,14)) { + QVariantMap replyTo; + if (versionNumber > VERSION_NUMBER(1,8,20)) { + replyTo.insert(_TYPE, TYPE_INPUT_MESSAGE_REPLY_TO_MESSAGE); + } else { + replyTo.insert(_TYPE, TYPE_MESSAGE_REPLY_TO_MESSAGE); + } + replyTo.insert(CHAT_ID, chatId); + replyTo.insert(MESSAGE_ID, replyToMessageId); + request.insert(REPLY_TO, replyTo); + } else { + request.insert(REPLY_TO_MESSAGE_ID, replyToMessageId); + } + } + return request; +} + +void TDLibWrapper::sendTextMessage(qlonglong chatId, const QString &message, qlonglong replyToMessageId) { LOG("Sending text message" << chatId << message << replyToMessageId); - QVariantMap requestObject; - requestObject.insert(_TYPE, "sendMessage"); - requestObject.insert(CHAT_ID, chatId); - if (replyToMessageId != "0") { - requestObject.insert("reply_to_message_id", replyToMessageId); - } + QVariantMap requestObject(newSendMessageRequest(chatId, replyToMessageId)); QVariantMap inputMessageContent; inputMessageContent.insert(_TYPE, "inputMessageText"); @@ -462,17 +484,13 @@ void TDLibWrapper::sendTextMessage(const QString &chatId, const QString &message this->sendRequest(requestObject); } -void TDLibWrapper::sendPhotoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId) +void TDLibWrapper::sendPhotoMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId) { LOG("Sending photo message" << chatId << filePath << message << replyToMessageId); - QVariantMap requestObject; - requestObject.insert(_TYPE, "sendMessage"); - requestObject.insert(CHAT_ID, chatId); - if (replyToMessageId != "0") { - requestObject.insert("reply_to_message_id", replyToMessageId); - } + QVariantMap requestObject(newSendMessageRequest(chatId, replyToMessageId)); QVariantMap inputMessageContent; inputMessageContent.insert(_TYPE, "inputMessagePhoto"); + QVariantMap formattedText; formattedText.insert("text", message); formattedText.insert(_TYPE, "formattedText"); @@ -486,17 +504,13 @@ void TDLibWrapper::sendPhotoMessage(const QString &chatId, const QString &filePa this->sendRequest(requestObject); } -void TDLibWrapper::sendVideoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId) +void TDLibWrapper::sendVideoMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId) { LOG("Sending video message" << chatId << filePath << message << replyToMessageId); - QVariantMap requestObject; - requestObject.insert(_TYPE, "sendMessage"); - requestObject.insert(CHAT_ID, chatId); - if (replyToMessageId != "0") { - requestObject.insert("reply_to_message_id", replyToMessageId); - } + QVariantMap requestObject(newSendMessageRequest(chatId, replyToMessageId)); QVariantMap inputMessageContent; inputMessageContent.insert(_TYPE, "inputMessageVideo"); + QVariantMap formattedText; formattedText.insert("text", message); formattedText.insert(_TYPE, "formattedText"); @@ -510,17 +524,13 @@ void TDLibWrapper::sendVideoMessage(const QString &chatId, const QString &filePa this->sendRequest(requestObject); } -void TDLibWrapper::sendDocumentMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId) +void TDLibWrapper::sendDocumentMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId) { LOG("Sending document message" << chatId << filePath << message << replyToMessageId); - QVariantMap requestObject; - requestObject.insert(_TYPE, "sendMessage"); - requestObject.insert(CHAT_ID, chatId); - if (replyToMessageId != "0") { - requestObject.insert("reply_to_message_id", replyToMessageId); - } + QVariantMap requestObject(newSendMessageRequest(chatId, replyToMessageId)); QVariantMap inputMessageContent; inputMessageContent.insert(_TYPE, "inputMessageDocument"); + QVariantMap formattedText; formattedText.insert("text", message); formattedText.insert(_TYPE, "formattedText"); @@ -534,17 +544,13 @@ void TDLibWrapper::sendDocumentMessage(const QString &chatId, const QString &fil this->sendRequest(requestObject); } -void TDLibWrapper::sendVoiceNoteMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId) +void TDLibWrapper::sendVoiceNoteMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId) { LOG("Sending voice note message" << chatId << filePath << message << replyToMessageId); - QVariantMap requestObject; - requestObject.insert(_TYPE, "sendMessage"); - requestObject.insert(CHAT_ID, chatId); - if (replyToMessageId != "0") { - requestObject.insert("reply_to_message_id", replyToMessageId); - } + QVariantMap requestObject(newSendMessageRequest(chatId, replyToMessageId)); QVariantMap inputMessageContent; inputMessageContent.insert(_TYPE, "inputMessageVoiceNote"); + QVariantMap formattedText; formattedText.insert("text", message); formattedText.insert(_TYPE, "formattedText"); @@ -558,24 +564,19 @@ void TDLibWrapper::sendVoiceNoteMessage(const QString &chatId, const QString &fi this->sendRequest(requestObject); } -void TDLibWrapper::sendLocationMessage(const QString &chatId, double latitude, double longitude, double horizontalAccuracy, const QString &replyToMessageId) +void TDLibWrapper::sendLocationMessage(qlonglong chatId, double latitude, double longitude, double horizontalAccuracy, qlonglong replyToMessageId) { LOG("Sending location message" << chatId << latitude << longitude << horizontalAccuracy << replyToMessageId); - QVariantMap requestObject; - requestObject.insert(_TYPE, "sendMessage"); - requestObject.insert(CHAT_ID, chatId); - if (replyToMessageId != "0") { - requestObject.insert("reply_to_message_id", replyToMessageId); - } + QVariantMap requestObject(newSendMessageRequest(chatId, replyToMessageId)); QVariantMap inputMessageContent; inputMessageContent.insert(_TYPE, "inputMessageLocation"); + QVariantMap location; location.insert("latitude", latitude); location.insert("longitude", longitude); location.insert("horizontal_accuracy", horizontalAccuracy); location.insert(_TYPE, "location"); inputMessageContent.insert("location", location); - inputMessageContent.insert("live_period", 0); inputMessageContent.insert("heading", 0); inputMessageContent.insert("proximity_alert_radius", 0); @@ -584,15 +585,10 @@ void TDLibWrapper::sendLocationMessage(const QString &chatId, double latitude, d this->sendRequest(requestObject); } -void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &fileId, const QString &replyToMessageId) +void TDLibWrapper::sendStickerMessage(qlonglong chatId, const QString &fileId, qlonglong replyToMessageId) { LOG("Sending sticker message" << chatId << fileId << replyToMessageId); - QVariantMap requestObject; - requestObject.insert(_TYPE, "sendMessage"); - requestObject.insert(CHAT_ID, chatId); - if (replyToMessageId != "0") { - requestObject.insert("reply_to_message_id", replyToMessageId); - } + QVariantMap requestObject(newSendMessageRequest(chatId, replyToMessageId)); QVariantMap inputMessageContent; inputMessageContent.insert(_TYPE, "inputMessageSticker"); @@ -606,15 +602,10 @@ void TDLibWrapper::sendStickerMessage(const QString &chatId, const QString &file this->sendRequest(requestObject); } -void TDLibWrapper::sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &explanation, const QString &replyToMessageId) +void TDLibWrapper::sendPollMessage(qlonglong chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &explanation, qlonglong replyToMessageId) { LOG("Sending poll message" << chatId << question << replyToMessageId); - QVariantMap requestObject; - requestObject.insert(_TYPE, "sendMessage"); - requestObject.insert(CHAT_ID, chatId); - if (replyToMessageId != "0") { - requestObject.insert("reply_to_message_id", replyToMessageId); - } + QVariantMap requestObject(newSendMessageRequest(chatId, replyToMessageId)); QVariantMap inputMessageContent; inputMessageContent.insert(_TYPE, "inputMessagePoll"); @@ -1187,9 +1178,18 @@ void TDLibWrapper::setChatDraftMessage(qlonglong chatId, qlonglong threadId, qlo inputMessageContent.insert(_TYPE, "inputMessageText"); inputMessageContent.insert("text", formattedText); draftMessage.insert(_TYPE, "draftMessage"); - draftMessage.insert("reply_to_message_id", replyToMessageId); draftMessage.insert("input_message_text", inputMessageContent); + if (versionNumber > VERSION_NUMBER(1,8,20)) { + QVariantMap replyTo; + replyTo.insert(_TYPE, TYPE_INPUT_MESSAGE_REPLY_TO_MESSAGE); + replyTo.insert(CHAT_ID, chatId); + replyTo.insert(MESSAGE_ID, replyToMessageId); + draftMessage.insert(REPLY_TO, replyTo); + } else { + draftMessage.insert(REPLY_TO_MESSAGE_ID, replyToMessageId); + } + requestObject.insert("draft_message", draftMessage); this->sendRequest(requestObject); } diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 4caff11..33e29b4 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -176,14 +176,14 @@ public: Q_INVOKABLE void viewMessage(qlonglong chatId, qlonglong messageId, bool force); Q_INVOKABLE void pinMessage(const QString &chatId, const QString &messageId, bool disableNotification = false); Q_INVOKABLE void unpinMessage(const QString &chatId, const QString &messageId); - 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"); - Q_INVOKABLE void sendDocumentMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0"); - Q_INVOKABLE void sendVoiceNoteMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0"); - Q_INVOKABLE void sendLocationMessage(const QString &chatId, double latitude, double longitude, double horizontalAccuracy, const QString &replyToMessageId = "0"); - Q_INVOKABLE void sendStickerMessage(const QString &chatId, const QString &fileId, const QString &replyToMessageId = "0"); - Q_INVOKABLE void sendPollMessage(const QString &chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &explanation, const QString &replyToMessageId = "0"); + Q_INVOKABLE void sendTextMessage(qlonglong chatId, const QString &message, qlonglong replyToMessageId = 0); + Q_INVOKABLE void sendPhotoMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId = 0); + Q_INVOKABLE void sendVideoMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId = 0); + Q_INVOKABLE void sendDocumentMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId = 0); + Q_INVOKABLE void sendVoiceNoteMessage(qlonglong chatId, const QString &filePath, const QString &message, qlonglong replyToMessageId = 0); + Q_INVOKABLE void sendLocationMessage(qlonglong chatId, double latitude, double longitude, double horizontalAccuracy, qlonglong replyToMessageId = 0); + Q_INVOKABLE void sendStickerMessage(qlonglong chatId, const QString &fileId, qlonglong replyToMessageId = 0); + Q_INVOKABLE void sendPollMessage(qlonglong chatId, const QString &question, const QVariantList &options, bool anonymous, int correctOption, bool multiple, const QString &explanation, qlonglong replyToMessageId = 0); Q_INVOKABLE void forwardMessages(const QString &chatId, const QString &fromChatId, const QVariantList &messageIds, bool sendCopy, bool removeCaption); Q_INVOKABLE void getMessage(qlonglong chatId, qlonglong messageId); Q_INVOKABLE void getMessageLinkInfo(const QString &url, const QString &extra = ""); @@ -375,6 +375,7 @@ private: void setLogVerbosityLevel(); QVariantMap &fillTdlibParameters(QVariantMap ¶meters); const Group *updateGroup(qlonglong groupId, const QVariantMap &groupInfo, QHash *groups); + QVariantMap newSendMessageRequest(qlonglong chatId, qlonglong replyToMessageId); void initializeTDLibReceiver(); private: -- 2.43.0 From de7b119941b4e27a22db60767381c6558ece79ad Mon Sep 17 00:00:00 2001 From: Peter G Date: Sat, 18 Nov 2023 21:18:47 +0000 Subject: [PATCH 04/75] Move macros to yaml (#523) Co-authored-by: nephros --- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index c482b80..b5eb5c1 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -6,9 +6,9 @@ Name: harbour-fernschreiber # >> macros +# << macros %define __provides_exclude_from ^%{_datadir}/.*$ %define __requires_exclude ^libtdjson.*$ -# << macros Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 9a4782a..c5e2948 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -30,6 +30,11 @@ PkgConfigBR: - nemonotifications-qt5 - openssl +# NB: spectacle has a bug where it will remove custom "#<< macros" lines, so define them here: +Macros: + - '__provides_exclude_from;^%{_datadir}/.*$' + - '__requires_exclude;^libtdjson.*$' + # Build dependencies without a pkgconfig setup can be listed here PkgBR: - gperf -- 2.43.0 From 6b0e54ec65850d2ec97e2ce662112d1354e8af9a Mon Sep 17 00:00:00 2001 From: okruhliak <47862310+okruhliak@users.noreply.github.com> Date: Sat, 18 Nov 2023 22:19:35 +0100 Subject: [PATCH 05/75] Update harbour-fernschreiber-sk.ts (#520) * Update harbour-fernschreiber-sk.ts * Update harbour-fernschreiber-sk.ts --- translations/harbour-fernschreiber-sk.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index ba07b3e..a7930ac 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1583,7 +1583,7 @@ Use non-graphical feedback (sound, vibration) for notifications - Pre upozornenia použiť negrafickú reakciu (zvuk, vibrovanie) + Pre oznamy použiť negrafickú reakciu (zvuk, vibrovanie) All events @@ -1603,11 +1603,11 @@ Enable notification sounds - Povoliť zvukové upozornenia + Povoliť zvukové oznamy When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. - Keď sú povolené zvukové upozornenia, Fernschreiber použije aktuálne zvukové upozornenia Sailfish OS pre čety, ktoré môžu byť upravené v nastaveniach systému. + Keď sú povolené zvukové oznamy, Fernschreiber použije aktuálne zvukové oznamy Sailfish OS pre čety, ktoré môžu byť upravené v nastaveniach systému. -- 2.43.0 From 1ffcfb48cacd576b1f8113f4962edcffb8beb6e7 Mon Sep 17 00:00:00 2001 From: jgibbon <99138+jgibbon@users.noreply.github.com> Date: Sat, 18 Nov 2023 22:24:27 +0100 Subject: [PATCH 06/75] Add specific unread info for higher counts of unread messages (#516) --- qml/components/PhotoTextsListItem.qml | 3 ++- qml/js/functions.js | 8 ++++++++ qml/pages/ChatPage.qml | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/qml/components/PhotoTextsListItem.qml b/qml/components/PhotoTextsListItem.qml index 62f431a..dadb1bd 100644 --- a/qml/components/PhotoTextsListItem.qml +++ b/qml/components/PhotoTextsListItem.qml @@ -1,6 +1,7 @@ import QtQuick 2.6 import Sailfish.Silica 1.0 import WerkWolf.Fernschreiber 1.0 +import "../js/functions.js" as Functions ListItem { id: chatListViewItem @@ -103,7 +104,7 @@ ListItem { anchors.centerIn: chatUnreadMessagesCountBackground visible: chatListViewItem.unreadCount > 0 opacity: isMuted ? Theme.opacityHigh : 1.0 - text: chatListViewItem.unreadCount > 99 ? "99+" : chatListViewItem.unreadCount + text: Functions.formatUnreadCount(chatListViewItem.unreadCount) } Rectangle { diff --git a/qml/js/functions.js b/qml/js/functions.js index dd6093d..7299b0d 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -27,6 +27,14 @@ function setGlobals(globals) { tdLibWrapper = globals.tdLibWrapper; appNotification = globals.appNotification; } +function formatUnreadCount(value) { + if(value < 1000) { + return value; + } else if(value > 9000) { + return '9k+'; + } + return ''+Math.floor(value / 1000)+'k'+((value % 1000)>0 ? '+' : ''); +} function getUserName(userInformation) { return ((userInformation.first_name || "") + " " + (userInformation.last_name || "")).trim(); diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index e126281..b816fe3 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -620,8 +620,8 @@ Page { onUnreadCountUpdated: { Debug.log("[ChatPage] Unread count updated, new count: ", unreadCount); chatInformation.unread_count = unreadCount; - chatUnreadMessagesItem.visible = ( !chatPage.loading && chatInformation.unread_count > 0 && chatOverviewItem.visible ); - chatUnreadMessagesCount.text = unreadCount > 99 ? "99+" : unreadCount; + chatUnreadMessagesItem.visible = ( !chatPage.loading && unreadCount > 0 && chatOverviewItem.visible ); + chatUnreadMessagesCount.text = Functions.formatUnreadCount(unreadCount) } onLastReadSentMessageUpdated: { Debug.log("[ChatPage] Updating last read sent index, new index: ", lastReadSentIndex); @@ -1430,7 +1430,7 @@ Page { color: Theme.primaryColor anchors.centerIn: chatUnreadMessagesCountBackground visible: chatUnreadMessagesItem.visible - text: chatInformation.unread_count > 99 ? "99+" : chatInformation.unread_count + text: Functions.formatUnreadCount(chatInformation.unread_count) } MouseArea { anchors.fill: parent -- 2.43.0 From 3ab0b948311109003de65ab84c58324968754caf Mon Sep 17 00:00:00 2001 From: Peter G Date: Sat, 18 Nov 2023 21:40:12 +0000 Subject: [PATCH 07/75] Highlight unread Converstations (#513) * Highlight unread conversations See: #512 * make highlighting configurable * more verbose variable names * remove the rectangle gain, it is too annoying * respect the setting --------- Co-authored-by: nephros --- qml/components/PhotoTextsListItem.qml | 3 +++ qml/components/settingsPage/SettingsBehavior.qml | 12 ++++++++++++ src/appsettings.cpp | 15 +++++++++++++++ src/appsettings.h | 5 +++++ 4 files changed, 35 insertions(+) diff --git a/qml/components/PhotoTextsListItem.qml b/qml/components/PhotoTextsListItem.qml index dadb1bd..959fdd5 100644 --- a/qml/components/PhotoTextsListItem.qml +++ b/qml/components/PhotoTextsListItem.qml @@ -151,6 +151,9 @@ ListItem { truncationMode: TruncationMode.Fade anchors.verticalCenter: parent.verticalCenter width: Math.min(contentColumn.width - (verifiedImage.visible ? (verifiedImage.width + primaryTextRow.spacing) : 0) - (mutedImage.visible ? (mutedImage.width + primaryTextRow.spacing) : 0), implicitWidth) + font.bold: appSettings.highlightUnreadConversations && ( !chatListViewItem.isMuted && (chatListViewItem.unreadCount > 0 || chatListViewItem.isMarkedAsUnread) ) + font.italic: appSettings.highlightUnreadConversations && (chatListViewItem.unreadReactionCount > 0) + color: (appSettings.highlightUnreadConversations && (chatListViewItem.unreadCount > 0)) ? Theme.highlightColor : Theme.primaryColor } Image { diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index f0b2ea2..8ec3aec 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -70,6 +70,18 @@ AccordionItem { } } + TextSwitch { + width: parent.columnWidth + checked: appSettings.highlightUnreadConversations + text: qsTr("Highlight unread messages") + description: qsTr("Highlight Conversations with unread messages") + automaticCheck: false + onClicked: { + appSettings.highlightUnreadConversations = !checked + } + } + + TextSwitch { width: parent.columnWidth checked: appSettings.useOpenWith diff --git a/src/appsettings.cpp b/src/appsettings.cpp index c5af969..d749f93 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -37,6 +37,7 @@ namespace { const QString KEY_DELAY_MESSAGE_READ("delayMessageRead"); const QString KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN("focusTextAreaOnChatOpen"); const QString KEY_SPONSORED_MESS("sponsoredMess"); + const QString KEY_HIGHLIGHT_UNREADCONVS("highlightUnreadConversations"); } AppSettings::AppSettings(QObject *parent) : QObject(parent), settings(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/de.ygriega/fernschreiber/settings.conf", QSettings::NativeFormat) @@ -240,6 +241,20 @@ void AppSettings::setDelayMessageRead(bool enable) } } +bool AppSettings::highlightUnreadConversations() const +{ + return settings.value(KEY_HIGHLIGHT_UNREADCONVS, true).toBool(); +} + +void AppSettings::setHighlightUnreadConversations(bool enable) +{ + if (highlightUnreadConversations() != enable) { + LOG(KEY_HIGHLIGHT_UNREADCONVS << enable); + settings.setValue(KEY_HIGHLIGHT_UNREADCONVS, enable); + emit highlightUnreadConversationsChanged(); + } +} + bool AppSettings::getFocusTextAreaOnChatOpen() const { return settings.value(KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN, false).toBool(); diff --git a/src/appsettings.h b/src/appsettings.h index fbd5709..8071b44 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -40,6 +40,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool delayMessageRead READ delayMessageRead WRITE setDelayMessageRead NOTIFY delayMessageReadChanged) Q_PROPERTY(bool focusTextAreaOnChatOpen READ getFocusTextAreaOnChatOpen WRITE setFocusTextAreaOnChatOpen NOTIFY focusTextAreaOnChatOpenChanged) Q_PROPERTY(SponsoredMess sponsoredMess READ getSponsoredMess WRITE setSponsoredMess NOTIFY sponsoredMessChanged) + Q_PROPERTY(bool highlightUnreadConversations READ highlightUnreadConversations WRITE setHighlightUnreadConversations NOTIFY highlightUnreadConversationsChanged) public: enum SponsoredMess { @@ -107,6 +108,9 @@ public: SponsoredMess getSponsoredMess() const; void setSponsoredMess(SponsoredMess sponsoredMess); + bool highlightUnreadConversations() const; + void setHighlightUnreadConversations(bool enable); + signals: void sendByEnterChanged(); void focusTextAreaAfterSendChanged(); @@ -124,6 +128,7 @@ signals: void delayMessageReadChanged(); void focusTextAreaOnChatOpenChanged(); void sponsoredMessChanged(); + void highlightUnreadConversationsChanged(); private: QSettings settings; -- 2.43.0 From e44c69281cf8cbdb7cb85f418b71963a1640cfe9 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 18 Nov 2023 22:44:49 +0100 Subject: [PATCH 08/75] Don't enable highlight conversations by default --- src/appsettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appsettings.cpp b/src/appsettings.cpp index d749f93..bee5b00 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -243,7 +243,7 @@ void AppSettings::setDelayMessageRead(bool enable) bool AppSettings::highlightUnreadConversations() const { - return settings.value(KEY_HIGHLIGHT_UNREADCONVS, true).toBool(); + return settings.value(KEY_HIGHLIGHT_UNREADCONVS, false).toBool(); } void AppSettings::setHighlightUnreadConversations(bool enable) -- 2.43.0 From 3620b8ed03db2c11ff6434042f0023b9610467bb Mon Sep 17 00:00:00 2001 From: Peter G Date: Sat, 18 Nov 2023 21:58:05 +0000 Subject: [PATCH 09/75] Add option to suppress notification previews (#521) * Add Switch in Settings * Don't set notification preview body * Support the setting in appSettings * fixup! Add Switch in Settings * Just show message count * Also show only when notifications are enabled at all --------- Co-authored-by: nephros --- qml/components/settingsPage/SettingsBehavior.qml | 14 ++++++++++++++ src/appsettings.cpp | 15 +++++++++++++++ src/appsettings.h | 5 +++++ src/notificationmanager.cpp | 6 +++++- 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index 8ec3aec..17746f7 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -147,6 +147,20 @@ AccordionItem { } } + TextSwitch { + width: parent.columnWidth + checked: appSettings.notificationSuppressContent && enabled + text: qsTr("Hide content in Notifications") + enabled: appSettings.notificationFeedback !== AppSettings.NotificationFeedbackNone + clip: height < implicitHeight + visible: height > 0 + automaticCheck: false + onClicked: { + appSettings.notificationSuppressContent = !checked + } + Behavior on height { SmoothedAnimation { duration: 200 } } + } + TextSwitch { width: parent.columnWidth checked: appSettings.notificationTurnsDisplayOn && enabled diff --git a/src/appsettings.cpp b/src/appsettings.cpp index bee5b00..776c6ae 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -29,6 +29,7 @@ namespace { const QString KEY_ANIMATE_STICKERS("animateStickers"); const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn"); const QString KEY_NOTIFICATION_SOUNDS_ENABLED("notificationSoundsEnabled"); + const QString KEY_NOTIFICATION_SUPPRESS_ENABLED("notificationSuppressContent"); const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback"); const QString KEY_STORAGE_OPTIMIZER("useStorageOptimizer"); const QString KEY_INLINEBOT_LOCATION_ACCESS("allowInlineBotLocationAccess"); @@ -156,6 +157,20 @@ void AppSettings::setNotificationSoundsEnabled(bool enable) } } +bool AppSettings::notificationSuppressContent() const +{ + return settings.value(KEY_NOTIFICATION_SUPPRESS_ENABLED, false).toBool(); +} + +void AppSettings::setNotificationSuppressContent(bool enable) +{ + if (notificationSuppressContent() != enable) { + LOG(KEY_NOTIFICATION_SUPPRESS_ENABLED << enable); + settings.setValue(KEY_NOTIFICATION_SUPPRESS_ENABLED, enable); + emit notificationSuppressContentChanged(); + } +} + AppSettings::NotificationFeedback AppSettings::notificationFeedback() const { return (NotificationFeedback) settings.value(KEY_NOTIFICATION_FEEDBACK, (int) NotificationFeedbackAll).toInt(); diff --git a/src/appsettings.h b/src/appsettings.h index 8071b44..7ddc7ca 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -32,6 +32,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged) Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged) Q_PROPERTY(bool notificationSoundsEnabled READ notificationSoundsEnabled WRITE setNotificationSoundsEnabled NOTIFY notificationSoundsEnabledChanged) + Q_PROPERTY(bool notificationSuppressContent READ notificationSuppressContent WRITE setNotificationSuppressContent NOTIFY notificationSuppressContentChanged) Q_PROPERTY(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged) Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged) Q_PROPERTY(bool allowInlineBotLocationAccess READ allowInlineBotLocationAccess WRITE setAllowInlineBotLocationAccess NOTIFY allowInlineBotLocationAccessChanged) @@ -84,6 +85,9 @@ public: bool notificationSoundsEnabled() const; void setNotificationSoundsEnabled(bool enable); + bool notificationSuppressContent() const; + void setNotificationSuppressContent(bool enable); + NotificationFeedback notificationFeedback() const; void setNotificationFeedback(NotificationFeedback feedback); @@ -120,6 +124,7 @@ signals: void animateStickersChanged(); void notificationTurnsDisplayOnChanged(); void notificationSoundsEnabledChanged(); + void notificationSuppressContentChanged(); void notificationFeedbackChanged(); void storageOptimizerChanged(); void allowInlineBotLocationAccessChanged(); diff --git a/src/notificationmanager.cpp b/src/notificationmanager.cpp index f45f743..2bd4bd8 100644 --- a/src/notificationmanager.cpp +++ b/src/notificationmanager.cpp @@ -377,7 +377,11 @@ void NotificationManager::publishNotification(const NotificationGroup *notificat nemoNotification->setHintValue(HINT_VISIBILITY, QString()); nemoNotification->setUrgency(Notification::Low); } else { - nemoNotification->setPreviewBody(notificationBody); + if (!appSettings->notificationSuppressContent()) { + nemoNotification->setPreviewBody(notificationBody); + } else { + nemoNotification->setPreviewBody(tr("%Ln unread messages", "", notificationGroup->totalCount)); + } nemoNotification->setPreviewSummary(summary); nemoNotification->setHintValue(HINT_SUPPRESS_SOUND, !appSettings->notificationSoundsEnabled()); nemoNotification->setHintValue(HINT_DISPLAY_ON, appSettings->notificationTurnsDisplayOn()); -- 2.43.0 From b11f7dd8b130131d98a04c82520863a837ef7622 Mon Sep 17 00:00:00 2001 From: Johannes Bachmann <45299708+dscheinah@users.noreply.github.com> Date: Sat, 18 Nov 2023 23:11:17 +0100 Subject: [PATCH 10/75] Always append last message content to notifications (#514) * always append last message content to notifications * make "always show notification" configurable * add unfinished translations * Fix spacing if no sender is printed --- .../settingsPage/SettingsBehavior.qml | 11 ++++++++++ src/appsettings.cpp | 15 ++++++++++++++ src/appsettings.h | 5 +++++ src/notificationmanager.cpp | 20 +++++++++++-------- translations/harbour-fernschreiber-de.ts | 8 ++++++++ translations/harbour-fernschreiber-en.ts | 8 ++++++++ translations/harbour-fernschreiber-es.ts | 8 ++++++++ translations/harbour-fernschreiber-fi.ts | 8 ++++++++ translations/harbour-fernschreiber-fr.ts | 8 ++++++++ translations/harbour-fernschreiber-hu.ts | 8 ++++++++ translations/harbour-fernschreiber-it.ts | 8 ++++++++ translations/harbour-fernschreiber-pl.ts | 8 ++++++++ translations/harbour-fernschreiber-ru.ts | 8 ++++++++ translations/harbour-fernschreiber-sk.ts | 8 ++++++++ translations/harbour-fernschreiber-sv.ts | 8 ++++++++ translations/harbour-fernschreiber-zh_CN.ts | 8 ++++++++ translations/harbour-fernschreiber.ts | 8 ++++++++ 17 files changed, 147 insertions(+), 8 deletions(-) diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index 17746f7..9c6b961 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -191,6 +191,17 @@ AccordionItem { } Behavior on height { SmoothedAnimation { duration: 200 } } } + + TextSwitch { + width: parent.columnWidth + checked: appSettings.notificationAlwaysShowPreview + text: qsTr("Always append message preview to notifications") + description: qsTr("In addition to showing the number of unread messages, the latest message will also be appended to notifications.") + automaticCheck: false + onClicked: { + appSettings.notificationAlwaysShowPreview = !checked + } + } } } } diff --git a/src/appsettings.cpp b/src/appsettings.cpp index 776c6ae..efd5b33 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -31,6 +31,7 @@ namespace { const QString KEY_NOTIFICATION_SOUNDS_ENABLED("notificationSoundsEnabled"); const QString KEY_NOTIFICATION_SUPPRESS_ENABLED("notificationSuppressContent"); const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback"); + const QString KEY_NOTIFICATION_ALWAYS_SHOW_PREVIEW("notificationAlwaysShowPreview"); const QString KEY_STORAGE_OPTIMIZER("useStorageOptimizer"); const QString KEY_INLINEBOT_LOCATION_ACCESS("allowInlineBotLocationAccess"); const QString KEY_REMAINING_INTERACTION_HINTS("remainingInteractionHints"); @@ -185,6 +186,20 @@ void AppSettings::setNotificationFeedback(NotificationFeedback feedback) } } +bool AppSettings::notificationAlwaysShowPreview() const +{ + return settings.value(KEY_NOTIFICATION_ALWAYS_SHOW_PREVIEW, false).toBool(); +} + +void AppSettings::setNotificationAlwaysShowPreview(bool enable) +{ + if (notificationAlwaysShowPreview() != enable) { + LOG(KEY_NOTIFICATION_ALWAYS_SHOW_PREVIEW << enable); + settings.setValue(KEY_NOTIFICATION_ALWAYS_SHOW_PREVIEW, enable); + emit notificationAlwaysShowPreviewChanged(); + } +} + bool AppSettings::storageOptimizer() const { return settings.value(KEY_STORAGE_OPTIMIZER, true).toBool(); diff --git a/src/appsettings.h b/src/appsettings.h index 7ddc7ca..e4a1a2d 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -34,6 +34,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool notificationSoundsEnabled READ notificationSoundsEnabled WRITE setNotificationSoundsEnabled NOTIFY notificationSoundsEnabledChanged) Q_PROPERTY(bool notificationSuppressContent READ notificationSuppressContent WRITE setNotificationSuppressContent NOTIFY notificationSuppressContentChanged) Q_PROPERTY(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged) + Q_PROPERTY(bool notificationAlwaysShowPreview READ notificationAlwaysShowPreview WRITE setNotificationAlwaysShowPreview NOTIFY notificationAlwaysShowPreviewChanged) Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged) Q_PROPERTY(bool allowInlineBotLocationAccess READ allowInlineBotLocationAccess WRITE setAllowInlineBotLocationAccess NOTIFY allowInlineBotLocationAccessChanged) Q_PROPERTY(int remainingInteractionHints READ remainingInteractionHints WRITE setRemainingInteractionHints NOTIFY remainingInteractionHintsChanged) @@ -91,6 +92,9 @@ public: NotificationFeedback notificationFeedback() const; void setNotificationFeedback(NotificationFeedback feedback); + bool notificationAlwaysShowPreview() const; + void setNotificationAlwaysShowPreview(bool enable); + bool storageOptimizer() const; void setStorageOptimizer(bool enable); @@ -126,6 +130,7 @@ signals: void notificationSoundsEnabledChanged(); void notificationSuppressContentChanged(); void notificationFeedbackChanged(); + void notificationAlwaysShowPreviewChanged(); void storageOptimizerChanged(); void allowInlineBotLocationAccessChanged(); void remainingInteractionHintsChanged(); diff --git a/src/notificationmanager.cpp b/src/notificationmanager.cpp index 2bd4bd8..f4d6127 100644 --- a/src/notificationmanager.cpp +++ b/src/notificationmanager.cpp @@ -341,8 +341,18 @@ void NotificationManager::publishNotification(const NotificationGroup *notificat QString notificationBody; const QVariantMap senderInformation = messageMap.value(SENDER_ID).toMap(); - if (notificationGroup->totalCount == 1 && !messageMap.isEmpty()) { + bool outputMessageCount = notificationGroup->totalCount > 1; + bool messageIsEmpty = messageMap.isEmpty(); + if (outputMessageCount || messageIsEmpty) { + // Either we have more than one notification or we have no content to display + LOG("Group" << notificationGroup->notificationGroupId << "has" << notificationGroup->totalCount << "notifications"); + notificationBody = tr("%Ln unread messages", "", notificationGroup->totalCount); + } + if ((!outputMessageCount || appSettings->notificationAlwaysShowPreview()) && !messageIsEmpty) { LOG("Group" << notificationGroup->notificationGroupId << "has 1 notification"); + if (outputMessageCount) { + notificationBody += "; "; + } if (chatInformation && (chatInformation->type == TDLibWrapper::ChatTypeBasicGroup || (chatInformation->type == TDLibWrapper::ChatTypeSupergroup && !chatInformation->isChannel))) { // Add author @@ -352,15 +362,9 @@ void NotificationManager::publishNotification(const NotificationGroup *notificat } else { fullName = FernschreiberUtils::getUserName(tdLibWrapper->getUserInformation(senderInformation.value(USER_ID).toString())); } - - notificationBody = notificationBody + fullName.trimmed() + ": "; + notificationBody += fullName.trimmed() + ": "; } notificationBody += FernschreiberUtils::getMessageShortText(tdLibWrapper, messageMap.value(CONTENT).toMap(), (chatInformation ? chatInformation->isChannel : false), tdLibWrapper->getUserInformation().value(ID).toLongLong(), senderInformation ); - nemoNotification->setBody(notificationBody); - } else { - // Either we have more than one notification or we have no content to display - LOG("Group" << notificationGroup->notificationGroupId << "has" << notificationGroup->totalCount << "notifications"); - notificationBody = tr("%Ln unread messages", "", notificationGroup->totalCount); } const QString summary(chatInformation ? chatInformation->title : QString()); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 30489bc..88e83b9 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1582,6 +1582,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. Wenn Töne eingeschaltet sind, wird Fernschreiber den aktuellen Sailfish OS-Hinweiston für Chats verwenden, der in den Systemeinstellungen konfiguriert werden kann. + + Always append message preview to notifications + Immer bei Hinweisen die Nachricht ausgeben + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + Zusätzlich zur Anzahl der ungelesenen Nachrichten wird immer die neuste Nachricht an Hinweise angefügt. + SettingsPage diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index dc306a1..f625cdb 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1584,6 +1584,14 @@ messages When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. + + Always append message preview to notifications + Always append message preview to notifications + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + SettingsPage diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 48fd1f2..34118fc 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1582,6 +1582,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. Cuando los sonidos están habilitados, Fernschreiber utilizará el sonido de notificación actual de Sailfish OS para los grupos, que se puede configurar en la configuración del sistema. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index a8e76f7..5a80d8d 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1583,6 +1583,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. Kun äänet ovat käytössä, Fernschreiber käyttää Sailfish OS:n ilmoitusääniä keskusteluille, jotia voit muuttaa järjestelmäasetuksista. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index cb76a6b..ef1651a 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1582,6 +1582,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. Lorsque le son est activé, Fernschreiber utilisera le réglage de Sailfish OS. Celui-ci est paramétrable depuis les paramètres du système. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 49311be..c1668ee 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1555,6 +1555,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 15c21b2..6073681 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1582,6 +1582,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. Quando i suoni di notifica sono attivi, Fernschreiber utilizza l'attuale suono di notifica per i messaggi scelto per Sailfish OS, il quale può essere modificato dalle impostazioni di sistema. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index ab36a1c..d72d6da 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1609,6 +1609,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. Gdy dźwięki są włączone, Fernschreiber użyje bieżącego dźwięku powiadomienia Sailfish OS do czatów, które można skonfigurować w ustawieniach systemu. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 31ec53d..4db5164 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1612,6 +1612,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. Если звуки разрешены, Fernschreiber использует звук, выбранный для чатов в настройках Sailfish OS. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index a7930ac..5ad68b4 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1609,6 +1609,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. Keď sú povolené zvukové oznamy, Fernschreiber použije aktuálne zvukové oznamy Sailfish OS pre čety, ktoré môžu byť upravené v nastaveniach systému. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index cca0617..a100f7c 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1582,6 +1582,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. När ljud är aktiverat, använder Fernschreiber aktuell Sailfish-signal för chatt-avisering, vilken kan ställas in i systemets ljudinställningar. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 20b60e9..4b5c2ec 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1556,6 +1556,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. 如果开启声音,Fernschreiber 会采用当前旗鱼系统通知声音作为对话通知声音,你可以在系统设置进行配置。 + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 9cb3f0b..6d319bc 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1582,6 +1582,14 @@ When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage -- 2.43.0 From f771a9a81b5f929c5d8a83f37dfa32dd173cf32d Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 18 Nov 2023 23:39:09 +0100 Subject: [PATCH 11/75] Some minor adjustments --- qml/components/settingsPage/SettingsSession.qml | 12 ------------ rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- translations/harbour-fernschreiber-de.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-en.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-es.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-fi.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-fr.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-hu.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-it.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-pl.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-ru.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-sk.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-sv.ts | 16 ++++++++++++---- translations/harbour-fernschreiber-zh_CN.ts | 16 ++++++++++++---- translations/harbour-fernschreiber.ts | 16 ++++++++++++---- 16 files changed, 158 insertions(+), 66 deletions(-) diff --git a/qml/components/settingsPage/SettingsSession.qml b/qml/components/settingsPage/SettingsSession.qml index 038c774..9f5a9b6 100644 --- a/qml/components/settingsPage/SettingsSession.qml +++ b/qml/components/settingsPage/SettingsSession.qml @@ -141,18 +141,6 @@ AccordionItem { } } - Label { - width: parent.width - text: qsTr("IP address: %1, origin: %2").arg(modelData.ip).arg(modelData.country) - font.pixelSize: Theme.fontSizeExtraSmall - color: Theme.secondaryColor - maximumLineCount: 1 - truncationMode: TruncationMode.Fade - anchors { - horizontalCenter: parent.horizontalCenter - } - } - Label { width: parent.width text: qsTr("Active since: %1, last online: %2").arg(Functions.getDateTimeTimepoint(modelData.log_in_date)).arg(Functions.getDateTimeElapsed(modelData.last_active_date)) diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index b5eb5c1..84c153c 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 1 +Release: 2 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index c5e2948..9580ba8 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 1 +Release: 2 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 88e83b9..7908487 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1590,6 +1590,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. Zusätzlich zur Anzahl der ungelesenen Nachrichten wird immer die neuste Nachricht an Hinweise angefügt. + + Highlight unread messages + Ungelesene Nachrichten hervorheben + + + Highlight Conversations with unread messages + Unterhaltungen mit ungelesenen Nachrichten hervorheben + + + Hide content in Notifications + Inhalte in Hinweisen verbergen + SettingsPage @@ -1687,10 +1699,6 @@ This app Diese App - - IP address: %1, origin: %2 - IP-Adresse: %1, Herkunft: %2 - Active since: %1, last online: %2 Aktiv seit: %1, zuletzt online: %2 diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index f625cdb..5bedf63 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1592,6 +1592,18 @@ messages In addition to showing the number of unread messages, the latest message will also be appended to notifications. In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1697,10 +1709,6 @@ messages This app This app - - IP address: %1, origin: %2 - IP address: %1, origin: %2 - Active since: %1, last online: %2 Active since: %1, last online: %2 diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 34118fc..7e8c543 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1590,6 +1590,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1695,10 +1707,6 @@ This app Esta apl - - IP address: %1, origin: %2 - Dirección IP: %1, origen: %2 - Active since: %1, last online: %2 Activo desde: %1, último en línea: %2 diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 5a80d8d..30fb57a 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1591,6 +1591,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1696,10 +1708,6 @@ This app Tämä sovellus - - IP address: %1, origin: %2 - IP-osoite: %1, sijainti: %2 - Active since: %1, last online: %2 Aktiivinen %1 alkaen, viimeksi paikalla: %2 diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index ef1651a..6619abf 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1590,6 +1590,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1695,10 +1707,6 @@ This app Cette app - - IP address: %1, origin: %2 - Adresse IP : %1, origine : %2 - Active since: %1, last online: %2 Actif depuis : %1, en ligne : %2 diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index c1668ee..a1b9709 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1563,6 +1563,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1668,10 +1680,6 @@ This app - - IP address: %1, origin: %2 - - Active since: %1, last online: %2 diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 6073681..f279676 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1590,6 +1590,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1695,10 +1707,6 @@ This app - - IP address: %1, origin: %2 - - Active since: %1, last online: %2 diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index d72d6da..0b77527 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1617,6 +1617,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1722,10 +1734,6 @@ This app Ta aplikacja - - IP address: %1, origin: %2 - Adres IP: %1, oryginalny: %2 - Active since: %1, last online: %2 Aktywny od: %1, ostatnio aktywny: %2 diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 4db5164..b2dcc9a 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1620,6 +1620,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1725,10 +1737,6 @@ This app Это приложение - - IP address: %1, origin: %2 - IP-адрес: %1, регион: %2 - Active since: %1, last online: %2 Активен с: %1, был онлайн: %2 diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index 5ad68b4..ccf207e 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1617,6 +1617,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1722,10 +1734,6 @@ This app Táto aplikácia - - IP address: %1, origin: %2 - IP adresa: %1, pôvod: %2 - Active since: %1, last online: %2 Aktívna od: %1, naposledy pripojená: %2 diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index a100f7c..a7ae697 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1590,6 +1590,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1695,10 +1707,6 @@ This app Denna app - - IP address: %1, origin: %2 - IP-adress: %1, ursprung: %2 - Active since: %1, last online: %2 Aktiv sedan: %1, senast online: %2 diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 4b5c2ec..0e012db 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1564,6 +1564,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1669,10 +1681,6 @@ This app 此应用 - - IP address: %1, origin: %2 - IP 地址: %1, 地点: %2 - Active since: %1, last online: %2 活跃时间: %1, 上次在线: %2 diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 6d319bc..b137d4a 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1590,6 +1590,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage @@ -1695,10 +1707,6 @@ This app - - IP address: %1, origin: %2 - - Active since: %1, last online: %2 -- 2.43.0 From 3ac8cebc06c0934d7284d47d3772373811d37f85 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 18 Nov 2023 23:45:10 +0100 Subject: [PATCH 12/75] Enable privileged mode for contacts sync --- harbour-fernschreiber.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harbour-fernschreiber.desktop b/harbour-fernschreiber.desktop index 9768ef0..0121eb1 100644 --- a/harbour-fernschreiber.desktop +++ b/harbour-fernschreiber.desktop @@ -6,6 +6,6 @@ Exec=harbour-fernschreiber Name=Fernschreiber [X-Sailjail] -Permissions=Audio;Contacts;Documents;Downloads;Internet;Location;MediaIndexing;Microphone;Music;Pictures;PublicDir;RemovableMedia;UserDirs;Videos +Permissions=Audio;Contacts;Documents;Downloads;Internet;Location;MediaIndexing;Microphone;Music;Pictures;Privileged;PublicDir;RemovableMedia;UserDirs;Videos OrganizationName=de.ygriega ApplicationName=fernschreiber -- 2.43.0 From 0224d2f338f2e157604035d40c59b650ed101439 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 19 Nov 2023 00:18:29 +0100 Subject: [PATCH 13/75] Trouble with usernames --- qml/components/settingsPage/SettingsUserProfile.qml | 2 +- src/contactsmodel.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qml/components/settingsPage/SettingsUserProfile.qml b/qml/components/settingsPage/SettingsUserProfile.qml index f4fad97..169c2a6 100644 --- a/qml/components/settingsPage/SettingsUserProfile.qml +++ b/qml/components/settingsPage/SettingsUserProfile.qml @@ -143,7 +143,7 @@ AccordionItem { visible: true canEdit: true headerText: qsTr("Username", "user name of the logged-in profile - header") - text: userInformation.username + text: userInformation.usernames.editable_username width: parent.columnWidth headerLeftAligned: true diff --git a/src/contactsmodel.cpp b/src/contactsmodel.cpp index fa24b24..2c59801 100644 --- a/src/contactsmodel.cpp +++ b/src/contactsmodel.cpp @@ -68,7 +68,7 @@ QVariant ContactsModel::data(const QModelIndex &index, int role) const case ContactRole::RoleDisplay: return requestedContact; case ContactRole::RoleTitle: return QString(requestedContact.value("first_name").toString() + " " + requestedContact.value("last_name").toString()).trimmed(); case ContactRole::RoleUserId: return requestedContact.value("id"); - case ContactRole::RoleUsername: return requestedContact.value("username"); + case ContactRole::RoleUsername: return requestedContact.value("usernames").toMap().value("editable_username").toString(); case ContactRole::RolePhotoSmall: return requestedContact.value("profile_photo").toMap().value("small"); case ContactRole::RoleUserStatus: return requestedContact.value("status").toMap().value("@type"); case ContactRole::RoleUserLastOnline: return requestedContact.value("status").toMap().value("was_online"); -- 2.43.0 From 61e3e366e6d5b9f3211814eba028169392ecc6aa Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 19 Nov 2023 13:52:18 +0200 Subject: [PATCH 14/75] Tweaked notification feedback settings UI (#526) --- .../settingsPage/SettingsBehavior.qml | 93 ++++++++++--------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index 9c6b961..18b487e 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -81,7 +81,6 @@ AccordionItem { } } - TextSwitch { width: parent.columnWidth checked: appSettings.useOpenWith @@ -93,6 +92,17 @@ AccordionItem { } } + TextSwitch { + width: parent.columnWidth + checked: appSettings.notificationAlwaysShowPreview + text: qsTr("Always append message preview to notifications") + description: qsTr("In addition to showing the number of unread messages, the latest message will also be appended to notifications.") + automaticCheck: false + onClicked: { + appSettings.notificationAlwaysShowPreview = !checked + } + } + ComboBox { id: feedbackComboBox width: parent.columnWidth @@ -147,59 +157,52 @@ AccordionItem { } } - TextSwitch { - width: parent.columnWidth - checked: appSettings.notificationSuppressContent && enabled - text: qsTr("Hide content in Notifications") - enabled: appSettings.notificationFeedback !== AppSettings.NotificationFeedbackNone - clip: height < implicitHeight - visible: height > 0 - automaticCheck: false - onClicked: { - appSettings.notificationSuppressContent = !checked - } - Behavior on height { SmoothedAnimation { duration: 200 } } + Item { + // Occupies one grid cell so that the column ends up under the combo box + // in the landscape layout + visible: parent.columns === 2 + width: 1 + height: 1 } - TextSwitch { - width: parent.columnWidth - checked: appSettings.notificationTurnsDisplayOn && enabled - text: qsTr("Notification turns on the display") + Column { enabled: appSettings.notificationFeedback !== AppSettings.NotificationFeedbackNone + width: parent.columnWidth height: enabled ? implicitHeight: 0 clip: height < implicitHeight visible: height > 0 - automaticCheck: false - onClicked: { - appSettings.notificationTurnsDisplayOn = !checked - } - Behavior on height { SmoothedAnimation { duration: 200 } } - } - TextSwitch { - width: parent.columnWidth - checked: appSettings.notificationSoundsEnabled && enabled - text: qsTr("Enable notification sounds") - description: qsTr("When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings.") - enabled: appSettings.notificationFeedback !== AppSettings.NotificationFeedbackNone - height: enabled ? implicitHeight: 0 - clip: height < implicitHeight - visible: height > 0 - automaticCheck: false - onClicked: { - appSettings.notificationSoundsEnabled = !checked - } Behavior on height { SmoothedAnimation { duration: 200 } } - } - TextSwitch { - width: parent.columnWidth - checked: appSettings.notificationAlwaysShowPreview - text: qsTr("Always append message preview to notifications") - description: qsTr("In addition to showing the number of unread messages, the latest message will also be appended to notifications.") - automaticCheck: false - onClicked: { - appSettings.notificationAlwaysShowPreview = !checked + TextSwitch { + checked: appSettings.notificationSuppressContent && enabled + text: qsTr("Hide content in notifications") + enabled: parent.enabled + automaticCheck: false + onClicked: { + appSettings.notificationSuppressContent = !checked + } + } + + TextSwitch { + checked: appSettings.notificationTurnsDisplayOn && enabled + text: qsTr("Notification turns on the display") + enabled: parent.enabled + automaticCheck: false + onClicked: { + appSettings.notificationTurnsDisplayOn = !checked + } + } + + TextSwitch { + checked: appSettings.notificationSoundsEnabled && enabled + text: qsTr("Enable notification sounds") + description: qsTr("When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings.") + enabled: parent.enabled + automaticCheck: false + onClicked: { + appSettings.notificationSoundsEnabled = !checked + } } } } -- 2.43.0 From 00deaa79fd3992118745abbda2560f1edf7c1ec0 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 19 Nov 2023 13:34:31 +0100 Subject: [PATCH 15/75] Fix chat permissions handling --- qml/pages/ChatPage.qml | 10 +++++----- translations/harbour-fernschreiber-de.ts | 2 +- translations/harbour-fernschreiber-en.ts | 2 +- translations/harbour-fernschreiber-es.ts | 2 +- translations/harbour-fernschreiber-fi.ts | 2 +- translations/harbour-fernschreiber-fr.ts | 2 +- translations/harbour-fernschreiber-hu.ts | 2 +- translations/harbour-fernschreiber-it.ts | 2 +- translations/harbour-fernschreiber-pl.ts | 2 +- translations/harbour-fernschreiber-ru.ts | 2 +- translations/harbour-fernschreiber-sk.ts | 2 +- translations/harbour-fernschreiber-sv.ts | 2 +- translations/harbour-fernschreiber-zh_CN.ts | 2 +- translations/harbour-fernschreiber.ts | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index b816fe3..c98c263 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -63,7 +63,7 @@ Page { ) property var selectedMessages: [] readonly property bool isSelecting: selectedMessages.length > 0 - readonly property bool canSendMessages: hasSendPrivilege("can_send_messages") + readonly property bool canSendMessages: hasSendPrivilege("can_send_basic_messages") property bool doSendBotStartMessage property string sendBotStartMessageParameter property var availableReactions @@ -1599,7 +1599,7 @@ Page { IconButton { id: attachImageIconButton - visible: chatPage.hasSendPrivilege("can_send_media_messages") + visible: chatPage.hasSendPrivilege("can_send_photos") icon.source: "image://theme/icon-m-image" onClicked: { var picker = pageStack.push("Sailfish.Pickers.ImagePickerPage", { @@ -1615,7 +1615,7 @@ Page { } } IconButton { - visible: chatPage.hasSendPrivilege("can_send_media_messages") + visible: chatPage.hasSendPrivilege("can_send_videos") icon.source: "image://theme/icon-m-video" onClicked: { var picker = pageStack.push("Sailfish.Pickers.VideoPickerPage", { @@ -1631,7 +1631,7 @@ Page { } } IconButton { - visible: chatPage.hasSendPrivilege("can_send_media_messages") + visible: chatPage.hasSendPrivilege("can_send_voice_notes") icon.source: "image://theme/icon-m-mic" icon.sourceSize { width: Theme.iconSizeMedium @@ -1644,7 +1644,7 @@ Page { } } IconButton { - visible: chatPage.hasSendPrivilege("can_send_media_messages") + visible: chatPage.hasSendPrivilege("can_send_documents") icon.source: "image://theme/icon-m-document" onClicked: { var picker = pageStack.push("Sailfish.Pickers.FilePickerPage", { diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 7908487..541ad0d 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1599,7 +1599,7 @@ Unterhaltungen mit ungelesenen Nachrichten hervorheben - Hide content in Notifications + Hide content in notifications Inhalte in Hinweisen verbergen diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 5bedf63..4b03af9 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1601,7 +1601,7 @@ messages - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 7e8c543..8fb1434 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1599,7 +1599,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 30fb57a..ff316bd 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1600,7 +1600,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index 6619abf..c9a5297 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1599,7 +1599,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index a1b9709..021c976 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1572,7 +1572,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index f279676..34ae96f 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1599,7 +1599,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 0b77527..b213f81 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1626,7 +1626,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index b2dcc9a..d1a5e7a 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1629,7 +1629,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index ccf207e..1ef59c9 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1626,7 +1626,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index a7ae697..48235f3 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1599,7 +1599,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 0e012db..c3b526f 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1573,7 +1573,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index b137d4a..ba39133 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1599,7 +1599,7 @@ - Hide content in Notifications + Hide content in notifications -- 2.43.0 From ea89ef4fcddc3b6e3fdb82effec1eb9b59ea5ac3 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 19 Nov 2023 14:24:19 +0100 Subject: [PATCH 16/75] Make replies backward-compatible again --- src/tdlibwrapper.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 509e7cc..646ac20 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -411,19 +411,10 @@ QVariantMap TDLibWrapper::newSendMessageRequest(qlonglong chatId, qlonglong repl request.insert(_TYPE, "sendMessage"); request.insert(CHAT_ID, chatId); if (replyToMessageId) { - if (versionNumber > VERSION_NUMBER(1,8,14)) { - QVariantMap replyTo; - if (versionNumber > VERSION_NUMBER(1,8,20)) { - replyTo.insert(_TYPE, TYPE_INPUT_MESSAGE_REPLY_TO_MESSAGE); - } else { - replyTo.insert(_TYPE, TYPE_MESSAGE_REPLY_TO_MESSAGE); - } - replyTo.insert(CHAT_ID, chatId); - replyTo.insert(MESSAGE_ID, replyToMessageId); - request.insert(REPLY_TO, replyTo); - } else { - request.insert(REPLY_TO_MESSAGE_ID, replyToMessageId); - } + QVariantMap replyTo; + replyTo.insert(_TYPE, TYPE_INPUT_MESSAGE_REPLY_TO_MESSAGE); + replyTo.insert(MESSAGE_ID, replyToMessageId); + request.insert(REPLY_TO, replyTo); } return request; } -- 2.43.0 From f133586aa232f9d0c5f67e80e470aebc63800a9c Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 19 Nov 2023 14:36:06 +0100 Subject: [PATCH 17/75] Hide unsupported emojis for reactions --- qml/components/MessageListViewItem.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index b01a39a..38cdc11 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -687,7 +687,7 @@ ListItem { Image { id: emojiPicture source: Emoji.getEmojiPath(modelData) - width: Theme.fontSizeLarge + width: status === Image.Ready ? Theme.fontSizeLarge : 0 height: Theme.fontSizeLarge } -- 2.43.0 From 8531a46015c8235b4c0bc4f681c44ab4d558c2f2 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 19 Nov 2023 21:49:00 +0100 Subject: [PATCH 18/75] More places affected by new username handling --- qml/components/InlineQuery.qml | 2 +- qml/components/MessageViaLabel.qml | 4 ++-- qml/components/ReplyMarkupButtons.qml | 4 ++-- .../chatInformationPage/ChatInformationPageContent.qml | 4 ++-- qml/components/messageContent/MessageSticker.qml | 2 +- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- src/knownusersmodel.cpp | 6 +++--- src/tdlibwrapper.cpp | 8 +++++--- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/qml/components/InlineQuery.qml b/qml/components/InlineQuery.qml index 1ad7cb3..5f97fb2 100644 --- a/qml/components/InlineQuery.qml +++ b/qml/components/InlineQuery.qml @@ -40,7 +40,7 @@ Loader { property string chatId property string userName - property bool userNameIsValid: userName !== "" && inlineBotInformation && userName.toLowerCase() === inlineBotInformation.username.toLowerCase() + property bool userNameIsValid: userName !== "" && inlineBotInformation && userName.toLowerCase() === inlineBotInformation.usernames.editable_username.toLowerCase() property string query property int currentOffset: 0 property string responseExtra: chatId+"|"+userName+"|"+query+"|"+currentOffset diff --git a/qml/components/MessageViaLabel.qml b/qml/components/MessageViaLabel.qml index b76619e..b0d34d3 100644 --- a/qml/components/MessageViaLabel.qml +++ b/qml/components/MessageViaLabel.qml @@ -31,12 +31,12 @@ Loader { property var botUserInformation: tdLibWrapper.getUserInformation(message.via_bot_user_id) color: Theme.secondaryColor font.pixelSize: Theme.fontSizeExtraSmall - text: qsTr("via %1", "message posted via bot user").arg("@" + Emoji.emojify(botUserInformation.username, font.pixelSize)+"") + text: qsTr("via %1", "message posted via bot user").arg("@" + Emoji.emojify(botUserInformation.usernames.editable_username, font.pixelSize)+"") textFormat: Text.RichText truncationMode: TruncationMode.Fade onLinkActivated: { if(link === "userId://" + message.via_bot_user_id && botUserInformation.type.is_inline) { - newMessageTextField.text = "@"+botUserInformation.username+" " + newMessageTextField.text = "@"+botUserInformation.usernames.editable_username+" " newMessageTextField.cursorPosition = newMessageTextField.text.length lostFocusTimer.start(); } diff --git a/qml/components/ReplyMarkupButtons.qml b/qml/components/ReplyMarkupButtons.qml index de2cd2c..99efe97 100644 --- a/qml/components/ReplyMarkupButtons.qml +++ b/qml/components/ReplyMarkupButtons.qml @@ -60,12 +60,12 @@ Column { }, inlineKeyboardButtonTypeSwitchInline: function() { if(modelData.type.in_current_chat) { - chatPage.setMessageText("@" + userInformation.username + " "+(modelData.type.query || "")) + chatPage.setMessageText("@" + userInformation.usernames.editable_username + " "+(modelData.type.query || "")) } else { pageStack.push(Qt.resolvedUrl("../pages/ChatSelectionPage.qml"), { myUserId: chatPage.myUserId, - payload: { neededPermissions: ["can_send_other_messages"], text:"@" + userInformation.username + " "+(modelData.type.query || "")}, + payload: { neededPermissions: ["can_send_other_messages"], text:"@" + userInformation.usernames.editable_username + " "+(modelData.type.query || "")}, state: "fillTextArea" }) } diff --git a/qml/components/chatInformationPage/ChatInformationPageContent.qml b/qml/components/chatInformationPage/ChatInformationPageContent.qml index 511bc38..bbd1992 100644 --- a/qml/components/chatInformationPage/ChatInformationPageContent.qml +++ b/qml/components/chatInformationPage/ChatInformationPageContent.qml @@ -300,8 +300,8 @@ SilicaFlickable { } leftMargin: imageContainer.getEased((imageContainer.minDimension + Theme.paddingMedium), 0, imageContainer.tweenFactor) + Theme.horizontalPageMargin title: chatInformationPage.chatInformation.title !== "" ? Emoji.emojify(chatInformationPage.chatInformation.title, Theme.fontSizeLarge) : qsTr("Unknown") - description: ((chatInformationPage.isPrivateChat || chatInformationPage.isSecretChat) && chatInformationPage.privateChatUserInformation.username) - ? ("@"+chatInformationPage.privateChatUserInformation.username) : "" + description: ((chatInformationPage.isPrivateChat || chatInformationPage.isSecretChat) && chatInformationPage.privateChatUserInformation.usernames.editable_username) + ? ("@"+chatInformationPage.privateChatUserInformation.usernames.editable_username) : "" } SilicaFlickable { diff --git a/qml/components/messageContent/MessageSticker.qml b/qml/components/messageContent/MessageSticker.qml index ce499f8..fb9f02d 100644 --- a/qml/components/messageContent/MessageSticker.qml +++ b/qml/components/messageContent/MessageSticker.qml @@ -27,7 +27,7 @@ MessageContentBase { property var stickerData: messageListItem ? messageListItem.myMessage.content.sticker : overlayFlickable.overlayMessage.content.sticker; readonly property bool asEmoji: appSettings.showStickersAsEmojis - readonly property bool animated: stickerData.type["@type"] === "stickerTypeAnimated" && appSettings.animateStickers + readonly property bool animated: stickerData.format["@type"] === "stickerFormatTgs" && appSettings.animateStickers readonly property bool stickerVisible: staticStickerLoader.item ? staticStickerLoader.item.visible : animatedStickerLoader.item ? animatedStickerLoader.item.visible : false readonly property bool isOwnSticker : messageListItem ? messageListItem.isOwnMessage : overlayFlickable.isOwnMessage diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 84c153c..ea6c80f 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 2 +Release: 3 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 9580ba8..c374f3f 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 2 +Release: 3 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/src/knownusersmodel.cpp b/src/knownusersmodel.cpp index 50fdbd2..243cfeb 100644 --- a/src/knownusersmodel.cpp +++ b/src/knownusersmodel.cpp @@ -56,10 +56,10 @@ QVariant KnownUsersModel::data(const QModelIndex &index, int role) const case KnownUserRole::RoleDisplay: return requestedUser; case KnownUserRole::RoleUserId: return requestedUser.value("id"); case KnownUserRole::RoleTitle: return QString(requestedUser.value("first_name").toString() + " " + requestedUser.value("last_name").toString()).trimmed(); - case KnownUserRole::RoleUsername: return requestedUser.value("username"); - case KnownUserRole::RoleUserHandle: return QString("@" + (requestedUser.value("username").toString().isEmpty() ? requestedUser.value("id").toString() : requestedUser.value("username").toString())); + case KnownUserRole::RoleUsername: return requestedUser.value("usernames").toMap().value("editable_username").toString(); + case KnownUserRole::RoleUserHandle: return QString("@" + (requestedUser.value("usernames").toMap().value("editable_username").toString().isEmpty() ? requestedUser.value("id").toString() : requestedUser.value("usernames").toMap().value("editable_username").toString())); case KnownUserRole::RolePhotoSmall: return requestedUser.value("profile_photo").toMap().value("small"); - case KnownUserRole::RoleFilter: return QString(requestedUser.value("first_name").toString() + " " + requestedUser.value("last_name").toString() + " " + requestedUser.value("username").toString()).trimmed(); + case KnownUserRole::RoleFilter: return QString(requestedUser.value("first_name").toString() + " " + requestedUser.value("last_name").toString() + " " + requestedUser.value("usernames").toMap().value("editable_username").toString()).trimmed(); } } return QVariant(); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 646ac20..ffa902d 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -48,6 +48,8 @@ namespace { const QString LAST_NAME("last_name"); const QString FIRST_NAME("first_name"); const QString USERNAME("username"); + const QString USERNAMES("usernames"); + const QString EDITABLE_USERNAME("editable_username"); const QString THREAD_ID("thread_id"); const QString VALUE("value"); const QString CHAT_LIST_TYPE("chat_list_type"); @@ -1829,9 +1831,9 @@ void TDLibWrapper::handleUserUpdated(const QVariantMap &userInformation) this->userInformation = userInformation; emit ownUserUpdated(userInformation); } - LOG("User information updated:" << userInformation.value(USERNAME).toString() << userInformation.value(FIRST_NAME).toString() << userInformation.value(LAST_NAME).toString()); + LOG("User information updated:" << userInformation.value(USERNAMES).toMap().value(EDITABLE_USERNAME).toString() << userInformation.value(FIRST_NAME).toString() << userInformation.value(LAST_NAME).toString()); this->allUsers.insert(updatedUserId, userInformation); - this->allUserNames.insert(userInformation.value(USERNAME).toString(), userInformation); + this->allUserNames.insert(userInformation.value(USERNAMES).toMap().value(EDITABLE_USERNAME).toString(), userInformation); emit userUpdated(updatedUserId, userInformation); } @@ -1845,7 +1847,7 @@ void TDLibWrapper::handleUserStatusUpdated(const QString &userId, const QVariant QVariantMap updatedUserInformation = this->allUsers.value(userId).toMap(); updatedUserInformation.insert(STATUS, userStatusInformation); this->allUsers.insert(userId, updatedUserInformation); - this->allUserNames.insert(userInformation.value(USERNAME).toString(), userInformation); + this->allUserNames.insert(userInformation.value(USERNAMES).toMap().value(EDITABLE_USERNAME).toString(), userInformation); emit userUpdated(userId, updatedUserInformation); } -- 2.43.0 From 195e255f08447c9c355f70de97fcd26b81007c39 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 19 Nov 2023 22:54:50 +0200 Subject: [PATCH 19/75] Added UI for configuring session inactivity timeout (#527) --- .../settingsPage/SettingsSession.qml | 251 ++++++++++-------- src/tdlibreceiver.cpp | 3 +- src/tdlibreceiver.h | 2 +- src/tdlibwrapper.cpp | 10 +- src/tdlibwrapper.h | 3 +- 5 files changed, 160 insertions(+), 109 deletions(-) diff --git a/qml/components/settingsPage/SettingsSession.qml b/qml/components/settingsPage/SettingsSession.qml index 9f5a9b6..cb65cf8 100644 --- a/qml/components/settingsPage/SettingsSession.qml +++ b/qml/components/settingsPage/SettingsSession.qml @@ -30,141 +30,182 @@ AccordionItem { Column { id: activeSessionsItem bottomPadding: Theme.paddingMedium - property variant activeSessions; - property bool loaded : false; + property variant activeSessions + property int inactiveSessionsTtlDays Component.onCompleted: { if (!activeSessions) { tdLibWrapper.getActiveSessions(); - } else { - activeSessionsItem.loaded = true; } } Connections { target: tdLibWrapper onSessionsReceived: { - activeSessionsItem.activeSessions = sessions; - activeSessionsItem.loaded = true; + activeSessionsItem.activeSessions = sessions + activeSessionsItem.inactiveSessionsTtlDays = inactive_session_ttl_days } onOkReceived: { if (request === "terminateSession") { appNotification.show(qsTr("Session was terminated")); - activeSessionsItem.loaded = false; tdLibWrapper.getActiveSessions(); } } } Loader { - id: sessionInformationLoader active: tdLibWrapper.authorizationState === TelegramAPI.AuthorizationReady width: parent.width sourceComponent: Component { - SilicaListView { - id: activeSessionsListView - width: parent.width - height: contentHeight - model: activeSessionsItem.activeSessions - headerPositioning: ListView.OverlayHeader - header: Separator { - width: parent.width - color: Theme.primaryColor - horizontalAlignment: Qt.AlignHCenter + Column { + BusyIndicator { + anchors.horizontalCenter: parent.horizontalCenter + running: !activeSessionsListView.count && !activeSessionsItem.inactiveSessionsTtlDays + size: BusyIndicatorSize.Medium + visible: opacity > 0 + height: running ? implicitHeight : 0 } - delegate: ListItem { - id: activeSessionListItem + + SilicaListView { + id: activeSessionsListView width: parent.width - contentHeight: activeSessionColumn.height + ( 2 * Theme.paddingMedium ) - - menu: ContextMenu { - hasContent: !modelData.is_current - onHeightChanged: { - if (parent && flickable) { - // Make sure we are inside the screen area - var bottom = parent.mapToItem(flickable, x, y).y + height - if (bottom > flickable.height) { - flickable.contentY += bottom - flickable.height - } - } - } - MenuItem { - onClicked: { - var sessionId = modelData.id; - Remorse.itemAction(activeSessionListItem, qsTr("Terminating session"), function() { tdLibWrapper.terminateSession(sessionId); }); - } - text: qsTr("Terminate Session") - } - } - - Column { - id: activeSessionColumn - width: parent.width - ( 2 * Theme.horizontalPageMargin ) - spacing: Theme.paddingSmall - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - - Label { - width: parent.width - text: qsTr("This app") - font.pixelSize: Theme.fontSizeMedium - font.bold: true - visible: modelData.is_current - color: Theme.highlightColor - anchors { - horizontalCenter: parent.horizontalCenter - } - } - - Label { - width: parent.width - text: modelData.application_name + " " + modelData.application_version - font.pixelSize: Theme.fontSizeMedium - font.bold: true - color: Theme.primaryColor - maximumLineCount: 1 - elide: Text.ElideRight - anchors { - horizontalCenter: parent.horizontalCenter - } - } - - Label { - width: parent.width - text: modelData.device_model + ", " + (modelData.platform + " " + modelData.system_version).trim() - font.pixelSize: Theme.fontSizeSmall - color: Theme.primaryColor - maximumLineCount: 1 - truncationMode: TruncationMode.Fade - anchors { - horizontalCenter: parent.horizontalCenter - } - } - - Label { - width: parent.width - text: qsTr("Active since: %1, last online: %2").arg(Functions.getDateTimeTimepoint(modelData.log_in_date)).arg(Functions.getDateTimeElapsed(modelData.last_active_date)) - font.pixelSize: Theme.fontSizeExtraSmall - color: Theme.primaryColor - maximumLineCount: 1 - truncationMode: TruncationMode.Fade - anchors { - horizontalCenter: parent.horizontalCenter - } - } - } - - Separator { - id: separator - anchors { - bottom: parent.bottom - } - + height: contentHeight + model: activeSessionsItem.activeSessions + headerPositioning: ListView.OverlayHeader + header: Separator { width: parent.width color: Theme.primaryColor horizontalAlignment: Qt.AlignHCenter + visible: activeSessionsListView.count > 0 + } + delegate: ListItem { + id: activeSessionListItem + width: parent.width + contentHeight: activeSessionColumn.height + ( 2 * Theme.paddingMedium ) + + menu: ContextMenu { + hasContent: !modelData.is_current + onHeightChanged: { + if (parent && flickable) { + // Make sure we are inside the screen area + var bottom = parent.mapToItem(flickable, x, y).y + height + if (bottom > flickable.height) { + flickable.contentY += bottom - flickable.height + } + } + } + MenuItem { + onClicked: { + var sessionId = modelData.id; + Remorse.itemAction(activeSessionListItem, qsTr("Terminating session"), function() { tdLibWrapper.terminateSession(sessionId); }); + } + text: qsTr("Terminate Session") + } + } + + Column { + id: activeSessionColumn + width: parent.width - ( 2 * Theme.horizontalPageMargin ) + spacing: Theme.paddingSmall + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + + Label { + width: parent.width + text: qsTr("This app") + font.pixelSize: Theme.fontSizeMedium + font.bold: true + visible: modelData.is_current + color: Theme.highlightColor + } + + Label { + width: parent.width + text: modelData.application_name + " " + modelData.application_version + font.pixelSize: Theme.fontSizeMedium + font.bold: true + maximumLineCount: 1 + elide: Text.ElideRight + } + + Label { + width: parent.width + text: modelData.device_model + ", " + (modelData.platform + " " + modelData.system_version).trim() + font.pixelSize: Theme.fontSizeSmall + maximumLineCount: 1 + truncationMode: TruncationMode.Fade + } + + Label { + width: parent.width + text: qsTr("Active since: %1, last online: %2").arg(Functions.getDateTimeTimepoint(modelData.log_in_date)).arg(Functions.getDateTimeElapsed(modelData.last_active_date)) + font.pixelSize: Theme.fontSizeExtraSmall + maximumLineCount: 1 + truncationMode: TruncationMode.Fade + } + } + + Separator { + anchors { + bottom: parent.bottom + } + + width: parent.width + color: Theme.primaryColor + horizontalAlignment: Qt.AlignHCenter + } + } + } + + ComboBox { + readonly property int ttl: activeSessionsItem.inactiveSessionsTtlDays + label: qsTr("Terminate old sessions if inactive for") + value: (currentItem && currentItem.text) ? currentItem.text : qsTr("%1 day(s)", "", ttl).arg(ttl) + visible: ttl > 0 + menu: ContextMenu { + id: ttlMenu + MenuItem { + readonly property int days: 7 + text: qsTr("1 week") + onClicked: tdLibWrapper.setInactiveSessionTtl(days) + } + MenuItem { + readonly property int days: 30 + text: qsTr("1 month") + onClicked: tdLibWrapper.setInactiveSessionTtl(days) + } + MenuItem { + readonly property int days: 90 + text: qsTr("3 months") + onClicked: tdLibWrapper.setInactiveSessionTtl(days) + } + MenuItem { + readonly property int days: 180 + text: qsTr("6 months") + onClicked: tdLibWrapper.setInactiveSessionTtl(days) + } + MenuItem { + readonly property int days: 365 + text: qsTr("1 year") + onClicked: tdLibWrapper.setInactiveSessionTtl(days) + } } + Component.onCompleted: updateSelection() + + onTtlChanged: updateSelection() + + function updateSelection() { + var menuItems = ttlMenu.children + var n = menuItems.length + for (var i = 0; i < n; i++) { + if (menuItems[i].days === ttl) { + currentIndex = i + return + } + } + currentIndex = -1 + } } } } diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index 11a46dc..f14eeeb 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -712,8 +712,9 @@ void TDLibReceiver::processUpdateMessageInteractionInfo(const QVariantMap &recei void TDLibReceiver::processSessions(const QVariantMap &receivedInformation) { + int inactive_session_ttl_days = receivedInformation.value("inactive_session_ttl_days").toInt(); QVariantList sessions = receivedInformation.value("sessions").toList(); - emit sessionsReceived(sessions); + emit sessionsReceived(inactive_session_ttl_days, sessions); } void TDLibReceiver::processAvailableReactions(const QVariantMap &receivedInformation) diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index a13ae04..cf6558c 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -101,7 +101,7 @@ signals: void userPrivacySettingRulesUpdated(const QVariantMap &updatedRules); void messageInteractionInfoUpdated(qlonglong chatId, qlonglong messageId, const QVariantMap &updatedInfo); void okReceived(const QString &request); - void sessionsReceived(const QVariantList &sessions); + void sessionsReceived(int inactive_session_ttl_days, const QVariantList &sessions); void availableReactionsReceived(qlonglong messageId, const QStringList &reactions); void chatUnreadMentionCountUpdated(qlonglong chatId, int unreadMentionCount); void chatUnreadReactionCountUpdated(qlonglong chatId, int unreadReactionCount); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index ffa902d..f815ccf 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -187,7 +187,7 @@ void TDLibWrapper::initializeTDLibReceiver() { connect(this->tdLibReceiver, SIGNAL(userPrivacySettingRulesUpdated(QVariantMap)), this, SLOT(handleUpdatedUserPrivacySettingRules(QVariantMap))); connect(this->tdLibReceiver, SIGNAL(messageInteractionInfoUpdated(qlonglong, qlonglong, QVariantMap)), this, SIGNAL(messageInteractionInfoUpdated(qlonglong, qlonglong, QVariantMap))); connect(this->tdLibReceiver, SIGNAL(okReceived(QString)), this, SIGNAL(okReceived(QString))); - connect(this->tdLibReceiver, SIGNAL(sessionsReceived(QVariantList)), this, SIGNAL(sessionsReceived(QVariantList))); + connect(this->tdLibReceiver, SIGNAL(sessionsReceived(int, QVariantList)), this, SIGNAL(sessionsReceived(int, QVariantList))); connect(this->tdLibReceiver, SIGNAL(availableReactionsReceived(qlonglong, QStringList)), this, SIGNAL(availableReactionsReceived(qlonglong, QStringList))); connect(this->tdLibReceiver, SIGNAL(chatUnreadMentionCountUpdated(qlonglong, int)), this, SIGNAL(chatUnreadMentionCountUpdated(qlonglong, int))); connect(this->tdLibReceiver, SIGNAL(chatUnreadReactionCountUpdated(qlonglong, int)), this, SIGNAL(chatUnreadReactionCountUpdated(qlonglong, int))); @@ -1520,6 +1520,14 @@ void TDLibWrapper::setNetworkType(NetworkType networkType) this->sendRequest(requestObject); } +void TDLibWrapper::setInactiveSessionTtl(int days) +{ + QVariantMap requestObject; + requestObject.insert(_TYPE, "setInactiveSessionTtl"); + requestObject.insert("inactive_session_ttl_days", days); + this->sendRequest(requestObject); +} + void TDLibWrapper::searchEmoji(const QString &queryString) { LOG("Searching emoji" << queryString); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 33e29b4..17a0896 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -251,6 +251,7 @@ public: Q_INVOKABLE void getPageSource(const QString &address); Q_INVOKABLE void setMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction); Q_INVOKABLE void setNetworkType(NetworkType networkType); + Q_INVOKABLE void setInactiveSessionTtl(int days); // Others (candidates for extraction ;)) Q_INVOKABLE void searchEmoji(const QString &queryString); @@ -331,7 +332,7 @@ signals: void userPrivacySettingUpdated(UserPrivacySetting setting, UserPrivacySettingRule rule); void messageInteractionInfoUpdated(qlonglong chatId, qlonglong messageId, const QVariantMap &updatedInfo); void okReceived(const QString &request); - void sessionsReceived(const QVariantList &sessions); + void sessionsReceived(int inactive_session_ttl_days, const QVariantList &sessions); void openFileExternally(const QString &filePath); void availableReactionsReceived(qlonglong messageId, const QStringList &reactions); void chatUnreadMentionCountUpdated(qlonglong chatId, int unreadMentionCount); -- 2.43.0 From acfcfd3ca43054a01501e7aa5cc105f58e6904b4 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 19 Nov 2023 22:51:33 +0100 Subject: [PATCH 20/75] Minor tweaks for the new session timout setting --- .../settingsPage/SettingsSession.qml | 3 +- translations/harbour-fernschreiber-de.ts | 35 ++++++++++++++++++ translations/harbour-fernschreiber-en.ts | 35 ++++++++++++++++++ translations/harbour-fernschreiber-es.ts | 35 ++++++++++++++++++ translations/harbour-fernschreiber-fi.ts | 35 ++++++++++++++++++ translations/harbour-fernschreiber-fr.ts | 35 ++++++++++++++++++ translations/harbour-fernschreiber-hu.ts | 34 ++++++++++++++++++ translations/harbour-fernschreiber-it.ts | 35 ++++++++++++++++++ translations/harbour-fernschreiber-pl.ts | 36 +++++++++++++++++++ translations/harbour-fernschreiber-ru.ts | 36 +++++++++++++++++++ translations/harbour-fernschreiber-sk.ts | 36 +++++++++++++++++++ translations/harbour-fernschreiber-sv.ts | 35 ++++++++++++++++++ translations/harbour-fernschreiber-zh_CN.ts | 34 ++++++++++++++++++ translations/harbour-fernschreiber.ts | 35 ++++++++++++++++++ 14 files changed, 458 insertions(+), 1 deletion(-) diff --git a/qml/components/settingsPage/SettingsSession.qml b/qml/components/settingsPage/SettingsSession.qml index cb65cf8..e94b2ca 100644 --- a/qml/components/settingsPage/SettingsSession.qml +++ b/qml/components/settingsPage/SettingsSession.qml @@ -159,7 +159,8 @@ AccordionItem { ComboBox { readonly property int ttl: activeSessionsItem.inactiveSessionsTtlDays - label: qsTr("Terminate old sessions if inactive for") + label: qsTr("Session Timeout") + description: qsTr("Inactive sessions will be terminated after this timeframe") value: (currentItem && currentItem.text) ? currentItem.text : qsTr("%1 day(s)", "", ttl).arg(ttl) visible: ttl > 0 menu: ContextMenu { diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 541ad0d..d0eac2d 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1711,6 +1711,41 @@ Sessions Sitzungen + + %1 day(s) + + %1 Tag + %1 Tage + + + + 1 week + 1 Woche + + + 1 month + 1 Monat + + + 3 months + 3 Monate + + + 6 months + 6 Monate + + + 1 year + 1 Jahr + + + Session Timeout + Timeout von Sitzungen + + + Inactive sessions will be terminated after this timeframe + Inaktive Sitzungen werden nach dieser Zeitdauer abgeschaltet + SettingsStorage diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 4b03af9..4008317 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1713,6 +1713,41 @@ messages Active since: %1, last online: %2 Active since: %1, last online: %2 + + %1 day(s) + + %1 day + %1 days + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 8fb1434..5bb74ef 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1711,6 +1711,41 @@ Active since: %1, last online: %2 Activo desde: %1, último en línea: %2 + + %1 day(s) + + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index ff316bd..d0b22c8 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1712,6 +1712,41 @@ Active since: %1, last online: %2 Aktiivinen %1 alkaen, viimeksi paikalla: %2 + + %1 day(s) + + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index c9a5297..96f7e9b 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1711,6 +1711,41 @@ Active since: %1, last online: %2 Actif depuis : %1, en ligne : %2 + + %1 day(s) + + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 021c976..796c1c3 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1684,6 +1684,40 @@ Active since: %1, last online: %2 + + %1 day(s) + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 34ae96f..48e863e 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1711,6 +1711,41 @@ Active since: %1, last online: %2 + + %1 day(s) + + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index b213f81..b16825d 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1738,6 +1738,42 @@ Active since: %1, last online: %2 Aktywny od: %1, ostatnio aktywny: %2 + + %1 day(s) + + + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index d1a5e7a..c3d389e 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1741,6 +1741,42 @@ Active since: %1, last online: %2 Активен с: %1, был онлайн: %2 + + %1 day(s) + + + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index 1ef59c9..d4b14cf 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1738,6 +1738,42 @@ Active since: %1, last online: %2 Aktívna od: %1, naposledy pripojená: %2 + + %1 day(s) + + + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 48235f3..d00eb6d 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1711,6 +1711,41 @@ Active since: %1, last online: %2 Aktiv sedan: %1, senast online: %2 + + %1 day(s) + + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index c3b526f..88727e2 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1685,6 +1685,40 @@ Active since: %1, last online: %2 活跃时间: %1, 上次在线: %2 + + %1 day(s) + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index ba39133..cc90573 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1711,6 +1711,41 @@ Active since: %1, last online: %2 + + %1 day(s) + + + + + + + 1 week + + + + 1 month + + + + 3 months + + + + 6 months + + + + 1 year + + + + Session Timeout + + + + Inactive sessions will be terminated after this timeframe + + SettingsStorage -- 2.43.0 From 8d59ee4c0011ea6d2a57dd0fc43ee547172ff748 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 20 Nov 2023 21:27:55 +0100 Subject: [PATCH 21/75] Restore search in chats --- qml/components/MessageListViewItem.qml | 2 ++ src/tdlibreceiver.cpp | 8 ++++++++ src/tdlibreceiver.h | 1 + 3 files changed, 11 insertions(+) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 38cdc11..189f429 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -133,8 +133,10 @@ ListItem { if (messageListItem.messageReactions) { messageListItem.messageReactions = null; } else if (messageListItem.chatReactions) { + Debug.log("Using chat reactions") messageListItem.messageReactions = chatReactions } else { + Debug.log("Obtaining message reactions") tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); } } diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index f14eeeb..8f65952 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -127,6 +127,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("updateSupergroup", &TDLibReceiver::processUpdateSuperGroup); handlers.insert("updateChatOnlineMemberCount", &TDLibReceiver::processChatOnlineMemberCountUpdated); handlers.insert("messages", &TDLibReceiver::processMessages); + handlers.insert("foundChatMessages", &TDLibReceiver::processFoundChatMessages); handlers.insert("sponsoredMessage", &TDLibReceiver::processSponsoredMessage); // TdLib <= 1.8.7 handlers.insert("sponsoredMessages", &TDLibReceiver::processSponsoredMessages); // TdLib >= 1.8.8 handlers.insert("updateNewMessage", &TDLibReceiver::processUpdateNewMessage); @@ -390,6 +391,13 @@ void TDLibReceiver::processMessages(const QVariantMap &receivedInformation) emit messagesReceived(cleanupList(receivedInformation.value(MESSAGES).toList()), total_count); } +void TDLibReceiver::processFoundChatMessages(const QVariantMap &receivedInformation) +{ + const int total_count = receivedInformation.value(TOTAL_COUNT).toInt(); + LOG("Received found chat messages, amount: " << total_count); + emit messagesReceived(cleanupList(receivedInformation.value(MESSAGES).toList()), total_count); +} + void TDLibReceiver::processSponsoredMessage(const QVariantMap &receivedInformation) { // TdLib <= 1.8.7 diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index cf6558c..bfb380e 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -139,6 +139,7 @@ private: void processUpdateSuperGroup(const QVariantMap &receivedInformation); void processChatOnlineMemberCountUpdated(const QVariantMap &receivedInformation); void processMessages(const QVariantMap &receivedInformation); + void processFoundChatMessages(const QVariantMap &receivedInformation); void processSponsoredMessage(const QVariantMap &receivedInformation); void processSponsoredMessages(const QVariantMap &receivedInformation); void processUpdateNewMessage(const QVariantMap &receivedInformation); -- 2.43.0 From 5b2fa38f7ed894a3e28060c77232427976c401bb Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 20 Nov 2023 21:53:57 +0100 Subject: [PATCH 22/75] Display reactions on last message again --- qml/components/MessageListViewItem.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 189f429..2ac1e87 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -135,6 +135,8 @@ ListItem { } else if (messageListItem.chatReactions) { Debug.log("Using chat reactions") messageListItem.messageReactions = chatReactions + showItemCompletelyTimer.requestedIndex = index; + showItemCompletelyTimer.start(); } else { Debug.log("Obtaining message reactions") tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); @@ -281,6 +283,7 @@ ListItem { interval: 200 triggeredOnStart: false onTriggered: { + Debug.log("Show item completely timer triggered, requested index: " + requestedIndex + ", current index: " + index) if (requestedIndex === index) { chatView.highlightMoveDuration = -1; chatView.highlightResizeDuration = -1; -- 2.43.0 From 58382ac1b6c489a607bc37292e2ddc7324246148 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 20 Nov 2023 22:34:52 +0100 Subject: [PATCH 23/75] Test build no.4 --- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index ea6c80f..568b883 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 3 +Release: 4 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index c374f3f..c8cc6b0 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 3 +Release: 4 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt -- 2.43.0 From 75bf14615436f94c8001449d22b033af4e897877 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Tue, 21 Nov 2023 22:31:23 +0200 Subject: [PATCH 24/75] Updated Russian translation (#528) --- translations/harbour-fernschreiber-ru.ts | 50 ++++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index c3d389e..09982cd 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -348,11 +348,11 @@ Leave Chat - Выйти из Чата + Выйти из чата Join Chat - Зайти в Чат + Зайти в чат Leaving chat @@ -427,7 +427,7 @@ Search in Chat - Найти в Чате + Поиск в чате Search in chat... @@ -1159,7 +1159,7 @@ Secret Chat - Секретный Чат + Секретный чат End-to-end-encrypted, accessible on this device only @@ -1241,7 +1241,7 @@ New Chat - Новый Чат + Новый чат Filter your chats... @@ -1249,7 +1249,7 @@ Search Chats - Найти Чаты + Поиск чатов Download of %1 successful. @@ -1460,7 +1460,7 @@ SearchChatsPage No chats found. - Чаты не найдены + Ничего не найдено Searching chats... @@ -1468,7 +1468,7 @@ Private Chat - Приватный Чат + Приватный чат Group @@ -1496,7 +1496,7 @@ Search Chats - Найти Чаты + Поиск чатов Search a chat... @@ -1614,23 +1614,23 @@ Always append message preview to notifications - + Всегда показывать последнее сообщение на экране событий In addition to showing the number of unread messages, the latest message will also be appended to notifications. - + Включать в текст на экране событий не только количество непрочитанных сообщений, но и содержимое последнего сообщения. Highlight unread messages - + Выделять непрочитанные сообщения Highlight Conversations with unread messages - + Помечать чаты и каналы с непрочитанными сообщениями другим шрифтом и цветом. Hide content in notifications - + Не показывать содержимое сообщений в уведомлениях @@ -1743,39 +1743,39 @@ %1 day(s) - - - - + + %1 день + %1 дня + %1 дней 1 week - + 1 неделя 1 month - + 1 месяц 3 months - + 3 месяца 6 months - + 6 месяцев 1 year - + 1 год Session Timeout - + Таймаут неактивности Inactive sessions will be terminated after this timeframe - + Неактивные сеансы будут автоматически завершены через указанное время. -- 2.43.0 From 4b9732b64f223aff28f6c70463dd582ce360e22d Mon Sep 17 00:00:00 2001 From: free software <45316884+carlosgonz0@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:31:41 -0500 Subject: [PATCH 25/75] Update harbour-fernschreiber-es.ts (#529) * Update harbour-fernschreiber-es.ts * Update harbour-fernschreiber-es.ts --- translations/harbour-fernschreiber-es.ts | 422 +++++++++++------------ 1 file changed, 211 insertions(+), 211 deletions(-) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 5bb74ef..06fd254 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -9,7 +9,7 @@ A Telegram client for Sailfish OS - Un cliente de Telegram para Sailfish SO + Cliente de Telegrama para Sailfish SO Send E-Mail @@ -17,7 +17,7 @@ Licensed under GNU GPLv3 - Licenciado bajo GNU GPLv3 + Licencia GNU GPLv3 Sources on GitHub @@ -37,7 +37,7 @@ This project uses the Telegram Database Library (TDLib). Thanks for making it available under the conditions of the Boost Software License 1.0! - Este proyecto usa la librería TDLib de Telegrama. ¡Gracias por estar disponible bajo las condiciones de la licencia software-boost 1.0! + Este proyecto usa librería TDLib de Telegrama. ¡Gracias por estar disponible bajo la licencia software-boost 1.0! Open Telegram Database Library on GitHub @@ -49,7 +49,7 @@ This product uses the Telegram API but is not endorsed or certified by Telegram. - Este programa usa la API de Telegrama, pero no está respaldado ni certificado por Telegrama. + Este programa usa API de Telegrama, pero no está respaldado ni certificado por Telegrama. TDLib version %1 @@ -57,7 +57,7 @@ This project uses twemoji. Copyright 2018 Twitter, Inc. and other contributors. Thanks for making it available under the conditions of the MIT License (coding) and CC-BY 4.0 (graphics)! - Este proyecto usa la librería Twemoji de Tweeter. Derechos de autor 2018 Twitter Inc, y otros colaboradores. ¡Gracias por estar disponible bajo las condiciones de la licencia MIT y CC-BY 4.0 + Este proyecto usa librería Twemoji de Tweeter. Derechos de autor 2018 Twitter Inc, y otros colaboradores. ¡Gracias por estar disponible bajo la licencia MIT y CC-BY 4.0 Open twemoji on GitHub @@ -69,7 +69,7 @@ This project uses rlottie. Copyright 2020 Samsung Electronics Co., Ltd. and other contributors. Thanks for making it available under the conditions of the MIT License! - Este proyecto usa la librería Rlottie de Samsung Electronics Co, y otros colaboradores. ¡Gracias por estar disponible bajo las condiciones de la licencia MIT + Este proyecto usa librería Rlottie de Samsung Electronics Co, y otros colaboradores. ¡Gracias por estar disponible bajo la licencia MIT Open rlottie on GitHub @@ -77,7 +77,7 @@ This project uses OpenStreetMap Nominatim for reverse geocoding of location attachments. Thanks for making it available as web service! - Este proyecto usa la librería OpenStreetMap Nominatim para la codificación geográfica inversa de archivos adjuntos de ubicación. ¡Gracias por estar disponible como servicio web! + Este proyecto usa librería OpenStreetMap Nominatim para la codificación geográfica inversa de archivos adjuntos de ubicación. ¡Gracias por estar disponible como servicio web! Open OSM Nominatim Wiki @@ -157,7 +157,7 @@ The Invite Link has been copied to the clipboard. - El enlace de invitación se ha copiado en el portapapeles. + Enlace invitación se ha copiado a portapapeles. %1, %2 @@ -250,7 +250,7 @@ Group Info - Información + Información Mark all messages as read @@ -258,7 +258,7 @@ No message in this chat. - No hay mensaje aún. + No hay mensaje. Mark chat as unread @@ -355,7 +355,7 @@ You joined the chat %1 - Te uniste al grupo + Unido al grupo Select Messages @@ -405,7 +405,7 @@ This secret chat is not yet ready. Your chat partner needs to go online first. - Esta conversación secreta aún no está lista. El contacto no está conectado. + Esta conversación secreta no está lista. El contacto no está conectado. Closing chat @@ -492,7 +492,7 @@ You don't have any chats yet. - No hay todavía conversaciones. + No hay conversaciones. @@ -510,11 +510,11 @@ Waiting for network... - Esperando la red... + Esperando red... Connecting to network... - Conectando al servidor... + Conectando a servidor... Connecting to proxy... @@ -593,7 +593,7 @@ New members can see older messages member permission - Los miembros nuevos pueden ver mensajes antiguos + Miembros nuevos pueden ver mensajes antiguos @@ -665,29 +665,29 @@ have registered with Telegram myself - se registró en Telegram + registrado a Telegram has registered with Telegram - te has registrado en Telegram + registrado a Telegrama joined this chat myself - se unió al grupo + unido a grupo joined this chat - se unió a este grupo + unido a grupo were added to this chat myself - se añadió a este grupo + unido a grupo was added to this chat - se añadió al grupo + unido a grupo left this chat @@ -715,11 +715,11 @@ changed the chat title myself - el título del grupo se cambió + título del grupo se cambió changed the chat title - el título del grupo se cambió + título del grupo se cambió sent a poll @@ -760,110 +760,110 @@ deleted the chat photo myself - borró la foto de la conversación + borró foto de conversación deleted the chat photo - borró la foto del grupo + borró foto de grupo changed the secret chat TTL setting myself - cambió los ajustes TTL en conversación secreta + cambió ajustes TTL en conversación secreta changed the secret chat TTL setting - cambió los ajustes TTL en conversación secreta + cambió ajustes TTL en conversación secreta upgraded this group to a supergroup myself - actualizó este grupo a un supergrupo + actualizó este grupo a supergrupo changed the pinned message myself - actualizó este grupo a un supergrupo + actualizó este grupo a supergrupo changed the pinned message - cambió el mensaje fijado + cambió mensaje fijado created a screenshot in this chat myself - creó un pantallazo en esta conversación + creó pantallazo a esta conversación created a screenshot in this chat - creó un pantallazo en esta conversación + creó pantallazo a esta conversación sent an unsupported message myself - envió un mensaje no admitido + envió mensaje no admitido sent an unsupported message - envió un mensaje no admitido + envió mensaje no admitido sent an unsupported message: %1 - envió un mensaje no admitido: %1 + envió mensaje no admitido: %1 upgraded this group to a supergroup - actualizó este grupo a un supergrupo + actualizó grupo a supergrupo sent a self-destructing photo that is expired myself - envió una foto autodestructiva que está caducada + envió foto autodestructiva que está caducada sent a self-destructing video that is expired myself - envió una foto autodestructiva que está caducada + envió foto autodestructiva que está caducada sent a self-destructing video that is expired - envió un vídeo autodestructivo que está caducado + envió vídeo autodestructivo que está caducado sent an unsupported message: %1 myself - envió un mensaje no admitido: %1 + envió mensaje no admitido: %1 sent a self-destructing photo that is expired - envió un foto autodestructivo que está caducado + envió foto autodestructivo que está caducado sent an audio myself - envió un audio + envió audio sent an audio - envió un audio + envió audio has added %1 to the chat - ha añadido %1 a la conversación + ha añadido %1 a conversación has removed %1 from the chat - ha quitado %1 de la conversación + ha quitado %1 de conversación have added %1 to the chat myself - ha añadido %1 a la conversación + ha añadido %1 a conversación have removed %1 from the chat myself - ha quitado %1 de la conversación + ha quitado %1 de conversación scored %Ln points @@ -883,20 +883,20 @@ sent a game myself - envió un juego + envió juego sent a game - envió un juego + envió juego sent a video note myself - envió una nota de video + envió nota de video sent a video note - envió una nota de video + envió nota de video @@ -937,11 +937,11 @@ Welcome to Fernschreiber! - Bienvenidos a Fernschreiber + Bienvenidos a Ferni! Please enter your phone number to continue. - Marcar el número telefónico. + Marcar número telefónico. Continue @@ -949,7 +949,7 @@ Please enter the code that you received: - Marcar el código recibido. + Marcar código recibido. Loading... @@ -957,19 +957,19 @@ Unable to authenticate you with the entered code. - No se pudo autenticar con el código marcado. + No se pudo autenticar con código marcado. Enter code again - Marcar código de nuevo + Remarcar código Restart authentication - Reiniciar la autenticación + Reiniciar autenticación Please enter your password: - Por favor, marcar el código: + Por favor, marcar código: Register User @@ -977,15 +977,15 @@ Enter your First Name - Marcar el nombre + Marcar nombre Enter your Last Name - Marcar el apellido + Marcar apellido User Registration - Registro de usuario + Registrar usuario Use the international format, e.g. %1 @@ -1112,14 +1112,14 @@ via %1 message posted via bot user - mensaje publicado a través del usuario Robot + via %1 MessageVoiceNote Voice Note - Nota de voz + Nota de voz @@ -1142,7 +1142,7 @@ End-to-end-encrypted, accessible on this device only - Encriptado fin-a-fin, accesible solo en este dispositivo + Encriptado fin-a-fin, accesible solo a este dispositivo Loading contacts... @@ -1150,7 +1150,7 @@ Transport-encrypted, uses Telegram Cloud, sharable across devices - Transporte-encriptado, usa la nube de Telegram, compartible entre dispositivos + Transporte-encriptado, usa nube de Telegrama, compartible entre dispositivos Search a contact... @@ -1158,11 +1158,11 @@ Synchronize Contacts with Telegram - Sincronizar con Telegram + Sincronizar con Telegrama Contacts successfully synchronized with Telegram. - Contactos sincronizados con éxito con Telegram. + Contactos sincronizados con éxito con Telegrama. No contacts found. @@ -1187,15 +1187,15 @@ Fernschreiber - Fernschreiber + Ferni Waiting for network... - Esperando la red... + Esperando red... Connecting to network... - Conectando al servidor... + Conectando a servidor... Connecting to proxy... @@ -1207,7 +1207,7 @@ Loading chat list... - cargando lista de conversaciones... + cargando lista de conversación... Settings @@ -1215,7 +1215,7 @@ You don't have any chats yet. - No hay todavía conversaciones. + No hay conversaciones. New Chat @@ -1235,11 +1235,11 @@ Download failed. - Error al bajar + Error a bajar Tap on the title bar to filter your chats - Deslizar hacia abajo para la polea de opciones + Deslizar hacia abajo para polea de opciones No matching chats found. @@ -1247,15 +1247,15 @@ You can search public chats or create a new chat via the pull-down menu. - Puede buscar grupos públicos o crear un grupo a través de la polea de opciones. + Puede buscar grupos públicos o crear un grupo a través de polea de opciones. Logging out - Saliendo de la cuenta + Saliendo de cuenta Unable to open link. - No se pudo abrir el enlace. + No se pudo abrir enlace. @@ -1277,11 +1277,11 @@ PollCreationPage All answers have to contain 1-100 characters. - Todas las respuestas deben contener de 1 a 100 caracteres. + Todas respuestas deben contener de 1 a 100 caracteres. To send a quiz, you have to specify the right answer. - Para enviar una cuestión, debe especificar la respuesta correcta. + Para enviar una cuestión, debe especificar respuesta correcta. You have to enter a question. @@ -1293,7 +1293,7 @@ A poll requires 2-10 answers. - Una encuesta requiere de 2 a 10 respuestas. + Encuesta requiere 2 a 10 respuestas. Create a Poll @@ -1307,7 +1307,7 @@ Enter your question here - Hacer la pregunta + Hacer pregunta Question (%Ln characters left) @@ -1323,7 +1323,7 @@ Enter an answer here - Hacer la respuesta + Hacer respuesta Answer (%Ln characters left) @@ -1334,7 +1334,7 @@ Add an answer - Agregar una respuesta + Agregar respuesta Poll Options @@ -1355,30 +1355,30 @@ Quizzes have one correct answer. Participants can't revoke their responses. - Los interrogatorios tienen una respuesta correcta. Los participantes no pueden revocar sus respuestas. + Cuestionarios tienen respuesta correcta. Participantes no pueden revocar las respuestas. Enter an optional explanation - Introducir una explicación opcional + Introducir explicación opcional Shown when the user selects a wrong answer. - Se muestra cuando la usuario selecciona una respuesta incorrecta. + Muestra cuando usuario selecciona respuesta incorrecta. An explanation can be up to 200 characters long. - Una explicación puede tener hasta 200 caracteres. + Explicación debe hasta 200 caracteres. PollResultsPage Quiz Results - Resultados de cuestionario + Resultados cuestionario Poll Results - Resultados de encuesta + Resultados encuesta %Ln vote(s) total @@ -1432,7 +1432,7 @@ SearchChatsPage No chats found. - No se han encontrado grupos. + No se encontrado grupos. Searching chats... @@ -1474,7 +1474,7 @@ Enter your query to start searching (at least 5 characters needed) - Para iniciar la búsqueda se necesitan al menos 5 caracteres + Iniciar búsqueda con al menos 5 caracteres @@ -1489,7 +1489,7 @@ Only display emojis instead of the actual stickers - Solo muestra los emoticonos en lugar de las pegatinas reales + Muestra emoticonos en lugar de pegatinas reales Show stickers as images @@ -1497,7 +1497,7 @@ Show background for stickers and align them centrally like images - Muestra un fondo para pegatinas y las alinea como imágenes + Muestra un fondo para pegatinas y alinea como imágenes Animate stickers @@ -1512,19 +1512,19 @@ Send message by enter - Enviar mensaje por tecla Entrar + Enviar mensaje tecla Entrar Send your message by pressing the enter key - Envía el mensajes pulsando la tecla Entrar + Envía mensajes pulsando tecla Entrar Focus text input on chat open - Enfocar entrada de texto en conversación + Enfocar entrada de texto a conversación Focus the text input area when entering a chat - Enfoca el área de entrada de texto al ingresar a una conversación + Enfoca área de entrada de texto al ingresar a conversación Focus text input area after send @@ -1532,7 +1532,7 @@ Focus the text input area after sending a message - Enfoca el área de entrada de texto después de enviar un mensaje + Enfoca área de entrada de texto después de enviar mensaje Delay before marking messages as read @@ -1540,15 +1540,15 @@ Fernschreiber will wait a bit before messages are marked as read - Si esta habilitado, la apl espera un segundo hasta que un mensaje que está en la pantalla se marque como leído. Si deshabilitas esta función, los mensajes se marcarán inmediatamente como leído una vez que esté en la pantalla sin desplazarse al mensaje + Si esta habilitado, apl espera un segundo hasta que mensaje que está en pantalla se marque como leído. Si deshabilita esta función, mensajes se marcarán inmediatamente como leído una vez que esté en pantalla sin desplazarse a mensaje Open-with menu integration - Integrar la opción Abrir-con + Integrar opción Abrir-Con Integrate Fernschreiber into open-with menu of Sailfish OS - Fernschreiber usa la opción abrir-con de Sailfish SO + Ferni usa opción Abrir-Con de Sailfish SO Notification feedback @@ -1556,7 +1556,7 @@ Use non-graphical feedback (sound, vibration) for notifications - Usa comentarios no gráficos (sonido, vibración) para las notificaciones + Usa comentarios no gráficos (sonido, vibración) para notificaciones All events @@ -1576,31 +1576,31 @@ Enable notification sounds - Habilitar sonidos de notificación + Habilitar sonidos notificación When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. - Cuando los sonidos están habilitados, Fernschreiber utilizará el sonido de notificación actual de Sailfish OS para los grupos, que se puede configurar en la configuración del sistema. + Cuando sonidos están habilitados, Ferni utilizará sonido de notificación actual de Sailfish OS para los grupos, que se puede ajustar a configuración del sistema. Always append message preview to notifications - + Agregar vista previa mensaje a notificaciones In addition to showing the number of unread messages, the latest message will also be appended to notifications. - + Mostrará cantidad mensajes no leídos, el último mensaje se agregará a notificaciones. Highlight unread messages - + Resaltar mensajes no leídos Highlight Conversations with unread messages - + Resaltar conversaciones a mensajes no leídos Hide content in notifications - + Ocultar contenido a notificaciones @@ -1622,7 +1622,7 @@ Privacy setting for managing whether you can be invited to chats. - Configuración de privacidad para administrar si puede ser invitado a grupos. + Ajustes de privacidad administrar si puede ser invitado a grupos. Yes @@ -1642,15 +1642,15 @@ Privacy setting for managing whether you can be found by your phone number. - Configuración de privacidad para administrar si puede ser encontrado por su número de teléfono. + Ajustes de privacidad administrar si puede ser encontrado por su número de teléfono. Show link in forwarded messages - Mostrar enlace en mensajes reenviados + Mostrar enlace a mensajes reenviados Privacy setting for managing whether a link to your account is included in forwarded messages. - Configuración de privacidad para administrar si un enlace de la cuenta está incluido en los mensajes reenviados. + Ajustes de privacidad administrar si un enlace de cuenta está incluido en mensajes reenviados. Show phone number @@ -1658,7 +1658,7 @@ Privacy setting for managing whether your phone number is visible. - Configuración de privacidad para administrar si su número de teléfono es visible. + Ajustes de privacidad administrar si su número de teléfono es visible. Show profile photo @@ -1666,7 +1666,7 @@ Privacy setting for managing whether your profile photo is visible. - Configuración de privacidad para administrar si la foto de perfil es visible. + Ajustes de privacidad administrar si la foto de perfil es visible. Show status @@ -1674,7 +1674,7 @@ Privacy setting for managing whether your online status is visible. - Configuración de privacidad para administrar si el estado en línea es visible. + Ajustes de privacidad administrar si el estado en línea es visible. Allow sending Location to inline bots @@ -1693,7 +1693,7 @@ Session was terminated - Se terminó la sesión + Se terminó sesión Terminating session @@ -1720,31 +1720,31 @@ 1 week - + 1 semana 1 month - + 1 mes 3 months - + 3 meses 6 months - + 6 meses 1 year - + 1 año Session Timeout - + Sesión caducada Inactive sessions will be terminated after this timeframe - + Sesiones inactivas finalizarán después de período de tiempo. @@ -1755,11 +1755,11 @@ Enable online-only mode - Modo solo en línea + Modo solo enlínea Disables offline caching. Certain features may be limited or missing in this mode. Changes require a restart of Fernschreiber to take effect. - Deshabilita el almacenamiento en caché sin conexión. Algunas funciones pueden estar limitadas o ausentes en este modo. Se requiere reiniciar Fernschreiber para su efecto. + Deshabilita almacenamiento en caché sin conexión. Algunas funciones pueden estar limitadas o ausentes en este modo. Se requiere reiniciar Ferni para efecto. Enable storage optimizer @@ -1770,7 +1770,7 @@ SettingsUserProfile User Profile - Perfil de usuario + Perfil usuario First Name @@ -1797,7 +1797,7 @@ Profile Pictures - Imagen de perfil + Imagen perfil Add Picture @@ -1809,7 +1809,7 @@ Deleting profile picture - Borrando la imagen de perfil + Borrando imagen perfil Uploading... @@ -1825,30 +1825,30 @@ Phone number: +%1 - + Número telefónico: +%1 Contacts successfully synchronized with Telegram. - Contactos sincronizados con éxito con Telegram. + Contactos sincronizados con éxito Telegrama. Synchronize Contacts with Telegram - Sincronizar con Telegram + Sincronizar Telegram SponsoredMessage Go to Channel - Ir al canal + Ir a canal Go to Message - Ir al mensaje + Ir a mensaje Start Bot - Iniciar Robot(Bot) + Iniciar Robot @@ -1859,37 +1859,37 @@ Removing sticker set - Quitando el álbum de pegatinas + Quitando álbum pegatinas Sticker set successfully removed! - ¡Album de pegatinas quitado correctamente! + ¡Album pegatinas quitado correctamente! StickerSetOverlay Sticker set successfully installed! - ¡Album de pegatinas instalado correctamente! + ¡Album pegatinas instalado correctamente! Sticker set successfully removed! - ¡Album de pegatinas quitado correctamente! + ¡Album pegatinas quitado correctamente! VideoPage Download of %1 successful. - Bajada de %1 exitosa. + Bajada %1 exitosa. Download failed. - Error al bajar + Error a bajar Copy video to gallery - Copiar video a la galería + Copiar video a galería @@ -1900,7 +1900,7 @@ Press the button to start recording - Presionar el botón para iniciar a grabar + Presionar botón para grabar Unavailable @@ -1935,7 +1935,7 @@ WebPagePreview Preview not supported for this link... - Vista previa no compatible con este enlace ... + Vista previa compatible con enlace ... @@ -1946,7 +1946,7 @@ has registered with Telegram - te has registrado en Telegram + Registrado a Telegrama Picture: %1 @@ -1970,43 +1970,43 @@ sent a picture - envió una imagen + envió imagen sent a video - envió un video + envió video sent an animation - envió una animación + envió animación sent an audio - envió un audio + envió audio sent a voice note - envió una nota de voz + envió nota de voz sent a document - envió un documento + envió documento sent a location - envió una ubicación + envió ubicación joined this chat - se unió a este grupo + Unido a grupo was added to this chat - se añadió a este grupo + Unido a grupo left this chat - dejó este grupo + dejó grupo %1M @@ -2018,61 +2018,61 @@ sent a venue - envió un lugar + envió lugar sent a picture myself - envió una imagen + envió imagen sent a video myself - envié un video + envié video sent an animation myself - envió una animación + envió animación sent an audio myself - envió un audio + envió audio sent a voice note myself - envió una nota de voz + envió nota de voz sent a document myself - envió un documento + envió documento sent a location myself - envió una ubicación + envió ubicación sent a venue myself - envió un lugar + envió lugar have registered with Telegram - se ha registrado en Telegram + registrado a Telegrama joined this chat myself - me uní a este grupo + unido a grupo were added to this chat myself - se agregó a esta grupo + unido a grupo left this chat @@ -2097,7 +2097,7 @@ online - en línea + enlínea was recently online @@ -2126,47 +2126,47 @@ changed the chat title to %1 myself - se cambió el título del grupo a %1 + cambió título de grupo a %1 changed the chat title to %1 - se cambió el título del grupo a %1 + cambió título de grupo a %1 sent a poll myself - envió una encuesta + envió encuesta sent a poll - envió una encuesta + envió encuesta sent an anonymous quiz myself - envió un cuestionario anónimo + envió cuestionario anónimo sent an anonymous quiz - envió un cuestionario anónimo + envió cuestionario anónimo sent a quiz myself - envió un cuestionario + envió cuestionario sent a quiz - envió un cuestionario + envió cuestionario sent an anonymous poll myself - envió una encuesta anónima + envió encuesta anónima sent an anonymous poll - envió una encuesta anónima + envió encuesta anónima Anonymous Quiz @@ -2187,120 +2187,120 @@ created this group myself - creó este grupo + creó grupo created this group - creó este grupo + creó grupo changed the chat photo myself - cambió la foto del grupo + cambió foto de grupo changed the chat photo - cambió la foto del grupo + cambió foto de grupo deleted the chat photo myself - borró la foto del grupo + borró foto de grupo deleted the chat photo - borró la foto del grupo + borró foto de grupo changed the secret chat TTL setting myself; TTL = Time To Live - cambió los ajustes de TTL de la conversación secreta + cambió ajustes de TTL de conversación secreta changed the secret chat TTL setting TTL = Time To Live - cambió los ajustes de TTL de la conversación secreta + cambió ajustes de TTL de conversación secreta upgraded this group to a supergroup myself - actualizó este grupo a un supergrupo + actualizó grupo a supergrupo changed the pinned message myself - cambió el mensaje fijado + cambió mensaje fijado changed the pinned message - cambió el mensaje fijado + cambió mensaje fijado created a screenshot in this chat myself - creó un pantallazo a esta conversación + creó pantallazo a conversación created a screenshot in this chat - creó un pantallazo a esta conversación + creó pantallazo a conversación sent an unsupported message myself - envió un mensaje no admitido + envió mensaje no admitido sent an unsupported message - envió un mensaje no admitido + envió mensaje no admitido sent an unsupported message: %1 myself; %1 is message type - envió un mensaje no admitido: %1 + envió mensaje no admitido: %1 sent an unsupported message: %1 %1 is message type - envió un mensaje no admitido: %1 + envió mensaje no admitido: %1 upgraded this group to a supergroup - actualizó este grupo a un supergrupo + actualizó grupo a supergrupo sent a self-destructing photo that is expired myself - envió una foto autodestructiva que está caducada + envió foto autodestructiva que está caducada sent a self-destructing photo that is expired - envió una foto autodestructiva que está caducada + envió foto autodestructiva que está caducada sent a self-destructing video that is expired myself - envió un vídeo autodestructivo que está caducado + envió vídeo autodestructivo que está caducado sent a self-destructing video that is expired - envió un vídeo autodestructivo que está caducado + envió vídeo autodestructivo que está caducado Unable to find user %1 - Error al buscar %1 + Error buscar %1 sent a video note myself - envió una nota de video + envió nota de video sent a video note - envió una nota de video + envió nota de video You are already a member of this chat. - Ya eres miembro de este grupo. + Ya miembro de grupo. Closed! @@ -2312,21 +2312,21 @@ has added %1 to the chat - ha añadido %1 al grupo + ha añadido %1 a grupo has removed %1 from the chat - ha quitado %1 del grupo + quitado %1 de grupo have added %1 to the chat myself - ha añadido %1 al grupo + agregado %1 a grupo have removed %1 from the chat myself - ha añadido %1 del grupo + agregado %1 de grupo scored %Ln points @@ -2339,11 +2339,11 @@ sent a game myself - envió un juego + envió juego sent a game - envió un juego + envió juego -- 2.43.0 From 256514e55d72f0cddc926b7c3e504cc4f9d40f72 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Tue, 21 Nov 2023 22:34:10 +0200 Subject: [PATCH 26/75] Added "unread mention" indicator to the chat list (#530) It's displayed in place of the "unread reaction" indicator. In case if there are both unread mentions and reactions, "unread mention" takes precedence. --- qml/components/PhotoTextsListItem.qml | 33 ++++++++++++++++++--------- src/tdlibreceiver.cpp | 3 +++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/qml/components/PhotoTextsListItem.qml b/qml/components/PhotoTextsListItem.qml index 959fdd5..344e25e 100644 --- a/qml/components/PhotoTextsListItem.qml +++ b/qml/components/PhotoTextsListItem.qml @@ -108,27 +108,38 @@ ListItem { } Rectangle { - id: chatUnreadReactionCountBackground color: isMuted ? ((Theme.colorScheme === Theme.DarkOnLight) ? "lightgray" : "dimgray") : Theme.highlightBackgroundColor width: Theme.fontSizeLarge height: Theme.fontSizeLarge anchors.right: parent.right anchors.top: parent.top radius: parent.width / 2 - visible: chatListViewItem.unreadReactionCount > 0 - } + visible: chatListViewItem.unreadReactionCount > 0 || chatListViewItem.unreadMentionCount > 0 - Icon { - source: "image://theme/icon-s-favorite" - height: Theme.iconSizeExtraSmall - width: Theme.iconSizeExtraSmall - highlighted: chatListViewItem.highlighted - anchors.centerIn: chatUnreadReactionCountBackground - visible: chatListViewItem.unreadReactionCount > 0 - } + Icon { + source: "image://theme/icon-s-favorite" + height: Theme.iconSizeExtraSmall + width: Theme.iconSizeExtraSmall + highlighted: chatListViewItem.highlighted + anchors.centerIn: parent + visible: chatListViewItem.unreadReactionCount > 0 && !chatListViewItem.unreadMentionCount + } + Text { + font { + pixelSize: Theme.iconSizeExtraSmall + bold: true + } + color: Theme.primaryColor + anchors.centerIn: parent + visible: chatListViewItem.unreadMentionCount > 0 + opacity: isMuted ? Theme.opacityHigh : 1.0 + text: "@" + } + } } } + Column { id: contentColumn anchors { diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index 8f65952..abd9d03 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -175,6 +175,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("updateMessageInteractionInfo", &TDLibReceiver::processUpdateMessageInteractionInfo); handlers.insert("sessions", &TDLibReceiver::processSessions); handlers.insert("availableReactions", &TDLibReceiver::processAvailableReactions); + handlers.insert("updateMessageMentionRead", &TDLibReceiver::processUpdateChatUnreadMentionCount); handlers.insert("updateChatUnreadMentionCount", &TDLibReceiver::processUpdateChatUnreadMentionCount); handlers.insert("updateChatUnreadReactionCount", &TDLibReceiver::processUpdateChatUnreadReactionCount); handlers.insert("updateActiveEmojiReactions", &TDLibReceiver::processUpdateActiveEmojiReactions); @@ -736,6 +737,8 @@ void TDLibReceiver::processAvailableReactions(const QVariantMap &receivedInforma void TDLibReceiver::processUpdateChatUnreadMentionCount(const QVariantMap &receivedInformation) { + // Handles both updateMessageMentionRead and updateChatUnreadMentionCount + // They both have chat_id and unread_mention_count which is all we need const qlonglong chatId = receivedInformation.value(CHAT_ID).toLongLong(); const int unreadMentionCount = receivedInformation.value(UNREAD_MENTION_COUNT).toInt(); LOG("Chat unread mention count updated" << chatId << unreadMentionCount); -- 2.43.0 From 02b6dd2e6df38b77085832a3ce41014eaf5e87ef Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 21 Nov 2023 21:55:08 +0100 Subject: [PATCH 27/75] Show reactions on double-click --- qml/components/MessageListViewItem.qml | 20 ++++++++++++-------- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 2ac1e87..fd73114 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -132,18 +132,22 @@ ListItem { if (messageListItem.messageReactions) { messageListItem.messageReactions = null; - } else if (messageListItem.chatReactions) { - Debug.log("Using chat reactions") - messageListItem.messageReactions = chatReactions - showItemCompletelyTimer.requestedIndex = index; - showItemCompletelyTimer.start(); - } else { - Debug.log("Obtaining message reactions") - tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); } } } + onDoubleClicked: { + if (messageListItem.chatReactions) { + Debug.log("Using chat reactions") + messageListItem.messageReactions = chatReactions + showItemCompletelyTimer.requestedIndex = index; + showItemCompletelyTimer.start(); + } else { + Debug.log("Obtaining message reactions") + tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); + } + } + onPressAndHold: { if (openMenuOnPressAndHold) { openContextMenu() diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 568b883..247c3bc 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 4 +Release: 5 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index c8cc6b0..0e87ef4 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 4 +Release: 5 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt -- 2.43.0 From 16bcef3c784a70e1683e84ba8b0e6e8849297ff2 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Wed, 22 Nov 2023 22:53:17 +0100 Subject: [PATCH 28/75] Interaction hint for new reactions behavior --- qml/pages/ChatPage.qml | 36 +++++++++++++++++++++ rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- src/appsettings.cpp | 15 +++++++++ src/appsettings.h | 5 +++ translations/harbour-fernschreiber-de.ts | 4 +++ translations/harbour-fernschreiber-en.ts | 4 +++ translations/harbour-fernschreiber-es.ts | 4 +++ translations/harbour-fernschreiber-fi.ts | 4 +++ translations/harbour-fernschreiber-fr.ts | 4 +++ translations/harbour-fernschreiber-hu.ts | 4 +++ translations/harbour-fernschreiber-it.ts | 4 +++ translations/harbour-fernschreiber-pl.ts | 4 +++ translations/harbour-fernschreiber-ru.ts | 4 +++ translations/harbour-fernschreiber-sk.ts | 4 +++ translations/harbour-fernschreiber-sv.ts | 4 +++ translations/harbour-fernschreiber-zh_CN.ts | 4 +++ translations/harbour-fernschreiber.ts | 4 +++ 18 files changed, 110 insertions(+), 2 deletions(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index c98c263..23f0da0 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -609,6 +609,15 @@ Page { chatViewCooldownTimer.restart(); chatViewStartupReadTimer.restart(); + + var remainingDoubleTapHints = appSettings.remainingDoubleTapHints; + Debug.log("Remaining double tap hints: " + remainingDoubleTapHints); + if (remainingDoubleTapHints > 0) { + doubleTapHintTimer.start(); + tapHint.visible = true; + tapHintLabel.visible = true; + appSettings.remainingDoubleTapHints = remainingDoubleTapHints - 1; + } } onNewMessageReceived: { if (( chatView.manuallyScrolledToBottom && Qt.application.state === Qt.ApplicationActive ) || message.sender_id.user_id === chatPage.myUserId) { @@ -2157,4 +2166,31 @@ Page { } } } + + Timer { + id: doubleTapHintTimer + running: true + triggeredOnStart: false + repeat: false + interval: 6000 + onTriggered: { + tapHint.visible = false; + tapHintLabel.visible = false; + } + } + + TapInteractionHint { + id: tapHint + loops: Animation.Infinite + taps: 2 + anchors.centerIn: parent + visible: false + } + + InteractionHintLabel { + id: tapHintLabel + anchors.bottom: parent.bottom + text: qsTr("Double-tap on a message to choose a reaction") + visible: false + } } diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 247c3bc..c642703 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 5 +Release: 6 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 0e87ef4..e4c228f 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 5 +Release: 6 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/src/appsettings.cpp b/src/appsettings.cpp index efd5b33..d63537a 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -35,6 +35,7 @@ namespace { const QString KEY_STORAGE_OPTIMIZER("useStorageOptimizer"); const QString KEY_INLINEBOT_LOCATION_ACCESS("allowInlineBotLocationAccess"); const QString KEY_REMAINING_INTERACTION_HINTS("remainingInteractionHints"); + const QString KEY_REMAINING_DOUBLE_TAP_HINTS("remainingDoubleTapHints"); const QString KEY_ONLINE_ONLY_MODE("onlineOnlyMode"); const QString KEY_DELAY_MESSAGE_READ("delayMessageRead"); const QString KEY_FOCUS_TEXTAREA_ON_CHAT_OPEN("focusTextAreaOnChatOpen"); @@ -243,6 +244,20 @@ void AppSettings::setRemainingInteractionHints(int remainingHints) } } +int AppSettings::remainingDoubleTapHints() const +{ + return settings.value(KEY_REMAINING_DOUBLE_TAP_HINTS, 3).toInt(); +} + +void AppSettings::setRemainingDoubleTapHints(int remainingHints) +{ + if (remainingDoubleTapHints() != remainingHints) { + LOG(KEY_REMAINING_DOUBLE_TAP_HINTS << remainingHints); + settings.setValue(KEY_REMAINING_DOUBLE_TAP_HINTS, remainingHints); + emit remainingDoubleTapHintsChanged(); + } +} + bool AppSettings::onlineOnlyMode() const { return settings.value(KEY_ONLINE_ONLY_MODE, false).toBool(); diff --git a/src/appsettings.h b/src/appsettings.h index e4a1a2d..84e59d9 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -38,6 +38,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged) Q_PROPERTY(bool allowInlineBotLocationAccess READ allowInlineBotLocationAccess WRITE setAllowInlineBotLocationAccess NOTIFY allowInlineBotLocationAccessChanged) Q_PROPERTY(int remainingInteractionHints READ remainingInteractionHints WRITE setRemainingInteractionHints NOTIFY remainingInteractionHintsChanged) + Q_PROPERTY(int remainingDoubleTapHints READ remainingDoubleTapHints WRITE setRemainingDoubleTapHints NOTIFY remainingDoubleTapHintsChanged) Q_PROPERTY(bool onlineOnlyMode READ onlineOnlyMode WRITE setOnlineOnlyMode NOTIFY onlineOnlyModeChanged) Q_PROPERTY(bool delayMessageRead READ delayMessageRead WRITE setDelayMessageRead NOTIFY delayMessageReadChanged) Q_PROPERTY(bool focusTextAreaOnChatOpen READ getFocusTextAreaOnChatOpen WRITE setFocusTextAreaOnChatOpen NOTIFY focusTextAreaOnChatOpenChanged) @@ -104,6 +105,9 @@ public: int remainingInteractionHints() const; void setRemainingInteractionHints(int remainingHints); + int remainingDoubleTapHints() const; + void setRemainingDoubleTapHints(int remainingHints); + bool onlineOnlyMode() const; void setOnlineOnlyMode(bool enable); @@ -134,6 +138,7 @@ signals: void storageOptimizerChanged(); void allowInlineBotLocationAccessChanged(); void remainingInteractionHintsChanged(); + void remainingDoubleTapHintsChanged(); void onlineOnlyModeChanged(); void delayMessageReadChanged(); void focusTextAreaOnChatOpenChanged(); diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index d0eac2d..c608557 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -483,6 +483,10 @@ Deleted User Gelöschtes Konto + + Double-tap on a message to choose a reaction + Drücke zweimal auf eine Nachricht, um eine Reaktion auszuwählen + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 4008317..3a0b0be 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -483,6 +483,10 @@ Deleted User Deleted User + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 06fd254..6b87cf8 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -483,6 +483,10 @@ Deleted User Usuario borrado + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index d0b22c8..7d08abb 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -483,6 +483,10 @@ Deleted User + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index 96f7e9b..a1c44e4 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -483,6 +483,10 @@ Deleted User Supprimer l'utilisateur + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 796c1c3..adcf023 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -473,6 +473,10 @@ Deleted User + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 48e863e..0ff0bfa 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -483,6 +483,10 @@ Deleted User + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index b16825d..436cd14 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -493,6 +493,10 @@ Deleted User Usunięty użytkownik + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 09982cd..9006ca3 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -493,6 +493,10 @@ Deleted User Удалённый пользователь + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index d4b14cf..df7ec3a 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -493,6 +493,10 @@ Deleted User Odstránený používateľ + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index d00eb6d..92078c6 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -483,6 +483,10 @@ Deleted User Tog bort användare + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 88727e2..c904169 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -473,6 +473,10 @@ Deleted User + + Double-tap on a message to choose a reaction + + ChatSelectionPage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index cc90573..d816a18 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -483,6 +483,10 @@ Deleted User + + Double-tap on a message to choose a reaction + + ChatSelectionPage -- 2.43.0 From bada6fb3e25195b68c0f249ed50ee050ec694fee Mon Sep 17 00:00:00 2001 From: free software <45316884+carlosgonz0@users.noreply.github.com> Date: Fri, 24 Nov 2023 17:11:41 -0500 Subject: [PATCH 29/75] Update harbour-fernschreiber-es.ts (#531) --- translations/harbour-fernschreiber-es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 6b87cf8..3ea5669 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -485,7 +485,7 @@ Double-tap on a message to choose a reaction - + Pulsar doble a mensaje y elegir reacción -- 2.43.0 From 2ae4e2eb057b1646bf4da77b376b0f40e8f2c66e Mon Sep 17 00:00:00 2001 From: Patrick Hervieux <5952038+pherjung@users.noreply.github.com> Date: Fri, 24 Nov 2023 23:13:18 +0100 Subject: [PATCH 30/75] Update French translation (#532) Co-authored-by: Patrick Hervieux --- translations/harbour-fernschreiber-fr.ts | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index a1c44e4..0c5097e 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1,6 +1,6 @@ - + AboutPage @@ -485,7 +485,7 @@ Double-tap on a message to choose a reaction - + Toucher deux fois sur un message pour réagir @@ -1170,7 +1170,7 @@ No contacts found. - + Aucun contact trouvé @@ -1588,23 +1588,23 @@ Always append message preview to notifications - + Toujours visualiser le message dans les notifications In addition to showing the number of unread messages, the latest message will also be appended to notifications. - + En plus d'afficher le nombre de messages non-lus, le dernier message sera également ajouté aux notifications. Highlight unread messages - + Mettre en valeur les messages non-lus Highlight Conversations with unread messages - + Mettre en valeur les conversations avec des messages non-lus Hide content in notifications - + Masquer le contenu dans les notifications @@ -1717,38 +1717,38 @@ %1 day(s) - - + + %1 jour(s) 1 week - + 1 semaine 1 month - + 1 mois 3 months - + 3 mois 6 months - + 6 mois 1 year - + 1 année Session Timeout - + Délai d'inactivité de session Inactive sessions will be terminated after this timeframe - + Sessions inactives seront terminées après ce délai -- 2.43.0 From 84594e4c2c0e90f99e523eaea6f694b37e58bd65 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 26 Nov 2023 19:05:51 +0200 Subject: [PATCH 31/75] Allow to remove a reaction (#536) --- qml/components/MessageListViewItem.qml | 19 ++++++++++++++--- src/tdlibwrapper.cpp | 29 ++++++++++++++++++++++++-- src/tdlibwrapper.h | 3 ++- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index fd73114..6065842 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -705,12 +705,25 @@ ListItem { MouseArea { anchors.fill: parent onClicked: { - tdLibWrapper.setMessageReaction(messageListItem.chatId, messageListItem.messageId, modelData); - messageListItem.messageReactions = null; + for (var i = 0; i < reactions.length; i++) { + var reaction = reactions[i] + var reactionText = reaction.reaction ? reaction.reaction : (reaction.type && reaction.type.emoji) ? reaction.type.emoji : "" + if (reactionText === modelData) { + if (reaction.is_chosen) { + // Reaction is already selected + tdLibWrapper.removeMessageReaction(chatId, messageId, reactionText) + messageReactions = null + return + } + break + } + } + // Reaction is not yet selected + tdLibWrapper.addMessageReaction(chatId, messageId, modelData) + messageReactions = null } } } - } } } diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index f815ccf..e082592 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1462,9 +1462,8 @@ void TDLibWrapper::getPageSource(const QString &address) connect(reply, SIGNAL(finished()), this, SLOT(handleGetPageSourceFinished())); } -void TDLibWrapper::setMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction) +void TDLibWrapper::addMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction) { - LOG("Set message reaction" << chatId << messageId << reaction); QVariantMap requestObject; requestObject.insert(CHAT_ID, chatId); requestObject.insert(MESSAGE_ID, messageId); @@ -1479,9 +1478,35 @@ void TDLibWrapper::setMessageReaction(qlonglong chatId, qlonglong messageId, con reactionType.insert(EMOJI, reaction); requestObject.insert(REACTION_TYPE, reactionType); requestObject.insert(_TYPE, "addMessageReaction"); + LOG("Add message reaction" << chatId << messageId << reaction); } else { requestObject.insert("reaction", reaction); requestObject.insert(_TYPE, "setMessageReaction"); + LOG("Toggle message reaction" << chatId << messageId << reaction); + } + this->sendRequest(requestObject); +} + +void TDLibWrapper::removeMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction) +{ + QVariantMap requestObject; + requestObject.insert(CHAT_ID, chatId); + requestObject.insert(MESSAGE_ID, messageId); + if (versionNumber > VERSION_NUMBER(1,8,5)) { + // "reaction_type": { + // "@type": "reactionTypeEmoji", + // "emoji": "..." + // } + QVariantMap reactionType; + reactionType.insert(_TYPE, REACTION_TYPE_EMOJI); + reactionType.insert(EMOJI, reaction); + requestObject.insert(REACTION_TYPE, reactionType); + requestObject.insert(_TYPE, "removeMessageReaction"); + LOG("Remove message reaction" << chatId << messageId << reaction); + } else { + requestObject.insert("reaction", reaction); + requestObject.insert(_TYPE, "setMessageReaction"); + LOG("Toggle message reaction" << chatId << messageId << reaction); } this->sendRequest(requestObject); } diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 17a0896..49cda61 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -249,7 +249,8 @@ public: Q_INVOKABLE void terminateSession(const QString &sessionId); Q_INVOKABLE void getMessageAvailableReactions(qlonglong chatId, qlonglong messageId); Q_INVOKABLE void getPageSource(const QString &address); - Q_INVOKABLE void setMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction); + Q_INVOKABLE void addMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction); + Q_INVOKABLE void removeMessageReaction(qlonglong chatId, qlonglong messageId, const QString &reaction); Q_INVOKABLE void setNetworkType(NetworkType networkType); Q_INVOKABLE void setInactiveSessionTtl(int days); -- 2.43.0 From 57017e8bff0c8a77d92b61adf37c7b829186fea5 Mon Sep 17 00:00:00 2001 From: Peter G Date: Sun, 26 Nov 2023 19:12:47 +0000 Subject: [PATCH 32/75] [Trivial]: Don't own bindir (#534) * [Trivial]: Don't own bindir This may seem like nitpicking, but the package should not own /usr/bin * Update rpm/harbour-fernschreiber.spec Co-authored-by: Sebastian Wolf --------- Co-authored-by: nephros Co-authored-by: Sebastian Wolf --- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index c642703..6d8bef5 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -69,7 +69,7 @@ desktop-file-install --delete-original \ %files %defattr(-,root,root,-) -%{_bindir} +%{_bindir}/%{name} %{_datadir}/%{name} %{_datadir}/applications/%{name}.desktop %{_datadir}/icons/hicolor/*/apps/%{name}.png diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index e4c228f..04890d5 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -46,7 +46,7 @@ Requires: # All installed files Files: - - '%{_bindir}' + - '%{_bindir}/*' - '%{_datadir}/%{name}' - '%{_datadir}/applications/%{name}.desktop' - '%{_datadir}/icons/hicolor/*/apps/%{name}.png' -- 2.43.0 From 98f067cda8d03df29cb7639410b95a651f805ce6 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 26 Nov 2023 20:36:30 +0100 Subject: [PATCH 33/75] Tweak reactions again... --- qml/components/MessageListViewItem.qml | 59 ++++++++++++++++++-------- qml/pages/ChatPage.qml | 4 ++ rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 4 +- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 6065842..737a26d 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -132,22 +132,13 @@ ListItem { if (messageListItem.messageReactions) { messageListItem.messageReactions = null; + selectReactionBubble.visible = false; + } else { + selectReactionBubble.visible = !selectReactionBubble.visible; } } } - onDoubleClicked: { - if (messageListItem.chatReactions) { - Debug.log("Using chat reactions") - messageListItem.messageReactions = chatReactions - showItemCompletelyTimer.requestedIndex = index; - showItemCompletelyTimer.start(); - } else { - Debug.log("Obtaining message reactions") - tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); - } - } - onPressAndHold: { if (openMenuOnPressAndHold) { openContextMenu() @@ -658,6 +649,39 @@ ListItem { } + Rectangle { + id: selectReactionBubble + visible: false + anchors { + horizontalCenter: messageListItem.isOwnMessage ? messageBackground.left : messageBackground.right + verticalCenter: messageBackground.verticalCenter + } + height: Theme.itemSizeExtraSmall + width: Theme.itemSizeExtraSmall + color: Theme.primaryColor + radius: parent.width / 2 + opacity: 0.5 + } + + IconButton { + id: selectReactionButton + visible: selectReactionBubble.visible + icon.source: "image://theme/icon-s-favorite" + anchors.centerIn: selectReactionBubble + onClicked: { + if (messageListItem.chatReactions) { + Debug.log("Using chat reactions") + messageListItem.messageReactions = chatReactions + showItemCompletelyTimer.requestedIndex = index; + showItemCompletelyTimer.start(); + } else { + Debug.log("Obtaining message reactions") + tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); + } + selectReactionBubble.visible = false; + } + } + } } @@ -666,7 +690,7 @@ ListItem { id: reactionsColumn width: parent.width - ( 2 * Theme.horizontalPageMargin ) anchors.top: messageTextRow.bottom - anchors.topMargin: Theme.paddingSmall + anchors.topMargin: Theme.paddingMedium anchors.horizontalCenter: parent.horizontalCenter visible: messageListItem.messageReactions ? ( messageListItem.messageReactions.length > 0 ? true : false ) : false opacity: messageListItem.messageReactions ? ( messageListItem.messageReactions.length > 0 ? 1 : 0 ) : 0 @@ -675,7 +699,7 @@ ListItem { Flickable { width: parent.width - height: reactionsResultRow.height + Theme.paddingSmall + height: reactionsResultRow.height + 2 * Theme.paddingMedium anchors.horizontalCenter: parent.horizontalCenter contentWidth: reactionsResultRow.width clip: true @@ -691,13 +715,13 @@ ListItem { Row { id: singleReactionRow - spacing: Theme.paddingSmall + spacing: Theme.paddingMedium Image { id: emojiPicture source: Emoji.getEmojiPath(modelData) - width: status === Image.Ready ? Theme.fontSizeLarge : 0 - height: Theme.fontSizeLarge + width: status === Image.Ready ? Theme.fontSizeExtraLarge : 0 + height: Theme.fontSizeExtraLarge } } @@ -721,6 +745,7 @@ ListItem { // Reaction is not yet selected tdLibWrapper.addMessageReaction(chatId, messageId, modelData) messageReactions = null + selectReactionBubble.visible = false } } } diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 23f0da0..c70e454 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -610,6 +610,8 @@ Page { chatViewCooldownTimer.restart(); chatViewStartupReadTimer.restart(); + /* + // Double-tap for reactions is currently disabled, let's see if we'll ever need it again var remainingDoubleTapHints = appSettings.remainingDoubleTapHints; Debug.log("Remaining double tap hints: " + remainingDoubleTapHints); if (remainingDoubleTapHints > 0) { @@ -618,6 +620,8 @@ Page { tapHintLabel.visible = true; appSettings.remainingDoubleTapHints = remainingDoubleTapHints - 1; } + */ + } onNewMessageReceived: { if (( chatView.manuallyScrolledToBottom && Qt.application.state === Qt.ApplicationActive ) || message.sender_id.user_id === chatPage.myUserId) { diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 6d8bef5..e114f17 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 6 +Release: 7 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 04890d5..4f49d27 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 6 +Release: 7 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt @@ -46,7 +46,7 @@ Requires: # All installed files Files: - - '%{_bindir}/*' + - '%{_bindir}/%{name}' - '%{_datadir}/%{name}' - '%{_datadir}/applications/%{name}.desktop' - '%{_datadir}/icons/hicolor/*/apps/%{name}.png' -- 2.43.0 From 24edb173471a9007ef930a42b496c9b8e53167ee Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 26 Nov 2023 20:53:09 +0100 Subject: [PATCH 34/75] Animate new reaction button --- qml/components/MessageListViewItem.qml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 737a26d..c174da2 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -652,6 +652,8 @@ ListItem { Rectangle { id: selectReactionBubble visible: false + opacity: visible ? 0.5 : 0.0 + Behavior on opacity { NumberAnimation {} } anchors { horizontalCenter: messageListItem.isOwnMessage ? messageBackground.left : messageBackground.right verticalCenter: messageBackground.verticalCenter @@ -660,12 +662,13 @@ ListItem { width: Theme.itemSizeExtraSmall color: Theme.primaryColor radius: parent.width / 2 - opacity: 0.5 } IconButton { id: selectReactionButton visible: selectReactionBubble.visible + opacity: visible ? 1.0 : 0.0 + Behavior on opacity { NumberAnimation {} } icon.source: "image://theme/icon-s-favorite" anchors.centerIn: selectReactionBubble onClicked: { -- 2.43.0 From 61faf0f4079e3c8f089052f33edc8eb7e5e3125a Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 26 Nov 2023 23:36:29 +0100 Subject: [PATCH 35/75] More tweaks for reactions --- qml/components/MessageListViewItem.qml | 43 +++++++++++++++++++------- qml/pages/ChatPage.qml | 3 ++ rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- src/tdlibwrapper.cpp | 1 + src/tdlibwrapper.h | 1 + 6 files changed, 39 insertions(+), 13 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index c174da2..98a5c32 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -115,6 +115,19 @@ ListItem { return interactionText; } + function openReactions() { + if (messageListItem.chatReactions) { + Debug.log("Using chat reactions") + messageListItem.messageReactions = chatReactions + showItemCompletelyTimer.requestedIndex = index; + showItemCompletelyTimer.start(); + } else { + Debug.log("Obtaining message reactions") + tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); + } + selectReactionBubble.visible = false; + } + onClicked: { if (messageListItem.precalculatedValues.pageIsSelecting) { page.toggleMessageSelection(myMessage); @@ -134,11 +147,17 @@ ListItem { messageListItem.messageReactions = null; selectReactionBubble.visible = false; } else { - selectReactionBubble.visible = !selectReactionBubble.visible; + if (messageListItem.chatReactions) { + selectReactionBubble.visible = !selectReactionBubble.visible; + } } } } + onDoubleClicked: { + openReactions(); + } + onPressAndHold: { if (openMenuOnPressAndHold) { openContextMenu() @@ -643,6 +662,17 @@ ListItem { textFormat: Text.StyledText maximumLineCount: 1 elide: Text.ElideRight + MouseArea { + anchors.fill: parent + onClicked: { + if (messageListItem.messageReactions) { + messageListItem.messageReactions = null; + selectReactionBubble.visible = false; + } else { + openReactions(); + } + } + } } } } @@ -672,16 +702,7 @@ ListItem { icon.source: "image://theme/icon-s-favorite" anchors.centerIn: selectReactionBubble onClicked: { - if (messageListItem.chatReactions) { - Debug.log("Using chat reactions") - messageListItem.messageReactions = chatReactions - showItemCompletelyTimer.requestedIndex = index; - showItemCompletelyTimer.start(); - } else { - Debug.log("Obtaining message reactions") - tdLibWrapper.getMessageAvailableReactions(messageListItem.chatId, messageListItem.messageId); - } - selectReactionBubble.visible = false; + openReactions(); } } diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index c70e454..48d741b 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -576,6 +576,9 @@ Page { onSponsoredMessageReceived: { chatPage.containsSponsoredMessages = true; } + onReactionsUpdated: { + availableReactions = tdLibWrapper.getChatReactions(chatInformation.id); + } } Connections { diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index e114f17..e074a21 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 7 +Release: 8 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 4f49d27..05f2fd4 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 7 +Release: 8 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index e082592..6b3e994 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -2093,6 +2093,7 @@ void TDLibWrapper::handleActiveEmojiReactionsUpdated(const QStringList& emojis) if (activeEmojiReactions != emojis) { activeEmojiReactions = emojis; LOG(emojis.count() << "reaction(s) available"); + emit reactionsUpdated(); } } diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 49cda61..c4773e3 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -339,6 +339,7 @@ signals: void chatUnreadMentionCountUpdated(qlonglong chatId, int unreadMentionCount); void chatUnreadReactionCountUpdated(qlonglong chatId, int unreadReactionCount); void tgUrlFound(const QString &tgUrl); + void reactionsUpdated(); public slots: void handleVersionDetected(const QString &version); -- 2.43.0 From 8258867407315ed3e5a7da22ec0f9e7238fa3ecf Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 27 Nov 2023 21:29:43 +0100 Subject: [PATCH 36/75] Open URLs without prefix --- qml/js/functions.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qml/js/functions.js b/qml/js/functions.js index 7299b0d..b2e2ca7 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -448,7 +448,12 @@ function handleLink(link) { } else if (link.indexOf(tMePrefixHttp) === 0) { handleTMeLink(link, tMePrefixHttp); } else { - Qt.openUrlExternally(link); + Debug.log("Trying to open URL externally: " + link) + if (link.indexOf("://") === -1) { + Qt.openUrlExternally("https://" + link) + } else { + Qt.openUrlExternally(link); + } } } } -- 2.43.0 From 80ecf50e743bd09f2649bdca5aa0af28885a9f28 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Wed, 29 Nov 2023 23:47:59 +0100 Subject: [PATCH 37/75] Only one star per list, restore users in poll results --- qml/components/MessageListViewItem.qml | 21 ++++++++++++++++++--- qml/pages/ChatPage.qml | 5 +++++ qml/pages/PollResultsPage.qml | 7 ++++--- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- src/tdlibreceiver.cpp | 7 +++++++ src/tdlibreceiver.h | 4 +++- src/tdlibwrapper.cpp | 1 + src/tdlibwrapper.h | 1 + 9 files changed, 41 insertions(+), 9 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 98a5c32..8de7e7c 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -147,9 +147,8 @@ ListItem { messageListItem.messageReactions = null; selectReactionBubble.visible = false; } else { - if (messageListItem.chatReactions) { - selectReactionBubble.visible = !selectReactionBubble.visible; - } + selectReactionBubble.visible = !selectReactionBubble.visible; + elementSelected(index); } } } @@ -181,6 +180,19 @@ ListItem { } } + Connections { + target: chatPage + onResetElements: { + messageListItem.messageReactions = null; + selectReactionBubble.visible = false; + } + onElementSelected: { + if (elementIndex !== index) { + selectReactionBubble.visible = false; + } + } + } + Loader { id: contextMenuLoader active: false @@ -285,6 +297,9 @@ ListItem { messageListItem.messageReactions = null; } } + onReactionsUpdated: { + chatReactions = tdLibWrapper.getChatReactions(page.chatInformation.id); + } } Timer { diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 48d741b..c7b1a73 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -67,6 +67,8 @@ Page { property bool doSendBotStartMessage property string sendBotStartMessageParameter property var availableReactions + signal resetElements() + signal elementSelected(int elementIndex) states: [ State { @@ -480,7 +482,10 @@ Page { if (pageStack.depth === 1) { // Only clear chat model if navigated back to overview page. In other cases we keep the information... chatModel.clear(); + } else { + resetElements(); } + break; } } diff --git a/qml/pages/PollResultsPage.qml b/qml/pages/PollResultsPage.qml index 69dabb7..0368757 100644 --- a/qml/pages/PollResultsPage.qml +++ b/qml/pages/PollResultsPage.qml @@ -143,10 +143,11 @@ Page { Connections { target: tdLibWrapper - onUsersReceived: { + onMessageSendersReceived: { + Debug.log("Received poll users...") if(extra === optionDelegate.usersResponseIdentifierString) { - for(var i = 0; i < userIds.length; i += 1) { - optionDelegate.users.append({id: userIds[i], user:tdLibWrapper.getUserInformation(userIds[i])}); + for(var i = 0; i < senders.length; i += 1) { + optionDelegate.users.append({id: senders[i].user_id, user:tdLibWrapper.getUserInformation(senders[i].user_id)}); } loadUsersTimer.start(); } diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index e074a21..420a075 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 8 +Release: 10 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 05f2fd4..655a6ce 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 8 +Release: 10 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index abd9d03..c93b549 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -160,6 +160,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("updateChatPinnedMessage", &TDLibReceiver::processUpdateChatPinnedMessage); handlers.insert("updateMessageIsPinned", &TDLibReceiver::processUpdateMessageIsPinned); handlers.insert("users", &TDLibReceiver::processUsers); + handlers.insert("messageSenders", &TDLibReceiver::processMessageSenders); handlers.insert("error", &TDLibReceiver::processError); handlers.insert("ok", &TDLibReceiver::ok); handlers.insert("secretChat", &TDLibReceiver::processSecretChat); @@ -634,6 +635,12 @@ void TDLibReceiver::processUsers(const QVariantMap &receivedInformation) emit usersReceived(receivedInformation.value(_EXTRA).toString(), receivedInformation.value("user_ids").toList(), receivedInformation.value(TOTAL_COUNT).toInt()); } +void TDLibReceiver::processMessageSenders(const QVariantMap &receivedInformation) +{ + LOG("Received Message Senders"); + emit messageSendersReceived(receivedInformation.value(_EXTRA).toString(), receivedInformation.value("senders").toList(), receivedInformation.value(TOTAL_COUNT).toInt()); +} + void TDLibReceiver::processError(const QVariantMap &receivedInformation) { LOG("Received an error"); diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index bfb380e..dda2cd0 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -88,7 +88,8 @@ signals: void chatTitleUpdated(const QString &chatId, const QString &title); void chatPinnedMessageUpdated(qlonglong chatId, qlonglong pinnedMessageId); void messageIsPinnedUpdated(qlonglong chatId, qlonglong messageId, bool isPinned); - void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers); + void usersReceived(const QString &extra, const QVariantList &senders, int totalUsers); + void messageSendersReceived(const QString &extra, const QVariantList &userIds, int totalUsers); void errorReceived(const int code, const QString &message, const QString &extra); void secretChat(qlonglong secretChatId, const QVariantMap &secretChat); void secretChatUpdated(qlonglong secretChatId, const QVariantMap &secretChat); @@ -173,6 +174,7 @@ private: void processUpdateChatPinnedMessage(const QVariantMap &receivedInformation); void processUpdateMessageIsPinned(const QVariantMap &receivedInformation); void processUsers(const QVariantMap &receivedInformation); + void processMessageSenders(const QVariantMap &receivedInformation); void processError(const QVariantMap &receivedInformation); void processSecretChat(const QVariantMap &receivedInformation); void processUpdateSecretChat(const QVariantMap &receivedInformation); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 6b3e994..6abda99 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -176,6 +176,7 @@ void TDLibWrapper::initializeTDLibReceiver() { connect(this->tdLibReceiver, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong)), this, SIGNAL(chatPinnedMessageUpdated(qlonglong, qlonglong))); connect(this->tdLibReceiver, SIGNAL(messageIsPinnedUpdated(qlonglong, qlonglong, bool)), this, SLOT(handleMessageIsPinnedUpdated(qlonglong, qlonglong, bool))); connect(this->tdLibReceiver, SIGNAL(usersReceived(QString, QVariantList, int)), this, SIGNAL(usersReceived(QString, QVariantList, int))); + connect(this->tdLibReceiver, SIGNAL(messageSendersReceived(QString, QVariantList, int)), this, SIGNAL(messageSendersReceived(QString, QVariantList, int))); connect(this->tdLibReceiver, SIGNAL(errorReceived(int, QString, QString)), this, SLOT(handleErrorReceived(int, QString, QString))); connect(this->tdLibReceiver, SIGNAL(contactsImported(QVariantList, QVariantList)), this, SIGNAL(contactsImported(QVariantList, QVariantList))); connect(this->tdLibReceiver, SIGNAL(messageEditedUpdated(qlonglong, qlonglong, QVariantMap)), this, SIGNAL(messageEditedUpdated(qlonglong, qlonglong, QVariantMap))); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index c4773e3..90ccf53 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -323,6 +323,7 @@ signals: void chatTitleUpdated(const QString &chatId, const QString &title); void chatPinnedMessageUpdated(qlonglong chatId, qlonglong pinnedMessageId); void usersReceived(const QString &extra, const QVariantList &userIds, int totalUsers); + void messageSendersReceived(const QString &extra, const QVariantList &senders, int totalUsers); void errorReceived(int code, const QString &message, const QString &extra); void contactsImported(const QVariantList &importerCount, const QVariantList &userIds); void messageNotFound(qlonglong chatId, qlonglong messageId); -- 2.43.0 From 07fdabc178ffb399d63fc49a9b3e2e1f0b535a65 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Fri, 1 Dec 2023 00:23:23 +0100 Subject: [PATCH 38/75] Handle event updateChatAvailableReactions --- rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- src/chatlistmodel.cpp | 30 ++++++++++++++++++++++++++++++ src/chatlistmodel.h | 2 ++ src/tdlibreceiver.cpp | 10 ++++++++++ src/tdlibreceiver.h | 2 ++ src/tdlibwrapper.cpp | 18 ++++++++++++++++++ src/tdlibwrapper.h | 2 ++ 8 files changed, 66 insertions(+), 2 deletions(-) diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 420a075..5f26d72 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 10 +Release: 11 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 655a6ce..27e4f25 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 10 +Release: 11 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt diff --git a/src/chatlistmodel.cpp b/src/chatlistmodel.cpp index 0b5d46d..1319938 100644 --- a/src/chatlistmodel.cpp +++ b/src/chatlistmodel.cpp @@ -44,6 +44,7 @@ namespace { const QString UNREAD_COUNT("unread_count"); const QString UNREAD_MENTION_COUNT("unread_mention_count"); const QString UNREAD_REACTION_COUNT("unread_reaction_count"); + const QString AVAILABLE_REACTIONS("available_reactions"); const QString NOTIFICATION_SETTINGS("notification_settings"); const QString LAST_READ_INBOX_MESSAGE_ID("last_read_inbox_message_id"); const QString LAST_READ_OUTBOX_MESSAGE_ID("last_read_outbox_message_id"); @@ -70,6 +71,7 @@ public: int unreadCount() const; int unreadMentionCount() const; int unreadReactionCount() const; + QVariant availableReactions() const; QVariant photoSmall() const; qlonglong lastReadInboxMessageId() const; qlonglong senderUserId() const; @@ -168,6 +170,11 @@ int ChatListModel::ChatData::unreadMentionCount() const return chatData.value(UNREAD_MENTION_COUNT).toInt(); } +QVariant ChatListModel::ChatData::availableReactions() const +{ + return chatData.value(AVAILABLE_REACTIONS); +} + int ChatListModel::ChatData::unreadReactionCount() const { return chatData.value(UNREAD_REACTION_COUNT).toInt(); @@ -400,6 +407,7 @@ ChatListModel::ChatListModel(TDLibWrapper *tdLibWrapper, AppSettings *appSetting connect(tdLibWrapper, SIGNAL(chatDraftMessageUpdated(qlonglong, QVariantMap, QString)), this, SLOT(handleChatDraftMessageUpdated(qlonglong, QVariantMap, QString))); connect(tdLibWrapper, SIGNAL(chatUnreadMentionCountUpdated(qlonglong, int)), this, SLOT(handleChatUnreadMentionCountUpdated(qlonglong, int))); connect(tdLibWrapper, SIGNAL(chatUnreadReactionCountUpdated(qlonglong, int)), this, SLOT(handleChatUnreadReactionCountUpdated(qlonglong, int))); + connect(tdLibWrapper, SIGNAL(chatAvailableReactionsUpdated(qlonglong, QString)), this, SLOT(handleChatAvailableReactionsUpdated(qlonglong, QString))); // Don't start the timer until we have at least one chat relativeTimeRefreshTimer = new QTimer(this); @@ -436,6 +444,7 @@ QHash ChatListModel::roleNames() const roles.insert(ChatListModel::RoleUnreadCount, "unread_count"); roles.insert(ChatListModel::RoleUnreadMentionCount, "unread_mention_count"); roles.insert(ChatListModel::RoleUnreadReactionCount, "unread_reaction_count"); + roles.insert(ChatListModel::RoleAvailableReactions, "available_reactions"); roles.insert(ChatListModel::RoleLastReadInboxMessageId, "last_read_inbox_message_id"); roles.insert(ChatListModel::RoleLastMessageSenderId, "last_message_sender_id"); roles.insert(ChatListModel::RoleLastMessageDate, "last_message_date"); @@ -472,6 +481,7 @@ QVariant ChatListModel::data(const QModelIndex &index, int role) const case ChatListModel::RolePhotoSmall: return data->photoSmall(); case ChatListModel::RoleUnreadCount: return data->unreadCount(); case ChatListModel::RoleUnreadMentionCount: return data->unreadMentionCount(); + case ChatListModel::RoleAvailableReactions: return data->availableReactions(); case ChatListModel::RoleUnreadReactionCount: return data->unreadReactionCount(); case ChatListModel::RoleLastReadInboxMessageId: return data->lastReadInboxMessageId(); case ChatListModel::RoleLastMessageSenderId: return data->senderUserId(); @@ -1036,6 +1046,26 @@ void ChatListModel::handleChatUnreadReactionCountUpdated(qlonglong chatId, int u } } +void ChatListModel::handleChatAvailableReactionsUpdated(qlonglong chatId, const QVariantMap availableReactions) +{ + if (chatIndexMap.contains(chatId)) { + LOG("Updating available reaction type for" << chatId << availableReactions); + const int chatIndex = chatIndexMap.value(chatId); + ChatData *chat = chatList.at(chatIndex); + chat->chatData.insert(AVAILABLE_REACTIONS, availableReactions); + QVector changedRoles; + changedRoles.append(ChatListModel::RoleAvailableReactions); + const QModelIndex modelIndex(index(chatIndex)); + emit dataChanged(modelIndex, modelIndex, changedRoles); + } else { + ChatData *chat = hiddenChats.value(chatId); + if (chat) { + LOG("Updating available reaction type for hidden chat" << chatId << availableReactions); + chat->chatData.insert(AVAILABLE_REACTIONS, availableReactions); + } + } +} + void ChatListModel::handleRelativeTimeRefreshTimer() { LOG("Refreshing timestamps"); diff --git a/src/chatlistmodel.h b/src/chatlistmodel.h index 9bcc837..af875df 100644 --- a/src/chatlistmodel.h +++ b/src/chatlistmodel.h @@ -42,6 +42,7 @@ public: RoleUnreadCount, RoleUnreadMentionCount, RoleUnreadReactionCount, + RoleAvailableReactions, RoleLastReadInboxMessageId, RoleLastMessageSenderId, RoleLastMessageDate, @@ -93,6 +94,7 @@ private slots: void handleChatDraftMessageUpdated(qlonglong chatId, const QVariantMap &draftMessage, const QString &order); void handleChatUnreadMentionCountUpdated(qlonglong chatId, int unreadMentionCount); void handleChatUnreadReactionCountUpdated(qlonglong chatId, int unreadReactionCount); + void handleChatAvailableReactionsUpdated(qlonglong chatId, const QVariantMap availableReactions); void handleRelativeTimeRefreshTimer(); signals: diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp index c93b549..44034c7 100644 --- a/src/tdlibreceiver.cpp +++ b/src/tdlibreceiver.cpp @@ -46,6 +46,7 @@ namespace { const QString UNREAD_COUNT("unread_count"); const QString UNREAD_MENTION_COUNT("unread_mention_count"); const QString UNREAD_REACTION_COUNT("unread_reaction_count"); + const QString AVAILABLE_REACTIONS("available_reactions"); const QString TEXT("text"); const QString LAST_READ_INBOX_MESSAGE_ID("last_read_inbox_message_id"); const QString LAST_READ_OUTBOX_MESSAGE_ID("last_read_outbox_message_id"); @@ -123,6 +124,7 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren handlers.insert("updateChatPosition", &TDLibReceiver::processUpdateChatPosition); handlers.insert("updateChatReadInbox", &TDLibReceiver::processUpdateChatReadInbox); handlers.insert("updateChatReadOutbox", &TDLibReceiver::processUpdateChatReadOutbox); + handlers.insert("updateChatAvailableReactions", &TDLibReceiver::processUpdateChatAvailableReactions); handlers.insert("updateBasicGroup", &TDLibReceiver::processUpdateBasicGroup); handlers.insert("updateSupergroup", &TDLibReceiver::processUpdateSuperGroup); handlers.insert("updateChatOnlineMemberCount", &TDLibReceiver::processChatOnlineMemberCountUpdated); @@ -363,6 +365,14 @@ void TDLibReceiver::processUpdateChatReadOutbox(const QVariantMap &receivedInfor emit chatReadOutboxUpdated(chat_id, last_read_outbox_message_id); } +void TDLibReceiver::processUpdateChatAvailableReactions(const QVariantMap &receivedInformation) +{ + const qlonglong chat_id(receivedInformation.value(CHAT_ID).toLongLong()); + const QVariantMap available_reactions(receivedInformation.value(AVAILABLE_REACTIONS).toMap()); + LOG("Available reactions updated for" << chat_id << "new information:" << available_reactions); + emit chatAvailableReactionsUpdated(chat_id, available_reactions); +} + void TDLibReceiver::processUpdateBasicGroup(const QVariantMap &receivedInformation) { const QVariantMap basicGroup(receivedInformation.value(BASIC_GROUP).toMap()); diff --git a/src/tdlibreceiver.h b/src/tdlibreceiver.h index dda2cd0..33771b6 100644 --- a/src/tdlibreceiver.h +++ b/src/tdlibreceiver.h @@ -52,6 +52,7 @@ signals: void chatPinnedUpdated(qlonglong chatId, bool isPinned); void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount); void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId); + void chatAvailableReactionsUpdated(const qlonglong &chatId, const QVariantMap &availableReactions); void basicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation); void superGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation); void chatOnlineMemberCountUpdated(const QString &chatId, int onlineMemberCount); @@ -136,6 +137,7 @@ private: void processUpdateChatPosition(const QVariantMap &receivedInformation); void processUpdateChatReadInbox(const QVariantMap &receivedInformation); void processUpdateChatReadOutbox(const QVariantMap &receivedInformation); + void processUpdateChatAvailableReactions(const QVariantMap &receivedInformation); void processUpdateBasicGroup(const QVariantMap &receivedInformation); void processUpdateSuperGroup(const QVariantMap &receivedInformation); void processChatOnlineMemberCountUpdated(const QVariantMap &receivedInformation); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 6abda99..70dcf65 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -137,6 +137,7 @@ void TDLibWrapper::initializeTDLibReceiver() { connect(this->tdLibReceiver, SIGNAL(chatOrderUpdated(QString, QString)), this, SIGNAL(chatOrderUpdated(QString, QString))); connect(this->tdLibReceiver, SIGNAL(chatReadInboxUpdated(QString, QString, int)), this, SIGNAL(chatReadInboxUpdated(QString, QString, int))); connect(this->tdLibReceiver, SIGNAL(chatReadOutboxUpdated(QString, QString)), this, SIGNAL(chatReadOutboxUpdated(QString, QString))); + connect(this->tdLibReceiver, SIGNAL(chatAvailableReactionsUpdated(qlonglong, QVariantMap)), this, SLOT(handleAvailableReactionsUpdated(qlonglong, QVariantMap))); connect(this->tdLibReceiver, SIGNAL(basicGroupUpdated(qlonglong, QVariantMap)), this, SLOT(handleBasicGroupUpdated(qlonglong, QVariantMap))); connect(this->tdLibReceiver, SIGNAL(superGroupUpdated(qlonglong, QVariantMap)), this, SLOT(handleSuperGroupUpdated(qlonglong, QVariantMap))); connect(this->tdLibReceiver, SIGNAL(chatOnlineMemberCountUpdated(QString, int)), this, SIGNAL(chatOnlineMemberCountUpdated(QString, int))); @@ -1632,12 +1633,15 @@ QVariantMap TDLibWrapper::getChat(const QString &chatId) QStringList TDLibWrapper::getChatReactions(const QString &chatId) { + LOG("Obtaining chat reactions for chat" << chatId); const QVariant available_reactions(chats.value(chatId).toMap().value(CHAT_AVAILABLE_REACTIONS)); const QVariantMap map(available_reactions.toMap()); const QString reactions_type(map.value(_TYPE).toString()); if (reactions_type == CHAT_AVAILABLE_REACTIONS_ALL) { + LOG("Chat uses all available reactions, currently available number" << activeEmojiReactions.size()); return activeEmojiReactions; } else if (reactions_type == CHAT_AVAILABLE_REACTIONS_SOME) { + LOG("Chat uses reduced set of reactions"); const QVariantList reactions(map.value(REACTIONS).toList()); const int n = reactions.count(); QStringList emojis; @@ -1659,10 +1663,13 @@ QStringList TDLibWrapper::getChatReactions(const QString &chatId) } } } + LOG("Found emojis for this chat" << emojis.size()); return emojis; } else if (reactions_type.isEmpty()) { + LOG("No chat reaction type specified, using all reactions"); return available_reactions.toStringList(); } else { + LOG("Unknown chat reaction type" << reactions_type); return QStringList(); } } @@ -1932,6 +1939,17 @@ void TDLibWrapper::handleUnreadChatCountUpdated(const QVariantMap &chatCountInfo } } +void TDLibWrapper::handleAvailableReactionsUpdated(qlonglong chatId, const QVariantMap &availableReactions) +{ + LOG("Updating available reactions for chat" << chatId << availableReactions); + QString chatIdString = QString::number(chatId); + QVariantMap chatInformation = this->getChat(chatIdString); + chatInformation.insert(CHAT_AVAILABLE_REACTIONS, availableReactions); + this->chats.insert(chatIdString, chatInformation); + emit chatAvailableReactionsUpdated(chatId, availableReactions); + +} + void TDLibWrapper::handleBasicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation) { emit basicGroupUpdated(updateGroup(groupId, groupInformation, &basicGroups)->groupId); diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h index 90ccf53..2487ae5 100644 --- a/src/tdlibwrapper.h +++ b/src/tdlibwrapper.h @@ -280,6 +280,7 @@ signals: void chatPinnedUpdated(qlonglong chatId, bool isPinned); void chatReadInboxUpdated(const QString &chatId, const QString &lastReadInboxMessageId, int unreadCount); void chatReadOutboxUpdated(const QString &chatId, const QString &lastReadOutboxMessageId); + void chatAvailableReactionsUpdated(const qlonglong &chatId, const QVariantMap &availableReactions); void userUpdated(const QString &userId, const QVariantMap &userInformation); void ownUserUpdated(const QVariantMap &userInformation); void basicGroupUpdated(qlonglong groupId); @@ -354,6 +355,7 @@ public slots: void handleChatReceived(const QVariantMap &chatInformation); void handleUnreadMessageCountUpdated(const QVariantMap &messageCountInformation); void handleUnreadChatCountUpdated(const QVariantMap &chatCountInformation); + void handleAvailableReactionsUpdated(qlonglong chatId, const QVariantMap &availableReactions); void handleBasicGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation); void handleSuperGroupUpdated(qlonglong groupId, const QVariantMap &groupInformation); void handleStickerSets(const QVariantList &stickerSets); -- 2.43.0 From 8eda82da1832568f2b3c4c48030b7efc09c68be8 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 3 Dec 2023 00:12:52 +0200 Subject: [PATCH 39/75] Fix broken signal-slot connection (#541) QObject::connect: No such signal TDLibWrapper::chatAvailableReactionsUpdated(qlonglong, QString) in src/chatlistmodel.cpp:410 --- src/chatlistmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chatlistmodel.cpp b/src/chatlistmodel.cpp index 1319938..a361c18 100644 --- a/src/chatlistmodel.cpp +++ b/src/chatlistmodel.cpp @@ -407,7 +407,7 @@ ChatListModel::ChatListModel(TDLibWrapper *tdLibWrapper, AppSettings *appSetting connect(tdLibWrapper, SIGNAL(chatDraftMessageUpdated(qlonglong, QVariantMap, QString)), this, SLOT(handleChatDraftMessageUpdated(qlonglong, QVariantMap, QString))); connect(tdLibWrapper, SIGNAL(chatUnreadMentionCountUpdated(qlonglong, int)), this, SLOT(handleChatUnreadMentionCountUpdated(qlonglong, int))); connect(tdLibWrapper, SIGNAL(chatUnreadReactionCountUpdated(qlonglong, int)), this, SLOT(handleChatUnreadReactionCountUpdated(qlonglong, int))); - connect(tdLibWrapper, SIGNAL(chatAvailableReactionsUpdated(qlonglong, QString)), this, SLOT(handleChatAvailableReactionsUpdated(qlonglong, QString))); + connect(tdLibWrapper, SIGNAL(chatAvailableReactionsUpdated(qlonglong,QVariantMap)), this, SLOT(handleChatAvailableReactionsUpdated(qlonglong,QVariantMap))); // Don't start the timer until we have at least one chat relativeTimeRefreshTimer = new QTimer(this); -- 2.43.0 From 64479f0dd3aeb5dfc876274b154bea1d2c4cd512 Mon Sep 17 00:00:00 2001 From: mbarashkov Date: Sun, 3 Dec 2023 01:44:14 +0300 Subject: [PATCH 40/75] Improve chat UI on tablets by making messages narrower and limiting content items width as well. (#540) Co-authored-by: Mikhail Barashkov --- qml/components/MessageListViewItem.qml | 12 +++++++++--- qml/components/settingsPage/ResponsiveGrid.qml | 3 ++- qml/js/functions.js | 4 ++++ qml/pages/ChatPage.qml | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 8de7e7c..5ff54d8 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -128,6 +128,10 @@ ListItem { selectReactionBubble.visible = false; } + function getContentWidthMultiplier() { + return Functions.isTablet(appWindow) ? 0.4 : 1.0 + } + onClicked: { if (messageListItem.precalculatedValues.pageIsSelecting) { page.toggleMessageSelection(myMessage); @@ -365,8 +369,10 @@ ListItem { id: messageTextRow spacing: Theme.paddingSmall width: precalculatedValues.entryWidth - anchors.horizontalCenter: parent.horizontalCenter + anchors.horizontalCenter: Functions.isTablet(appWindow) ? undefined : parent.horizontalCenter + anchors.left: Functions.isTablet(appWindow) ? parent.left : undefined y: Theme.paddingSmall + anchors.leftMargin: Functions.isTablet(appWindow) ? Theme.paddingMedium : undefined Loader { id: profileThumbnailLoader @@ -596,7 +602,7 @@ ListItem { id: webPagePreviewLoader active: false asynchronous: true - width: parent.width + width: parent.width * getContentWidthMultiplier() height: (status === Loader.Ready) ? item.implicitHeight : myMessage.content.web_page ? precalculatedValues.webPagePreviewHeight : 0 sourceComponent: Component { @@ -610,7 +616,7 @@ ListItem { Loader { id: extraContentLoader - width: parent.width + width: parent.width * getContentWidthMultiplier() asynchronous: true height: item ? item.height : (messageListItem.hasContentComponent ? chatView.getContentComponentHeight(model.content_type, myMessage.content, width) : 0) } diff --git a/qml/components/settingsPage/ResponsiveGrid.qml b/qml/components/settingsPage/ResponsiveGrid.qml index 1d1bb55..8caf663 100644 --- a/qml/components/settingsPage/ResponsiveGrid.qml +++ b/qml/components/settingsPage/ResponsiveGrid.qml @@ -19,9 +19,10 @@ import QtQuick 2.6 import Sailfish.Silica 1.0 +import "../../js/functions.js" as Functions Grid { width: parent.width - ( 2 * x ) - columns: (appWindow.deviceOrientation & Orientation.LandscapeMask) || Screen.sizeCategory === Screen.Large || Screen.sizeCategory === Screen.ExtraLarge ? 2 : 1 + columns: Functions.isTablet(appWindow) ? 2 : 1 readonly property real columnWidth: width/columns } diff --git a/qml/js/functions.js b/qml/js/functions.js index b2e2ca7..e1c2634 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -540,3 +540,7 @@ function getMessagesNeededForwardPermissions(messages) { } return neededPermissions } + +function isTablet(appWindow) { + return (appWindow.deviceOrientation & Silica.Orientation.LandscapeMask) || Silica.Screen.sizeCategory === Silica.Screen.Large || Silica.Screen.sizeCategory === Silica.Screen.ExtraLarge +} diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index c7b1a73..41ad784 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1193,7 +1193,7 @@ Page { readonly property int profileThumbnailDimensions: showUserInfo ? Theme.itemSizeSmall : 0 readonly property int pageMarginDouble: 2 * Theme.horizontalPageMargin readonly property int paddingMediumDouble: 2 * Theme.paddingMedium - readonly property int entryWidth: chatView.width - pageMarginDouble + readonly property int entryWidth: Functions.isTablet(appWindow) ? chatView.width * 0.75 : chatView.width - pageMarginDouble readonly property int textItemWidth: entryWidth - profileThumbnailDimensions - Theme.paddingSmall readonly property int backgroundWidth: page.isChannel ? textItemWidth : textItemWidth - pageMarginDouble readonly property int backgroundRadius: textItemWidth/50 -- 2.43.0 From bba4a6468c3af50f56d1dd80f81d73dee476d148 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 2 Dec 2023 23:50:13 +0100 Subject: [PATCH 41/75] Not only tablets have widescreen ;) --- qml/components/MessageListViewItem.qml | 8 ++++---- qml/components/settingsPage/ResponsiveGrid.qml | 2 +- qml/js/functions.js | 2 +- qml/pages/ChatPage.qml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 5ff54d8..81cf572 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -129,7 +129,7 @@ ListItem { } function getContentWidthMultiplier() { - return Functions.isTablet(appWindow) ? 0.4 : 1.0 + return Functions.isWidescreen(appWindow) ? 0.4 : 1.0 } onClicked: { @@ -369,10 +369,10 @@ ListItem { id: messageTextRow spacing: Theme.paddingSmall width: precalculatedValues.entryWidth - anchors.horizontalCenter: Functions.isTablet(appWindow) ? undefined : parent.horizontalCenter - anchors.left: Functions.isTablet(appWindow) ? parent.left : undefined + anchors.horizontalCenter: Functions.isWidescreen(appWindow) ? undefined : parent.horizontalCenter + anchors.left: Functions.isWidescreen(appWindow) ? parent.left : undefined y: Theme.paddingSmall - anchors.leftMargin: Functions.isTablet(appWindow) ? Theme.paddingMedium : undefined + anchors.leftMargin: Functions.isWidescreen(appWindow) ? Theme.paddingMedium : undefined Loader { id: profileThumbnailLoader diff --git a/qml/components/settingsPage/ResponsiveGrid.qml b/qml/components/settingsPage/ResponsiveGrid.qml index 8caf663..a5bc592 100644 --- a/qml/components/settingsPage/ResponsiveGrid.qml +++ b/qml/components/settingsPage/ResponsiveGrid.qml @@ -23,6 +23,6 @@ import "../../js/functions.js" as Functions Grid { width: parent.width - ( 2 * x ) - columns: Functions.isTablet(appWindow) ? 2 : 1 + columns: Functions.isWidescreen(appWindow) ? 2 : 1 readonly property real columnWidth: width/columns } diff --git a/qml/js/functions.js b/qml/js/functions.js index e1c2634..5199d82 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -541,6 +541,6 @@ function getMessagesNeededForwardPermissions(messages) { return neededPermissions } -function isTablet(appWindow) { +function isWidescreen(appWindow) { return (appWindow.deviceOrientation & Silica.Orientation.LandscapeMask) || Silica.Screen.sizeCategory === Silica.Screen.Large || Silica.Screen.sizeCategory === Silica.Screen.ExtraLarge } diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 41ad784..d6dbe80 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1193,7 +1193,7 @@ Page { readonly property int profileThumbnailDimensions: showUserInfo ? Theme.itemSizeSmall : 0 readonly property int pageMarginDouble: 2 * Theme.horizontalPageMargin readonly property int paddingMediumDouble: 2 * Theme.paddingMedium - readonly property int entryWidth: Functions.isTablet(appWindow) ? chatView.width * 0.75 : chatView.width - pageMarginDouble + readonly property int entryWidth: Functions.isWidescreen(appWindow) ? chatView.width * 0.75 : chatView.width - pageMarginDouble readonly property int textItemWidth: entryWidth - profileThumbnailDimensions - Theme.paddingSmall readonly property int backgroundWidth: page.isChannel ? textItemWidth : textItemWidth - pageMarginDouble readonly property int backgroundRadius: textItemWidth/50 -- 2.43.0 From 2dd1d2c380c8348c077c9dd22661d1d7e49cfdc7 Mon Sep 17 00:00:00 2001 From: mbarashkov Date: Sun, 3 Dec 2023 02:46:47 +0300 Subject: [PATCH 42/75] Jump to post from quote (#538) * Jump to post from quote * Add a setting to go to quoted message. --------- Co-authored-by: Mikhail Barashkov --- qml/components/MessageListViewItem.qml | 8 ++++++-- .../settingsPage/SettingsBehavior.qml | 11 ++++++++++ qml/pages/ChatPage.qml | 20 +++++++++++++++++++ src/appsettings.cpp | 15 ++++++++++++++ src/appsettings.h | 5 +++++ src/chatmodel.cpp | 20 +++++++++++++++++++ src/chatmodel.h | 2 ++ translations/harbour-fernschreiber-de.ts | 8 ++++++++ translations/harbour-fernschreiber-en.ts | 8 ++++++++ translations/harbour-fernschreiber-es.ts | 8 ++++++++ translations/harbour-fernschreiber-fi.ts | 8 ++++++++ translations/harbour-fernschreiber-fr.ts | 8 ++++++++ translations/harbour-fernschreiber-hu.ts | 8 ++++++++ translations/harbour-fernschreiber-it.ts | 8 ++++++++ translations/harbour-fernschreiber-pl.ts | 8 ++++++++ translations/harbour-fernschreiber-ru.ts | 8 ++++++++ translations/harbour-fernschreiber-sk.ts | 8 ++++++++ translations/harbour-fernschreiber-sv.ts | 8 ++++++++ translations/harbour-fernschreiber-zh_CN.ts | 8 ++++++++ translations/harbour-fernschreiber.ts | 8 ++++++++ 20 files changed, 183 insertions(+), 2 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 81cf572..9baf0c1 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -489,8 +489,12 @@ ListItem { page.toggleMessageSelection(myMessage) } else { messageOptionsDrawer.open = false - messageOverlayLoader.overlayMessage = messageInReplyToRow.inReplyToMessage - messageOverlayLoader.active = true + if(appSettings.goToQuotedMessage) { + chatPage.showMessage(messageInReplyToRow.inReplyToMessage.id, true) + } else { + messageOverlayLoader.active = true + messageOverlayLoader.overlayMessage = messageInReplyToRow.inReplyToMessage + } } } onPressAndHold: { diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index 18b487e..2232791 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -103,6 +103,17 @@ AccordionItem { } } + TextSwitch { + width: parent.columnWidth + checked: appSettings.goToQuotedMessage + text: qsTr("Go to quoted message") + description: qsTr("When tapping a quoted message, open it in chat instead of showing it in an overlay.") + automaticCheck: false + onClicked: { + appSettings.goToQuotedMessage = !checked + } + } + ComboBox { id: feedbackComboBox width: parent.columnWidth diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index d6dbe80..4150c50 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -54,6 +54,7 @@ Page { property bool iterativeInitialization: false; property var messageToShow; property string messageIdToShow; + property string messageIdToScrollTo; readonly property bool userIsMember: ((isPrivateChat || isSecretChat) && chatInformation["@type"]) || // should be optimized (isBasicGroup || isSuperGroup) && ( (chatGroupInformation.status["@type"] === "chatMemberStatusMember") @@ -409,6 +410,23 @@ Page { chatPage.focus = true; } + function showMessage(messageId, initialRun) { + // Means we tapped a quoted message and had to load it. + if(initialRun) { + chatPage.messageIdToScrollTo = messageId + } + if (chatPage.messageIdToScrollTo && chatPage.messageIdToScrollTo != "") { + var index = chatModel.getMessageIndex(chatPage.messageIdToScrollTo); + if(index !== -1) { + chatPage.messageIdToScrollTo = ""; + chatView.scrollToIndex(index); + } else if(initialRun) { + // we only want to do this once. + chatModel.triggerLoadHistoryForMessage(chatPage.messageIdToScrollTo) + } + } + } + Timer { id: forwardMessagesTimer interval: 200 @@ -657,6 +675,8 @@ Page { if (chatView.height > chatView.contentHeight) { Debug.log("[ChatPage] Chat content quite small..."); viewMessageTimer.queueViewMessage(chatView.count - 1); + } else if (chatPage.messageIdToScrollTo && chatPage.messageIdToScrollTo != "") { + showMessage(chatPage.messageIdToScrollTo, false) } chatViewCooldownTimer.restart(); chatViewStartupReadTimer.restart(); diff --git a/src/appsettings.cpp b/src/appsettings.cpp index d63537a..6df3f38 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -32,6 +32,7 @@ namespace { const QString KEY_NOTIFICATION_SUPPRESS_ENABLED("notificationSuppressContent"); const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback"); const QString KEY_NOTIFICATION_ALWAYS_SHOW_PREVIEW("notificationAlwaysShowPreview"); + const QString KEY_GO_TO_QUOTED_MESSAGE("goToQuotedMessage"); const QString KEY_STORAGE_OPTIMIZER("useStorageOptimizer"); const QString KEY_INLINEBOT_LOCATION_ACCESS("allowInlineBotLocationAccess"); const QString KEY_REMAINING_INTERACTION_HINTS("remainingInteractionHints"); @@ -201,6 +202,20 @@ void AppSettings::setNotificationAlwaysShowPreview(bool enable) } } +bool AppSettings::goToQuotedMessage() const +{ + return settings.value(KEY_GO_TO_QUOTED_MESSAGE, false).toBool(); +} + +void AppSettings::setGoToQuotedMessage(bool enable) +{ + if (goToQuotedMessage() != enable) { + LOG(KEY_GO_TO_QUOTED_MESSAGE << enable); + settings.setValue(KEY_GO_TO_QUOTED_MESSAGE, enable); + emit goToQuotedMessageChanged(); + } +} + bool AppSettings::storageOptimizer() const { return settings.value(KEY_STORAGE_OPTIMIZER, true).toBool(); diff --git a/src/appsettings.h b/src/appsettings.h index 84e59d9..acc38b2 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -35,6 +35,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool notificationSuppressContent READ notificationSuppressContent WRITE setNotificationSuppressContent NOTIFY notificationSuppressContentChanged) Q_PROPERTY(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged) Q_PROPERTY(bool notificationAlwaysShowPreview READ notificationAlwaysShowPreview WRITE setNotificationAlwaysShowPreview NOTIFY notificationAlwaysShowPreviewChanged) + Q_PROPERTY(bool goToQuotedMessage READ goToQuotedMessage WRITE setGoToQuotedMessage NOTIFY goToQuotedMessageChanged) Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged) Q_PROPERTY(bool allowInlineBotLocationAccess READ allowInlineBotLocationAccess WRITE setAllowInlineBotLocationAccess NOTIFY allowInlineBotLocationAccessChanged) Q_PROPERTY(int remainingInteractionHints READ remainingInteractionHints WRITE setRemainingInteractionHints NOTIFY remainingInteractionHintsChanged) @@ -96,6 +97,9 @@ public: bool notificationAlwaysShowPreview() const; void setNotificationAlwaysShowPreview(bool enable); + bool goToQuotedMessage() const; + void setGoToQuotedMessage(bool enable); + bool storageOptimizer() const; void setStorageOptimizer(bool enable); @@ -135,6 +139,7 @@ signals: void notificationSuppressContentChanged(); void notificationFeedbackChanged(); void notificationAlwaysShowPreviewChanged(); + void goToQuotedMessageChanged(); void storageOptimizerChanged(); void allowInlineBotLocationAccessChanged(); void remainingInteractionHintsChanged(); diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index b4bf632..96c40ce 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -363,6 +363,15 @@ void ChatModel::initialize(const QVariantMap &chatInformation) tdLibWrapper->getChatHistory(chatId, this->chatInformation.value(LAST_READ_INBOX_MESSAGE_ID).toLongLong()); } +void ChatModel::triggerLoadHistoryForMessage(qlonglong messageId) +{ + if (!this->inIncrementalUpdate && !messages.isEmpty()) { + LOG("Trigger loading message with id..." << messageId); + this->inIncrementalUpdate = true; + this->tdLibWrapper->getChatHistory(chatId, messageId); + } +} + void ChatModel::triggerLoadMoreHistory() { if (!this->inIncrementalUpdate && !messages.isEmpty()) { @@ -400,6 +409,17 @@ QVariantMap ChatModel::getMessage(int index) return QVariantMap(); } +int ChatModel::getMessageIndex(qlonglong messageId) +{ + if (messages.size() == 0) { + return -1; + } + if (messageIndexMap.contains(messageId)) { + return messageIndexMap.value(messageId); + } + return -1; +} + int ChatModel::getLastReadMessageIndex() { LOG("Obtaining last read message index"); diff --git a/src/chatmodel.h b/src/chatmodel.h index bf4781f..bbf1b4a 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -40,12 +40,14 @@ public: Q_INVOKABLE void clear(bool contentOnly = false); Q_INVOKABLE void initialize(const QVariantMap &chatInformation); Q_INVOKABLE void triggerLoadMoreHistory(); + Q_INVOKABLE void triggerLoadHistoryForMessage(qlonglong messageId); Q_INVOKABLE void triggerLoadMoreFuture(); Q_INVOKABLE QVariantMap getChatInformation(); Q_INVOKABLE QVariantMap getMessage(int index); Q_INVOKABLE int getLastReadMessageIndex(); Q_INVOKABLE void setSearchQuery(const QString newSearchQuery); + Q_INVOKABLE int getMessageIndex(qlonglong messageId); QVariantMap smallPhoto() const; qlonglong getChatId() const; diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index c608557..bef6175 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1606,6 +1606,14 @@ Hide content in notifications Inhalte in Hinweisen verbergen + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 3a0b0be..345cc41 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1608,6 +1608,14 @@ messages Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 3ea5669..9a3615d 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1606,6 +1606,14 @@ Hide content in notifications Ocultar contenido a notificaciones + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 7d08abb..ca6341c 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1607,6 +1607,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index 0c5097e..9cbf533 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1606,6 +1606,14 @@ Hide content in notifications Masquer le contenu dans les notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index adcf023..e07e622 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1579,6 +1579,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 0ff0bfa..8920edd 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1606,6 +1606,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 436cd14..2cf1221 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1633,6 +1633,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 9006ca3..76461d8 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1636,6 +1636,14 @@ Hide content in notifications Не показывать содержимое сообщений в уведомлениях + + Go to quoted message + Переходить к цитируемому сообщению + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + По нажатию на цитируемое сообщение, переходить к нему в чате вместо отображения во всплывающем окне. + SettingsPage diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index df7ec3a..bee3622 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1633,6 +1633,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 92078c6..61b8abe 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1606,6 +1606,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index c904169..63b71e5 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1580,6 +1580,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index d816a18..d508bc5 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1606,6 +1606,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage -- 2.43.0 From 4ed949537605cf329288ef2208740bcd8b3606eb Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 3 Dec 2023 00:44:17 +0100 Subject: [PATCH 43/75] Highlight message that was jumped to --- qml/components/MessageListViewItem.qml | 22 +++++++++++++++++++++- qml/pages/ChatPage.qml | 2 ++ translations/harbour-fernschreiber-de.ts | 4 ++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 9baf0c1..523f74c 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -47,6 +47,7 @@ ListItem { readonly property bool canDeleteMessage: myMessage.can_be_deleted_for_all_users || (myMessage.can_be_deleted_only_for_self && myMessage.chat_id === page.myUserId) property bool hasContentComponent property bool additionalOptionsOpened + property bool wasNavigatedTo: false readonly property var additionalItemsModel: (extraContentLoader.item && ("extraContextMenuItems" in extraContentLoader.item)) ? extraContentLoader.item.extraContextMenuItems : 0 @@ -67,7 +68,7 @@ ListItem { property var chatReactions property var messageReactions - highlighted: (down || isSelected || additionalOptionsOpened) && !menuOpen + highlighted: (down || isSelected || additionalOptionsOpened || wasNavigatedTo) && !menuOpen openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting signal replyToMessage() @@ -195,6 +196,12 @@ ListItem { selectReactionBubble.visible = false; } } + onNavigatedTo: { + if (targetIndex === index) { + messageListItem.wasNavigatedTo = true; + restoreNormalityTimer.start(); + } + } } Loader { @@ -327,6 +334,19 @@ ListItem { } } + Timer { + id: restoreNormalityTimer + + repeat: false + running: false + interval: 1000 + triggeredOnStart: false + onTriggered: { + Debug.log("Restore normality for index " + index); + messageListItem.wasNavigatedTo = false; + } + } + Component.onCompleted: { delegateComponentLoadingTimer.start(); if (myMessage.reply_to_message_id) { diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 4150c50..17ced0b 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -70,6 +70,7 @@ Page { property var availableReactions signal resetElements() signal elementSelected(int elementIndex) + signal navigatedTo(int targetIndex) states: [ State { @@ -420,6 +421,7 @@ Page { if(index !== -1) { chatPage.messageIdToScrollTo = ""; chatView.scrollToIndex(index); + navigatedTo(index); } else if(initialRun) { // we only want to do this once. chatModel.triggerLoadHistoryForMessage(chatPage.messageIdToScrollTo) diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index bef6175..1662801 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1608,11 +1608,11 @@ Go to quoted message - + Zu zitierter Nachricht springen When tapping a quoted message, open it in chat instead of showing it in an overlay. - + Beim Tippen auf eine zitierte Nachricht zu dieser springen anstatt es in einem Overlay anzuzeigen. -- 2.43.0 From 47ee85915d71cc8c9f98932cd8264bae66eb0910 Mon Sep 17 00:00:00 2001 From: free software <45316884+carlosgonz0@users.noreply.github.com> Date: Sun, 3 Dec 2023 04:48:20 -0500 Subject: [PATCH 44/75] Update harbour-fernschreiber-es.ts (#542) --- translations/harbour-fernschreiber-es.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 9a3615d..158d540 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1608,11 +1608,11 @@ Go to quoted message - + Ir a mensaje citado When tapping a quoted message, open it in chat instead of showing it in an overlay. - + Al Pulsar mensaje citado, abrirá en Charla en lugar de mostrarlo en una superposición. @@ -1725,9 +1725,9 @@ %1 day(s) - - - + + %1 dia + %1 dias @@ -2351,11 +2351,11 @@ sent a game myself - envió juego + envió un juego sent a game - envió juego + envió un juego -- 2.43.0 From b2363af36f6f6c691a9a347da068e704ab193b45 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 3 Dec 2023 13:53:32 +0200 Subject: [PATCH 45/75] Tweaked the logic of moving reactions into the view (#543) There's no need to reposition list items if reactions bar are already fully visible. --- qml/components/MessageListViewItem.qml | 14 +++++++++----- qml/pages/ChatPage.qml | 5 ++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 523f74c..a0cf5d8 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -325,11 +325,15 @@ ListItem { onTriggered: { Debug.log("Show item completely timer triggered, requested index: " + requestedIndex + ", current index: " + index) if (requestedIndex === index) { - chatView.highlightMoveDuration = -1; - chatView.highlightResizeDuration = -1; - chatView.scrollToIndex(requestedIndex); - chatView.highlightMoveDuration = 0; - chatView.highlightResizeDuration = 0; + var p = chatView.contentItem.mapFromItem(reactionsColumn, 0, 0) + if (chatView.contentY > p.y || p.y + reactionsColumn.height > chatView.contentY + chatView.height) { + Debug.log("Moving reactions for item at", requestedIndex, "info the view") + chatView.highlightMoveDuration = -1 + chatView.highlightResizeDuration = -1 + chatView.scrollToIndex(requestedIndex, height <= chatView.height ? ListView.Contain : ListView.End) + chatView.highlightMoveDuration = 0 + chatView.highlightResizeDuration = 0 + } } } } diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 17ced0b..b0423b1 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1241,10 +1241,9 @@ Page { manuallyScrolledToBottom = chatView.atYEnd } - function scrollToIndex(index) { + function scrollToIndex(index, mode) { if(index > 0 && index < chatView.count) { - positionViewAtIndex(index, ListView.Contain) - // currentIndex = index; + positionViewAtIndex(index, (mode === undefined) ? ListView.Contain : mode) if(index === chatView.count - 1) { manuallyScrolledToBottom = true; } -- 2.43.0 From c1ab982cb12ac76a5eef479eb72cf506332dd143 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 3 Dec 2023 12:59:41 +0100 Subject: [PATCH 46/75] Restore content width in landscape as per discussion in #540 --- qml/pages/ChatPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index b0423b1..c06fb51 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1215,7 +1215,7 @@ Page { readonly property int profileThumbnailDimensions: showUserInfo ? Theme.itemSizeSmall : 0 readonly property int pageMarginDouble: 2 * Theme.horizontalPageMargin readonly property int paddingMediumDouble: 2 * Theme.paddingMedium - readonly property int entryWidth: Functions.isWidescreen(appWindow) ? chatView.width * 0.75 : chatView.width - pageMarginDouble + readonly property int entryWidth: chatView.width - pageMarginDouble readonly property int textItemWidth: entryWidth - profileThumbnailDimensions - Theme.paddingSmall readonly property int backgroundWidth: page.isChannel ? textItemWidth : textItemWidth - pageMarginDouble readonly property int backgroundRadius: textItemWidth/50 -- 2.43.0 From 4af73184b2c1cac84915fb55a287c1b184f4478b Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 3 Dec 2023 13:22:45 +0100 Subject: [PATCH 47/75] Prepare 0.17 release --- README.md | 8 ++++++-- rpm/harbour-fernschreiber.changes | 20 ++++++++++++++++++++ rpm/harbour-fernschreiber.spec | 2 +- rpm/harbour-fernschreiber.yaml | 2 +- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 765e970..bfb06b6 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,11 @@ Fernschreiber wouldn't be the same without all the people helping in making it b - Chat info page, performance improvements to chat page, location support, app initialization/registration with Telegram, project dependencies, emoji handling, qml/js optimizations, multi-message actions, i18n fixes, chat permission handling, code reviews, logging categories, bot support, github build: [jgibbon](https://github.com/jgibbon) - Copy message to clipboard: [Christian Stemmle](https://github.com/chstem) - Hide send message button if send-by-enter is switched on, focus text input on entering a chat: [santhoshmanikandan](https://github.com/santhoshmanikandan) -- Integration of logout and sesison options to settings page: [Peter G.](https://github.com/nephros) +- Integration of logout and sesison options to settings page, search results optimization, highlight unread conversations: [Peter G.](https://github.com/nephros) +- Option to always append last message in notifications: [Johannes Bachmann](https://github.com/dscheinah) +- Option to jump to quoted message, widescreen UI adjustments: [Mikhail Barashkov](https://github.com/mbarashkov) + +This list might not be complete. In case I forgot something/somebody, please let me know or create a PR, thanks! :) ### Logo/Icon - Designed by [Matteo](https://github.com/iamnomeutente), adjustments by [Slava Monich](https://github.com/monich) @@ -48,7 +52,7 @@ const char TDLIB_API_HASH[] = "1234567890abcdef1234567890abcdef"; You get the Telegram API ID and hash as soon as you've registered your own application on [https://my.telegram.org](https://my.telegram.org). -Moreover, you need to have a compiled version of [TDLib 1.8.3](https://github.com/tdlib/td) or higher in the sub-directory `tdlib`. This sub-directory must contain another sub-directory that fits to the target device architecture (e.g. armv7hl, i486). Within this directory, there needs to be a folder called `lib` that contains at least `libtdjson.so`. For armv7hl the relative path would consequently be `tdlib/armv7hl/lib`. +Moreover, you need to have a compiled version of [TDLib 1.8.21](https://github.com/tdlib/td) or higher in the sub-directory `tdlib`. This sub-directory must contain another sub-directory that fits to the target device architecture (e.g. armv7hl, i486). Within this directory, there needs to be a folder called `lib` that contains at least `libtdjson.so`. For armv7hl the relative path would consequently be `tdlib/armv7hl/lib`. You may just want to download the [tdlib.zip from our fork](https://github.com/Wunderfitz/td/releases) to just use the exact version of the latest official Fernschreiber release. To use it, you need to extract it into your local `tdlib/` folder as described above. If so, you're done and can compile Fernschreiber using the Sailfish SDK. If you want to build TDLib for yourself, please keep on reading. diff --git a/rpm/harbour-fernschreiber.changes b/rpm/harbour-fernschreiber.changes index 768e8ac..a138beb 100644 --- a/rpm/harbour-fernschreiber.changes +++ b/rpm/harbour-fernschreiber.changes @@ -12,6 +12,26 @@ # * date Author's Name version-release # - Summary of changes +* Sun Dec 03 2023 Sebastian J. Wolf 0.17 +- Update to TDLib 1.8.21, expect some hiccups ;) +- Added contacts sync (OpenRepos builds only) +- Tweaks to reaction handling (opens now on double click or click + star) +- Option to jump to quoted message +- Option to highlight unread conversations +- Option to suppress notification previews +- Option to append last message content to notifications +- Added "unread mention" indicator to chat list +- Improve message when search yields no results +- New unread info for chats with high amount of unread messages +- Setting for session inactivity timeout +- UI improvements in landscape mode +- Fix: Restore video functionality on SFOS 4.5 +- Fix: Chat list timestamp now updated more reliably +- Fix: Faster reconnect after network changes +- Fix: Some URLs couldn't be opened +- Updated translations for several languages +- Thanks to monich, nephros, arustg, jgibbon, carlosgonz0, okruhliak, dscheinah, pherjung and mbarashkov for your contributions + * Sun Jun 12 2022 Sebastian J. Wolf 0.16 - Support message reactions - Support t.me/+... links diff --git a/rpm/harbour-fernschreiber.spec b/rpm/harbour-fernschreiber.spec index 5f26d72..224bf45 100644 --- a/rpm/harbour-fernschreiber.spec +++ b/rpm/harbour-fernschreiber.spec @@ -12,7 +12,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 11 +Release: 12 Group: Qt/Qt License: LICENSE URL: http://werkwolf.eu/ diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml index 27e4f25..82dd0f5 100644 --- a/rpm/harbour-fernschreiber.yaml +++ b/rpm/harbour-fernschreiber.yaml @@ -1,7 +1,7 @@ Name: harbour-fernschreiber Summary: Fernschreiber is a Telegram client for Sailfish OS Version: 0.17 -Release: 11 +Release: 12 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt -- 2.43.0 From ab647e6e4d38f9cdd15c78efcbdf503946e4dd52 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 3 Dec 2023 14:30:57 +0100 Subject: [PATCH 48/75] Switch to gh tool for release creation, see https://github.com/actions/runner-images/issues/8362 --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef7c334..566aae9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -84,7 +84,7 @@ jobs: assets+=("-a" "$asset") done tag_name="${GITHUB_REF##*/}" - hub release create "${assets[@]}" -m "$tag_name" "$tag_name" + gh release create "$tag_name" "${assets[@]}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -97,6 +97,6 @@ jobs: assets+=("-a" "$asset") done tag_name="${GITHUB_REF##*/}" - hub release create -p "${assets[@]}" -m "$tag_name" -m "This is a pre-release for testing purposes only. It may or may not be unstable." -m "Join the Telegram group to help out: https://github.com/Wunderfitz/harbour-fernschreiber/issues/162" "$tag_name" + gh release create "$tag_name" -p -n "This is a pre-release for testing purposes only. It may or may not be unstable." "${assets[@]}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -- 2.43.0 From a1277fe79a3973d0c2072c839b2858305e7d923d Mon Sep 17 00:00:00 2001 From: free software <45316884+carlosgonz0@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:18:30 -0500 Subject: [PATCH 49/75] Improvements: harbour-fernschreiber-es.ts (#544) --- translations/harbour-fernschreiber-es.ts | 130 +++++++++++------------ 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 158d540..5b9cf21 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -45,7 +45,7 @@ About Telegram - Telegram + Telegrama This product uses the Telegram API but is not endorsed or certified by Telegram. @@ -173,7 +173,7 @@ New Secret Chat - Crear conversación secreta + Crear Charla Secreta Unmute Chat @@ -193,7 +193,7 @@ Loading common chats… chats you have in common with a user - Cargando conversaciones comunes… + Cargando charlas comunes… Loading group members… @@ -274,11 +274,11 @@ Unpin chat - Desanclar conversación + Desanclar charla Pin chat - Anclar conversación + Anclar charla Unmute chat @@ -339,7 +339,7 @@ This chat is empty. - Esta conversación está vacía. + Esta charla está vacía. Leave Chat @@ -351,7 +351,7 @@ Leaving chat - Saliendo de conversación + Saliendo de charla You joined the chat %1 @@ -405,15 +405,15 @@ This secret chat is not yet ready. Your chat partner needs to go online first. - Esta conversación secreta no está lista. El contacto no está conectado. + Esta charla secreta no está lista. El contacto no está conectado. Closing chat - Cerrando la conversación + Cerrando charla Close Chat - Cerrar conversación + Cerrar charla Search in Chat @@ -473,11 +473,11 @@ Deleting chat - Borrando la conversación + Borrando charla Delete Chat - Borrar conversación + Borrar Charla Deleted User @@ -492,11 +492,11 @@ ChatSelectionPage Select Chat - Seleccionar conversación + Seleccionar Charla You don't have any chats yet. - No hay conversaciones. + No hay charlas. @@ -536,7 +536,7 @@ chats conversación - conversaciones + charlas @@ -577,7 +577,7 @@ Change Chat Info member permission - Cambiar detalles de conversación + Cambiar detalles de Charla Invite Users @@ -612,7 +612,7 @@ Set how long every chat member has to wait between Messages - Establecer cuánto tiempo debe esperar cada miembro de conversación entre mensajes + Establecer cuánto tiempo debe esperar cada miembro de charla entre Mensajes @@ -669,7 +669,7 @@ have registered with Telegram myself - registrado a Telegram + registrado a Telegrama has registered with Telegram @@ -696,11 +696,11 @@ left this chat myself - dejó esta conversación + dejó esta charla left this chat - dejó esta conversación + dejó esta charla sent a voice note @@ -755,7 +755,7 @@ changed the chat photo myself - cambió la foto de la conversación + cambió foto de charla changed the chat photo @@ -764,7 +764,7 @@ deleted the chat photo myself - borró foto de conversación + borró foto de charla deleted the chat photo @@ -773,11 +773,11 @@ changed the secret chat TTL setting myself - cambió ajustes TTL en conversación secreta + cambió ajustes TTL en charla secreta changed the secret chat TTL setting - cambió ajustes TTL en conversación secreta + cambió ajustes TTL en charla secreta upgraded this group to a supergroup @@ -796,11 +796,11 @@ created a screenshot in this chat myself - creó pantallazo a esta conversación + creó pantallazo a esta charla created a screenshot in this chat - creó pantallazo a esta conversación + creó pantallazo a esta charla sent an unsupported message @@ -853,21 +853,21 @@ has added %1 to the chat - ha añadido %1 a conversación + ha añadido %1 a charla has removed %1 from the chat - ha quitado %1 de conversación + ha quitado %1 de charla have added %1 to the chat myself - ha añadido %1 a conversación + ha añadido %1 a charla have removed %1 from the chat myself - ha quitado %1 de conversación + ha quitado %1 de charla scored %Ln points @@ -887,11 +887,11 @@ sent a game myself - envió juego + envió un juego sent a game - envió juego + envió un juego sent a video note @@ -1211,7 +1211,7 @@ Loading chat list... - cargando lista de conversación... + cargando lista de charla... Settings @@ -1219,11 +1219,11 @@ You don't have any chats yet. - No hay conversaciones. + No hay charlas. New Chat - Crear conversación + Crear Charla Filter your chats... @@ -1489,7 +1489,7 @@ Show stickers as emojis - Mostrar pegatinas como emoticonos + Mostrar pegatinas como Emoticonos Only display emojis instead of the actual stickers @@ -1497,7 +1497,7 @@ Show stickers as images - Mostrar pegatinas como imágenes + Mostrar pegatinas como Imágenes Show background for stickers and align them centrally like images @@ -1505,7 +1505,7 @@ Animate stickers - Mostrar pegatinas animadas + Mostrar pegatinas Animadas @@ -1524,15 +1524,15 @@ Focus text input on chat open - Enfocar entrada de texto a conversación + Enfocar entrada de texto de Charla Focus the text input area when entering a chat - Enfoca área de entrada de texto al ingresar a conversación + Enfoca área de entrada de texto al ingresar a charla Focus text input area after send - Enfocar área de entrada de texto + Enfocar área de entrada de Texto Focus the text input area after sending a message @@ -1540,11 +1540,11 @@ Delay before marking messages as read - Marcar mensajes como leídos + Marcar mensajes como Leídos Fernschreiber will wait a bit before messages are marked as read - Si esta habilitado, apl espera un segundo hasta que mensaje que está en pantalla se marque como leído. Si deshabilita esta función, mensajes se marcarán inmediatamente como leído una vez que esté en pantalla sin desplazarse a mensaje + Si esta habilitado, Apl espera un segundo hasta que mensaje que está en monitor se marque como leído. Si deshabilita esta función, mensajes se marcarán inmediatamente como leído una vez que esté en monitor sin desplazarse a mensaje Open-with menu integration @@ -1576,19 +1576,19 @@ Notification turns on the display - Mostrar notificación por pantalla + Mostrar notificación por Monitor Enable notification sounds - Habilitar sonidos notificación + Habilitar sonidos de Notificación When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. - Cuando sonidos están habilitados, Ferni utilizará sonido de notificación actual de Sailfish OS para los grupos, que se puede ajustar a configuración del sistema. + Cuando los sonidos están habilitados, Ferni utilizará sonido de notificación actual de Sailfish OS para los grupos, que se puede ajustar a configuración del sistema. Always append message preview to notifications - Agregar vista previa mensaje a notificaciones + Vista previa de mensaje en Notificaciones In addition to showing the number of unread messages, the latest message will also be appended to notifications. @@ -1596,15 +1596,15 @@ Highlight unread messages - Resaltar mensajes no leídos + Resaltar mensajes no Leídos Highlight Conversations with unread messages - Resaltar conversaciones a mensajes no leídos + Resalta la charla en mensajes no leídos Hide content in notifications - Ocultar contenido a notificaciones + Ocultar contenido de notificaciones Go to quoted message @@ -1630,7 +1630,7 @@ Allow chat invites - Permitir invitaciones de grupo + Permitir invitaciones de Grupo Privacy setting for managing whether you can be invited to chats. @@ -1650,7 +1650,7 @@ Allow finding by phone number - Permitir buscarme por número + Permitir buscarme por Número Privacy setting for managing whether you can be found by your phone number. @@ -1658,7 +1658,7 @@ Show link in forwarded messages - Mostrar enlace a mensajes reenviados + Mostrar enlace a mensajes Reenviados Privacy setting for managing whether a link to your account is included in forwarded messages. @@ -1666,7 +1666,7 @@ Show phone number - Mostrar número telefónico + Mostrar número Telefónico Privacy setting for managing whether your phone number is visible. @@ -1674,7 +1674,7 @@ Show profile photo - Mostrar foto de perfil + Mostrar foto de Perfil Privacy setting for managing whether your profile photo is visible. @@ -1682,7 +1682,7 @@ Show status - Mostrar estado + Mostrar Estado Privacy setting for managing whether your online status is visible. @@ -1690,7 +1690,7 @@ Allow sending Location to inline bots - Enviar ubicación de Robot enlínea + Enviar ubicación de Robot Enlínea Some inline bots request location data when using them @@ -1767,15 +1767,15 @@ Enable online-only mode - Modo solo enlínea + Modo solo Enlínea Disables offline caching. Certain features may be limited or missing in this mode. Changes require a restart of Fernschreiber to take effect. - Deshabilita almacenamiento en caché sin conexión. Algunas funciones pueden estar limitadas o ausentes en este modo. Se requiere reiniciar Ferni para efecto. + Deshabilita el almacenamiento en caché sin conexión. Algunas funciones pueden estar limitadas o ausentes en este modo. Se requiere reiniciar Ferni para efecto. Enable storage optimizer - Optimizador de almacenamiento + Optimizar Almacenamiento @@ -1845,7 +1845,7 @@ Synchronize Contacts with Telegram - Sincronizar Telegram + Sincronizar Telegrama @@ -2226,12 +2226,12 @@ changed the secret chat TTL setting myself; TTL = Time To Live - cambió ajustes de TTL de conversación secreta + cambió ajustes de TTL de charla secreta changed the secret chat TTL setting TTL = Time To Live - cambió ajustes de TTL de conversación secreta + cambió ajustes de TTL de charla secreta upgraded this group to a supergroup @@ -2250,11 +2250,11 @@ created a screenshot in this chat myself - creó pantallazo a conversación + creó pantallazo de charla created a screenshot in this chat - creó pantallazo a conversación + creó pantallazo a charla sent an unsupported message -- 2.43.0 From 047ea51d0ed6d3dd1bbf4b537628e61fbdbf1916 Mon Sep 17 00:00:00 2001 From: okruhliak <47862310+okruhliak@users.noreply.github.com> Date: Mon, 4 Dec 2023 22:19:07 +0100 Subject: [PATCH 50/75] Update harbour-fernschreiber-sk.ts (#545) --- translations/harbour-fernschreiber-sk.ts | 38 ++++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index bee3622..c5dc16f 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -495,7 +495,7 @@ Double-tap on a message to choose a reaction - + Dvojitým klepnutím na správu vybrať reakciu @@ -1615,31 +1615,31 @@ Always append message preview to notifications - + K upozorneniam vždy pripojiť ukážku správy In addition to showing the number of unread messages, the latest message will also be appended to notifications. - + Okrem zobrazenia počtu neprečítaných správ pripojiť k upozorneniam aj najnovšiu správu. Highlight unread messages - + Zvýrazniť neprečítané správy Highlight Conversations with unread messages - + Zvýrazniť konverzácie s neprečítanými správami Hide content in notifications - + V upozorneniach skryť obsah Go to quoted message - + Prejsť na citovanú správu When tapping a quoted message, open it in chat instead of showing it in an overlay. - + Citovanú správu otvoriť v čete namiesto v náhľade. @@ -1752,39 +1752,39 @@ %1 day(s) - - - - + + %1 deň + %1 dni + %1 dní 1 week - + 1 týždeň 1 month - + 1 mesiac 3 months - + 3 mesiace 6 months - + 6 mesiacov 1 year - + 1 rok Session Timeout - + Časový limit relácie Inactive sessions will be terminated after this timeframe - + Neaktívne relácie budú po tomto časovom rámci ukončené -- 2.43.0 From 2fad48e3595094410d986f7decfa0e1cb3acb3f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85ke=20Engelbrektson?= Date: Mon, 4 Dec 2023 22:19:53 +0100 Subject: [PATCH 51/75] Update harbour-fernschreiber-sv.ts (#547) Update Swedish translation --- translations/harbour-fernschreiber-sv.ts | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 61b8abe..6617ef1 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -185,7 +185,7 @@ ID has been copied to the clipboard. - + ID har kopierats till urklipp. @@ -485,7 +485,7 @@ Double-tap on a message to choose a reaction - + Dubbeltryck på ett meddelande för att välja en reaktion @@ -1170,7 +1170,7 @@ No contacts found. - + Inga kontakter hittades. @@ -1588,31 +1588,31 @@ Always append message preview to notifications - + Visa alltid förhandsgranskning av meddelanden i aviseringar In addition to showing the number of unread messages, the latest message will also be appended to notifications. - + Förutom att visa antalet olästa meddelanden kommer det senaste meddelandet också att visas i aviseringarna. Highlight unread messages - + Färgmarkera olästa meddelanden Highlight Conversations with unread messages - + Färgmarkera konversationer med olästa meddelanden Hide content in notifications - + Dölj innehåll i aviseringar Go to quoted message - + Gå till citerat meddelande When tapping a quoted message, open it in chat instead of showing it in an overlay. - + Vid tryck på ett citerat meddelande öppnas det i chatten istället för att visas i ett överlägg. @@ -1725,38 +1725,38 @@ %1 day(s) - - - + + %1 dag + %1 dagar 1 week - + 1 vecka 1 month - + 1 månad 3 months - + 3 månader 6 months - + 6 månader 1 year - + 1 år Session Timeout - + Tidsgräns för session Inactive sessions will be terminated after this timeframe - + Inaktiva sessioner avslutas efter den här tidsramen -- 2.43.0 From 4857b14fb87672e958bb3ea9823dfc93e36975c7 Mon Sep 17 00:00:00 2001 From: jgibbon Date: Thu, 28 Dec 2023 13:03:13 +0100 Subject: [PATCH 52/75] fix range + message updates; implement album filter --- harbour-fernschreiber.pro | 10 + qml/components/MessageListViewItem.qml | 47 ++- qml/components/TDLibMinithumbnail.qml | 15 +- qml/components/TDLibThumbnail.qml | 4 +- .../messageContent/MessageContentBase.qml | 1 - .../messageContent/MessagePhoto.qml | 36 +-- .../messageContent/MessagePhotoAlbum.qml | 207 +++++++++++++ .../messageContent/MessageVideo.qml | 7 +- .../messageContent/MessageVideoAlbum.qml | 19 ++ .../mediaAlbumPage/FullscreenOverlay.qml | 279 ++++++++++++++++++ .../mediaAlbumPage/PhotoComponent.qml | 16 + .../mediaAlbumPage/VideoComponent.qml | 181 ++++++++++++ .../mediaAlbumPage/ZoomArea.qml | 148 ++++++++++ .../mediaAlbumPage/ZoomImage.qml | 127 ++++++++ qml/pages/ChatPage.qml | 76 ++++- qml/pages/MediaAlbumPage.qml | 109 +++++++ src/boolfiltermodel.cpp | 153 ++++++++++ src/boolfiltermodel.h | 63 ++++ src/chatmodel.cpp | 210 ++++++++++++- src/chatmodel.h | 7 + src/harbour-fernschreiber.cpp | 2 + 21 files changed, 1649 insertions(+), 68 deletions(-) create mode 100644 qml/components/messageContent/MessagePhotoAlbum.qml create mode 100644 qml/components/messageContent/MessageVideoAlbum.qml create mode 100644 qml/components/messageContent/mediaAlbumPage/FullscreenOverlay.qml create mode 100644 qml/components/messageContent/mediaAlbumPage/PhotoComponent.qml create mode 100644 qml/components/messageContent/mediaAlbumPage/VideoComponent.qml create mode 100644 qml/components/messageContent/mediaAlbumPage/ZoomArea.qml create mode 100644 qml/components/messageContent/mediaAlbumPage/ZoomImage.qml create mode 100644 qml/pages/MediaAlbumPage.qml create mode 100644 src/boolfiltermodel.cpp create mode 100644 src/boolfiltermodel.h diff --git a/harbour-fernschreiber.pro b/harbour-fernschreiber.pro index 79af618..a16ad98 100644 --- a/harbour-fernschreiber.pro +++ b/harbour-fernschreiber.pro @@ -22,6 +22,7 @@ DEFINES += QT_STATICPLUGIN SOURCES += src/harbour-fernschreiber.cpp \ src/appsettings.cpp \ + src/boolfiltermodel.cpp \ src/chatpermissionfiltermodel.cpp \ src/chatlistmodel.cpp \ src/chatmodel.cpp \ @@ -105,14 +106,21 @@ DISTFILES += qml/harbour-fernschreiber.qml \ qml/components/messageContent/MessageGame.qml \ qml/components/messageContent/MessageLocation.qml \ qml/components/messageContent/MessagePhoto.qml \ + qml/components/messageContent/MessagePhotoAlbum.qml \ qml/components/messageContent/MessagePoll.qml \ qml/components/messageContent/MessageSticker.qml \ qml/components/messageContent/MessageVenue.qml \ + qml/components/messageContent/MessageVideoAlbum.qml \ qml/components/messageContent/MessageVideoNote.qml \ qml/components/messageContent/MessageVideo.qml \ qml/components/messageContent/MessageVoiceNote.qml \ qml/components/messageContent/SponsoredMessage.qml \ qml/components/messageContent/WebPagePreview.qml \ + qml/components/messageContent/mediaAlbumPage/FullscreenOverlay.qml \ + qml/components/messageContent/mediaAlbumPage/PhotoComponent.qml \ + qml/components/messageContent/mediaAlbumPage/VideoComponent.qml \ + qml/components/messageContent/mediaAlbumPage/ZoomArea.qml \ + qml/components/messageContent/mediaAlbumPage/ZoomImage.qml \ qml/components/settingsPage/Accordion.qml \ qml/components/settingsPage/AccordionItem.qml \ qml/components/settingsPage/ResponsiveGrid.qml \ @@ -130,6 +138,7 @@ DISTFILES += qml/harbour-fernschreiber.qml \ qml/pages/CoverPage.qml \ qml/pages/DebugPage.qml \ qml/pages/InitializationPage.qml \ + qml/pages/MediaAlbumPage.qml \ qml/pages/NewChatPage.qml \ qml/pages/OverviewPage.qml \ qml/pages/AboutPage.qml \ @@ -212,6 +221,7 @@ INSTALLS += telegram 86.png 108.png 128.png 172.png 256.png \ HEADERS += \ src/appsettings.h \ + src/boolfiltermodel.h \ src/chatpermissionfiltermodel.h \ src/chatlistmodel.h \ src/chatmodel.h \ diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index a0cf5d8..5b597f6 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -32,6 +32,7 @@ ListItem { property int messageIndex property int messageViewCount property var myMessage + property var messageAlbumMessageIds property var reactions property bool canReplyToMessage readonly property bool isAnonymous: myMessage.sender_id["@type"] === "messageSenderChat" @@ -68,7 +69,7 @@ ListItem { property var chatReactions property var messageReactions - highlighted: (down || isSelected || additionalOptionsOpened || wasNavigatedTo) && !menuOpen + highlighted: (down || (isSelected && messageAlbumMessageIds.length === 0) || additionalOptionsOpened || wasNavigatedTo) && !menuOpen openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting signal replyToMessage() @@ -268,20 +269,20 @@ ListItem { Connections { target: chatModel onMessagesReceived: { - messageBackground.isUnread = index > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage"; + messageBackground.isUnread = messageIndex > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage"; } onMessagesIncrementalUpdate: { - messageBackground.isUnread = index > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage"; + messageBackground.isUnread = messageIndex > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage"; } onNewMessageReceived: { - messageBackground.isUnread = index > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage"; + messageBackground.isUnread = messageIndex > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage"; } onUnreadCountUpdated: { - messageBackground.isUnread = index > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage"; + messageBackground.isUnread = messageIndex > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage"; } onLastReadSentMessageUpdated: { - Debug.log("[ChatModel] Messages in this chat were read, new last read: ", lastReadSentIndex, ", updating description for index ", index, ", status: ", (index <= lastReadSentIndex)); - messageDateText.text = getMessageStatusText(myMessage, index, lastReadSentIndex, messageDateText.useElapsed); + Debug.log("[ChatModel] Messages in this chat were read, new last read: ", lastReadSentIndex, ", updating description for index ", index, ", status: ", (messageIndex <= lastReadSentIndex)); + messageDateText.text = getMessageStatusText(myMessage, messageIndex, lastReadSentIndex, messageDateText.useElapsed); } } @@ -302,7 +303,7 @@ ListItem { pageStack.currentPage === chatPage) { Debug.log("Available reactions for this message: " + reactions); messageListItem.messageReactions = reactions; - showItemCompletelyTimer.requestedIndex = index; + showItemCompletelyTimer.requestedIndex = messageIndex; showItemCompletelyTimer.start(); } else { messageListItem.messageReactions = null; @@ -323,6 +324,13 @@ ListItem { interval: 200 triggeredOnStart: false onTriggered: { + if (requestedIndex === messageIndex) { + chatView.highlightMoveDuration = -1; + chatView.highlightResizeDuration = -1; + chatView.scrollToIndex(requestedIndex); + chatView.highlightMoveDuration = 0; + chatView.highlightResizeDuration = 0; + } Debug.log("Show item completely timer triggered, requested index: " + requestedIndex + ", current index: " + index) if (requestedIndex === index) { var p = chatView.contentItem.mapFromItem(reactionsColumn, 0, 0) @@ -376,8 +384,10 @@ ListItem { onTriggered: { if (messageListItem.hasContentComponent) { var type = myMessage.content["@type"]; + var albumComponentPart = (myMessage.media_album_id !== "0" && ['messagePhoto', 'messageVideo'].indexOf(type) !== -1) ? 'Album' : ''; + console.log('delegateComponentLoadingTimer', myMessage.media_album_id, albumComponentPart) extraContentLoader.setSource( - "../components/messageContent/" + type.charAt(0).toUpperCase() + type.substring(1) + ".qml", + "../components/messageContent/" + type.charAt(0).toUpperCase() + type.substring(1) + albumComponentPart + ".qml", { messageListItem: messageListItem }) @@ -441,7 +451,7 @@ ListItem { } height: messageTextColumn.height + precalculatedValues.paddingMediumDouble width: precalculatedValues.backgroundWidth - property bool isUnread: index > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage" + property bool isUnread: messageIndex > chatModel.getLastReadMessageIndex() && myMessage['@type'] !== "sponsoredMessage" color: Theme.colorScheme === Theme.LightOnDark ? (isUnread ? Theme.secondaryHighlightColor : Theme.secondaryColor) : (isUnread ? Theme.backgroundGlowColor : Theme.overlayBackgroundColor) radius: parent.width / 50 opacity: isUnread ? 0.5 : 0.2 @@ -463,7 +473,13 @@ ListItem { id: userText width: parent.width - text: messageListItem.isOwnMessage ? qsTr("You") : Emoji.emojify( myMessage['@type'] === "sponsoredMessage" ? tdLibWrapper.getChat(myMessage.sponsor_chat_id).title : ( messageListItem.isAnonymous ? page.chatInformation.title : Functions.getUserName(messageListItem.userInformation) ), font.pixelSize) + text: messageListItem.isOwnMessage + ? qsTr("You") + : Emoji.emojify( myMessage['@type'] === "sponsoredMessage" + ? tdLibWrapper.getChat(myMessage.sponsor_chat_id).title + : ( messageListItem.isAnonymous + ? page.chatInformation.title + : Functions.getUserName(messageListItem.userInformation) ), font.pixelSize) font.pixelSize: Theme.fontSizeExtraSmall font.weight: Font.ExtraBold color: messageListItem.textColor @@ -646,7 +662,8 @@ ListItem { id: extraContentLoader width: parent.width * getContentWidthMultiplier() asynchronous: true - height: item ? item.height : (messageListItem.hasContentComponent ? chatView.getContentComponentHeight(model.content_type, myMessage.content, width) : 0) + readonly property var defaultExtraContentHeight: messageListItem.hasContentComponent ? chatView.getContentComponentHeight(model.content_type, myMessage.content, width, model.album_message_ids.length) : 0 + height: item ? item.height : defaultExtraContentHeight } Binding { @@ -671,7 +688,7 @@ ListItem { running: true repeat: true onTriggered: { - messageDateText.text = getMessageStatusText(myMessage, index, chatView.lastReadSentIndex, messageDateText.useElapsed); + messageDateText.text = getMessageStatusText(myMessage, messageIndex, chatView.lastReadSentIndex, messageDateText.useElapsed); } } @@ -684,13 +701,13 @@ ListItem { font.pixelSize: Theme.fontSizeTiny color: messageListItem.isOwnMessage ? Theme.secondaryHighlightColor : Theme.secondaryColor horizontalAlignment: messageListItem.textAlign - text: getMessageStatusText(myMessage, index, chatView.lastReadSentIndex, messageDateText.useElapsed) + text: getMessageStatusText(myMessage, messageIndex, chatView.lastReadSentIndex, messageDateText.useElapsed) MouseArea { anchors.fill: parent enabled: !messageListItem.precalculatedValues.pageIsSelecting onClicked: { messageDateText.useElapsed = !messageDateText.useElapsed; - messageDateText.text = getMessageStatusText(myMessage, index, chatView.lastReadSentIndex, messageDateText.useElapsed); + messageDateText.text = getMessageStatusText(myMessage, messageIndex, chatView.lastReadSentIndex, messageDateText.useElapsed); } } } diff --git a/qml/components/TDLibMinithumbnail.qml b/qml/components/TDLibMinithumbnail.qml index c2b8220..22b2aad 100644 --- a/qml/components/TDLibMinithumbnail.qml +++ b/qml/components/TDLibMinithumbnail.qml @@ -24,6 +24,7 @@ Loader { id: loader property var minithumbnail property bool highlighted + property int fillMode: tdLibImage.fillMode anchors.fill: parent active: !!minithumbnail sourceComponent: Component { @@ -32,7 +33,7 @@ Loader { id: minithumbnailImage anchors.fill: parent source: "data:image/jpg;base64,"+minithumbnail.data - fillMode: tdLibImage.fillMode + fillMode: loader.fillMode opacity: status === Image.Ready ? 1.0 : 0.0 cache: false visible: opacity > 0 @@ -43,12 +44,12 @@ Loader { effect: PressEffect { source: minithumbnailImage } } } - - FastBlur { - anchors.fill: parent - source: minithumbnailImage - radius: Theme.paddingLarge - } + // this had a visible impact on performance +// FastBlur { +// anchors.fill: parent +// source: minithumbnailImage +// radius: Theme.paddingLarge +// } } } } diff --git a/qml/components/TDLibThumbnail.qml b/qml/components/TDLibThumbnail.qml index 291f507..b1aa0dc 100644 --- a/qml/components/TDLibThumbnail.qml +++ b/qml/components/TDLibThumbnail.qml @@ -59,7 +59,7 @@ Item { readonly property bool hasVisibleThumbnail: thumbnailImage.opacity !== 1.0 && !(videoThumbnailLoader.item && videoThumbnailLoader.item.opacity === 1.0) - + property alias fillMode: thumbnailImage.fillMode layer { enabled: highlighted effect: PressEffect { source: tdlibThumbnail } @@ -67,6 +67,7 @@ Item { TDLibMinithumbnail { id: minithumbnailLoader + fillMode: thumbnailImage.fillMode active: !!minithumbnail && thumbnailImage.opacity < 1.0 } BackgroundImage { @@ -103,6 +104,7 @@ Item { sourceSize.width: width sourceSize.height: height mimeType: tdlibThumbnail.videoMimeType + fillMode: thumbnailImage.fillMode == Image.PreserveAspectFit ? Thumbnail.PreserveAspectFit : Thumbnail.PreserveAspectCrop visible: opacity > 0 opacity: status === Thumbnail.Ready ? 1.0 : 0.0 Behavior on opacity { FadeAnimation {} } diff --git a/qml/components/messageContent/MessageContentBase.qml b/qml/components/messageContent/MessageContentBase.qml index f85bbfd..2ba2878 100644 --- a/qml/components/messageContent/MessageContentBase.qml +++ b/qml/components/messageContent/MessageContentBase.qml @@ -20,7 +20,6 @@ import QtQuick 2.6 import Sailfish.Silica 1.0 import QtMultimedia 5.6 import "../" -import "../../js/functions.js" as Functions import "../../js/debug.js" as Debug Item { diff --git a/qml/components/messageContent/MessagePhoto.qml b/qml/components/messageContent/MessagePhoto.qml index beb2381..d561dab 100644 --- a/qml/components/messageContent/MessagePhoto.qml +++ b/qml/components/messageContent/MessagePhoto.qml @@ -22,28 +22,25 @@ import "../" MessageContentBase { - function calculateBiggest() { - var candidateBiggest = rawMessage.content.photo.sizes[rawMessage.content.photo.sizes.length - 1]; - if (candidateBiggest.width === 0 && rawMessage.content.photo.sizes.length > 1) { - for (var i = (rawMessage.content.photo.sizes.length - 2); i >= 0; i--) { - candidateBiggest = rawMessage.content.photo.sizes[i]; - if (candidateBiggest.width > 0) { + height: Math.max(Theme.itemSizeExtraSmall, Math.min(Math.round(width * 0.66666666), width / getAspectRatio())) + readonly property alias photoData: photo.photo; + + onClicked: { + pageStack.push(Qt.resolvedUrl("../../pages/MediaAlbumPage.qml"), { + "messages" : [rawMessage], + }) + } + function getAspectRatio() { + var candidate = photoData.sizes[photoData.sizes.length - 1]; + if (candidate.width === 0 && photoData.sizes.length > 1) { + for (var i = (photoData.sizes.length - 2); i >= 0; i--) { + candidate = photoData.sizes[i]; + if (candidate.width > 0) { break; } } } - return candidateBiggest; - } - - height: Math.max(Theme.itemSizeExtraSmall, Math.min(defaultHeight, width / (biggest.width/biggest.height))) - readonly property int defaultHeight: Math.round(width * 0.66666666) - readonly property var biggest: calculateBiggest(); - - onClicked: { - pageStack.push(Qt.resolvedUrl("../../pages/ImagePage.qml"), { - "photoData" : photo.photo, -// "pictureFileInformation" : photo.fileInformation - }) + return candidate.width / candidate.height; } TDLibPhoto { id: photo @@ -51,7 +48,4 @@ MessageContentBase { photo: rawMessage.content.photo highlighted: parent.highlighted } - BackgroundImage { - visible: !rawMessage.content.photo.minithumbnail && photo.image.status !== Image.Ready - } } diff --git a/qml/components/messageContent/MessagePhotoAlbum.qml b/qml/components/messageContent/MessagePhotoAlbum.qml new file mode 100644 index 0000000..bf3a942 --- /dev/null +++ b/qml/components/messageContent/MessagePhotoAlbum.qml @@ -0,0 +1,207 @@ +/* + 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 "../" + +MessageContentBase { + id: messageContent + property string chatId + readonly property int heightUnit: Math.round(width * 0.66666666) + readonly property var albumId: rawMessage.media_album_id + property var albumMessageIds: messageListItem ? messageListItem.messageAlbumMessageIds : []//overlayFlickable.messageAlbumMessageIds + onAlbumMessageIdsChanged: albumMessages = getMessages() //chatModel.getMessagesForAlbum(messageContent.albumId) + property var albumMessages: getMessages()//chatModel.getMessagesForAlbum(messageContent.albumId) + property bool firstLarge: albumMessages.length % 2 !== 0; + + clip: true + height: defaultExtraContentHeight//(firstLarge ? heightUnit * 0.75 : 0 ) + heightUnit * 0.25 * albumMessageIds.length + + + onClicked: { + if(messageListItem.precalculatedValues.pageIsSelecting) { + page.toggleMessageSelection(rawMessage); + return; + } + openDetail(-1); + } + function getMessages() { + var msgs = [rawMessage]; + if(messageContent.albumId === '0' || messageContent.albumMessageIds.length < 2) { + return msgs; + } +// var othermsgIds = + // getMessages from tdlib isn't faster +// if(rawMessage && rawMessage.chat_id) { +// var messages = []; +// return albumMessageIds.map(function(msgId){ +// if(msgId === rawMessage.id) { +// return rawMessage; +// } +// return tdLibWrapper.getMessage(rawMessage.chat_id, msgId); +// }) +// } + chatModel.getMessagesForAlbum(messageContent.albumId, 1).forEach(function(msg){ + msgs.push(msg); + }); + // + return msgs; //chatModel.getMessagesForAlbum(messageContent.albumId); + } + + function openDetail(index) { + console.log('open detail', index || 0); + + + pageStack.push(Qt.resolvedUrl("../../pages/MediaAlbumPage.qml"), { + "messages" : albumMessages, + "index": index || 0 + }) + } + Connections { // TODO: needed? + target: tdLibWrapper + + onReceivedMessage: { + if (albumMessageIds.indexOf(messageId)) { +// albumMessages = getMessages() + } + } + } + + Component { + id: photoPreviewComponent + MessagePhoto { +// width: parent.width +// height: parent.height + messageListItem: messageContent.messageListItem + overlayFlickable: messageContent.overlayFlickable + rawMessage: albumMessages[modelIndex] + highlighted: mediaBackgroundItem.highlighted + } + } + Component { + id: videoPreviewComponent + Item { + property bool highlighted: mediaBackgroundItem.highlighted + anchors.fill: parent + clip: true + TDLibThumbnail { + id: tdLibImage + width: parent.width //don't use anchors here for easier custom scaling + height: parent.height + highlighted: parent.highlighted + thumbnail: albumMessages[modelIndex].content.video.thumbnail + minithumbnail: albumMessages[modelIndex].content.video.minithumbnail + } + Rectangle { + anchors { + fill: videoIcon + leftMargin: -Theme.paddingSmall + topMargin: -Theme.paddingSmall + bottomMargin: -Theme.paddingSmall + rightMargin: -Theme.paddingLarge + + } + + radius: Theme.paddingSmall + color: Theme.rgba(Theme.overlayBackgroundColor, 0.4) + + } + + Icon { + id: videoIcon + source: "image://theme/icon-m-video" + width: Theme.iconSizeSmall + height: Theme.iconSizeSmall + highlighted: parent.highlighted + anchors { + right: parent.right + rightMargin: Theme.paddingSmall + bottom: parent.bottom + } + } + } + } + + Flow { + id: contentGrid + property int firstWidth: firstLarge ? contentGrid.width : normalWidth + property int firstHeight: firstLarge ? heightUnit - contentGrid.spacing : normalHeight + property int normalWidth: (contentGrid.width - contentGrid.spacing) / 2 + property int normalHeight: (heightUnit / 2) - contentGrid.spacing + + anchors.fill: parent + spacing: Theme.paddingMedium + + Repeater { + model: albumMessages + delegate: BackgroundItem { + id: mediaBackgroundItem + property bool isLarge: firstLarge && model.index === 0 + width: model.index === 0 ? contentGrid.firstWidth : contentGrid.normalWidth + height: model.index === 0 ? contentGrid.firstHeight : contentGrid.normalHeight + + readonly property bool isSelected: messageListItem.precalculatedValues.pageIsSelecting && page.selectedMessages.some(function(existingMessage) { + return existingMessage.id === albumMessages[index].id + }); + highlighted: isSelected || down || messageContent.highlighted + onClicked: { + if(messageListItem.precalculatedValues.pageIsSelecting) { + page.toggleMessageSelection(albumMessages[index]); + return; + } + + openDetail(index); + } + onPressAndHold: { + page.toggleMessageSelection(albumMessages[index]); + } + + Loader { + anchors.fill: parent +// asynchronous: true + + readonly property int modelIndex: index + sourceComponent: albumMessages[index].content["@type"] === 'messageVideo' ? videoPreviewComponent : photoPreviewComponent + opacity: status === Loader.Ready + Behavior on opacity {FadeAnimator{}} + } + + /* + TODO video: + rawMessage.content.video.thumbnail + TDLibPhoto { + id: photo + anchors.fill: parent + photo: rawMessage.content.photo + highlighted: parent.highlighted + } + */ + Rectangle { + visible: mediaBackgroundItem.isSelected + anchors { + fill: parent + } + color: 'transparent' + border.color: Theme.highlightColor + border.width: Theme.paddingSmall + } + } + } + } +} diff --git a/qml/components/messageContent/MessageVideo.qml b/qml/components/messageContent/MessageVideo.qml index 8bec2ca..fe90397 100644 --- a/qml/components/messageContent/MessageVideo.qml +++ b/qml/components/messageContent/MessageVideo.qml @@ -26,7 +26,12 @@ import "../../js/debug.js" as Debug MessageContentBase { id: videoMessageComponent - property var videoData: ( rawMessage.content['@type'] === "messageVideo" ) ? rawMessage.content.video : ( ( rawMessage.content['@type'] === "messageAnimation" ) ? rawMessage.content.animation : rawMessage.content.video_note ) + property var videoData: ( rawMessage.content['@type'] === "messageVideo" ) + ? rawMessage.content.video + : ( + ( rawMessage.content['@type'] === "messageAnimation" ) + ? rawMessage.content.animation + : rawMessage.content.video_note ) property string videoUrl; property int previewFileId; property int videoFileId; diff --git a/qml/components/messageContent/MessageVideoAlbum.qml b/qml/components/messageContent/MessageVideoAlbum.qml new file mode 100644 index 0000000..11b5798 --- /dev/null +++ b/qml/components/messageContent/MessageVideoAlbum.qml @@ -0,0 +1,19 @@ +/* + 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 . +*/ +MessagePhotoAlbum {} diff --git a/qml/components/messageContent/mediaAlbumPage/FullscreenOverlay.qml b/qml/components/messageContent/mediaAlbumPage/FullscreenOverlay.qml new file mode 100644 index 0000000..8a069f1 --- /dev/null +++ b/qml/components/messageContent/mediaAlbumPage/FullscreenOverlay.qml @@ -0,0 +1,279 @@ +/* + 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 QtGraphicalEffects 1.0 +import Sailfish.Silica 1.0 +import "../../../js/functions.js" as Functions + + +Item { + // id + id: overlay + // property declarations + property int pageCount + property int currentIndex + property alias text: captionLabel.text + property bool active: true + property var message + readonly property color gradientColor: '#bb000000' + readonly property int gradientPadding: Theme.itemSizeMedium + // signal declarations + // JavaScript functions + // object properties + anchors.fill: parent + opacity: active ? 1 : 0 + Behavior on opacity { FadeAnimator {} } + // large property bindings + // child objects + // states + // transitions + + onActiveChanged: { + console.log('overlay active', active) + } + + function forwardMessage() { + var neededPermissions = Functions.getMessagesNeededForwardPermissions([message]); + pageStack.push(Qt.resolvedUrl("../../../pages/ChatSelectionPage.qml"), { + myUserId: tdLibWrapper.getUserInformation().id, + headerDescription: qsTr("Forward %Ln messages", "dialog header", 1), + payload: {fromChatId: message.chat_id, messageIds:[message.id], neededPermissions: neededPermissions}, + state: "forwardMessages" + }); + } + + // "header" + + LinearGradient { + id: topGradient + property int startY: 0; +// Behavior on startY { NumberAnimation {duration: 2000} } + start: Qt.point(0, Math.min(height-gradientPadding*2, startY)) + anchors { + left: parent.left + right: parent.right + top: parent.top + bottom: closeButton.bottom + + bottomMargin: -gradientPadding + } + + gradient: Gradient { + GradientStop { position: 0.0; color: gradientColor } + GradientStop { position: 1.0; color: 'transparent' } + } + } + + + IconButton { + id: closeButton + icon.source: "image://theme/icon-m-cancel?" + (pressed + ? Theme.highlightColor + : Theme.lightPrimaryColor) + onClicked: pageStack.pop() + anchors { + right: parent.right + top: parent.top + margins: Theme.horizontalPageMargin + } + } + + SilicaFlickable { + id: captionFlickable + anchors { + left: parent.left +// leftMargin: Theme.horizontalPageMargin + right: closeButton.left + top: parent.top +// topMargin: Theme.horizontalPageMargin + } + interactive: captionLabel.expanded && contentHeight > height + clip: true + height: Math.min(contentHeight, parent.height / 4) + contentHeight: captionLabel.height + Theme.horizontalPageMargin + flickableDirection: Flickable.VerticalFlick + VerticalScrollDecorator { + opacity: visible ? 1.0 : 0.0 + flickable: captionFlickable + } + + Label { + id: captionLabel + property bool expandable: expanded || height < contentHeight + property bool expanded + + height: text ? + expanded + ? contentHeight + : Theme.itemSizeMedium + : 0; + // maximumLineCount: expanded ? 0 : 3 + color: Theme.primaryColor +// text: model.modelData.content.caption.text + text: Emoji.emojify(Functions.enhanceMessageText(message.content.caption, false), Theme.fontSizeExtraSmall) + onTextChanged: expanded = false + font.pixelSize: Theme.fontSizeExtraSmall + wrapMode: Text.WrapAnywhere + bottomPadding: expanded ? Theme.paddingLarge : 0 + anchors { + left: parent.left + leftMargin: Theme.horizontalPageMargin + rightMargin: Theme.paddingLarge + right: parent.right + top: parent.top + topMargin: Theme.horizontalPageMargin + } + + Behavior on height { NumberAnimation {duration: 300} } + Behavior on text { + SequentialAnimation { + FadeAnimation { + target: captionLabel + to: 0.0 + duration: 300 + } + PropertyAction {} + FadeAnimation { + target: captionLabel + to: 1.0 + duration: 300 + } + } + } + + } + + OpacityRampEffect { + sourceItem: captionLabel + enabled: !captionLabel.expanded + direction: OpacityRamp.TopToBottom + } + MouseArea { + anchors.fill: captionLabel + enabled: captionLabel.expandable + onClicked: { + captionLabel.expanded = !captionLabel.expanded + } + } + } + + // "footer" + LinearGradient { + anchors { + left: parent.left + right: parent.right + top: buttons.top + bottom: parent.bottom + topMargin: -gradientPadding + } + + gradient: Gradient { + GradientStop { position: 0.0; color: 'transparent' } + GradientStop { position: 1.0; color: gradientColor } + } + } + Loader { + asynchronous: true + active: overlay.pageCount > 1 + + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: buttons.bottom + } + sourceComponent: Component { + + Row { + id: pageIndicatorRow + height: Theme.paddingSmall + spacing: height + Repeater { + id: pageIndicator + model: overlay.pageCount + Rectangle { + property bool active: model.index === overlay.currentIndex + width: pageIndicatorRow.height + height: pageIndicatorRow.height + color: active ? Theme.lightPrimaryColor : Theme.rgba(Theme.lightSecondaryColor, Theme.opacityLow) + Behavior on color { ColorAnimation {} } + radius: Theme.paddingSmall + } + } + } + } + } + + + Row { + id: buttons + height: Theme.itemSizeSmall + width: childrenRect.width + spacing: Theme.paddingLarge + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + bottomMargin: Theme.paddingLarge + } + +// IconButton { +// icon.source: "image://theme/icon-m-cancel?" + (pressed +// ? Theme.highlightColor +// : Theme.lightPrimaryColor) +// onClicked: pageStack.pop() + +// } + IconButton { + icon.source: "image://theme/icon-m-downloads?" + (pressed + ? Theme.highlightColor + : Theme.lightPrimaryColor) + onClicked: pageStack.pop() + } + Item { + width: Theme.itemSizeSmall + height: Theme.itemSizeSmall + } + + IconButton { + enabled: message.can_be_forwarded + opacity: enabled ? 1.0 : 0.2 + icon.source: "image://theme/icon-m-share?" + (pressed + ? Theme.highlightColor + : Theme.lightPrimaryColor) + onClicked: forwardMessage() + } + } + states: [ + State { + name: 'hasCaption' + when: captionLabel.height > 0 + PropertyChanges { target: topGradient; + startY: captionFlickable.height + } + AnchorChanges { + target: topGradient +// anchors.top: captionLabel.verticalCenter + anchors.bottom: captionFlickable.bottom + } + } + ] + transitions: + Transition { + AnchorAnimation { duration: 200 } + NumberAnimation { properties: "startY"; duration: 200 } + } +} diff --git a/qml/components/messageContent/mediaAlbumPage/PhotoComponent.qml b/qml/components/messageContent/mediaAlbumPage/PhotoComponent.qml new file mode 100644 index 0000000..71d31b5 --- /dev/null +++ b/qml/components/messageContent/mediaAlbumPage/PhotoComponent.qml @@ -0,0 +1,16 @@ + +import QtQuick 2.6 + +ZoomImage { + photoData: model.modelData.content.photo + onClicked: { + console.log('clicked', zoomed) + if(zoomed) { + zoomOut(true) + page.overlayActive = true + } else { + page.overlayActive = !page.overlayActive + } + } + +} diff --git a/qml/components/messageContent/mediaAlbumPage/VideoComponent.qml b/qml/components/messageContent/mediaAlbumPage/VideoComponent.qml new file mode 100644 index 0000000..a3a01ac --- /dev/null +++ b/qml/components/messageContent/mediaAlbumPage/VideoComponent.qml @@ -0,0 +1,181 @@ +import QtQuick 2.6 +import Sailfish.Silica 1.0 +import WerkWolf.Fernschreiber 1.0 +import QtMultimedia 5.6 +import QtGraphicalEffects 1.0 +import "../../" + +Video { + id: video + property var videoData: model.modelData.content.video + readonly property bool isPlaying: playbackState === MediaPlayer.PlayingState + readonly property bool isCurrent: index === page.index + property bool shouldPlay + autoLoad: true + source: file.isDownloadingCompleted ? file.path : '' + onIsCurrentChanged: { + if(!isCurrent) { + pause() + } + } + onStatusChanged: { + if(status === MediaPlayer.EndOfMedia) { + page.overlayActive = true + } + } + TDLibThumbnail { + id: tdLibImage + + property bool active: !file.isDownloadingCompleted || (!video.isPlaying && (video.position === 0 || video.status === MediaPlayer.EndOfMedia)) + opacity: active ? 1 : 0 + visible: active || opacity > 0 + + width: parent.width //don't use anchors here for easier custom scaling + height: parent.height +// highlighted: parent.highlighted + thumbnail: videoData.thumbnail + minithumbnail: videoData.minithumbnail + fillMode: Image.PreserveAspectFit + + + } + + TDLibFile { + id: file + autoLoad: false + tdlib: tdLibWrapper + fileInformation: videoData.video + property real progress: isDownloadingCompleted ? 1.0 : (downloadedSize / size) + onDownloadingCompletedChanged: { + if(isDownloadingCompleted) { + video.source = file.path + if(video.shouldPlay) { + video.play() + delayedOverlayHide.start() + video.shouldPlay = false + } + } + } + } + Label { + anchors.centerIn: parent + text: 'dl: '+file.downloadedSize + + ' \ns: '+file.size + + ' \nes: '+file.expectedSize + + ' \nd:'+file.isDownloadingActive + + ' \nc:'+file.isDownloadingCompleted + + } + + MouseArea { + anchors.fill: parent + onClicked: page.overlayActive = !page.overlayActive + } + + RadialGradient { // white videos = invisible button. I can't tell since which SFOS version the opaque button is available, so: + id: buttonBg + anchors.centerIn: parent + width: Theme.itemSizeLarge; height: Theme.itemSizeLarge + property color baseColor: Theme.rgba(palette.overlayBackgroundColor, 0.2) + + enabled: videoUI.active || !file.isDownloadingCompleted + opacity: enabled ? 1 : 0 + Behavior on opacity { FadeAnimator {} } + gradient: Gradient { + + GradientStop { position: 0.0; color: buttonBg.baseColor } + GradientStop { position: 0.3; color: buttonBg.baseColor } + GradientStop { position: 0.5; color: 'transparent' } + } + + IconButton { + anchors.fill: parent + icon.source: "image://theme/icon-l-"+(video.isPlaying || video.shouldPlay ? 'pause' : 'play')+"?" + (pressed + ? Theme.highlightColor + : Theme.lightPrimaryColor) + onClicked: { + if (!file.isDownloadingCompleted) { + video.shouldPlay = !video.shouldPlay; + if(video.shouldPlay) { + file.load() + } else { + file.cancel() + } + return; + } + + if (video.isPlaying) { + video.pause() + } else { + video.play() + delayedOverlayHide.start() + } + } + } + } + + ProgressCircle { + property bool active: file.isDownloadingActive + opacity: active ? 1 : 0 + Behavior on opacity { FadeAnimator {} } + anchors.centerIn: parent + value: file.progress + } + Item { + id: videoUI + property bool active: overlay.active// && file.isDownloadingCompleted + anchors.fill: parent + opacity: active ? 1 : 0 + Behavior on opacity { FadeAnimator {} } + + Slider { + id: slider + value: video.position + minimumValue: 0 + maximumValue: video.duration || 0.1 + enabled: parent.active && video.seekable + width: parent.width + handleVisible: false + animateValue: true + stepSize: 500 + anchors { + bottom: parent.bottom + bottomMargin: Theme.itemSizeMedium + } + valueText: value > 0 || down ? Format.formatDuration((value)/1000, Formatter.Duration) : '' + leftMargin: Theme.horizontalPageMargin + rightMargin: Theme.horizontalPageMargin + onDownChanged: { + if(!down) { + video.seek(value) + value = Qt.binding(function() { return video.position }) + } + } + Label { + anchors { + right: parent.right + rightMargin: Theme.horizontalPageMargin + bottom: parent.bottom + topMargin: Theme.paddingSmall + } + font.pixelSize: Theme.fontSizeExtraSmall + text: file.isDownloadingCompleted + ? Format.formatDuration((parent.maximumValue - parent.value)/1000, Formatter.Duration) + : (video.videoData.duration + ? Format.formatDuration(video.videoData.duration, Formatter.Duration) + ', ' + : '') + Format.formatFileSize(file.size || file.expectedSize) + color: Theme.secondaryColor + } + } + + Timer { + id: delayedOverlayHide + interval: 500 + onTriggered: { + if(video.isPlaying) { + page.overlayActive = false + } + } + } + } +} diff --git a/qml/components/messageContent/mediaAlbumPage/ZoomArea.qml b/qml/components/messageContent/mediaAlbumPage/ZoomArea.qml new file mode 100644 index 0000000..0fb04bc --- /dev/null +++ b/qml/components/messageContent/mediaAlbumPage/ZoomArea.qml @@ -0,0 +1,148 @@ +import QtQuick 2.6 +import Sailfish.Silica 1.0 + +SilicaFlickable { + // id + id: flickable + // property declarations + property real zoom + property bool zoomed + // override if needed + property bool zoomEnabled: true + property real minimumZoom: fitZoom + property real maximumZoom: 4 //Math.max(fitZoom, 1) * 3 + + default property alias zoomContentItem: zoomContentItem.data + property alias implicitContentWidth: zoomContentItem.implicitWidth + property alias implicitContentHeight: zoomContentItem.implicitHeight + // factor for "PreserveAspectFit" + readonly property real fitZoom: implicitContentWidth > 0 && implicitContentHeight > 0 + ? Math.min(maximumZoom, width / implicitContentWidth, height / implicitContentHeight) + : 1.0 + readonly property int minimumBoundaryAxis: (implicitContentWidth / implicitContentHeight) > (width / height) ? Qt.Horizontal : Qt.Vertical + + // JavaScript functions + function zoomOut(animated) { + if (zoomed) { + if(animated) { zoomOutAnimation.start() } + else { + zoom = fitZoom + zoomed = false + } + } + } + + // object properties + contentWidth: Math.max(width, zoomContentItem.width) + contentHeight: Math.max(height, zoomContentItem.height) + enabled: !zoomOutAnimation.running && implicitContentWidth > 0 && implicitContentHeight > 0 + flickableDirection: Flickable.HorizontalAndVerticalFlick + interactive: zoomed + // According to Jolla, otherwise pinching would sometimes not work: + pressDelay: 0 + Binding { // Update zoom on orientation changes and set as default + target: flickable + when: !zoomed + property: "zoom" + value: minimumZoom + } + // child objects + + PinchArea { + id: pinchArea + parent: flickable.contentItem + width: flickable.contentWidth + height: flickable.contentHeight + enabled: zoomEnabled && minimumZoom !== maximumZoom && flickable.enabled + onPinchUpdated: { + scrollDecoratorTimer.restart() + var f = flickable; + var requestedZoomFactor = 1.0 + pinch.scale - pinch.previousScale; + var previousWidth = f.contentWidth + var previousHeight = f.contentHeight + var targetWidth + var targetHeight + var targetZoom = requestedZoomFactor * f.zoom; + if (targetZoom < f.minimumZoom) { + f.zoom = f.minimumZoom; + f.zoomed = false; + f.contentX = 0; + f.contentY = 0; + return + } else if(targetZoom >= f.maximumZoom) { + f.zoom = f.maximumZoom; + targetHeight = f.implicitContentHeight * f.zoom + targetWidth = f.implicitContentWidth * f.zoom + } + else if(targetZoom < f.maximumZoom) { + if (f.minimumBoundaryAxis == Qt.Horizontal) { + targetWidth = f.contentWidth * requestedZoomFactor + f.zoom = targetWidth / f.implicitContentWidth + targetHeight = f.implicitContentHeight * f.zoom + } else { + targetHeight = f.contentHeight * requestedZoomFactor + f.zoom = targetHeight / f.implicitContentHeight + targetWidth = f.implicitContentWidth * f.zoom + } + } + // calculate center difference + f.contentX += pinch.previousCenter.x - pinch.center.x + f.contentY += pinch.previousCenter.y - pinch.center.y + // move to new (zoomed) center. this jumps a tiny bit, but is bearable: + if (targetWidth > f.width) + f.contentX -= (previousWidth - targetWidth)/(previousWidth/pinch.previousCenter.x) + if (targetHeight > f.height) + f.contentY -= (previousHeight - targetHeight)/(previousHeight/pinch.previousCenter.y) + + f.zoomed = true + } + onPinchFinished: { + returnToBounds() + } + Item { + id: zoomContentItem + anchors.centerIn: parent + implicitWidth: flickable.width + implicitHeight: flickable.height + width: Math.ceil(implicitWidth * zoom) + height: Math.ceil(implicitHeight * zoom) + } + } + // enable zoom to minimumZoom on click + ParallelAnimation { + id: zoomOutAnimation + NumberAnimation { + target: flickable + properties: "contentX, contentY" + to: 0 + } + NumberAnimation { + target: flickable + property: "zoom" + to: fitZoom + } + onRunningChanged: { + if(!running) { + zoomed = false + } + } + } + + // show scroll decorators when scrolling OR zooming + Timer { + id: scrollDecoratorTimer + readonly property bool moving: flickable.moving + readonly property bool showing: moving || running + onMovingChanged: restart() + interval: 300 + } + + VerticalScrollDecorator { + flickable: flickable + opacity: scrollDecoratorTimer.showing ? 1.0 : 0.0 + } + HorizontalScrollDecorator { + flickable: flickable + opacity: scrollDecoratorTimer.showing ? 1.0 : 0.0 + } +} diff --git a/qml/components/messageContent/mediaAlbumPage/ZoomImage.qml b/qml/components/messageContent/mediaAlbumPage/ZoomImage.qml new file mode 100644 index 0000000..bc3418b --- /dev/null +++ b/qml/components/messageContent/mediaAlbumPage/ZoomImage.qml @@ -0,0 +1,127 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import WerkWolf.Fernschreiber 1.0 +import "../../" + +ZoomArea { + // id + id: zoomArea + property var photoData //albumMessages[index].content.photo + property bool active: true + property alias image: image + + signal clicked + + maximumZoom: Math.max(Screen.width, Screen.height) / 200 +// maximumZoom: Math.max(fitZoom, 1) * 3 + implicitContentWidth: image.implicitWidth + implicitContentHeight: image.implicitHeight + zoomEnabled: image.status == Image.Ready + + onActiveChanged: { + if (!active) { + zoomOut() + } + } + + Component.onCompleted: { +// var photoData = albumMessages[index].content.photo; + if (photoData) { + + var biggestIndex = -1 + for (var i = 0; i < photoData.sizes.length; i++) { + if (biggestIndex === -1 || photoData.sizes[i].width > photoData.sizes[biggestIndex].width) { + biggestIndex = i; + } + } + if (biggestIndex > -1) { +// imageDelegate.imageWidth = photoData.sizes[biggestIndex].width; +// imageDelegate.imageHeight = photoData.sizes[biggestIndex].height; + image.sourceSize.width = photoData.sizes[biggestIndex].width + image.sourceSize.height = photoData.sizes[biggestIndex].height + image.fileInformation = photoData.sizes[biggestIndex].photo + + console.log('loading photo', JSON.stringify(image.fileInformation)) + } + } + } + TDLibImage { + id: image + + width: parent.width + height: parent.height + source: file.isDownloadingCompleted ? file.path : "" +// enabled: true //!!file.fileId +// anchors.fill: parent + anchors.centerIn: parent + + fillMode: Image.PreserveAspectFit + asynchronous: true + smooth: !(movingVertically || movingHorizontally) + +// sourceSize.width: Screen.height +// visible: opacity > 0 +// opacity: status === Image.Ready ? 1 : 0 + + Behavior on opacity { FadeAnimator{} } + } +// Label { +// anchors.fill: parent +// text: 'ok?' + image.enabled +' fileid:' +!!(image.file.fileId) +// + '\n - dl?' + image.file.isDownloadingActive +// + '\n completed?' + image.file.isDownloadingCompleted + ' path:'+ image.file.path +// + '\n ' + image.source +// wrapMode: Text.WrapAtWordBoundaryOrAnywhere +// } +// Rectangle { +// color: 'green' +// anchors.fill: image +// opacity: 0.3 + +// } + +// Image { +// id: image +// anchors.fill: parent +// smooth: !(movingVertically || movingHorizontally) +// sourceSize.width: Screen.height +// fillMode: Image.PreserveAspectFit +// asynchronous: true +// cache: false + +// onSourceChanged: { +// zoomOut() +// } + +// opacity: status == Image.Ready ? 1 : 0 +// Behavior on opacity { FadeAnimator{} } +// } + Item { + anchors.fill: parent + + } + MouseArea { + anchors.centerIn: parent + width: zoomArea.contentWidth + height: zoomArea.contentHeight + onClicked: zoomArea.clicked() + } + + + BusyIndicator { + running: image.file.isDownloadingActive && !delayBusyIndicator.running + size: BusyIndicatorSize.Large + anchors.centerIn: parent + parent: zoomArea + Timer { + id: delayBusyIndicator + running: image.file.isDownloadingActive + interval: 1000 + } + } +// Rectangle { +// color: 'green' +// anchors.fill: parent +// parent: zoomArea +// } +} diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index c06fb51..0c08770 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -609,7 +609,8 @@ Page { Connections { target: chatModel onMessagesReceived: { - Debug.log("[ChatPage] Messages received, view has ", chatView.count, " messages, last known message index ", modelIndex, ", own messages were read before index ", lastReadSentIndex); + var proxyIndex = chatProxyModel.mapRowFromSource(modelIndex, -1); + Debug.log("[ChatPage] Messages received, view has ", chatView.count, " messages, last known message index ", proxyIndex, "("+modelIndex+"), own messages were read before index ", lastReadSentIndex); if (totalCount === 0) { if (chatPage.iterativeInitialization) { chatPage.iterativeInitialization = false; @@ -623,9 +624,9 @@ Page { } chatView.lastReadSentIndex = lastReadSentIndex; - chatView.scrollToIndex(modelIndex); + chatView.scrollToIndex(proxyIndex); chatPage.loading = false; - if (chatOverviewItem.visible && modelIndex >= (chatView.count - 10)) { + if (chatOverviewItem.visible && proxyIndex >= (chatView.count - 10)) { chatView.inCooldown = true; chatModel.triggerLoadMoreFuture(); } @@ -669,10 +670,13 @@ Page { chatView.lastReadSentIndex = lastReadSentIndex; } onMessagesIncrementalUpdate: { - Debug.log("Incremental update received. View now has ", chatView.count, " messages, view is on index ", modelIndex, ", own messages were read before index ", lastReadSentIndex); + var proxyIndex = chatProxyModel.mapRowFromSource(modelIndex, -1); + Debug.log("Incremental update received. View now has ", chatView.count, " messages, view is on index ", proxyIndex, "("+modelIndex+"), own messages were read before index ", lastReadSentIndex); chatView.lastReadSentIndex = lastReadSentIndex; if (!chatPage.isInitialized) { - chatView.scrollToIndex(modelIndex); + if (proxyIndex > -1) { + chatView.scrollToIndex(proxyIndex); + } } if (chatView.height > chatView.contentHeight) { Debug.log("[ChatPage] Chat content quite small..."); @@ -748,14 +752,26 @@ Page { onTriggered: { Debug.log("scroll position changed, message index: ", lastQueuedIndex); Debug.log("unread count: ", chatInformation.unread_count); - var messageToRead = chatModel.getMessage(lastQueuedIndex); + var modelIndex = chatProxyModel.mapRowToSource(lastQueuedIndex); + var messageToRead = chatModel.getMessage(modelIndex); if (messageToRead['@type'] === "sponsoredMessage") { Debug.log("sponsored message to read: ", messageToRead.id); tdLibWrapper.viewMessage(chatInformation.id, messageToRead.message_id, false); } else if (chatInformation.unread_count > 0 && lastQueuedIndex > -1) { - Debug.log("message to read: ", messageToRead.id); - if (messageToRead && messageToRead.id) { - tdLibWrapper.viewMessage(chatInformation.id, messageToRead.id, false); + if (messageToRead) { + Debug.log("message to read: ", messageToRead.id); + var messageId = messageToRead.id; + var type = messageToRead.content["@type"]; + if (messageToRead.media_album_id !== '0') { + var albumIds = chatModel.getMessageIdsForAlbum(messageToRead.media_album_id); + if (albumIds.length > 0) { + messageId = albumIds[albumIds.length - 1]; + Debug.log("message to read last album message id: ", messageId); + } + } + if (messageId) { + tdLibWrapper.viewMessage(chatInformation.id, messageId, false); + } } lastQueuedIndex = -1 } @@ -1223,7 +1239,6 @@ Page { readonly property int messageInReplyToHeight: Theme.fontSizeExtraSmall * 2.571428571 + Theme.paddingSmall; readonly property int webPagePreviewHeight: ( (textColumnWidth * 2 / 3) + (6 * Theme.fontSizeExtraSmall) + ( 7 * Theme.paddingSmall) ) readonly property bool pageIsSelecting: chatPage.isSelecting - } function handleScrollPositionChanged() { @@ -1246,6 +1261,9 @@ Page { positionViewAtIndex(index, (mode === undefined) ? ListView.Contain : mode) if(index === chatView.count - 1) { manuallyScrolledToBottom = true; + if(!chatView.atYEnd) { + chatView.positionViewAtEnd(); + } } } } @@ -1278,7 +1296,13 @@ Page { } } - model: chatModel + BoolFilterModel { + id: chatProxyModel + sourceModel: chatModel + filterRoleName: "album_entry_filter" + filterValue: false + } + model: chatProxyModel header: Component { Loader { active: !!chatPage.botInformation @@ -1311,7 +1335,8 @@ Page { } } - function getContentComponentHeight(contentType, content, parentWidth) { + function getContentComponentHeight(contentType, content, parentWidth, albumEntries) { + var unit; switch(contentType) { case "messageAnimatedEmoji": return content.animated_emoji.sticker.height; @@ -1327,6 +1352,10 @@ Page { case "messageVenue": return parentWidth * 0.66666666; // 2 / 3; case "messagePhoto": + if(albumEntries > 0) { + unit = (parentWidth * 0.66666666) + return (albumEntries % 2 !== 0 ? unit * 0.75 : 0) + unit * albumEntries * 0.25 + } var biggest = content.photo.sizes[content.photo.sizes.length - 1]; var aspectRatio = biggest.width/biggest.height; return Math.max(Theme.itemSizeExtraSmall, Math.min(parentWidth * 0.66666666, parentWidth / aspectRatio)); @@ -1335,6 +1364,10 @@ Page { case "messageSticker": return content.sticker.height; case "messageVideo": + if(albumEntries > 0) { + unit = (parentWidth * 0.66666666) + return (albumEntries % 2 !== 0 ? unit * 0.75 : 0) + unit * albumEntries * 0.25 + } return Functions.getVideoHeight(parentWidth, content.video); case "messageVideoNote": return parentWidth @@ -1390,10 +1423,11 @@ Page { chatId: chatModel.chatId myMessage: model.display messageId: model.message_id + messageAlbumMessageIds: model.album_message_ids messageViewCount: model.view_count reactions: model.reactions chatReactions: availableReactions - messageIndex: model.index + messageIndex: chatProxyModel.mapRowToSource(model.index) hasContentComponent: !!myMessage.content && chatView.delegateMessagesContent.indexOf(model.content_type) > -1 canReplyToMessage: chatPage.canSendMessages onReplyToMessage: { @@ -1414,9 +1448,21 @@ Page { id: messageListViewItemSimpleComponent MessageListViewItemSimple {} } - sourceComponent: chatView.simpleDelegateMessages.indexOf(model.content_type) > -1 ? messageListViewItemSimpleComponent : messageListViewItemComponent + Component { + id: messageListViewItemHiddenComponent + Item { + property var myMessage: display + property bool senderIsUser: myMessage.sender_id["@type"] === "messageSenderUser" + property var userInformation: senderIsUser ? tdLibWrapper.getUserInformation(myMessage.sender_id.user_id) : null + property bool isOwnMessage: senderIsUser && chatPage.myUserId === myMessage.sender_id.user_id + height: 1 + } + } + sourceComponent: chatView.simpleDelegateMessages.indexOf(model.content_type) > -1 + ? messageListViewItemSimpleComponent + : messageListViewItemComponent } - VerticalScrollDecorator {} + VerticalScrollDecorator { flickable: chatView } ViewPlaceholder { id: chatViewPlaceholder diff --git a/qml/pages/MediaAlbumPage.qml b/qml/pages/MediaAlbumPage.qml new file mode 100644 index 0000000..77a5caa --- /dev/null +++ b/qml/pages/MediaAlbumPage.qml @@ -0,0 +1,109 @@ +/* + 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 . +*/ +// jolla-gallery/pages/FlickableImageView.qml +/* + +FullscreenContentPage + - PagedView (jolla-gallery/FlickableImageView) + - delegate: Loader + - SilicaFlickable (Silica.private/ZoomableFlickable) (Sailfish.Gallery/ImageViewer) + - PinchArea + - dragDetector(?) + - image + - Item (Sailfish.Gallery/GalleryOverlay) + +*/ + +import QtQuick 2.6 +import Sailfish.Silica 1.0 +import WerkWolf.Fernschreiber 1.0 +import "../components" + +import "../components/messageContent/mediaAlbumPage" +import "../js/twemoji.js" as Emoji +import "../js/functions.js" as Functions + +Page { + // id + id: page + // property declarations + + property alias index: pagedView.currentIndex + property alias overlayActive: overlay.active + property alias delegate: pagedView.delegate + property var messages: []; + // message.content.caption.text + palette.colorScheme: Theme.LightOnDark + clip: status !== PageStatus.Active || pageStack.dragInProgress + navigationStyle: PageNavigation.Vertical + backgroundColor: 'black' + allowedOrientations: Orientation.All + // signal declarations + // JavaScript functions + + // object (parent) properties + // large property bindings + // child objects + // states + // transitions + + + + // content + PagedView { + id: pagedView + anchors.fill: parent + model: messages + delegate: Component { + Loader { + id: loader + asynchronous: true + visible: status == Loader.Ready + width: PagedView.contentWidth + height: PagedView.contentHeight + + states: [ + State { + when: model.modelData.content['@type'] === 'messagePhoto' + PropertyChanges { + target: loader + source: "../components/messageContent/mediaAlbumPage/PhotoComponent.qml" + } + }, + State { + when: model.modelData.content['@type'] === 'messageVideo' + PropertyChanges { + target: loader + source: "../components/messageContent/mediaAlbumPage/VideoComponent.qml" + } + } + ] + } + } + } + + // overlay + FullscreenOverlay { + id: overlay + pageCount: messages.length + currentIndex: page.index + message: messages[currentIndex] +// + } +} diff --git a/src/boolfiltermodel.cpp b/src/boolfiltermodel.cpp new file mode 100644 index 0000000..0882292 --- /dev/null +++ b/src/boolfiltermodel.cpp @@ -0,0 +1,153 @@ +/* + 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 . +*/ + +#include "boolfiltermodel.h" + +#define DEBUG_MODULE BoolFilterModel +#include "debuglog.h" + +BoolFilterModel::BoolFilterModel(QObject *parent) : QSortFilterProxyModel(parent) +{ + setDynamicSortFilter(true); +// setFilterCaseSensitivity(Qt::CaseInsensitive); +// setFilterFixedString(QString()); + filterValue = true; +} + +void BoolFilterModel::setSource(QObject *model) +{ + setSourceModel(qobject_cast(model)); +} + +void BoolFilterModel::setSourceModel(QAbstractItemModel *model) +{ + if (sourceModel() != model) { + LOG(model); + QSortFilterProxyModel::setSourceModel(model); + updateFilterRole(); + emit sourceChanged(); + } +} + +QString BoolFilterModel::getFilterRoleName() const +{ + return filterRoleName; +} + +void BoolFilterModel::setFilterRoleName(QString role) +{ + if (filterRoleName != role) { + filterRoleName = role; + LOG(role); + updateFilterRole(); + emit filterRoleNameChanged(); + } +} + +bool BoolFilterModel::getFilterValue() const +{ + return filterValue; +} + +void BoolFilterModel::setFilterValue(bool value) +{ + if(value != filterValue) { + filterValue = value; + invalidateFilter(); + } +} + +int BoolFilterModel::mapRowFromSource(int i, int fallbackDirection) +{ + QModelIndex myIndex = mapFromSource(sourceModel()->index(i, 0)); + LOG("mapping index" << i << "to source model:" << myIndex.row() << "valid?" << myIndex.isValid()); + if(myIndex.isValid()) { + return myIndex.row(); + } + + if(fallbackDirection > 0) { + int max = sourceModel()->rowCount(); + i += 1; + while (i < max) { + myIndex = mapFromSource(sourceModel()->index(i, 0)); + + LOG("fallback ++ " << i << "to source model:" << myIndex.row() << "valid?" << myIndex.isValid()); + if(myIndex.isValid()) { + return myIndex.row(); + } + i += 1; + } + } else if(fallbackDirection < 0) { + i -= 1; + while (i > -1) { + myIndex = mapFromSource(sourceModel()->index(i, 0)); + LOG("fallback -- " << i << "to source model:" << myIndex.row() << "valid?" << myIndex.isValid()); + if(myIndex.isValid()) { + return myIndex.row(); + } + i -= 1; + } + } + + return myIndex.row(); // may still be -1 +} + +int BoolFilterModel::mapRowToSource(int i) +{ + QModelIndex sourceIndex = mapToSource(index(i, 0)); + return sourceIndex.row(); +} +bool BoolFilterModel::filterAcceptsRow(int sourceRow, + const QModelIndex &sourceParent) const + { +// sourceModel()->index(sourceRow, 0, sourceParent.child(sourceRow, 0)).data(); //.toString().contains( /*string for column 0*/ )) +// LOG("Filter Role " << filterRole()); +// QModelIndex index = this->sourceModel()->index(sourceRow,1,sourceParent); +// sourceModel()->index(sourceRow, 0, sourceParent.child(sourceRow, 0)).data(filterRole()).toBool(); +// LOG("Filter index DATA"<< sourceModel()->index(sourceRow, 0, sourceParent.child(sourceRow, 0)).data(filterRole())); //<< index << index.isValid()); +// LOG("Filter parent " << sourceParent << sourceParent.isValid()); +// LOG("Filter Model Value" << sourceModel()->index(sourceRow, 0, sourceParent.child(sourceRow, 0)).data(filterRole()).toBool()); +// LOG("Filter Model filterValue" << filterValue); +// LOG("Filter Model result" << (sourceModel()->index(sourceRow, 0, sourceParent.child(sourceRow, 0)).data(filterRole()).toBool() == filterValue)); +// LOG("Filter Model MESSAGE" << sourceModel()->index(sourceRow, 0, sourceParent.child(sourceRow, 0)).data()); + return sourceModel()->index(sourceRow, 0, sourceParent.child(sourceRow, 0)).data(filterRole()).toBool() == filterValue; + } + +int BoolFilterModel::findRole(QAbstractItemModel *model, QString role) +{ + if (model && !role.isEmpty()) { + const QByteArray roleName(role.toUtf8()); + const QHash roleMap(model->roleNames()); + const QList roles(roleMap.keys()); + const int n = roles.count(); + for (int i = 0; i < n; i++) { + const QByteArray name(roleMap.value(roles.at(i))); + if (name == roleName) { + LOG(role << roles.at(i)); + return roles.at(i); + } + } + LOG("Unknown role" << role); + } + return -1; +} + +void BoolFilterModel::updateFilterRole() +{ + const int role = findRole(sourceModel(), filterRoleName); + setFilterRole((role >= 0) ? role : Qt::DisplayRole); +} diff --git a/src/boolfiltermodel.h b/src/boolfiltermodel.h new file mode 100644 index 0000000..770b8d3 --- /dev/null +++ b/src/boolfiltermodel.h @@ -0,0 +1,63 @@ +/* + 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 . +*/ + +#ifndef BOOLFILTERMODEL_H +#define BOOLFILTERMODEL_H + +#include + +class BoolFilterModel : public QSortFilterProxyModel +{ + Q_OBJECT + Q_PROPERTY(QString filterRoleName READ getFilterRoleName WRITE setFilterRoleName NOTIFY filterRoleNameChanged) + Q_PROPERTY(bool filterValue READ getFilterValue WRITE setFilterValue NOTIFY filterValueChanged) + Q_PROPERTY(QObject* sourceModel READ sourceModel WRITE setSource NOTIFY sourceChanged) + +public: + BoolFilterModel(QObject *parent = Q_NULLPTR); + + void setSource(QObject* model); + void setSourceModel(QAbstractItemModel *model) Q_DECL_OVERRIDE; + + + QString getFilterRoleName() const; + void setFilterRoleName(QString role); + + bool getFilterValue() const; + void setFilterValue(bool value); + Q_INVOKABLE int mapRowFromSource(int i, int fallbackDirection); + Q_INVOKABLE int mapRowToSource(int i); + +signals: + void sourceChanged(); + void filterRoleNameChanged(); + void filterValueChanged(); + +private slots: + void updateFilterRole(); + +private: + static int findRole(QAbstractItemModel *model, QString role); + +private: + QString filterRoleName; + bool filterValue; +protected: + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; +}; + +#endif // BOOLFILTERMODEL_H diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index 96c40ce..7dad231 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -30,6 +30,7 @@ namespace { const QString ID("id"); const QString CONTENT("content"); const QString CHAT_ID("chat_id"); + const QString DATE("date"); const QString PHOTO("photo"); const QString SMALL("small"); const QString UNREAD_COUNT("unread_count"); @@ -48,6 +49,7 @@ namespace { // "view_count": 47 // } const QString TYPE_MESSAGE_INTERACTION_INFO("messageInteractionInfo"); + const QString MEDIA_ALBUM_ID("media_album_id"); const QString INTERACTION_INFO("interaction_info"); const QString VIEW_COUNT("view_count"); const QString REACTIONS("reactions"); @@ -63,7 +65,9 @@ public: RoleMessageId, RoleMessageContentType, RoleMessageViewCount, - RoleMessageReactions + RoleMessageReactions, + RoleMessageAlbumEntryFilter, + RoleMessageAlbumMessageIds, }; enum RoleFlag { @@ -71,7 +75,9 @@ public: RoleFlagMessageId = 0x02, RoleFlagMessageContentType = 0x04, RoleFlagMessageViewCount = 0x08, - RoleFlagMessageReactions = 0x16 + RoleFlagMessageReactions = 0x16, + RoleFlagMessageAlbumEntryFilter = 0x32, + RoleFlagMessageAlbumMessageIds = 0x64 }; MessageData(const QVariantMap &data, qlonglong msgid); @@ -86,12 +92,16 @@ public: uint updateViewCount(const QVariantMap &interactionInfo); uint updateInteractionInfo(const QVariantMap &interactionInfo); uint updateReactions(const QVariantMap &interactionInfo); + uint updateAlbumEntryFilter(const bool isAlbumChild); + uint updateAlbumEntryMessageIds(const QVariantList &newAlbumMessageIds); QVector diff(const MessageData *message) const; QVector setMessageData(const QVariantMap &data); QVector setContent(const QVariantMap &content); QVector setReplyMarkup(const QVariantMap &replyMarkup); QVector setInteractionInfo(const QVariantMap &interactionInfo); + QVector setAlbumEntryFilter(bool isAlbumChild); + QVector setAlbumEntryMessageIds(const QVariantList &newAlbumMessageIds); int senderUserId() const; qlonglong senderChatId() const; @@ -104,6 +114,8 @@ public: QString messageContentType; int viewCount; QVariantList reactions; + bool albumEntryFilter; + QVariantList albumMessageIds; }; ChatModel::MessageData::MessageData(const QVariantMap &data, qlonglong msgid) : @@ -112,7 +124,9 @@ ChatModel::MessageData::MessageData(const QVariantMap &data, qlonglong msgid) : messageType(data.value(_TYPE).toString()), messageContentType(data.value(CONTENT).toMap().value(_TYPE).toString()), viewCount(data.value(INTERACTION_INFO).toMap().value(VIEW_COUNT).toInt()), - reactions(data.value(INTERACTION_INFO).toMap().value(REACTIONS).toList()) + reactions(data.value(INTERACTION_INFO).toMap().value(REACTIONS).toList()), + albumEntryFilter(false), + albumMessageIds(QVariantList()) { } @@ -134,6 +148,12 @@ QVector ChatModel::MessageData::flagsToRoles(uint flags) if (flags & RoleFlagMessageReactions) { roles.append(RoleMessageReactions); } + if (flags & RoleFlagMessageAlbumEntryFilter) { + roles.append(RoleMessageAlbumEntryFilter); + } + if (flags & RoleFlagMessageAlbumMessageIds) { + roles.append(RoleMessageAlbumMessageIds); + } return roles; } @@ -169,6 +189,12 @@ QVector ChatModel::MessageData::diff(const MessageData *message) const if (message->reactions != reactions) { roles.append(RoleMessageReactions); } + if (message->albumEntryFilter != albumEntryFilter) { + roles.append(RoleMessageAlbumEntryFilter); + } + if (message->albumMessageIds != albumMessageIds) { + roles.append(RoleMessageAlbumMessageIds); + } } return roles; } @@ -237,6 +263,37 @@ uint ChatModel::MessageData::updateReactions(const QVariantMap &interactionInfo) return (reactions == oldReactions) ? 0 : RoleFlagMessageReactions; } +uint ChatModel::MessageData::updateAlbumEntryFilter(const bool isAlbumChild) +{ + LOG("Updating album filter... for id " << messageId << " value:" << isAlbumChild << "previously" << albumEntryFilter); + const bool oldAlbumFiltered = albumEntryFilter; + albumEntryFilter = isAlbumChild; + return (isAlbumChild == oldAlbumFiltered) ? 0 : RoleFlagMessageAlbumEntryFilter; +} + + +QVector ChatModel::MessageData::setAlbumEntryFilter(bool isAlbumChild) +{ + LOG("setAlbumEntryFilter"); + return flagsToRoles(updateAlbumEntryFilter(isAlbumChild)); +} + +uint ChatModel::MessageData::updateAlbumEntryMessageIds(const QVariantList &newAlbumMessageIds) +{ + LOG("Updating albumMessageIds... id" << messageId); + LOG(" Updating albumMessageIds..." << newAlbumMessageIds << "previously" << albumMessageIds << "same?" << (newAlbumMessageIds == albumMessageIds)); + const QVariantList oldAlbumMessageIds = albumMessageIds; + albumMessageIds = newAlbumMessageIds; + + LOG(" Updating albumMessageIds... same again?" << (newAlbumMessageIds == oldAlbumMessageIds)); + return (newAlbumMessageIds == oldAlbumMessageIds) ? 0 : RoleFlagMessageAlbumMessageIds; +} + +QVector ChatModel::MessageData::setAlbumEntryMessageIds(const QVariantList &newAlbumMessageIds) +{ + return flagsToRoles(updateAlbumEntryMessageIds(newAlbumMessageIds)); +} + QVector ChatModel::MessageData::setInteractionInfo(const QVariantMap &info) { return flagsToRoles(updateInteractionInfo(info)); @@ -295,6 +352,8 @@ QHash ChatModel::roleNames() const roles.insert(MessageData::RoleMessageContentType, "content_type"); roles.insert(MessageData::RoleMessageViewCount, "view_count"); roles.insert(MessageData::RoleMessageReactions, "reactions"); + roles.insert(MessageData::RoleMessageAlbumEntryFilter, "album_entry_filter"); + roles.insert(MessageData::RoleMessageAlbumMessageIds, "album_message_ids"); return roles; } @@ -314,6 +373,8 @@ QVariant ChatModel::data(const QModelIndex &index, int role) const case MessageData::RoleMessageContentType: return message->messageContentType; case MessageData::RoleMessageViewCount: return message->viewCount; case MessageData::RoleMessageReactions: return message->reactions; + case MessageData::RoleMessageAlbumEntryFilter: return message->albumEntryFilter; + case MessageData::RoleMessageAlbumMessageIds: return message->albumMessageIds; } } return QVariant(); @@ -331,6 +392,7 @@ void ChatModel::clear(bool contentOnly) qDeleteAll(messages); messages.clear(); messageIndexMap.clear(); + albumMessageMap.clear(); endResetModel(); } @@ -356,6 +418,7 @@ void ChatModel::initialize(const QVariantMap &chatInformation) this->chatId = chatId; this->messages.clear(); this->messageIndexMap.clear(); + this->albumMessageMap.clear(); this->searchQuery.clear(); endResetModel(); emit chatIdChanged(); @@ -420,6 +483,36 @@ int ChatModel::getMessageIndex(qlonglong messageId) return -1; } +QVariantList ChatModel::getMessageIdsForAlbum(qlonglong albumId) +{ + QVariantList foundMessages; + if(albumMessageMap.contains(albumId)) { // there should be only one in here + QHash< qlonglong, QVariantList >::iterator i = albumMessageMap.find(albumId); + return i.value(); + } + return foundMessages; +} + +QVariantList ChatModel::getMessagesForAlbum(qlonglong albumId, int startAt) +{ + LOG("getMessagesForAlbumId" << albumId); + QVariantList messageIds = getMessageIdsForAlbum(albumId); + int count = messageIds.size(); + if ( count == 0) { + return messageIds; + } + QVariantList foundMessages; + for (int messageNum = startAt; messageNum < count; ++messageNum) { + const int position = messageIndexMap.value(messageIds.at(messageNum).toLongLong(), -1); + if(position >= 0 && position < messages.size()) { + foundMessages.append(messages.at(position)->messageData); + } else { + LOG("Not found in messages: #"<< messageNum); + } + } + return foundMessages; +} + int ChatModel::getLastReadMessageIndex() { LOG("Obtaining last read message index"); @@ -477,7 +570,8 @@ void ChatModel::handleMessagesReceived(const QVariantList &messages, int totalCo const qlonglong messageId = messageData.value(ID).toLongLong(); if (messageId && messageData.value(CHAT_ID).toLongLong() == chatId && !messageIndexMap.contains(messageId)) { LOG("New message will be added:" << messageId); - messagesToBeAdded.append(new MessageData(messageData, messageId)); + MessageData* message = new MessageData(messageData, messageId); + messagesToBeAdded.append(message); } } @@ -485,6 +579,7 @@ void ChatModel::handleMessagesReceived(const QVariantList &messages, int totalCo if (!messagesToBeAdded.isEmpty()) { insertMessages(messagesToBeAdded); + setMessagesAlbum(messagesToBeAdded); } // First call only returns a few messages, we need to get a little more than that... @@ -540,6 +635,7 @@ void ChatModel::handleNewMessageReceived(qlonglong chatId, const QVariantMap &me QList messagesToBeAdded; messagesToBeAdded.append(new MessageData(message, messageId)); insertMessages(messagesToBeAdded); + setMessagesAlbum(messagesToBeAdded); emit newMessageReceived(message); } else { LOG("New message in this chat, but not relevant as less recent messages need to be loaded first!"); @@ -591,6 +687,7 @@ void ChatModel::handleMessageSendSucceeded(qlonglong messageId, qlonglong oldMes messages.replace(pos, newMessage); messageIndexMap.remove(oldMessageId); messageIndexMap.insert(messageId, pos); + // TODO when we support sending album messages, handle ID change in albumMessageMap const QVector changedRoles(newMessage->diff(oldMessage)); delete oldMessage; LOG("Message was replaced at index" << pos); @@ -635,7 +732,8 @@ void ChatModel::handleMessageContentUpdated(qlonglong chatId, qlonglong messageI LOG("We know the message that was updated" << messageId); const int pos = messageIndexMap.value(messageId, -1); if (pos >= 0) { - const QVector changedRoles(messages.at(pos)->setContent(newContent)); + MessageData* messageData = messages.at(pos); + const QVector changedRoles(messageData->setContent(newContent)); LOG("Message was updated at index" << pos); const QModelIndex messageIndex(index(pos)); emit dataChanged(messageIndex, messageIndex, changedRoles); @@ -664,7 +762,8 @@ void ChatModel::handleMessageEditedUpdated(qlonglong chatId, qlonglong messageId LOG("We know the message that was updated" << messageId); const int pos = messageIndexMap.value(messageId, -1); if (pos >= 0) { - const QVector changedRoles(messages.at(pos)->setReplyMarkup(replyMarkup)); + MessageData* messageData = messages.at(pos); + const QVector changedRoles(messageData->setReplyMarkup(replyMarkup)); LOG("Message was edited at index" << pos); const QModelIndex messageIndex(index(pos)); emit dataChanged(messageIndex, messageIndex, changedRoles); @@ -709,18 +808,31 @@ void ChatModel::handleMessagesDeleted(qlonglong chatId, const QList & } } + void ChatModel::removeRange(int firstDeleted, int lastDeleted) { if (firstDeleted >= 0 && firstDeleted <= lastDeleted) { LOG("Removing range" << firstDeleted << "..." << lastDeleted << "| current messages size" << messages.size()); beginRemoveRows(QModelIndex(), firstDeleted, lastDeleted); + QList rescanAlbumIds; for (int i = firstDeleted; i <= lastDeleted; i++) { MessageData *message = messages.at(i); messageIndexMap.remove(message->messageId); + + qlonglong albumId = message->messageData.value(MEDIA_ALBUM_ID).toLongLong(); + if(albumId != 0 && albumMessageMap.contains(albumId)) { + rescanAlbumIds.append(albumId); + } delete message; } messages.erase(messages.begin() + firstDeleted, messages.begin() + (lastDeleted + 1)); + // rebuild following messageIndexMap + for(int i = firstDeleted; i < messages.size(); ++i) { + messageIndexMap.insert(messages.at(i)->messageId, i); + } endRemoveRows(); + + updateAlbumMessages(rescanAlbumIds, true); } } @@ -757,7 +869,7 @@ void ChatModel::appendMessages(const QList newMessages) beginInsertRows(QModelIndex(), oldSize, oldSize + count - 1); messages.append(newMessages); for (int i = 0; i < count; i++) { - // Appens new indeces to the map + // Append new indices to the map messageIndexMap.insert(newMessages.at(i)->messageId, oldSize + i); } endInsertRows(); @@ -785,6 +897,90 @@ void ChatModel::prependMessages(const QList newMessages) endInsertRows(); } +void ChatModel::updateAlbumMessages(qlonglong albumId, bool checkDeleted) +{ + if(albumMessageMap.contains(albumId)) { + const QVariantList empty; + QHash< qlonglong, QVariantList >::iterator album = albumMessageMap.find(albumId); + QVariantList messageIds = album.value(); + std::sort(messageIds.begin(), messageIds.end()); + int count; + // first: clear deleted messageIds: + if(checkDeleted) { + QVariantList::iterator it = messageIds.begin(); + while (it != messageIds.end()) { + if (!messageIndexMap.contains(it->toLongLong())) { + it = messageIds.erase(it); + } + else { + ++it; + } + } + } + // second: remaining ones still exist + count = messageIds.size(); + if(count == 0) { + albumMessageMap.remove(albumId); + } else { + for (int i = 0; i < count; i++) { + const int position = messageIndexMap.value(messageIds.at(i).toLongLong(), -1); + if(position > -1) { + // set list for first entry, empty for all others + QVector changedRolesFilter; + QVector changedRolesIds; + + QModelIndex messageIndex(index(position)); + if(i == 0) { + changedRolesFilter = messages.at(position)->setAlbumEntryFilter(false); + changedRolesIds = messages.at(position)->setAlbumEntryMessageIds(messageIds); + } else { + changedRolesFilter = messages.at(position)->setAlbumEntryFilter(true); + changedRolesIds = messages.at(position)->setAlbumEntryMessageIds(empty); + } + emit dataChanged(messageIndex, messageIndex, changedRolesIds); + emit dataChanged(messageIndex, messageIndex, changedRolesFilter); + } + } + } + albumMessageMap.insert(albumId, messageIds); + } +} + +void ChatModel::updateAlbumMessages(QList albumIds, bool checkDeleted) +{ + const int albumsCount = albumIds.size(); + for (int i = 0; i < albumsCount; i++) { + updateAlbumMessages(albumIds.at(i), checkDeleted); + } +} + +void ChatModel::setMessagesAlbum(const QList newMessages) +{ + const int count = newMessages.size(); + for (int i = 0; i < count; i++) { + setMessagesAlbum(newMessages.at(i)); + } +} + +void ChatModel::setMessagesAlbum(MessageData *message) +{ + qlonglong albumId = message->messageData.value(MEDIA_ALBUM_ID).toLongLong(); + if (albumId > 0 && (message->messageContentType != "messagePhoto" || message->messageContentType != "messageVideo")) { + qlonglong messageId = message->messageId; + + if(albumMessageMap.contains(albumId)) { + // find message id within album: + QHash< qlonglong, QVariantList >::iterator i = albumMessageMap.find(albumId); + if(!i.value().contains(messageId)) { + i.value().append(messageId); + } + } else { // new album id + albumMessageMap.insert(albumId, QVariantList() << messageId); + } + updateAlbumMessages(albumId, false); + } +} + QVariantMap ChatModel::enhanceMessage(const QVariantMap &message) { QVariantMap enhancedMessage = message; diff --git a/src/chatmodel.h b/src/chatmodel.h index bbf1b4a..e2e8bbc 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -44,6 +44,8 @@ public: Q_INVOKABLE void triggerLoadMoreFuture(); Q_INVOKABLE QVariantMap getChatInformation(); Q_INVOKABLE QVariantMap getMessage(int index); + Q_INVOKABLE QVariantList getMessageIdsForAlbum(qlonglong albumId); + Q_INVOKABLE QVariantList getMessagesForAlbum(qlonglong albumId, int startAt); Q_INVOKABLE int getLastReadMessageIndex(); Q_INVOKABLE void setSearchQuery(const QString newSearchQuery); @@ -85,6 +87,10 @@ private: void insertMessages(const QList newMessages); void appendMessages(const QList newMessages); void prependMessages(const QList newMessages); + void updateAlbumMessages(qlonglong albumId, bool checkDeleted); + void updateAlbumMessages(QList albumIds, bool checkDeleted); + void setMessagesAlbum(const QList newMessages); + void setMessagesAlbum(MessageData *message); QVariantMap enhanceMessage(const QVariantMap &message); int calculateLastKnownMessageId(); int calculateLastReadSentMessageId(); @@ -95,6 +101,7 @@ private: TDLibWrapper *tdLibWrapper; QList messages; QHash messageIndexMap; + QHash albumMessageMap; QVariantMap chatInformation; qlonglong chatId; bool inReload; diff --git a/src/harbour-fernschreiber.cpp b/src/harbour-fernschreiber.cpp index a584ea7..a6dfd66 100644 --- a/src/harbour-fernschreiber.cpp +++ b/src/harbour-fernschreiber.cpp @@ -51,6 +51,7 @@ #include "processlauncher.h" #include "stickermanager.h" #include "textfiltermodel.h" +#include "boolfiltermodel.h" #include "tgsplugin.h" #include "fernschreiberutils.h" #include "knownusersmodel.h" @@ -130,6 +131,7 @@ int main(int argc, char *argv[]) qmlRegisterType(uri, 1, 0, "TDLibFile"); qmlRegisterType(uri, 1, 0, "NamedAction"); qmlRegisterType(uri, 1, 0, "TextFilterModel"); + qmlRegisterType(uri, 1, 0, "BoolFilterModel"); qmlRegisterType(uri, 1, 0, "ChatPermissionFilterModel"); qmlRegisterSingletonType(uri, 1, 0, "DebugLog", DebugLogJS::createSingleton); -- 2.43.0 From e0019d33d6f3f7dbbdb7d1815f7da1de2e2bc337 Mon Sep 17 00:00:00 2001 From: Mikhail Barashkov Date: Mon, 1 Jan 2024 19:30:57 +0300 Subject: [PATCH 53/75] Fix not all possible destinations shown to forward a message. --- qml/js/functions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/js/functions.js b/qml/js/functions.js index 5199d82..f9454d3 100644 --- a/qml/js/functions.js +++ b/qml/js/functions.js @@ -517,7 +517,7 @@ function handleErrorMessage(code, message) { } function getMessagesNeededForwardPermissions(messages) { - var neededPermissions = ["can_send_messages"] + var neededPermissions = ["can_send_basic_messages"] var mediaMessageTypes = ["messageAudio", "messageDocument", "messagePhoto", "messageVideo", "messageVideoNote", "messageVoiceNote"] var otherMessageTypes = ["messageAnimation", "messageGame", "messageSticker"] -- 2.43.0 From 7e125aabf6752ff113cb7fe178e1ece9dad13b83 Mon Sep 17 00:00:00 2001 From: Nikolay Sinyov Date: Sat, 4 May 2024 18:19:28 +0300 Subject: [PATCH 54/75] Fixed merged problems in translation --- translations/harbour-fernschreiber-es.ts | 124 ----------------------- translations/harbour-fernschreiber-sk.ts | 39 ------- translations/harbour-fernschreiber-sv.ts | 66 ------------ 3 files changed, 229 deletions(-) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index d007d14..cdd1e62 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -405,11 +405,7 @@ This secret chat is not yet ready. Your chat partner needs to go online first. -<<<<<<< HEAD - Esta conversación secreta no está lista. El contacto no está conectado. -======= Esta charla secreta no está lista. El contacto no está conectado. ->>>>>>> fix_ballons/master Closing chat @@ -500,9 +496,6 @@ You don't have any chats yet. -<<<<<<< HEAD - No hay conversaciones. -======= No hay charlas. @@ -511,7 +504,6 @@ Could not synchronize your contacts with Telegram. No se puede sincronizar los contactos con Telegrama. ->>>>>>> fix_ballons/master @@ -677,11 +669,7 @@ have registered with Telegram myself -<<<<<<< HEAD - registrado a Telegram -======= registrado a Telegrama ->>>>>>> fix_ballons/master has registered with Telegram @@ -776,11 +764,7 @@ deleted the chat photo myself -<<<<<<< HEAD - borró foto de conversación -======= borró foto de charla ->>>>>>> fix_ballons/master deleted the chat photo @@ -789,19 +773,11 @@ changed the secret chat TTL setting myself -<<<<<<< HEAD - cambió ajustes TTL en conversación secreta - - - changed the secret chat TTL setting - cambió ajustes TTL en conversación secreta -======= cambió ajustes TTL en charla secreta changed the secret chat TTL setting cambió ajustes TTL en charla secreta ->>>>>>> fix_ballons/master upgraded this group to a supergroup @@ -820,19 +796,11 @@ created a screenshot in this chat myself -<<<<<<< HEAD - creó pantallazo a esta conversación - - - created a screenshot in this chat - creó pantallazo a esta conversación -======= creó pantallazo a esta charla created a screenshot in this chat creó pantallazo a esta charla ->>>>>>> fix_ballons/master sent an unsupported message @@ -885,37 +853,21 @@ has added %1 to the chat -<<<<<<< HEAD - ha añadido %1 a conversación - - - has removed %1 from the chat - ha quitado %1 de conversación -======= ha añadido %1 a charla has removed %1 from the chat ha quitado %1 de charla ->>>>>>> fix_ballons/master have added %1 to the chat myself -<<<<<<< HEAD - ha añadido %1 a conversación -======= ha añadido %1 a charla ->>>>>>> fix_ballons/master have removed %1 from the chat myself -<<<<<<< HEAD - ha quitado %1 de conversación -======= ha quitado %1 de charla ->>>>>>> fix_ballons/master scored %Ln points @@ -1259,11 +1211,7 @@ Loading chat list... -<<<<<<< HEAD - cargando lista de conversación... -======= cargando lista de charla... ->>>>>>> fix_ballons/master Settings @@ -1271,11 +1219,7 @@ You don't have any chats yet. -<<<<<<< HEAD - No hay conversaciones. -======= No hay charlas. ->>>>>>> fix_ballons/master New Chat @@ -1580,19 +1524,11 @@ Focus text input on chat open -<<<<<<< HEAD - Enfocar entrada de texto a conversación - - - Focus the text input area when entering a chat - Enfoca área de entrada de texto al ingresar a conversación -======= Enfocar entrada de texto de Charla Focus the text input area when entering a chat Enfoca área de entrada de texto al ingresar a charla ->>>>>>> fix_ballons/master Focus text input area after send @@ -1608,11 +1544,7 @@ Fernschreiber will wait a bit before messages are marked as read -<<<<<<< HEAD - Si esta habilitado, apl espera un segundo hasta que mensaje que está en pantalla se marque como leído. Si deshabilita esta función, mensajes se marcarán inmediatamente como leído una vez que esté en pantalla sin desplazarse a mensaje -======= Si esta habilitado, Apl espera un segundo hasta que mensaje que está en monitor se marque como leído. Si deshabilita esta función, mensajes se marcarán inmediatamente como leído una vez que esté en monitor sin desplazarse a mensaje ->>>>>>> fix_ballons/master Open-with menu integration @@ -1648,17 +1580,6 @@ Enable notification sounds -<<<<<<< HEAD - Habilitar sonidos notificación - - - When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings. - Cuando sonidos están habilitados, Ferni utilizará sonido de notificación actual de Sailfish OS para los grupos, que se puede ajustar a configuración del sistema. - - - Always append message preview to notifications - Agregar vista previa mensaje a notificaciones -======= Habilitar sonidos de Notificación @@ -1668,7 +1589,6 @@ Always append message preview to notifications Vista previa de mensaje en Notificaciones ->>>>>>> fix_ballons/master In addition to showing the number of unread messages, the latest message will also be appended to notifications. @@ -1676,17 +1596,6 @@ Highlight unread messages -<<<<<<< HEAD - Resaltar mensajes no leídos - - - Highlight Conversations with unread messages - Resaltar conversaciones a mensajes no leídos - - - Hide content in notifications - Ocultar contenido a notificaciones -======= Resaltar mensajes no Leídos @@ -1696,7 +1605,6 @@ Hide content in notifications Ocultar contenido de notificaciones ->>>>>>> fix_ballons/master Go to quoted message @@ -1750,11 +1658,7 @@ Show link in forwarded messages -<<<<<<< HEAD - Mostrar enlace a mensajes reenviados -======= Mostrar enlace a mensajes Reenviados ->>>>>>> fix_ballons/master Privacy setting for managing whether a link to your account is included in forwarded messages. @@ -1863,19 +1767,11 @@ Enable online-only mode -<<<<<<< HEAD - Modo solo enlínea - - - Disables offline caching. Certain features may be limited or missing in this mode. Changes require a restart of Fernschreiber to take effect. - Deshabilita almacenamiento en caché sin conexión. Algunas funciones pueden estar limitadas o ausentes en este modo. Se requiere reiniciar Ferni para efecto. -======= Modo solo Enlínea Disables offline caching. Certain features may be limited or missing in this mode. Changes require a restart of Fernschreiber to take effect. Deshabilita el almacenamiento en caché sin conexión. Algunas funciones pueden estar limitadas o ausentes en este modo. Se requiere reiniciar Ferni para efecto. ->>>>>>> fix_ballons/master Enable storage optimizer @@ -1949,11 +1845,7 @@ Synchronize Contacts with Telegram -<<<<<<< HEAD - Sincronizar Telegram -======= Sincronizar Telegrama ->>>>>>> fix_ballons/master @@ -2334,20 +2226,12 @@ changed the secret chat TTL setting myself; TTL = Time To Live -<<<<<<< HEAD - cambió ajustes de TTL de conversación secreta -======= cambió ajustes de TTL de charla secreta ->>>>>>> fix_ballons/master changed the secret chat TTL setting TTL = Time To Live -<<<<<<< HEAD - cambió ajustes de TTL de conversación secreta -======= cambió ajustes de TTL de charla secreta ->>>>>>> fix_ballons/master upgraded this group to a supergroup @@ -2366,19 +2250,11 @@ created a screenshot in this chat myself -<<<<<<< HEAD - creó pantallazo a conversación - - - created a screenshot in this chat - creó pantallazo a conversación -======= creó pantallazo de charla created a screenshot in this chat creó pantallazo a charla ->>>>>>> fix_ballons/master sent an unsupported message diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index 6900bb8..8bc17ec 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -495,11 +495,7 @@ Double-tap on a message to choose a reaction -<<<<<<< HEAD - -======= Dvojitým klepnutím na správu vybrať reakciu ->>>>>>> fix_ballons/master @@ -1777,48 +1773,14 @@ %1 day(s) -<<<<<<< HEAD - - - - -======= %1 deň %1 dni %1 dní ->>>>>>> fix_ballons/master 1 week -<<<<<<< HEAD - - - - 1 month - - - - 3 months - - - - 6 months - - - - 1 year - - - - Session Timeout - - - - Inactive sessions will be terminated after this timeframe - -======= 1 týždeň @@ -1844,7 +1806,6 @@ Inactive sessions will be terminated after this timeframe Neaktívne relácie budú po tomto časovom rámci ukončené ->>>>>>> fix_ballons/master diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index a10ff2e..bd32aae 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -485,11 +485,7 @@ Double-tap on a message to choose a reaction -<<<<<<< HEAD - -======= Dubbeltryck på ett meddelande för att välja en reaktion ->>>>>>> fix_ballons/master @@ -1585,33 +1581,6 @@ Always append message preview to notifications -<<<<<<< HEAD - - - - In addition to showing the number of unread messages, the latest message will also be appended to notifications. - - - - Highlight unread messages - - - - Highlight Conversations with unread messages - - - - Hide content in notifications - - - - Go to quoted message - - - - When tapping a quoted message, open it in chat instead of showing it in an overlay. - -======= Visa alltid förhandsgranskning av meddelanden i aviseringar @@ -1637,7 +1606,6 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. Vid tryck på ett citerat meddelande öppnas det i chatten istället för att visas i ett överlägg. ->>>>>>> fix_ballons/master @@ -1750,46 +1718,13 @@ %1 day(s) -<<<<<<< HEAD - - - -======= %1 dag %1 dagar ->>>>>>> fix_ballons/master 1 week -<<<<<<< HEAD - - - - 1 month - - - - 3 months - - - - 6 months - - - - 1 year - - - - Session Timeout - - - - Inactive sessions will be terminated after this timeframe - -======= 1 vecka @@ -1815,7 +1750,6 @@ Inactive sessions will be terminated after this timeframe Inaktiva sessioner avslutas efter den här tidsramen ->>>>>>> fix_ballons/master -- 2.43.0 From 4471e543d239d47ef96e5ca8fd5f6c908813522a Mon Sep 17 00:00:00 2001 From: Nikolay Sinyov Date: Sat, 4 May 2024 19:45:21 +0300 Subject: [PATCH 55/75] merge translation --- translations/harbour-fernschreiber-de.ts | 11 +++++++++++ translations/harbour-fernschreiber-en.ts | 11 +++++++++++ translations/harbour-fernschreiber-es.ts | 11 +++++++++++ translations/harbour-fernschreiber-fi.ts | 11 +++++++++++ translations/harbour-fernschreiber-fr.ts | 11 +++++++++++ translations/harbour-fernschreiber-hu.ts | 10 ++++++++++ translations/harbour-fernschreiber-it.ts | 11 +++++++++++ translations/harbour-fernschreiber-pl.ts | 12 ++++++++++++ translations/harbour-fernschreiber-ru.ts | 12 ++++++++++++ translations/harbour-fernschreiber-sk.ts | 12 ++++++++++++ translations/harbour-fernschreiber-sv.ts | 11 +++++++++++ translations/harbour-fernschreiber-zh_CN.ts | 10 ++++++++++ translations/harbour-fernschreiber.ts | 11 +++++++++++ 13 files changed, 144 insertions(+) diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index ae2ff61..ef14fdf 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -896,6 +896,17 @@ hat eine Videonachricht geschickt + + FullscreenOverlay + + Forward %Ln messages + dialog header + + %Ln Nachricht weiterleiten + %Ln Nachrichten weiterleiten + + + ImagePage diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index d030fd2..4f9f525 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -898,6 +898,17 @@ messages sent a video note + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Forward %Ln message + Forward %Ln messages + + + ImagePage diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index f12be43..6cef020 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -896,6 +896,17 @@ envió nota de video + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Reenviar %Ln mensaje + Reenviar %Ln mensajes + + + ImagePage diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index d11cb99..691fae8 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -897,6 +897,17 @@ lähetti videoviestin + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Välitä %Ln viesti + Välitä %Ln viestiä + + + ImagePage diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index 2c1ad8d..d011ef1 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -896,6 +896,17 @@ a envoyé une note vidéo + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Transférer %Ln message + Transférer %Ln messages + + + ImagePage diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index ccf965e..60dbe5a 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -882,6 +882,16 @@ + + FullscreenOverlay + + Forward %Ln messages + dialog header + + + + + ImagePage diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 5303829..67d1bdf 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -896,6 +896,17 @@ ha inviato un videomessaggio + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Inoltra %Ln messaggio + Inoltra %Ln messaggi + + + ImagePage diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 040f2bc..261f37d 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -910,6 +910,18 @@ wysłał notatkę video + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Przekaż %Ln wiadomość + Przekaż %Ln wiadomości + Przekaż %Ln wiadomości + + + ImagePage diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 4e7d338..0913993 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -913,6 +913,18 @@ отправил(а) видео заметку + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Перенаправить %Ln сообщение + Перенаправить %Ln сообщения + Перенаправить %Ln сообщений + + + ImagePage diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index a794119..36ab490 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -910,6 +910,18 @@ poslal video-poznámku + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Postúpená %Ln správa + Postúpené %Ln správy + Postúpených %Ln správ + + + ImagePage diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index bd32aae..16953c3 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -896,6 +896,17 @@ skickade ett videomeddelande + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Vidarebefordra %Ln meddelande + Vidarebefordra %Ln meddelanden + + + ImagePage diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index 7887ddb..38d819c 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -883,6 +883,16 @@ 发送视频消息 + + FullscreenOverlay + + Forward %Ln messages + dialog header + + 转发 %Ln 则消息 + + + ImagePage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 2481b12..134628e 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -896,6 +896,17 @@ sent a video note + + FullscreenOverlay + + Forward %Ln messages + dialog header + + Forward %Ln message + Forward %Ln messages + + + ImagePage -- 2.43.0 From 234a84ac045b3dd5cf922971708cbd72c4b95407 Mon Sep 17 00:00:00 2001 From: Nikolay Sinyov Date: Sat, 4 May 2024 21:00:20 +0300 Subject: [PATCH 56/75] Fixed merge --- qml/components/MessageListViewItem.qml | 3 ++- src/tdlibwrapper.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 683c0e2..a83d23e 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -151,7 +151,8 @@ ListItem { if (messageListItem.messageReactions) { messageListItem.messageReactions = null; - selectReactionBubble.visible = false; + } else if (messageListItem.chatReactions) { + messageListItem.messageReactions = chatReactions } else { selectReactionBubble.visible = !selectReactionBubble.visible; elementSelected(index); diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 70dcf65..f4da7aa 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1633,15 +1633,23 @@ QVariantMap TDLibWrapper::getChat(const QString &chatId) QStringList TDLibWrapper::getChatReactions(const QString &chatId) { +<<<<<<< HEAD LOG("Obtaining chat reactions for chat" << chatId); +======= +>>>>>>> 1ee8d13 (Adapt to changes in TdLib (#524)) const QVariant available_reactions(chats.value(chatId).toMap().value(CHAT_AVAILABLE_REACTIONS)); const QVariantMap map(available_reactions.toMap()); const QString reactions_type(map.value(_TYPE).toString()); if (reactions_type == CHAT_AVAILABLE_REACTIONS_ALL) { +<<<<<<< HEAD LOG("Chat uses all available reactions, currently available number" << activeEmojiReactions.size()); return activeEmojiReactions; } else if (reactions_type == CHAT_AVAILABLE_REACTIONS_SOME) { LOG("Chat uses reduced set of reactions"); +======= + return activeEmojiReactions; + } else if (reactions_type == CHAT_AVAILABLE_REACTIONS_SOME) { +>>>>>>> 1ee8d13 (Adapt to changes in TdLib (#524)) const QVariantList reactions(map.value(REACTIONS).toList()); const int n = reactions.count(); QStringList emojis; @@ -1663,6 +1671,7 @@ QStringList TDLibWrapper::getChatReactions(const QString &chatId) } } } +<<<<<<< HEAD LOG("Found emojis for this chat" << emojis.size()); return emojis; } else if (reactions_type.isEmpty()) { @@ -1670,6 +1679,12 @@ QStringList TDLibWrapper::getChatReactions(const QString &chatId) return available_reactions.toStringList(); } else { LOG("Unknown chat reaction type" << reactions_type); +======= + return emojis; + } else if (reactions_type.isEmpty()) { + return available_reactions.toStringList(); + } else { +>>>>>>> 1ee8d13 (Adapt to changes in TdLib (#524)) return QStringList(); } } -- 2.43.0 From 659cf4e8ca14ddba3924082ddaf9787e9fd09bcc Mon Sep 17 00:00:00 2001 From: Nikolay Sinyov Date: Sat, 4 May 2024 21:15:09 +0300 Subject: [PATCH 57/75] Fixed --- src/tdlibwrapper.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index f4da7aa..567d50d 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1633,23 +1633,16 @@ QVariantMap TDLibWrapper::getChat(const QString &chatId) QStringList TDLibWrapper::getChatReactions(const QString &chatId) { -<<<<<<< HEAD + LOG("Obtaining chat reactions for chat" << chatId); -======= ->>>>>>> 1ee8d13 (Adapt to changes in TdLib (#524)) const QVariant available_reactions(chats.value(chatId).toMap().value(CHAT_AVAILABLE_REACTIONS)); const QVariantMap map(available_reactions.toMap()); const QString reactions_type(map.value(_TYPE).toString()); if (reactions_type == CHAT_AVAILABLE_REACTIONS_ALL) { -<<<<<<< HEAD LOG("Chat uses all available reactions, currently available number" << activeEmojiReactions.size()); return activeEmojiReactions; } else if (reactions_type == CHAT_AVAILABLE_REACTIONS_SOME) { LOG("Chat uses reduced set of reactions"); -======= - return activeEmojiReactions; - } else if (reactions_type == CHAT_AVAILABLE_REACTIONS_SOME) { ->>>>>>> 1ee8d13 (Adapt to changes in TdLib (#524)) const QVariantList reactions(map.value(REACTIONS).toList()); const int n = reactions.count(); QStringList emojis; @@ -1671,7 +1664,6 @@ QStringList TDLibWrapper::getChatReactions(const QString &chatId) } } } -<<<<<<< HEAD LOG("Found emojis for this chat" << emojis.size()); return emojis; } else if (reactions_type.isEmpty()) { @@ -1679,12 +1671,6 @@ QStringList TDLibWrapper::getChatReactions(const QString &chatId) return available_reactions.toStringList(); } else { LOG("Unknown chat reaction type" << reactions_type); -======= - return emojis; - } else if (reactions_type.isEmpty()) { - return available_reactions.toStringList(); - } else { ->>>>>>> 1ee8d13 (Adapt to changes in TdLib (#524)) return QStringList(); } } -- 2.43.0 From 547b6b1e0b825cc5693a5d38ae9b6bfe7b44e675 Mon Sep 17 00:00:00 2001 From: Nikolay Sinyov Date: Sat, 4 May 2024 21:16:31 +0300 Subject: [PATCH 58/75] Fixed --- qml/components/MessageListViewItem.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index a83d23e..683c0e2 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -151,8 +151,7 @@ ListItem { if (messageListItem.messageReactions) { messageListItem.messageReactions = null; - } else if (messageListItem.chatReactions) { - messageListItem.messageReactions = chatReactions + selectReactionBubble.visible = false; } else { selectReactionBubble.visible = !selectReactionBubble.visible; elementSelected(index); -- 2.43.0 From 77f03f1f02c245f37083cef435883229bbb70eaa Mon Sep 17 00:00:00 2001 From: Johannes Bachmann <45299708+dscheinah@users.noreply.github.com> Date: Sat, 18 Nov 2023 23:11:17 +0100 Subject: [PATCH 59/75] Always append last message content to notifications (#514) * always append last message content to notifications * make "always show notification" configurable * add unfinished translations * Fix spacing if no sender is printed --- qml/components/settingsPage/SettingsBehavior.qml | 11 +++++++++++ src/appsettings.h | 6 ++++++ translations/harbour-fernschreiber-es.ts | 8 ++++++++ translations/harbour-fernschreiber.ts | 3 +++ 4 files changed, 28 insertions(+) diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index 2232791..c10aba7 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -216,6 +216,17 @@ AccordionItem { } } } + + TextSwitch { + width: parent.columnWidth + checked: appSettings.notificationAlwaysShowPreview + text: qsTr("Always append message preview to notifications") + description: qsTr("In addition to showing the number of unread messages, the latest message will also be appended to notifications.") + automaticCheck: false + onClicked: { + appSettings.notificationAlwaysShowPreview = !checked + } + } } } } diff --git a/src/appsettings.h b/src/appsettings.h index acc38b2..77090aa 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -97,9 +97,12 @@ public: bool notificationAlwaysShowPreview() const; void setNotificationAlwaysShowPreview(bool enable); +<<<<<<< HEAD bool goToQuotedMessage() const; void setGoToQuotedMessage(bool enable); +======= +>>>>>>> b11f7dd (Always append last message content to notifications (#514)) bool storageOptimizer() const; void setStorageOptimizer(bool enable); @@ -139,7 +142,10 @@ signals: void notificationSuppressContentChanged(); void notificationFeedbackChanged(); void notificationAlwaysShowPreviewChanged(); +<<<<<<< HEAD void goToQuotedMessageChanged(); +======= +>>>>>>> b11f7dd (Always append last message content to notifications (#514)) void storageOptimizerChanged(); void allowInlineBotLocationAccessChanged(); void remainingInteractionHintsChanged(); diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 6cef020..5669837 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1618,6 +1618,14 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. Al Pulsar mensaje citado, abrirá en Charla en lugar de mostrarlo en una superposición. + + Always append message preview to notifications + + + + In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + SettingsPage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 134628e..a2fe241 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1598,6 +1598,7 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. +<<<<<<< HEAD Highlight unread messages @@ -1618,6 +1619,8 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. +======= +>>>>>>> b11f7dd (Always append last message content to notifications (#514)) SettingsPage -- 2.43.0 From 070f3e1bd744b34b4fad9e0e1f3a56678b10785e Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 18 Nov 2023 23:39:09 +0100 Subject: [PATCH 60/75] Some minor adjustments --- translations/harbour-fernschreiber-de.ts | 6 ++++++ translations/harbour-fernschreiber-en.ts | 4 ++++ translations/harbour-fernschreiber-es.ts | 12 ++++++++++++ translations/harbour-fernschreiber-fi.ts | 4 ++++ translations/harbour-fernschreiber-fr.ts | 12 ++++++++++++ translations/harbour-fernschreiber-hu.ts | 7 +++++++ translations/harbour-fernschreiber-it.ts | 7 +++++++ translations/harbour-fernschreiber-pl.ts | 4 ++++ translations/harbour-fernschreiber-ru.ts | 12 ++++++++++++ translations/harbour-fernschreiber-sv.ts | 1 + translations/harbour-fernschreiber.ts | 3 --- 11 files changed, 69 insertions(+), 3 deletions(-) diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index ef14fdf..f6ce4b3 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1607,6 +1607,7 @@ Unterhaltungen mit ungelesenen Nachrichten hervorheben +<<<<<<< HEAD Hide content in notifications Inhalte in Hinweisen verbergen @@ -1618,6 +1619,11 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. Beim Tippen auf eine zitierte Nachricht zu dieser springen anstatt es in einem Overlay anzuzeigen. +======= + Hide content in Notifications + Inhalte in Hinweisen verbergen + +>>>>>>> f771a9a (Some minor adjustments) SettingsPage diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 4f9f525..39496c0 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1609,6 +1609,7 @@ messages +<<<<<<< HEAD Hide content in notifications @@ -1618,6 +1619,9 @@ messages When tapping a quoted message, open it in chat instead of showing it in an overlay. +======= + Hide content in Notifications +>>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 5669837..d7523cc 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1626,6 +1626,18 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 691fae8..8dd5348 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1608,6 +1608,7 @@ +<<<<<<< HEAD Hide content in notifications @@ -1617,6 +1618,9 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. +======= + Hide content in Notifications +>>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index d011ef1..d036871 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1618,6 +1618,18 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 60dbe5a..3c5a445 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1579,6 +1579,7 @@ +<<<<<<< HEAD Hide content in notifications @@ -1588,6 +1589,9 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. +======= + Hide content in Notifications +>>>>>>> f771a9a (Some minor adjustments) @@ -1697,6 +1701,7 @@ Active since: %1, last online: %2 +<<<<<<< HEAD @@ -1731,6 +1736,8 @@ Inactive sessions will be terminated after this timeframe +======= +>>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 67d1bdf..8c62d93 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1607,6 +1607,7 @@ +<<<<<<< HEAD Hide content in notifications @@ -1616,6 +1617,9 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. +======= + Hide content in Notifications +>>>>>>> f771a9a (Some minor adjustments) @@ -1725,6 +1729,7 @@ Active since: %1, last online: %2 +<<<<<<< HEAD @@ -1760,6 +1765,8 @@ Inactive sessions will be terminated after this timeframe +======= +>>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 261f37d..95f5ffb 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1635,6 +1635,7 @@ +<<<<<<< HEAD Hide content in notifications @@ -1644,6 +1645,9 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. +======= + Hide content in Notifications +>>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 0913993..c385e5a 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1649,6 +1649,18 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. По нажатию на цитируемое сообщение, переходить к нему в чате вместо отображения во всплывающем окне. + + Highlight unread messages + + + + Highlight Conversations with unread messages + + + + Hide content in Notifications + + SettingsPage diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 16953c3..480a402 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1607,6 +1607,7 @@ Färgmarkera konversationer med olästa meddelanden +<<<<<<< HEAD Hide content in notifications Dölj innehåll i aviseringar diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index a2fe241..134628e 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1598,7 +1598,6 @@ In addition to showing the number of unread messages, the latest message will also be appended to notifications. -<<<<<<< HEAD Highlight unread messages @@ -1619,8 +1618,6 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. -======= ->>>>>>> b11f7dd (Always append last message content to notifications (#514)) SettingsPage -- 2.43.0 From ea513a5e42cd473c4d78317205dce34151883f3e Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 18 Nov 2023 23:45:10 +0100 Subject: [PATCH 61/75] Enable privileged mode for contacts sync --- translations/harbour-fernschreiber-de.ts | 6 ------ translations/harbour-fernschreiber-en.ts | 4 ---- translations/harbour-fernschreiber-fi.ts | 4 ---- translations/harbour-fernschreiber-hu.ts | 7 ------- translations/harbour-fernschreiber-it.ts | 7 ------- translations/harbour-fernschreiber-pl.ts | 4 ---- translations/harbour-fernschreiber-sv.ts | 1 - 7 files changed, 33 deletions(-) diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index f6ce4b3..ef14fdf 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1607,7 +1607,6 @@ Unterhaltungen mit ungelesenen Nachrichten hervorheben -<<<<<<< HEAD Hide content in notifications Inhalte in Hinweisen verbergen @@ -1619,11 +1618,6 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. Beim Tippen auf eine zitierte Nachricht zu dieser springen anstatt es in einem Overlay anzuzeigen. -======= - Hide content in Notifications - Inhalte in Hinweisen verbergen - ->>>>>>> f771a9a (Some minor adjustments) SettingsPage diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index 39496c0..4f9f525 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1609,7 +1609,6 @@ messages -<<<<<<< HEAD Hide content in notifications @@ -1619,9 +1618,6 @@ messages When tapping a quoted message, open it in chat instead of showing it in an overlay. -======= - Hide content in Notifications ->>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 8dd5348..691fae8 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1608,7 +1608,6 @@ -<<<<<<< HEAD Hide content in notifications @@ -1618,9 +1617,6 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. -======= - Hide content in Notifications ->>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 3c5a445..60dbe5a 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1579,7 +1579,6 @@ -<<<<<<< HEAD Hide content in notifications @@ -1589,9 +1588,6 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. -======= - Hide content in Notifications ->>>>>>> f771a9a (Some minor adjustments) @@ -1701,7 +1697,6 @@ Active since: %1, last online: %2 -<<<<<<< HEAD @@ -1736,8 +1731,6 @@ Inactive sessions will be terminated after this timeframe -======= ->>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 8c62d93..67d1bdf 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1607,7 +1607,6 @@ -<<<<<<< HEAD Hide content in notifications @@ -1617,9 +1616,6 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. -======= - Hide content in Notifications ->>>>>>> f771a9a (Some minor adjustments) @@ -1729,7 +1725,6 @@ Active since: %1, last online: %2 -<<<<<<< HEAD @@ -1765,8 +1760,6 @@ Inactive sessions will be terminated after this timeframe -======= ->>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index 95f5ffb..261f37d 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1635,7 +1635,6 @@ -<<<<<<< HEAD Hide content in notifications @@ -1645,9 +1644,6 @@ When tapping a quoted message, open it in chat instead of showing it in an overlay. -======= - Hide content in Notifications ->>>>>>> f771a9a (Some minor adjustments) diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 480a402..16953c3 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1607,7 +1607,6 @@ Färgmarkera konversationer med olästa meddelanden -<<<<<<< HEAD Hide content in notifications Dölj innehåll i aviseringar -- 2.43.0 From 4ea558bfa5934457e0d138e923c32a68894dbf2e Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sun, 19 Nov 2023 13:52:18 +0200 Subject: [PATCH 62/75] Tweaked notification feedback settings UI (#526) --- .../settingsPage/SettingsBehavior.qml | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index c10aba7..678473d 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -216,15 +216,35 @@ AccordionItem { } } } + TextSwitch { + checked: appSettings.notificationSuppressContent && enabled + text: qsTr("Hide content in notifications") + enabled: parent.enabled + automaticCheck: false + onClicked: { + appSettings.notificationSuppressContent = !checked + } + } - TextSwitch { - width: parent.columnWidth - checked: appSettings.notificationAlwaysShowPreview - text: qsTr("Always append message preview to notifications") - description: qsTr("In addition to showing the number of unread messages, the latest message will also be appended to notifications.") - automaticCheck: false - onClicked: { - appSettings.notificationAlwaysShowPreview = !checked + TextSwitch { + checked: appSettings.notificationTurnsDisplayOn && enabled + text: qsTr("Notification turns on the display") + enabled: parent.enabled + automaticCheck: false + onClicked: { + appSettings.notificationTurnsDisplayOn = !checked + } + } + + TextSwitch { + checked: appSettings.notificationSoundsEnabled && enabled + text: qsTr("Enable notification sounds") + description: qsTr("When sounds are enabled, Fernschreiber will use the current Sailfish OS notification sound for chats, which can be configured in the system settings.") + enabled: parent.enabled + automaticCheck: false + onClicked: { + appSettings.notificationSoundsEnabled = !checked + } } } } -- 2.43.0 From 1e88f3c9ba4605154fb77797267f447f68286f2a Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 19 Nov 2023 13:34:31 +0100 Subject: [PATCH 63/75] Fix chat permissions handling --- translations/harbour-fernschreiber-es.ts | 2 +- translations/harbour-fernschreiber-fr.ts | 2 +- translations/harbour-fernschreiber-ru.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index d7523cc..9cdc703 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1635,7 +1635,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index d036871..183764c 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1627,7 +1627,7 @@ - Hide content in Notifications + Hide content in notifications diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index c385e5a..35288a3 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1658,7 +1658,7 @@ - Hide content in Notifications + Hide content in notifications -- 2.43.0 From 02573174fcb9a5a3540a7532cd1cfa240539ff80 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 19 Nov 2023 22:51:33 +0100 Subject: [PATCH 64/75] Minor tweaks for the new session timout setting --- translations/harbour-fernschreiber-es.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 9cdc703..dd080b6 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1756,6 +1756,7 @@ 1 week +<<<<<<< HEAD 1 semana -- 2.43.0 From 72c4419a4828fc1bdfc19d27b04161a09590b37b Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Mon, 20 Nov 2023 22:34:52 +0100 Subject: [PATCH 65/75] Test build no.4 --- rpm/harbour-fernschreiber.yaml | 55 ---------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 rpm/harbour-fernschreiber.yaml diff --git a/rpm/harbour-fernschreiber.yaml b/rpm/harbour-fernschreiber.yaml deleted file mode 100644 index 82dd0f5..0000000 --- a/rpm/harbour-fernschreiber.yaml +++ /dev/null @@ -1,55 +0,0 @@ -Name: harbour-fernschreiber -Summary: Fernschreiber is a Telegram client for Sailfish OS -Version: 0.17 -Release: 12 -# The contents of the Group field should be one of the groups listed here: -# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS -Group: Qt/Qt -URL: http://werkwolf.eu/ -License: LICENSE -# This must be generated before uploading a package to a remote build service. -# Usually this line does not need to be modified. -Sources: -- '%{name}-%{version}.tar.bz2' -Description: | - Fernschreiber is a Telegram client for Sailfish OS -Configure: none -Builder: qmake5 - -# This section specifies build dependencies that are resolved using pkgconfig. -# This is the preferred way of specifying build dependencies for your package. -PkgConfigBR: - - sailfishapp >= 1.0.2 - - Qt5Core - - Qt5Qml - - Qt5Quick - - Qt5DBus - - Qt5Sql - - Qt5Multimedia - - Qt5Positioning - - nemonotifications-qt5 - - openssl - -# NB: spectacle has a bug where it will remove custom "#<< macros" lines, so define them here: -Macros: - - '__provides_exclude_from;^%{_datadir}/.*$' - - '__requires_exclude;^libtdjson.*$' - -# Build dependencies without a pkgconfig setup can be listed here -PkgBR: - - gperf - -# Runtime dependencies which are not automatically detected -Requires: - - sailfishsilica-qt5 >= 0.10.9 - - nemo-qml-plugin-contacts-qt5 - -# All installed files -Files: - - '%{_bindir}/%{name}' - - '%{_datadir}/%{name}' - - '%{_datadir}/applications/%{name}.desktop' - - '%{_datadir}/icons/hicolor/*/apps/%{name}.png' - -# For more information about yaml and what's supported in Sailfish OS -# build system, please see https://wiki.merproject.org/wiki/Spectacle -- 2.43.0 From fd8dee466e09134f5efea0135bec9178bc7fea5c Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Tue, 21 Nov 2023 22:31:23 +0200 Subject: [PATCH 66/75] Updated Russian translation (#528) --- translations/harbour-fernschreiber-ru.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 35288a3..b6dcd84 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1651,15 +1651,15 @@ Highlight unread messages - + Выделять непрочитанные сообщения Highlight Conversations with unread messages - + Помечать чаты и каналы с непрочитанными сообщениями другим шрифтом и цветом. Hide content in notifications - + Не показывать содержимое сообщений в уведомлениях -- 2.43.0 From 20be5acfdcc41781eecbfbc9edb90e2290e7ca5f Mon Sep 17 00:00:00 2001 From: free software <45316884+carlosgonz0@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:31:41 -0500 Subject: [PATCH 67/75] Update harbour-fernschreiber-es.ts (#529) * Update harbour-fernschreiber-es.ts * Update harbour-fernschreiber-es.ts --- translations/harbour-fernschreiber-es.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index dd080b6..5bb9487 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1620,23 +1620,23 @@ Always append message preview to notifications - + Agregar vista previa mensaje a notificaciones In addition to showing the number of unread messages, the latest message will also be appended to notifications. - + Mostrará cantidad mensajes no leídos, el último mensaje se agregará a notificaciones. Highlight unread messages - + Resaltar mensajes no leídos Highlight Conversations with unread messages - + Resaltar conversaciones a mensajes no leídos Hide content in notifications - + Ocultar contenido a notificaciones @@ -1756,7 +1756,6 @@ 1 week -<<<<<<< HEAD 1 semana @@ -2376,11 +2375,11 @@ sent a game myself - envió un juego + envió juego sent a game - envió un juego + envió juego -- 2.43.0 From d6444c22b2b32f8b3a53c111e3d16c4ce78f18ee Mon Sep 17 00:00:00 2001 From: Patrick Hervieux <5952038+pherjung@users.noreply.github.com> Date: Fri, 24 Nov 2023 23:13:18 +0100 Subject: [PATCH 68/75] Update French translation (#532) Co-authored-by: Patrick Hervieux --- translations/harbour-fernschreiber-fr.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index 183764c..062a5c0 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1620,15 +1620,15 @@ Highlight unread messages - + Mettre en valeur les messages non-lus Highlight Conversations with unread messages - + Mettre en valeur les conversations avec des messages non-lus Hide content in notifications - + Masquer le contenu dans les notifications -- 2.43.0 From 24d4b9ffb1e8246795e1742c45ba2dbbcddbf8d1 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 26 Nov 2023 20:36:30 +0100 Subject: [PATCH 69/75] Tweak reactions again... --- qml/components/MessageListViewItem.qml | 1 - qml/components/settingsPage/SettingsBehavior.qml | 1 - 2 files changed, 2 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 683c0e2..b066bcb 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -812,7 +812,6 @@ ListItem { Image { id: emojiPicture source: Emoji.getEmojiPath(modelData) - width: status === Image.Ready ? Theme.fontSizeExtraLarge : 0 height: Theme.fontSizeExtraLarge } diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index 678473d..0faa786 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -249,4 +249,3 @@ AccordionItem { } } } -} -- 2.43.0 From 18957e5f9d3347984dff99ee467f7e461b6d7221 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Fri, 1 Dec 2023 00:23:23 +0100 Subject: [PATCH 70/75] Handle event updateChatAvailableReactions --- src/tdlibwrapper.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp index 567d50d..70dcf65 100644 --- a/src/tdlibwrapper.cpp +++ b/src/tdlibwrapper.cpp @@ -1633,7 +1633,6 @@ QVariantMap TDLibWrapper::getChat(const QString &chatId) QStringList TDLibWrapper::getChatReactions(const QString &chatId) { - LOG("Obtaining chat reactions for chat" << chatId); const QVariant available_reactions(chats.value(chatId).toMap().value(CHAT_AVAILABLE_REACTIONS)); const QVariantMap map(available_reactions.toMap()); -- 2.43.0 From 06dcda1fd4fa4885090093409a9835ae55c19848 Mon Sep 17 00:00:00 2001 From: mbarashkov Date: Sun, 3 Dec 2023 01:44:14 +0300 Subject: [PATCH 71/75] Improve chat UI on tablets by making messages narrower and limiting content items width as well. (#540) Co-authored-by: Mikhail Barashkov --- qml/pages/ChatPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index d20a373..1861091 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1230,7 +1230,7 @@ Page { readonly property int profileThumbnailDimensions: showUserInfo ? Theme.itemSizeSmall : 0 readonly property int pageMarginDouble: 2 * Theme.horizontalPageMargin readonly property int paddingMediumDouble: 2 * Theme.paddingMedium - readonly property int entryWidth: chatView.width - pageMarginDouble + readonly property int entryWidth: Functions.isTablet(appWindow) ? chatView.width * 0.75 : chatView.width - pageMarginDouble readonly property int textItemWidth: entryWidth - profileThumbnailDimensions - Theme.paddingSmall readonly property int backgroundWidth: page.isPrivateChat ? textItemWidth - pageMarginDouble : textItemWidth //уменьшенная ширина сообщений для приватных чатов readonly property int backgroundRadius: textItemWidth/50 -- 2.43.0 From 4fc0ce70b599a3171ee0d11553fcbcc6c2478aec Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sat, 2 Dec 2023 23:50:13 +0100 Subject: [PATCH 72/75] Not only tablets have widescreen ;) --- qml/pages/ChatPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 1861091..e23c483 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1230,7 +1230,7 @@ Page { readonly property int profileThumbnailDimensions: showUserInfo ? Theme.itemSizeSmall : 0 readonly property int pageMarginDouble: 2 * Theme.horizontalPageMargin readonly property int paddingMediumDouble: 2 * Theme.paddingMedium - readonly property int entryWidth: Functions.isTablet(appWindow) ? chatView.width * 0.75 : chatView.width - pageMarginDouble + readonly property int entryWidth: Functions.isWidescreen(appWindow) ? chatView.width * 0.75 : chatView.width - pageMarginDouble readonly property int textItemWidth: entryWidth - profileThumbnailDimensions - Theme.paddingSmall readonly property int backgroundWidth: page.isPrivateChat ? textItemWidth - pageMarginDouble : textItemWidth //уменьшенная ширина сообщений для приватных чатов readonly property int backgroundRadius: textItemWidth/50 -- 2.43.0 From 3ac98a4e17ca55e7e3b63ae25bb76982f0e124ee Mon Sep 17 00:00:00 2001 From: mbarashkov Date: Sun, 3 Dec 2023 02:46:47 +0300 Subject: [PATCH 73/75] Jump to post from quote (#538) * Jump to post from quote * Add a setting to go to quoted message. --------- Co-authored-by: Mikhail Barashkov --- qml/components/settingsPage/SettingsBehavior.qml | 1 + src/appsettings.h | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index 0faa786..c1d15ab 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -216,6 +216,7 @@ AccordionItem { } } } + TextSwitch { checked: appSettings.notificationSuppressContent && enabled text: qsTr("Hide content in notifications") diff --git a/src/appsettings.h b/src/appsettings.h index 77090aa..acc38b2 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -97,12 +97,9 @@ public: bool notificationAlwaysShowPreview() const; void setNotificationAlwaysShowPreview(bool enable); -<<<<<<< HEAD bool goToQuotedMessage() const; void setGoToQuotedMessage(bool enable); -======= ->>>>>>> b11f7dd (Always append last message content to notifications (#514)) bool storageOptimizer() const; void setStorageOptimizer(bool enable); @@ -142,10 +139,7 @@ signals: void notificationSuppressContentChanged(); void notificationFeedbackChanged(); void notificationAlwaysShowPreviewChanged(); -<<<<<<< HEAD void goToQuotedMessageChanged(); -======= ->>>>>>> b11f7dd (Always append last message content to notifications (#514)) void storageOptimizerChanged(); void allowInlineBotLocationAccessChanged(); void remainingInteractionHintsChanged(); -- 2.43.0 From 053f5eae10ee884d577e37e929203f625f799c37 Mon Sep 17 00:00:00 2001 From: free software <45316884+carlosgonz0@users.noreply.github.com> Date: Sun, 3 Dec 2023 04:48:20 -0500 Subject: [PATCH 74/75] Update harbour-fernschreiber-es.ts (#542) --- translations/harbour-fernschreiber-es.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 5bb9487..0abb207 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -2375,11 +2375,11 @@ sent a game myself - envió juego + envió un juego sent a game - envió juego + envió un juego -- 2.43.0 From 6ec3d2931f1f3918a405c910c69c29f6e559dd16 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 3 Dec 2023 12:59:41 +0100 Subject: [PATCH 75/75] Restore content width in landscape as per discussion in #540 --- qml/pages/ChatPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index e23c483..d20a373 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -1230,7 +1230,7 @@ Page { readonly property int profileThumbnailDimensions: showUserInfo ? Theme.itemSizeSmall : 0 readonly property int pageMarginDouble: 2 * Theme.horizontalPageMargin readonly property int paddingMediumDouble: 2 * Theme.paddingMedium - readonly property int entryWidth: Functions.isWidescreen(appWindow) ? chatView.width * 0.75 : chatView.width - pageMarginDouble + readonly property int entryWidth: chatView.width - pageMarginDouble readonly property int textItemWidth: entryWidth - profileThumbnailDimensions - Theme.paddingSmall readonly property int backgroundWidth: page.isPrivateChat ? textItemWidth - pageMarginDouble : textItemWidth //уменьшенная ширина сообщений для приватных чатов readonly property int backgroundRadius: textItemWidth/50 -- 2.43.0