From 2729fee0ac286f7851bcce8450b4c9181bcbb83e Mon Sep 17 00:00:00 2001 From: ZavaruKitsu Date: Sun, 4 Feb 2024 02:56:07 +0300 Subject: [PATCH] feat: show channel badge --- Telegram/Resources/icons/ayu/channel.png | Bin 0 -> 283 bytes Telegram/Resources/icons/ayu/channel@2x.png | Bin 0 -> 407 bytes Telegram/Resources/icons/ayu/channel@3x.png | Bin 0 -> 475 bytes Telegram/SourceFiles/ayu/ui/ayu_icons.style | 5 ++++ .../history/view/history_view_message.cpp | 27 +++++++++++++----- Telegram/SourceFiles/ui/chat/chat_style.cpp | 9 ++++++ Telegram/SourceFiles/ui/chat/chat_style.h | 3 ++ 7 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 Telegram/Resources/icons/ayu/channel.png create mode 100644 Telegram/Resources/icons/ayu/channel@2x.png create mode 100644 Telegram/Resources/icons/ayu/channel@3x.png diff --git a/Telegram/Resources/icons/ayu/channel.png b/Telegram/Resources/icons/ayu/channel.png new file mode 100644 index 0000000000000000000000000000000000000000..00c56934e625953a56f450205275266518f95cfd GIT binary patch literal 283 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k&H|6fVg?3oVGw3ym^DWND9BhG z?#5~V|e@yB~QOQ_huub!vXG^s;<7r49{gg+dQ|hkv$fnVR7EL zXQj7hYii^xm-n_DiZ{N?PPx>UduJQ(%Rfo8mZf>zUHIaa>-9^$Dw?X-O3!|AowZf$ zoMpz^|7M}?J%%@XGZN3nUJw0zvE_n^i~A?nlC>MnHcfwIaBpRcz|X=-ORR%pikRc- adiB>8WVDGr3)KO-ox#)9&t;ucLK6VQ`e=Iq literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/ayu/channel@2x.png b/Telegram/Resources/icons/ayu/channel@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b104817e0e988520377f2f8fc3069c0dc2ec3669 GIT binary patch literal 407 zcmV;I0cie-P)6o+Sgy$_jq^l>e3$y zL&I?#FMok*y`+i`@+r^rcr5$Ahr65#JjJ+G`~m2OX)dJ)UIPFC002ovPDHLkV1g&6 Bt4sg@ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/ayu/channel@3x.png b/Telegram/Resources/icons/ayu/channel@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..756b3d38e5bd77da1d30cb294828ba9423b31a52 GIT binary patch literal 475 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbBI14-?iy0WWg+Z8+Vb&Z8pde#$ zkh>GZx^prwfgF}}M_)$E)e-c@Nas{3)jv*C{Z>PQQb#o9n_Iz&)qm=_|i37XW z0%j0HK`Ves_5!1Zr0eDGFNl<2=1`FRh}Vz-)uXDe7fRlYzisznY>G*>w`|t^E0c0r!776__gY18~*=H zoE73*w$658@%_Khfaf8fPt&~Y8IrR@tVSz@>AWM8g2!4o0y)j4IuiHmPHZkWG1!T8hWCXE+M zs}0U8r(CJH9PcGC^Rw*>S0&57Ra-vDlqNZR+levOsL`uokdKiuG#vtQ?GoKe0a`Zh2w O7(8A5T-G@yGywnv7{lxU literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/ayu/ui/ayu_icons.style b/Telegram/SourceFiles/ayu/ui/ayu_icons.style index 59199295b..1d82087e1 100644 --- a/Telegram/SourceFiles/ayu/ui/ayu_icons.style +++ b/Telegram/SourceFiles/ayu/ui/ayu_icons.style @@ -17,4 +17,9 @@ ayuLReadMenuIcon: icon {{ "ayu/lread", menuIconColor }}; ayuSReadMenuIcon: icon {{ "ayu/sread", menuIconColor }}; ayuStreamerModeMenuIcon: icon {{ "ayu/streamer", menuIconColor }}; +inChannelBadgeIcon: icon {{ "ayu/channel", msgInDateFg }}; +inChannelBadgeSelectedIcon: icon {{ "ayu/channel", msgInDateFgSelected }}; +outChannelBadgeIcon: icon {{ "ayu/channel", msgOutDateFg }}; +outChannelBadgeSelectedIcon: icon {{ "ayu/channel", msgOutDateFgSelected }}; + infoExteraBadge: icon {{ "ayu/exterabadge", profileVerifiedCheckBg }}; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 5ee5599b0..8012e7822 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -46,6 +46,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL // AyuGram includes #include "ayu/features/messageshot/message_shot.h" +#include "styles/style_ayu_icons.h" namespace HistoryView { @@ -468,6 +469,8 @@ void Message::refreshRightBadge() { Assert(msgsigned->isAnonymousRank); return msgsigned->postAuthor; } + } else if (data()->history()->peer->isMegagroup() && data()->author()->isChannel() && !data()->out()) { + return tr::lng_channel_badge(tr::now); } const auto channel = data()->history()->peer->asMegagroup(); const auto user = data()->author()->asUser(); @@ -773,7 +776,8 @@ QSize Message::performCountOptimalSize() { ? st::msgFont->width(FastReplyText()) : 0; if (!_rightBadge.isEmpty()) { - const auto badgeWidth = _rightBadge.maxWidth(); + const auto badgeWidth = + _rightBadge.toString() == tr::lng_channel_badge(tr::now) ? st::inChannelBadgeIcon.width() : _rightBadge.maxWidth(); namew += st::msgPadding.right() + std::max(badgeWidth, replyWidth); } else if (replyWidth) { @@ -1399,7 +1403,8 @@ void Message::paintFromName( if (!displayFromName()) { return; } - const auto badgeWidth = _rightBadge.isEmpty() ? 0 : _rightBadge.maxWidth(); + const auto badgeWidth = _rightBadge.isEmpty() ? 0 : + _rightBadge.toString() == tr::lng_channel_badge(tr::now) ? context.messageStyle()->channelBadgeIcon.width() : _rightBadge.maxWidth(); const auto replyWidth = [&] { if (isUnderCursor() && displayFastReply()) { return st::msgFont->width(FastReplyText()); @@ -1499,11 +1504,19 @@ void Message::paintFromName( trect.top() + st::msgFont->ascent, FastReplyText()); } else { - _rightBadge.draw( - p, - trect.left() + trect.width() - rightWidth, - trect.top(), - rightWidth); + if (_rightBadge.toString() == tr::lng_channel_badge(tr::now)) { + stm->channelBadgeIcon.paint( + p, + trect.left() + trect.width() - rightWidth, + trect.top() + (_rightBadge.minHeight() - stm->channelBadgeIcon.height()) / 2, + rightWidth); + } else { + _rightBadge.draw( + p, + trect.left() + trect.width() - rightWidth, + trect.top(), + rightWidth); + } } } trect.setY(trect.y() + st::msgNameFont->height); diff --git a/Telegram/SourceFiles/ui/chat/chat_style.cpp b/Telegram/SourceFiles/ui/chat/chat_style.cpp index 777818484..2aead249a 100644 --- a/Telegram/SourceFiles/ui/chat/chat_style.cpp +++ b/Telegram/SourceFiles/ui/chat/chat_style.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL // AyuGram includes #include "ayu/ayu_settings.h" +#include "styles/style_ayu_icons.h" namespace Ui { @@ -322,6 +323,14 @@ ChatStyle::ChatStyle(rpl::producer colorIndices) { st::historyBubbleTailInRightSelected, st::historyBubbleTailOutRight, st::historyBubbleTailOutRightSelected); + + make( + &MessageStyle::channelBadgeIcon, + st::inChannelBadgeIcon, + st::inChannelBadgeSelectedIcon, + st::outChannelBadgeIcon, + st::outChannelBadgeSelectedIcon); + make( &MessageStyle::historyRepliesIcon, st::historyRepliesInIcon, diff --git a/Telegram/SourceFiles/ui/chat/chat_style.h b/Telegram/SourceFiles/ui/chat/chat_style.h index dca47f0f8..96cbcd8b8 100644 --- a/Telegram/SourceFiles/ui/chat/chat_style.h +++ b/Telegram/SourceFiles/ui/chat/chat_style.h @@ -61,6 +61,9 @@ struct MessageStyle { style::TextPalette semiboldPalette; style::TextPalette fwdTextPalette; style::TextPalette replyTextPalette; + + style::icon channelBadgeIcon = { Qt::Uninitialized }; + style::icon tailLeft = { Qt::Uninitialized }; style::icon tailRight = { Qt::Uninitialized }; style::icon historyRepliesIcon = { Qt::Uninitialized };