Show myself as "My Notes" in Saved Messages sublists.

This commit is contained in:
John Preston 2024-01-01 09:23:57 +04:00
parent fbc600a978
commit bfe7683cdb
15 changed files with 99 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

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

View File

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

View File

@ -266,11 +266,12 @@ void PaintFolderEntryText(
}
enum class Flag {
SavedMessages = 0x08,
RepliesMessages = 0x10,
AllowUserOnline = 0x20,
TopicJumpRipple = 0x40,
HiddenAuthor = 0x80,
SavedMessages = 0x008,
RepliesMessages = 0x010,
AllowUserOnline = 0x020,
TopicJumpRipple = 0x040,
HiddenAuthor = 0x080,
MyNotes = 0x100,
};
inline constexpr bool is_flag_type(Flag) { return true; }
@ -336,6 +337,13 @@ void PaintRow(
context.st->padding.top(),
context.width,
context.st->photoSize);
} else if (flags & Flag::MyNotes) {
EmptyUserpic::PaintMyNotes(
p,
context.st->padding.left(),
context.st->padding.top(),
context.width,
context.st->photoSize);
} else if (!from && hiddenSenderInfo) {
hiddenSenderInfo->emptyUserpic.paintCircle(
p,
@ -619,11 +627,14 @@ void PaintRow(
if (flags
& (Flag::SavedMessages
| Flag::RepliesMessages
| Flag::HiddenAuthor)) {
| Flag::HiddenAuthor
| Flag::MyNotes)) {
auto text = (flags & Flag::SavedMessages)
? tr::lng_saved_messages(tr::now)
: (flags & Flag::RepliesMessages)
? tr::lng_replies_messages(tr::now)
: (flags & Flag::MyNotes)
? tr::lng_my_notes(tr::now)
: tr::lng_hidden_author_messages(tr::now);
const auto textWidth = st::semiboldFont->width(text);
if (textWidth > rectForName.width()) {
@ -792,7 +803,11 @@ void RowPainter::Paint(
: nullptr;
const auto allowUserOnline = true;// !context.narrow || badgesState.empty();
const auto flags = (allowUserOnline ? Flag::AllowUserOnline : Flag(0))
| ((peer && peer->isSelf()) ? Flag::SavedMessages : Flag(0))
| ((sublist && from->isSelf())
? Flag::MyNotes
: (peer && peer->isSelf())
? Flag::SavedMessages
: Flag(0))
| ((from && from->isRepliesChat())
? Flag::RepliesMessages
: Flag(0))

View File

@ -1997,7 +1997,7 @@ bool Message::hasFromPhoto() const {
} else if (const auto forwarded = item->Get<HistoryMessageForwarded>()) {
const auto peer = item->history()->peer;
if (peer->isSelf() || peer->isRepliesChat()) {
return true;
return !hasOutLayout();
}
}
return !item->out() && !item->history()->peer->isUser();

View File

@ -167,6 +167,22 @@ void PaintHiddenAuthorInner(
fg);
}
void PaintMyNotesInner(
QPainter &p,
int x,
int y,
int size,
const style::color &fg) {
PaintIconInner(
p,
x,
y,
size,
st::defaultDialogRow.photoSize,
st::dialogsMyNotesUserpic,
fg);
}
void PaintExternalMessagesInner(
QPainter &p,
int x,
@ -421,8 +437,8 @@ void EmptyUserpic::PaintHiddenAuthor(
int size) {
auto bg = QLinearGradient(x, y, x, y + size);
bg.setStops({
{ 0., st::historyPeerSavedMessagesBg->c },
{ 1., st::historyPeerSavedMessagesBg2->c }
{ 0., st::premiumButtonBg2->c },
{ 1., st::premiumButtonBg3->c },
});
const auto &fg = st::historyPeerUserpicFg;
PaintHiddenAuthor(p, x, y, outerWidth, size, QBrush(bg), fg);
@ -452,6 +468,45 @@ QImage EmptyUserpic::GenerateHiddenAuthor(int size) {
});
}
void EmptyUserpic::PaintMyNotes(
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;
PaintMyNotes(p, x, y, outerWidth, size, QBrush(bg), fg);
}
void EmptyUserpic::PaintMyNotes(
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);
PaintMyNotesInner(p, x, y, size, fg);
}
QImage EmptyUserpic::GenerateMyNotes(int size) {
return Generate(size, [&](QPainter &p) {
PaintMyNotes(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

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