From 6dcd52deb563f4873fc323aa79ba5ce0c86c5eaf Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 25 Aug 2025 13:38:51 +0400 Subject: [PATCH] Support all userpic types in Switch. --- .../ui/controls/userpic_button.cpp | 29 +++++++++++++++++++ .../SourceFiles/ui/controls/userpic_button.h | 4 +++ .../window/window_chat_switch_process.cpp | 2 ++ 3 files changed, 35 insertions(+) diff --git a/Telegram/SourceFiles/ui/controls/userpic_button.cpp b/Telegram/SourceFiles/ui/controls/userpic_button.cpp index ffd74c3efe..ad0402e41f 100644 --- a/Telegram/SourceFiles/ui/controls/userpic_button.cpp +++ b/Telegram/SourceFiles/ui/controls/userpic_button.cpp @@ -561,6 +561,20 @@ void UserpicButton::paintEvent(QPaintEvent *e) { photoPosition.y(), width(), _st.photoSize); + } else if (showMyNotes()) { + Ui::EmptyUserpic::PaintMyNotes( + p, + photoPosition.x(), + photoPosition.y(), + width(), + _st.photoSize); + } else if (showAuthorHidden()) { + Ui::EmptyUserpic::PaintHiddenAuthor( + p, + photoPosition.x(), + photoPosition.y(), + width(), + _st.photoSize); } else { if (_a_appearance.animating()) { p.drawPixmapLeft(photoPosition, width(), _oldUserpic); @@ -976,6 +990,13 @@ void UserpicButton::showSavedMessagesOnSelf(bool enabled) { } } +void UserpicButton::showMyNotesOnSelf(bool enabled) { + if (_showMyNotesOnSelf != enabled) { + _showMyNotesOnSelf = enabled; + update(); + } +} + bool UserpicButton::showSavedMessages() const { return _showSavedMessagesOnSelf && _peer && _peer->isSelf(); } @@ -984,6 +1005,14 @@ bool UserpicButton::showRepliesMessages() const { return _showSavedMessagesOnSelf && _peer && _peer->isRepliesChat(); } +bool UserpicButton::showMyNotes() const { + return _showMyNotesOnSelf && _peer && _peer->isSelf(); +} + +bool UserpicButton::showAuthorHidden() const { + return _showMyNotesOnSelf && _peer && _peer->isSavedHiddenAuthor(); +} + void UserpicButton::startChangeOverlayAnimation() { auto over = isOver() || isDown(); _changeOverlayShown.start( diff --git a/Telegram/SourceFiles/ui/controls/userpic_button.h b/Telegram/SourceFiles/ui/controls/userpic_button.h index f126fac07a..6703a3977f 100644 --- a/Telegram/SourceFiles/ui/controls/userpic_button.h +++ b/Telegram/SourceFiles/ui/controls/userpic_button.h @@ -96,6 +96,7 @@ public: bool enabled, Fn chosen); void showSavedMessagesOnSelf(bool enabled); + void showMyNotesOnSelf(bool enabled); void overrideShape(PeerUserpicShape shape); // Role::ChoosePhoto or Role::ChangePhoto @@ -140,6 +141,8 @@ private: void updateVideo(); [[nodiscard]] bool showSavedMessages() const; [[nodiscard]] bool showRepliesMessages() const; + [[nodiscard]] bool showMyNotes() const; + [[nodiscard]] bool showAuthorHidden() const; void checkStreamedIsStarted(); bool createStreamingObjects(not_null photo); void clearStreaming(); @@ -184,6 +187,7 @@ private: base::unique_qptr _menu; bool _showSavedMessagesOnSelf = false; + bool _showMyNotesOnSelf = false; bool _canOpenPhoto = false; bool _cursorInChangeOverlay = false; bool _changeOverlayEnabled = false; diff --git a/Telegram/SourceFiles/window/window_chat_switch_process.cpp b/Telegram/SourceFiles/window/window_chat_switch_process.cpp index a66b31c6b3..c856a98ac7 100644 --- a/Telegram/SourceFiles/window/window_chat_switch_process.cpp +++ b/Telegram/SourceFiles/window/window_chat_switch_process.cpp @@ -88,6 +88,7 @@ void Button::setup( this, sublistPeer, st::chatSwitchUserpicSublist); + userpic->showMyNotesOnSelf(true); userpic->show(); userpic->move( ((width() - userpicSize.width()) / 2), @@ -102,6 +103,7 @@ void Button::setup( this, peer, *userpicSt); + userpic->showSavedMessagesOnSelf(true); userpic->show(); userpic->move( (((width() - userpicSize.width()) / 2)