Added phrase for personal photo to short info box.

This commit is contained in:
23rd 2023-07-24 20:02:46 +03:00
parent 3a472d1b90
commit 65a344be76
4 changed files with 51 additions and 10 deletions

View File

@ -1143,6 +1143,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_profile_shared_links#other" = "{count} shared links"; "lng_profile_shared_links#other" = "{count} shared links";
"lng_profile_copy_phone" = "Copy Phone Number"; "lng_profile_copy_phone" = "Copy Phone Number";
"lng_profile_copy_fullname" = "Copy Name"; "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_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."; "lng_via_link_group_many#one" = "**{count} user** restricts adding them to groups.\nYou can send them an invite link as message instead.";

View File

@ -105,6 +105,7 @@ PeerShortInfoCover::PeerShortInfoCover(
userpic userpic
) | rpl::start_with_next([=](PeerShortInfoUserpic &&value) { ) | rpl::start_with_next([=](PeerShortInfoUserpic &&value) {
applyUserpic(std::move(value)); applyUserpic(std::move(value));
applyAdditionalStatus(value.additionalStatus);
}, lifetime()); }, lifetime());
style::PaletteChanged( style::PaletteChanged(
@ -136,16 +137,7 @@ PeerShortInfoCover::PeerShortInfoCover(
return base::EventFilterResult::Cancel; return base::EventFilterResult::Cancel;
}); });
_name->moveToLeft( refreshLabelsGeometry();
_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);
_roundedTopImage = QImage( _roundedTopImage = QImage(
QSize(_st.size, _st.radius) * style::DevicePixelRatio(), QSize(_st.size, _st.radius) * style::DevicePixelRatio(),
@ -415,6 +407,23 @@ QImage PeerShortInfoCover::currentVideoFrame() const {
: QImage(); : 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) { void PeerShortInfoCover::applyUserpic(PeerShortInfoUserpic &&value) {
if (_index != value.index) { if (_index != value.index) {
_index = value.index; _index = value.index;
@ -593,6 +602,28 @@ void PeerShortInfoCover::refreshBarImages() {
_barLarge = makeBar(_largeWidth); _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 { QRect PeerShortInfoCover::radialRect() const {
const auto cover = _widget->rect(); const auto cover = _widget->rect();
const auto size = st::boxLoadingSize; const auto size = st::boxLoadingSize;

View File

@ -50,6 +50,7 @@ struct PeerShortInfoUserpic {
float64 photoLoadingProgress = 0.; float64 photoLoadingProgress = 0.;
std::shared_ptr<Media::Streaming::Document> videoDocument; std::shared_ptr<Media::Streaming::Document> videoDocument;
crl::time videoStartPosition = 0; crl::time videoStartPosition = 0;
QString additionalStatus;
}; };
class PeerShortInfoCover final { class PeerShortInfoCover final {
@ -87,6 +88,7 @@ private:
[[nodiscard]] QImage currentVideoFrame() const; [[nodiscard]] QImage currentVideoFrame() const;
void applyUserpic(PeerShortInfoUserpic &&value); void applyUserpic(PeerShortInfoUserpic &&value);
void applyAdditionalStatus(const QString &status);
[[nodiscard]] QRect radialRect() const; [[nodiscard]] QRect radialRect() const;
void videoWaiting(); void videoWaiting();
@ -99,6 +101,7 @@ private:
void updateRadialState(); void updateRadialState();
void refreshCoverCursor(); void refreshCoverCursor();
void refreshBarImages(); void refreshBarImages();
void refreshLabelsGeometry();
const style::ShortInfoCover &_st; const style::ShortInfoCover &_st;
@ -108,6 +111,7 @@ private:
object_ptr<Ui::FlatLabel> _name; object_ptr<Ui::FlatLabel> _name;
std::unique_ptr<CustomLabelStyle> _statusStyle; std::unique_ptr<CustomLabelStyle> _statusStyle;
object_ptr<Ui::FlatLabel> _status; object_ptr<Ui::FlatLabel> _status;
object_ptr<Ui::FlatLabel> _additionalStatus = { nullptr };
std::array<QImage, 4> _roundMask; std::array<QImage, 4> _roundMask;
QImage _userpicImage; QImage _userpicImage;

View File

@ -335,6 +335,11 @@ bool ProcessCurrent(
: state->photoView : state->photoView
? state->photoView->owner().get() ? state->photoView->owner().get()
: nullptr; : nullptr;
state->current.additionalStatus = ((state->photoId == userpicPhotoId)
&& peer->isUser()
&& peer->asUser()->hasPersonalPhoto())
? tr::lng_profile_photo_by_you(tr::now)
: QString();
state->waitingLoad = false; state->waitingLoad = false;
if (!changedPhotoId if (!changedPhotoId
&& (state->current.index > 0 || !changedUserpic) && (state->current.index > 0 || !changedUserpic)