Added icon for forwarded messages in dialogs list.
This commit is contained in:
parent
4b503ad7ed
commit
089432be5e
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;
|
dialogsMiniPreviewRight: 3px;
|
||||||
dialogsMiniPlay: icon{{ "dialogs/dialogs_mini_play", videoPlayIconFg }};
|
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 }};
|
dialogsUnreadMention: icon{{ "dialogs/dialogs_mention", dialogsUnreadFg }};
|
||||||
dialogsUnreadMentionOver: icon{{ "dialogs/dialogs_mention", dialogsUnreadFgOver }};
|
dialogsUnreadMentionOver: icon{{ "dialogs/dialogs_mention", dialogsUnreadFgOver }};
|
||||||
dialogsUnreadMentionActive: icon{{ "dialogs/dialogs_mention", dialogsUnreadFgActive }};
|
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/effects/spoiler_mess.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/image/image.h"
|
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/power_saving.h"
|
#include "ui/power_saving.h"
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
|
@ -159,6 +158,7 @@ void MessageView::prepare(
|
||||||
options.ignoreTopic = true;
|
options.ignoreTopic = true;
|
||||||
options.spoilerLoginCode = true;
|
options.spoilerLoginCode = true;
|
||||||
auto preview = item->toPreview(options);
|
auto preview = item->toPreview(options);
|
||||||
|
_displayMiniForwardIcon = preview.forwardedMessage;
|
||||||
const auto hasImages = !preview.images.empty();
|
const auto hasImages = !preview.images.empty();
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
const auto context = Core::MarkedTextContext{
|
const auto context = Core::MarkedTextContext{
|
||||||
|
@ -169,7 +169,7 @@ void MessageView::prepare(
|
||||||
const auto senderTill = (preview.arrowInTextPosition > 0)
|
const auto senderTill = (preview.arrowInTextPosition > 0)
|
||||||
? preview.arrowInTextPosition
|
? preview.arrowInTextPosition
|
||||||
: preview.imagesInTextPosition;
|
: preview.imagesInTextPosition;
|
||||||
if (hasImages && senderTill > 0) {
|
if ((hasImages || _displayMiniForwardIcon) && senderTill > 0) {
|
||||||
auto sender = Text::Mid(preview.text, 0, senderTill);
|
auto sender = Text::Mid(preview.text, 0, senderTill);
|
||||||
TextUtilities::Trim(sender);
|
TextUtilities::Trim(sender);
|
||||||
_senderCache.setMarkedText(
|
_senderCache.setMarkedText(
|
||||||
|
@ -314,6 +314,18 @@ void MessageView::paint(
|
||||||
rect.setLeft(rect.x() + skip);
|
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) {
|
for (const auto &image : _imagesCache) {
|
||||||
if (rect.width() < st::dialogsMiniPreview) {
|
if (rect.width() < st::dialogsMiniPreview) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -92,6 +92,7 @@ private:
|
||||||
mutable std::vector<ItemPreviewImage> _imagesCache;
|
mutable std::vector<ItemPreviewImage> _imagesCache;
|
||||||
mutable std::unique_ptr<SpoilerAnimation> _spoiler;
|
mutable std::unique_ptr<SpoilerAnimation> _spoiler;
|
||||||
mutable std::unique_ptr<LoadingContext> _loadingContext;
|
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)
|
? tr::lng_from_you(tr::now)
|
||||||
: sender->shortName();
|
: sender->shortName();
|
||||||
};
|
};
|
||||||
|
if (!options.ignoreForwardedMessage) {
|
||||||
|
result.forwardedMessage = Get<HistoryMessageForwarded>() != nullptr;
|
||||||
|
}
|
||||||
const auto fromForwarded = [&]() -> std::optional<QString> {
|
const auto fromForwarded = [&]() -> std::optional<QString> {
|
||||||
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||||
return forwarded->originalSender
|
return forwarded->originalSender
|
||||||
|
|
|
@ -28,6 +28,7 @@ struct ItemPreview {
|
||||||
int arrowInTextPosition = -1;
|
int arrowInTextPosition = -1;
|
||||||
int imagesInTextPosition = 0;
|
int imagesInTextPosition = 0;
|
||||||
std::any loadingContext;
|
std::any loadingContext;
|
||||||
|
bool forwardedMessage = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ToPreviewOptions {
|
struct ToPreviewOptions {
|
||||||
|
@ -37,6 +38,7 @@ struct ToPreviewOptions {
|
||||||
bool generateImages = true;
|
bool generateImages = true;
|
||||||
bool ignoreGroup = false;
|
bool ignoreGroup = false;
|
||||||
bool ignoreTopic = true;
|
bool ignoreTopic = true;
|
||||||
|
bool ignoreForwardedMessage = false;
|
||||||
bool spoilerLoginCode = false;
|
bool spoilerLoginCode = false;
|
||||||
bool translated = false;
|
bool translated = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,7 +66,15 @@ constexpr auto kSystemAlertDuration = crl::time(0);
|
||||||
return result;
|
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;
|
auto text = textWithEntities.text;
|
||||||
for (const auto &e : textWithEntities.entities) {
|
for (const auto &e : textWithEntities.entities) {
|
||||||
if (e.type() == EntityType::Spoiler) {
|
if (e.type() == EntityType::Spoiler) {
|
||||||
|
@ -1175,9 +1183,11 @@ void NativeManager::doShowNotification(NotificationFields &&fields) {
|
||||||
? tr::lng_forward_messages(tr::now, lt_count, fields.forwardedCount)
|
? tr::lng_forward_messages(tr::now, lt_count, fields.forwardedCount)
|
||||||
: item->groupId()
|
: item->groupId()
|
||||||
? tr::lng_in_dlg_album(tr::now)
|
? tr::lng_in_dlg_album(tr::now)
|
||||||
: TextWithPermanentSpoiler(item->notificationText({
|
: TextWithForwardedChar(
|
||||||
.spoilerLoginCode = options.spoilerLoginCode,
|
TextWithPermanentSpoiler(item->notificationText({
|
||||||
}));
|
.spoilerLoginCode = options.spoilerLoginCode,
|
||||||
|
})),
|
||||||
|
(fields.forwardedCount == 1));
|
||||||
|
|
||||||
// #TODO optimize
|
// #TODO optimize
|
||||||
auto userpicView = item->history()->peer->createUserpicView();
|
auto userpicView = item->history()->peer->createUserpicView();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user