Improve suggested photo service message.

This commit is contained in:
John Preston 2022-12-19 10:51:21 +04:00
parent 5ebea97ded
commit 14f113266f
7 changed files with 25 additions and 12 deletions

View file

@ -1563,9 +1563,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_action_webview_data_done" = "You have just successfully transferred data from the «{text}» button to the bot."; "lng_action_webview_data_done" = "You have just successfully transferred data from the «{text}» button to the bot.";
"lng_action_gift_received" = "{user} sent you a gift for {cost}"; "lng_action_gift_received" = "{user} sent you a gift for {cost}";
"lng_action_gift_received_me" = "You sent to {user} a gift for {cost}"; "lng_action_gift_received_me" = "You sent to {user} a gift for {cost}";
"lng_action_suggested_photo_title" = "Suggested Photo"; "lng_action_suggested_photo_me" = "You suggested {user} to use this profile photo.";
"lng_action_suggested_photo_me" = "You suggested {user} to use this photo for their account."; "lng_action_suggested_photo" = "{user} suggests you to use this profile photo.";
"lng_action_suggested_photo" = "{user} suggests you to use this photo for your account."; "lng_action_suggested_photo_button" = "View Photo";
"lng_action_attach_menu_bot_allowed" = "You allowed this bot to message you when you added it in the attachment menu."; "lng_action_attach_menu_bot_allowed" = "You allowed this bot to message you when you added it in the attachment menu.";
"lng_action_topic_created_inside" = "Topic created"; "lng_action_topic_created_inside" = "Topic created";
"lng_action_topic_closed_inside" = "Topic closed"; "lng_action_topic_closed_inside" = "Topic closed";
@ -2330,7 +2330,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_context_animated_reactions_many#one" = "Reactions contain emoji from **{count} pack**."; "lng_context_animated_reactions_many#one" = "Reactions contain emoji from **{count} pack**.";
"lng_context_animated_reactions_many#other" = "Reactions contain emoji from **{count} packs**."; "lng_context_animated_reactions_many#other" = "Reactions contain emoji from **{count} packs**.";
"lng_context_spoiler_effect" = "Spoiler Effect"; "lng_context_spoiler_effect" = "Hide with Spoiler";
"lng_context_disable_spoiler" = "Disable Spoiler Effect"; "lng_context_disable_spoiler" = "Disable Spoiler Effect";
"lng_downloads_section" = "Downloads"; "lng_downloads_section" = "Downloads";

View file

@ -58,6 +58,10 @@ QString PremiumGift::subtitle() {
return FormatGiftMonths(_gift->months()); return FormatGiftMonths(_gift->months());
} }
QString PremiumGift::button() {
return tr::lng_sticker_premium_view(tr::now);
}
ClickHandlerPtr PremiumGift::createViewLink() { ClickHandlerPtr PremiumGift::createViewLink() {
const auto from = _gift->from(); const auto from = _gift->from();
const auto to = _parent->history()->peer; const auto to = _parent->history()->peer;

View file

@ -27,6 +27,7 @@ public:
QSize size() override; QSize size() override;
QString title() override; QString title() override;
QString subtitle() override; QString subtitle() override;
QString button() override;
void draw( void draw(
Painter &p, Painter &p,
const PaintContext &context, const PaintContext &context,

View file

@ -28,9 +28,7 @@ ServiceBox::ServiceBox(
, _button([&] { , _button([&] {
auto result = Button(); auto result = Button();
result.repaint = [=] { repaint(); }; result.repaint = [=] { repaint(); };
result.text.setText( result.text.setText(st::semiboldTextStyle, _content->button());
st::semiboldTextStyle,
tr::lng_sticker_premium_view(tr::now));
const auto height = st::msgServiceGiftBoxButtonHeight; const auto height = st::msgServiceGiftBoxButtonHeight;
const auto &padding = st::msgServiceGiftBoxButtonPadding; const auto &padding = st::msgServiceGiftBoxButtonPadding;
@ -64,8 +62,10 @@ ServiceBox::ServiceBox(
+ _content->top() + _content->top()
+ _content->size().height() + _content->size().height()
+ st::msgServiceGiftBoxTitlePadding.top() + st::msgServiceGiftBoxTitlePadding.top()
+ _title.countHeight(_maxWidth) + (_title.isEmpty()
+ st::msgServiceGiftBoxTitlePadding.bottom() ? 0
: (_title.countHeight(_maxWidth)
+ st::msgServiceGiftBoxTitlePadding.bottom()))
+ _subtitle.countHeight(_maxWidth) + _subtitle.countHeight(_maxWidth)
+ st::msgServiceGiftBoxButtonMargins.top() + st::msgServiceGiftBoxButtonMargins.top()
+ _button.size.height() + _button.size.height()
@ -98,8 +98,10 @@ void ServiceBox::draw(Painter &p, const PaintContext &context) const {
p.setPen(context.st->msgServiceFg()); p.setPen(context.st->msgServiceFg());
const auto &padding = st::msgServiceGiftBoxTitlePadding; const auto &padding = st::msgServiceGiftBoxTitlePadding;
top += padding.top(); top += padding.top();
_title.draw(p, st::msgPadding.left(), top, _maxWidth, style::al_top); if (!_title.isEmpty()) {
top += _title.countHeight(_maxWidth) + padding.bottom(); _title.draw(p, st::msgPadding.left(), top, _maxWidth, style::al_top);
top += _title.countHeight(_maxWidth) + padding.bottom();
}
_subtitle.draw(p, st::msgPadding.left(), top, _maxWidth, style::al_top); _subtitle.draw(p, st::msgPadding.left(), top, _maxWidth, style::al_top);
top += _subtitle.countHeight(_maxWidth) + padding.bottom(); top += _subtitle.countHeight(_maxWidth) + padding.bottom();
} }

View file

@ -23,6 +23,7 @@ public:
[[nodiscard]] virtual QSize size() = 0; [[nodiscard]] virtual QSize size() = 0;
[[nodiscard]] virtual QString title() = 0; [[nodiscard]] virtual QString title() = 0;
[[nodiscard]] virtual QString subtitle() = 0; [[nodiscard]] virtual QString subtitle() = 0;
[[nodiscard]] virtual QString button() = 0;
virtual void draw( virtual void draw(
Painter &p, Painter &p,
const PaintContext &context, const PaintContext &context,

View file

@ -52,7 +52,11 @@ QSize UserpicSuggestion::size() {
} }
QString UserpicSuggestion::title() { QString UserpicSuggestion::title() {
return tr::lng_action_suggested_photo_title(tr::now); return QString();
}
QString UserpicSuggestion::button() {
return tr::lng_action_suggested_photo_button(tr::now);
} }
QString UserpicSuggestion::subtitle() { QString UserpicSuggestion::subtitle() {

View file

@ -31,6 +31,7 @@ public:
QSize size() override; QSize size() override;
QString title() override; QString title() override;
QString subtitle() override; QString subtitle() override;
QString button() override;
void draw( void draw(
Painter &p, Painter &p,
const PaintContext &context, const PaintContext &context,