mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 22:27:20 +02:00
Added icon for forwarded messages in dialogs list.
This commit is contained in:
parent
4b503ad7ed
commit
089432be5e
9 changed files with 39 additions and 6 deletions
BIN
Telegram/Resources/icons/mini_forward.png
Normal file
BIN
Telegram/Resources/icons/mini_forward.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 337 B |
BIN
Telegram/Resources/icons/mini_forward@2x.png
Normal file
BIN
Telegram/Resources/icons/mini_forward@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 527 B |
BIN
Telegram/Resources/icons/mini_forward@3x.png
Normal file
BIN
Telegram/Resources/icons/mini_forward@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 772 B |
|
@ -436,6 +436,11 @@ dialogsMiniPreviewSkip: 2px;
|
|||
dialogsMiniPreviewRight: 3px;
|
||||
dialogsMiniPlay: icon{{ "dialogs/dialogs_mini_play", videoPlayIconFg }};
|
||||
|
||||
dialogsMiniForwardIcon: icon {{ "mini_forward", dialogsTextFg, point(0px, 1px) }};
|
||||
dialogsMiniForwardIconOver: icon {{ "mini_forward", dialogsTextFgOver, point(0px, 1px) }};
|
||||
dialogsMiniForwardIconActive: icon {{ "mini_forward", dialogsTextFgActive, point(0px, 1px) }};
|
||||
dialogsMiniForwardIconSkip: 2px;
|
||||
|
||||
dialogsUnreadMention: icon{{ "dialogs/dialogs_mention", dialogsUnreadFg }};
|
||||
dialogsUnreadMentionOver: icon{{ "dialogs/dialogs_mention", dialogsUnreadFgOver }};
|
||||
dialogsUnreadMentionActive: icon{{ "dialogs/dialogs_mention", dialogsUnreadFgActive }};
|
||||
|
|
|
@ -16,7 +16,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/effects/spoiler_mess.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/power_saving.h"
|
||||
#include "core/ui_integration.h"
|
||||
|
@ -159,6 +158,7 @@ void MessageView::prepare(
|
|||
options.ignoreTopic = true;
|
||||
options.spoilerLoginCode = true;
|
||||
auto preview = item->toPreview(options);
|
||||
_displayMiniForwardIcon = preview.forwardedMessage;
|
||||
const auto hasImages = !preview.images.empty();
|
||||
const auto history = item->history();
|
||||
const auto context = Core::MarkedTextContext{
|
||||
|
@ -169,7 +169,7 @@ void MessageView::prepare(
|
|||
const auto senderTill = (preview.arrowInTextPosition > 0)
|
||||
? preview.arrowInTextPosition
|
||||
: preview.imagesInTextPosition;
|
||||
if (hasImages && senderTill > 0) {
|
||||
if ((hasImages || _displayMiniForwardIcon) && senderTill > 0) {
|
||||
auto sender = Text::Mid(preview.text, 0, senderTill);
|
||||
TextUtilities::Trim(sender);
|
||||
_senderCache.setMarkedText(
|
||||
|
@ -314,6 +314,18 @@ void MessageView::paint(
|
|||
rect.setLeft(rect.x() + skip);
|
||||
}
|
||||
}
|
||||
|
||||
if (_displayMiniForwardIcon) {
|
||||
const auto &icon = context.active
|
||||
? st::dialogsMiniForwardIconActive
|
||||
: context.selected
|
||||
? st::dialogsMiniForwardIconOver
|
||||
: st::dialogsMiniForwardIcon;
|
||||
icon.paint(p, rect.topLeft(), rect.width());
|
||||
rect.setLeft(rect.x()
|
||||
+ icon.width()
|
||||
+ st::dialogsMiniForwardIconSkip);
|
||||
}
|
||||
for (const auto &image : _imagesCache) {
|
||||
if (rect.width() < st::dialogsMiniPreview) {
|
||||
break;
|
||||
|
|
|
@ -92,6 +92,7 @@ private:
|
|||
mutable std::vector<ItemPreviewImage> _imagesCache;
|
||||
mutable std::unique_ptr<SpoilerAnimation> _spoiler;
|
||||
mutable std::unique_ptr<LoadingContext> _loadingContext;
|
||||
mutable bool _displayMiniForwardIcon = false;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -2958,6 +2958,9 @@ ItemPreview HistoryItem::toPreview(ToPreviewOptions options) const {
|
|||
? tr::lng_from_you(tr::now)
|
||||
: sender->shortName();
|
||||
};
|
||||
if (!options.ignoreForwardedMessage) {
|
||||
result.forwardedMessage = Get<HistoryMessageForwarded>() != nullptr;
|
||||
}
|
||||
const auto fromForwarded = [&]() -> std::optional<QString> {
|
||||
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||
return forwarded->originalSender
|
||||
|
|
|
@ -28,6 +28,7 @@ struct ItemPreview {
|
|||
int arrowInTextPosition = -1;
|
||||
int imagesInTextPosition = 0;
|
||||
std::any loadingContext;
|
||||
bool forwardedMessage = false;
|
||||
};
|
||||
|
||||
struct ToPreviewOptions {
|
||||
|
@ -37,6 +38,7 @@ struct ToPreviewOptions {
|
|||
bool generateImages = true;
|
||||
bool ignoreGroup = false;
|
||||
bool ignoreTopic = true;
|
||||
bool ignoreForwardedMessage = false;
|
||||
bool spoilerLoginCode = false;
|
||||
bool translated = false;
|
||||
};
|
||||
|
|
|
@ -66,7 +66,15 @@ constexpr auto kSystemAlertDuration = crl::time(0);
|
|||
return result;
|
||||
}
|
||||
|
||||
QString TextWithPermanentSpoiler(const TextWithEntities &textWithEntities) {
|
||||
[[nodiscard]] QString TextWithForwardedChar(
|
||||
const QString &text,
|
||||
bool forwarded) {
|
||||
static const auto result = QString::fromUtf8("\xE2\x9E\xA1\xEF\xB8\x8F");
|
||||
return forwarded ? result + text : text;
|
||||
}
|
||||
|
||||
[[nodiscard]] QString TextWithPermanentSpoiler(
|
||||
const TextWithEntities &textWithEntities) {
|
||||
auto text = textWithEntities.text;
|
||||
for (const auto &e : textWithEntities.entities) {
|
||||
if (e.type() == EntityType::Spoiler) {
|
||||
|
@ -1175,9 +1183,11 @@ void NativeManager::doShowNotification(NotificationFields &&fields) {
|
|||
? tr::lng_forward_messages(tr::now, lt_count, fields.forwardedCount)
|
||||
: item->groupId()
|
||||
? tr::lng_in_dlg_album(tr::now)
|
||||
: TextWithPermanentSpoiler(item->notificationText({
|
||||
.spoilerLoginCode = options.spoilerLoginCode,
|
||||
}));
|
||||
: TextWithForwardedChar(
|
||||
TextWithPermanentSpoiler(item->notificationText({
|
||||
.spoilerLoginCode = options.spoilerLoginCode,
|
||||
})),
|
||||
(fields.forwardedCount == 1));
|
||||
|
||||
// #TODO optimize
|
||||
auto userpicView = item->history()->peer->createUserpicView();
|
||||
|
|
Loading…
Add table
Reference in a new issue