diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 85149cb42..cb98565ea 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1143,6 +1143,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_profile_shared_links#other" = "{count} shared links"; "lng_profile_copy_phone" = "Copy Phone Number"; "lng_profile_copy_fullname" = "Copy Name"; +"lng_profile_photo_by_you" = "photo set by you"; "lng_via_link_group_one" = "**{user}** restricts adding them to groups.\nYou can send them an invite link as message instead."; "lng_via_link_group_many#one" = "**{count} user** restricts adding them to groups.\nYou can send them an invite link as message instead."; diff --git a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp index 1bf236db1..5d8e93901 100644 --- a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.cpp @@ -105,6 +105,7 @@ PeerShortInfoCover::PeerShortInfoCover( userpic ) | rpl::start_with_next([=](PeerShortInfoUserpic &&value) { applyUserpic(std::move(value)); + applyAdditionalStatus(value.additionalStatus); }, lifetime()); style::PaletteChanged( @@ -136,16 +137,7 @@ PeerShortInfoCover::PeerShortInfoCover( return base::EventFilterResult::Cancel; }); - _name->moveToLeft( - _st.namePosition.x(), - _st.size - _st.namePosition.y() - _name->height(), - _st.size); - _status->moveToLeft( - _st.statusPosition.x(), - (_st.size - - _st.statusPosition.y() - - _status->height()), - _st.size); + refreshLabelsGeometry(); _roundedTopImage = QImage( QSize(_st.size, _st.radius) * style::DevicePixelRatio(), @@ -415,6 +407,23 @@ QImage PeerShortInfoCover::currentVideoFrame() const { : QImage(); } +void PeerShortInfoCover::applyAdditionalStatus(const QString &status) { + if (status.isEmpty()) { + if (_additionalStatus) { + _additionalStatus.destroy(); + refreshLabelsGeometry(); + } + return; + } + if (_additionalStatus) { + _additionalStatus->setText(status); + } else { + _additionalStatus.create(_widget.get(), status, _statusStyle->st); + _additionalStatus->show(); + refreshLabelsGeometry(); + } +} + void PeerShortInfoCover::applyUserpic(PeerShortInfoUserpic &&value) { if (_index != value.index) { _index = value.index; @@ -593,6 +602,28 @@ void PeerShortInfoCover::refreshBarImages() { _barLarge = makeBar(_largeWidth); } +void PeerShortInfoCover::refreshLabelsGeometry() { + const auto statusTop = _st.size + - _st.statusPosition.y() + - _status->height(); + const auto diff = _st.namePosition.y() + - _name->height() + - _st.statusPosition.y(); + if (_additionalStatus) { + _additionalStatus->moveToLeft( + _status->x(), + statusTop - diff - _additionalStatus->height()); + } + _name->moveToLeft( + _st.namePosition.x(), + _st.size + - _st.namePosition.y() + - _name->height() + - (_additionalStatus ? (diff + _additionalStatus->height()) : 0), + _st.size); + _status->moveToLeft(_st.statusPosition.x(), statusTop, _st.size); +} + QRect PeerShortInfoCover::radialRect() const { const auto cover = _widget->rect(); const auto size = st::boxLoadingSize; diff --git a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.h b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.h index 07e60132a..0e130562d 100644 --- a/Telegram/SourceFiles/boxes/peers/peer_short_info_box.h +++ b/Telegram/SourceFiles/boxes/peers/peer_short_info_box.h @@ -50,6 +50,7 @@ struct PeerShortInfoUserpic { float64 photoLoadingProgress = 0.; std::shared_ptr videoDocument; crl::time videoStartPosition = 0; + QString additionalStatus; }; class PeerShortInfoCover final { @@ -87,6 +88,7 @@ private: [[nodiscard]] QImage currentVideoFrame() const; void applyUserpic(PeerShortInfoUserpic &&value); + void applyAdditionalStatus(const QString &status); [[nodiscard]] QRect radialRect() const; void videoWaiting(); @@ -99,6 +101,7 @@ private: void updateRadialState(); void refreshCoverCursor(); void refreshBarImages(); + void refreshLabelsGeometry(); const style::ShortInfoCover &_st; @@ -108,6 +111,7 @@ private: object_ptr _name; std::unique_ptr _statusStyle; object_ptr _status; + object_ptr _additionalStatus = { nullptr }; std::array _roundMask; QImage _userpicImage; diff --git a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp index 8baf378b5..9965e8810 100644 --- a/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/prepare_short_info_box.cpp @@ -335,6 +335,11 @@ bool ProcessCurrent( : state->photoView ? state->photoView->owner().get() : nullptr; + state->current.additionalStatus = ((state->photoId == userpicPhotoId) + && peer->isUser() + && peer->asUser()->hasPersonalPhoto()) + ? tr::lng_profile_photo_by_you(tr::now) + : QString(); state->waitingLoad = false; if (!changedPhotoId && (state->current.index > 0 || !changedUserpic)