Show special name/userpic for "Author Hidden".

This commit is contained in:
John Preston 2023-12-28 17:13:30 +00:00
parent 4e6d8f06d9
commit 452257dcd5
8 changed files with 100 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -2525,6 +2525,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_comments_open_none" = "Leave a comment";
"lng_replies_view_original" = "View in chat";
"lng_replies_messages" = "Replies";
"lng_hidden_author_messages" = "Author Hidden";
"lng_replies_discussion_started" = "Discussion started";
"lng_replies_no_comments" = "No comments here yet...";

View File

@ -347,6 +347,7 @@ dialogsForumIcon: ThreeStateIcon {
dialogsArchiveUserpic: icon {{ "archive_userpic", historyPeerUserpicFg }};
dialogsRepliesUserpic: icon {{ "replies_userpic", historyPeerUserpicFg }};
dialogsInaccessibleUserpic: icon {{ "dialogs/inaccessible_userpic", historyPeerUserpicFg }};
dialogsHiddenAuthorUserpic: icon {{ "hidden_author_userpic", historyPeerUserpicFg }};
dialogsSendStateSkip: 20px;
dialogsSendingIcon: ThreeStateIcon {

View File

@ -270,6 +270,7 @@ enum class Flag {
RepliesMessages = 0x10,
AllowUserOnline = 0x20,
TopicJumpRipple = 0x40,
HiddenAuthor = 0x80,
};
inline constexpr bool is_flag_type(Flag) { return true; }
@ -312,6 +313,7 @@ void PaintRow(
const auto history = entry->asHistory();
const auto thread = entry->asThread();
const auto sublist = entry->asSublist();
if (flags & Flag::SavedMessages) {
EmptyUserpic::PaintSavedMessages(
@ -327,6 +329,13 @@ void PaintRow(
context.st->padding.top(),
context.width,
context.st->photoSize);
} else if (flags & Flag::HiddenAuthor) {
EmptyUserpic::PaintHiddenAuthor(
p,
context.st->padding.left(),
context.st->padding.top(),
context.width,
context.st->photoSize);
} else if (!from && hiddenSenderInfo) {
hiddenSenderInfo->emptyUserpic.paintCircle(
p,
@ -548,7 +557,7 @@ void PaintRow(
// Empty history
}
} else if (!item->isEmpty()) {
if (thread && !promoted) {
if ((thread || sublist) && !promoted) {
PaintRowDate(p, date, rectForName, context);
}
@ -607,10 +616,15 @@ void PaintRow(
}
p.setFont(st::semiboldFont);
if (flags & (Flag::SavedMessages | Flag::RepliesMessages)) {
if (flags
& (Flag::SavedMessages
| Flag::RepliesMessages
| Flag::HiddenAuthor)) {
auto text = (flags & Flag::SavedMessages)
? tr::lng_saved_messages(tr::now)
: tr::lng_replies_messages(tr::now);
: (flags & Flag::RepliesMessages)
? tr::lng_replies_messages(tr::now)
: tr::lng_hidden_author_messages(tr::now);
const auto textWidth = st::semiboldFont->width(text);
if (textWidth > rectForName.width()) {
text = st::semiboldFont->elided(text, rectForName.width());
@ -622,7 +636,7 @@ void PaintRow(
: st::dialogsNameFg);
p.drawTextLeft(rectForName.left(), rectForName.top(), context.width, text);
} else if (from) {
if (history && !context.search) {
if ((history || sublist) && !context.search) {
const auto badgeWidth = fromBadge.drawGetWidth(
p,
rectForName,
@ -773,11 +787,18 @@ void RowPainter::Paint(
? (history->peer->migrateTo()
? history->peer->migrateTo()
: history->peer.get())
: sublist
? sublist->peer().get()
: nullptr;
const auto allowUserOnline = true;// !context.narrow || badgesState.empty();
const auto flags = (allowUserOnline ? Flag::AllowUserOnline : Flag(0))
| (peer && peer->isSelf() ? Flag::SavedMessages : Flag(0))
| (peer && peer->isRepliesChat() ? Flag::RepliesMessages : Flag(0))
| ((peer && peer->isSelf()) ? Flag::SavedMessages : Flag(0))
| ((from && from->isRepliesChat())
? Flag::RepliesMessages
: Flag(0))
| ((sublist && from->isSavedHiddenAuthor())
? Flag::HiddenAuthor
: Flag(0))
| (row->topicJumpRipple() ? Flag::TopicJumpRipple : Flag(0));
const auto paintItemCallback = [&](int nameleft, int namewidth) {
const auto texttop = context.st->textTop;

View File

@ -151,6 +151,22 @@ void PaintRepliesMessagesInner(
fg);
}
void PaintHiddenAuthorInner(
QPainter &p,
int x,
int y,
int size,
const style::color &fg) {
PaintIconInner(
p,
x,
y,
size,
st::defaultDialogRow.photoSize,
st::dialogsHiddenAuthorUserpic,
fg);
}
void PaintExternalMessagesInner(
QPainter &p,
int x,
@ -397,6 +413,45 @@ QImage EmptyUserpic::GenerateRepliesMessages(int size) {
});
}
void EmptyUserpic::PaintHiddenAuthor(
QPainter &p,
int x,
int y,
int outerWidth,
int size) {
auto bg = QLinearGradient(x, y, x, y + size);
bg.setStops({
{ 0., st::historyPeerSavedMessagesBg->c },
{ 1., st::historyPeerSavedMessagesBg2->c }
});
const auto &fg = st::historyPeerUserpicFg;
PaintHiddenAuthor(p, x, y, outerWidth, size, QBrush(bg), fg);
}
void EmptyUserpic::PaintHiddenAuthor(
QPainter &p,
int x,
int y,
int outerWidth,
int size,
QBrush bg,
const style::color &fg) {
x = style::RightToLeft() ? (outerWidth - x - size) : x;
PainterHighQualityEnabler hq(p);
p.setBrush(bg);
p.setPen(Qt::NoPen);
p.drawEllipse(x, y, size, size);
PaintHiddenAuthorInner(p, x, y, size, fg);
}
QImage EmptyUserpic::GenerateHiddenAuthor(int size) {
return Generate(size, [&](QPainter &p) {
PaintHiddenAuthor(p, 0, 0, size, size);
});
}
std::pair<uint64, uint64> EmptyUserpic::uniqueKey() const {
const auto first = (uint64(0xFFFFFFFFU) << 32)
| anim::getPremultiplied(_colors.color1->c);

View File

@ -81,6 +81,22 @@ public:
const style::color &fg);
[[nodiscard]] static QImage GenerateRepliesMessages(int size);
static void PaintHiddenAuthor(
QPainter &p,
int x,
int y,
int outerWidth,
int size);
static void PaintHiddenAuthor(
QPainter &p,
int x,
int y,
int outerWidth,
int size,
QBrush bg,
const style::color &fg);
[[nodiscard]] static QImage GenerateHiddenAuthor(int size);
~EmptyUserpic();
private: