feat: show channel badge

This commit is contained in:
ZavaruKitsu 2024-02-04 02:56:07 +03:00
parent 964f9bd904
commit 2729fee0ac
7 changed files with 37 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 475 B

View file

@ -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 }};

View file

@ -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);

View file

@ -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<ColorIndicesCompressed> colorIndices) {
st::historyBubbleTailInRightSelected,
st::historyBubbleTailOutRight,
st::historyBubbleTailOutRightSelected);
make(
&MessageStyle::channelBadgeIcon,
st::inChannelBadgeIcon,
st::inChannelBadgeSelectedIcon,
st::outChannelBadgeIcon,
st::outChannelBadgeSelectedIcon);
make(
&MessageStyle::historyRepliesIcon,
st::historyRepliesInIcon,

View file

@ -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 };