Support all userpic types in Switch.

This commit is contained in:
John Preston
2025-08-25 13:38:51 +04:00
parent edc70e9acb
commit 6dcd52deb5
3 changed files with 35 additions and 0 deletions
@@ -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(
@@ -96,6 +96,7 @@ public:
bool enabled,
Fn<void(ChosenImage)> 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<PhotoData*> photo);
void clearStreaming();
@@ -184,6 +187,7 @@ private:
base::unique_qptr<PopupMenu> _menu;
bool _showSavedMessagesOnSelf = false;
bool _showMyNotesOnSelf = false;
bool _canOpenPhoto = false;
bool _cursorInChangeOverlay = false;
bool _changeOverlayEnabled = false;
@@ -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)