Skip to content

Commit

Permalink
Show myself as "My Notes" in Saved Messages sublists.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jan 1, 2024
1 parent fbc600a commit bfe7683
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 11 deletions.
Binary file added Telegram/Resources/icons/dialogs/avatar_hidden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Telegram/Resources/icons/dialogs/avatar_notes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Telegram/Resources/icons/hidden_author_userpic.png
Binary file not shown.
Binary file removed Telegram/Resources/icons/[email protected]
Binary file not shown.
Binary file removed Telegram/Resources/icons/[email protected]
Binary file not shown.
1 change: 1 addition & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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...";

Expand Down
3 changes: 2 additions & 1 deletion Telegram/SourceFiles/dialogs/dialogs.style
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
29 changes: 22 additions & 7 deletions Telegram/SourceFiles/dialogs/ui/dialogs_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/history/view/history_view_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
59 changes: 57 additions & 2 deletions Telegram/SourceFiles/ui/empty_userpic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions Telegram/SourceFiles/ui/empty_userpic.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ class EmptyUserpic final : public base::has_weak_ptr {
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:
Expand Down

0 comments on commit bfe7683

Please sign in to comment.