From 14f113266ff6862c9d684dc60629a0d9846722de Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 19 Dec 2022 10:51:21 +0400 Subject: [PATCH] Improve suggested photo service message. --- Telegram/Resources/langs/lang.strings | 8 ++++---- .../view/media/history_view_premium_gift.cpp | 4 ++++ .../view/media/history_view_premium_gift.h | 1 + .../view/media/history_view_service_box.cpp | 16 +++++++++------- .../view/media/history_view_service_box.h | 1 + .../media/history_view_userpic_suggestion.cpp | 6 +++++- .../view/media/history_view_userpic_suggestion.h | 1 + 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index f876b188e..8780bd95e 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -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_gift_received" = "{user} sent you 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 photo for their account."; -"lng_action_suggested_photo" = "{user} suggests you to use this photo for your account."; +"lng_action_suggested_photo_me" = "You suggested {user} to use this profile photo."; +"lng_action_suggested_photo" = "{user} suggests you to use this profile photo."; +"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_topic_created_inside" = "Topic created"; "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#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_downloads_section" = "Downloads"; diff --git a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp index 06e1dfe4b..252b1e621 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.cpp @@ -58,6 +58,10 @@ QString PremiumGift::subtitle() { return FormatGiftMonths(_gift->months()); } +QString PremiumGift::button() { + return tr::lng_sticker_premium_view(tr::now); +} + ClickHandlerPtr PremiumGift::createViewLink() { const auto from = _gift->from(); const auto to = _parent->history()->peer; diff --git a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.h b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.h index 7a786ce79..a548abe84 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_premium_gift.h +++ b/Telegram/SourceFiles/history/view/media/history_view_premium_gift.h @@ -27,6 +27,7 @@ public: QSize size() override; QString title() override; QString subtitle() override; + QString button() override; void draw( Painter &p, const PaintContext &context, diff --git a/Telegram/SourceFiles/history/view/media/history_view_service_box.cpp b/Telegram/SourceFiles/history/view/media/history_view_service_box.cpp index c9069384c..149998353 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_service_box.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_service_box.cpp @@ -28,9 +28,7 @@ ServiceBox::ServiceBox( , _button([&] { auto result = Button(); result.repaint = [=] { repaint(); }; - result.text.setText( - st::semiboldTextStyle, - tr::lng_sticker_premium_view(tr::now)); + result.text.setText(st::semiboldTextStyle, _content->button()); const auto height = st::msgServiceGiftBoxButtonHeight; const auto &padding = st::msgServiceGiftBoxButtonPadding; @@ -64,8 +62,10 @@ ServiceBox::ServiceBox( + _content->top() + _content->size().height() + st::msgServiceGiftBoxTitlePadding.top() - + _title.countHeight(_maxWidth) - + st::msgServiceGiftBoxTitlePadding.bottom() + + (_title.isEmpty() + ? 0 + : (_title.countHeight(_maxWidth) + + st::msgServiceGiftBoxTitlePadding.bottom())) + _subtitle.countHeight(_maxWidth) + st::msgServiceGiftBoxButtonMargins.top() + _button.size.height() @@ -98,8 +98,10 @@ void ServiceBox::draw(Painter &p, const PaintContext &context) const { p.setPen(context.st->msgServiceFg()); const auto &padding = st::msgServiceGiftBoxTitlePadding; top += padding.top(); - _title.draw(p, st::msgPadding.left(), top, _maxWidth, style::al_top); - top += _title.countHeight(_maxWidth) + padding.bottom(); + if (!_title.isEmpty()) { + _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); top += _subtitle.countHeight(_maxWidth) + padding.bottom(); } diff --git a/Telegram/SourceFiles/history/view/media/history_view_service_box.h b/Telegram/SourceFiles/history/view/media/history_view_service_box.h index b9b4bcfc6..79178994a 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_service_box.h +++ b/Telegram/SourceFiles/history/view/media/history_view_service_box.h @@ -23,6 +23,7 @@ public: [[nodiscard]] virtual QSize size() = 0; [[nodiscard]] virtual QString title() = 0; [[nodiscard]] virtual QString subtitle() = 0; + [[nodiscard]] virtual QString button() = 0; virtual void draw( Painter &p, const PaintContext &context, diff --git a/Telegram/SourceFiles/history/view/media/history_view_userpic_suggestion.cpp b/Telegram/SourceFiles/history/view/media/history_view_userpic_suggestion.cpp index e40bb45f4..734f11676 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_userpic_suggestion.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_userpic_suggestion.cpp @@ -52,7 +52,11 @@ QSize UserpicSuggestion::size() { } 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() { diff --git a/Telegram/SourceFiles/history/view/media/history_view_userpic_suggestion.h b/Telegram/SourceFiles/history/view/media/history_view_userpic_suggestion.h index 348f0e09c..083a19c83 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_userpic_suggestion.h +++ b/Telegram/SourceFiles/history/view/media/history_view_userpic_suggestion.h @@ -31,6 +31,7 @@ public: QSize size() override; QString title() override; QString subtitle() override; + QString button() override; void draw( Painter &p, const PaintContext &context,