diff --git a/Telegram/Resources/icons/message_psa_tooltip.png b/Telegram/Resources/icons/message_psa_tooltip.png new file mode 100644 index 000000000..01a75e411 Binary files /dev/null and b/Telegram/Resources/icons/message_psa_tooltip.png differ diff --git a/Telegram/Resources/icons/message_psa_tooltip@2x.png b/Telegram/Resources/icons/message_psa_tooltip@2x.png new file mode 100644 index 000000000..4bb0c04f0 Binary files /dev/null and b/Telegram/Resources/icons/message_psa_tooltip@2x.png differ diff --git a/Telegram/Resources/icons/message_psa_tooltip@3x.png b/Telegram/Resources/icons/message_psa_tooltip@3x.png new file mode 100644 index 000000000..6f8a029e5 Binary files /dev/null and b/Telegram/Resources/icons/message_psa_tooltip@3x.png differ diff --git a/Telegram/Resources/langs/cloud_lang.strings b/Telegram/Resources/langs/cloud_lang.strings index c4c4a7ab9..1abb893e7 100644 --- a/Telegram/Resources/langs/cloud_lang.strings +++ b/Telegram/Resources/langs/cloud_lang.strings @@ -6,10 +6,10 @@ For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ -"cloud_lng_badge_psa_covid" = "Covid-19"; -"cloud_lng_about_psa_covid" = "This channel provides you with a public service announcement in relation to the ongoing pandemics.\nTo remove this channel from your chats list,\nright click it and select 'Hide'."; -"cloud_lng_forwarded_psa_covid" = "Covid-19 Notification from {channel}"; -"cloud_lng_tooltip_psa_covid" = "This message provides you with a public service announcement in relation to the ongoing pandemics. Learn more about this initiative at: https://telegram.org/blog/coronavirus"; +"cloud_lng_badge_psa_covid" = "COVID-19"; +"cloud_lng_about_psa_covid" = "This message provides you with a public service announcement in relation to the ongoing COVID-19 pandemic. To remove it from your chats list, right click it and select **Hide**."; +"cloud_lng_forwarded_psa_covid" = "COVID-19 Notification from {channel}"; +"cloud_lng_tooltip_psa_covid" = "This message provides you with a public service announcement in relation to the ongoing COVID-19 pandemic. Learn more about this initiative at https://telegram.org/blog/coronavirus"; "cloud_lng_passport_in_ar" = "Arabic"; "cloud_lng_passport_in_az" = "Azerbaijani"; diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index fd8b94f45..624dab4a6 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -509,12 +509,17 @@ historyGroupRadialLine: 3px; historyAboutProxy: FlatLabel(defaultFlatLabel) { align: align(top); textFg: windowSubTextFg; + minWidth: 300px; } historyAboutProxyPadding: margins(20px, 10px, 20px, 10px); historyMapPoint: icon {{ "map_point", mapPointDrop }}; historyMapPointInner: icon {{ "map_point_inner", mapPointDot }}; +historyPsaForwardPalette: TextPalette(defaultTextPalette) { + linkFg: boxTextFgGood; +} + webPageLeft: 10px; webPageBar: 2px; webPageTitleFont: semiboldFont; diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index 7ea092c39..b491226e4 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -32,6 +32,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include +namespace { + +const auto kPsaForwardedPrefix = "cloud_lng_forwarded_psa_"; + +} // namespace + void HistoryMessageVia::create(UserId userId) { bot = Auth().data().user(userId); maxWidth = st::msgServiceNameFont->width( @@ -127,7 +133,7 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const { } else { phrase = name; } - if (via) { + if (via && psaType.isEmpty()) { if (fromChannel) { phrase = tr::lng_forwarded_channel_via( tr::now, @@ -144,11 +150,19 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const { textcmdLink(2, '@' + via->bot->username)); } } else { - if (fromChannel) { - phrase = tr::lng_forwarded_channel( - tr::now, - lt_channel, - textcmdLink(1, phrase)); + if (fromChannel || !psaType.isEmpty()) { + auto custom = psaType.isEmpty() + ? QString() + : Lang::Current().getNonDefaultValue( + kPsaForwardedPrefix + psaType.toUtf8()); + phrase = !custom.isEmpty() + ? custom.replace("{channel}", textcmdLink(1, phrase)) + : (psaType.isEmpty() + ? tr::lng_forwarded_channel + : tr::lng_forwarded_psa_default)( + tr::now, + lt_channel, + textcmdLink(1, phrase)); } else { phrase = tr::lng_forwarded( tr::now, diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index cf016050f..6582bca1f 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -77,6 +77,7 @@ struct HistoryMessageForwarded : public RuntimeComponent hiddenSenderInfo; QString originalAuthor; + QString psaType; MsgId originalId = 0; mutable Ui::Text::String text = { 1 }; diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index 207f520c6..45f947551 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -383,6 +383,7 @@ struct HistoryMessage::CreateConfig { QString author; PeerId senderOriginal = 0; QString senderNameOriginal; + QString forwardPsaType; MsgId originalId = 0; PeerId savedFromPeer = 0; MsgId savedFromMsgId = 0; @@ -407,6 +408,7 @@ void HistoryMessage::FillForwardedInfo( } config.originalDate = data.vdate().v; config.senderNameOriginal = qs(data.vfrom_name().value_or_empty()); + config.forwardPsaType = qs(data.vpsa_type().value_or_empty()); config.originalId = data.vchannel_post().value_or_empty(); config.authorOriginal = qs(data.vpost_author().value_or_empty()); const auto savedFromPeer = data.vsaved_from_peer(); @@ -867,6 +869,7 @@ void HistoryMessage::setupForwardedComponent(const CreateConfig &config) { } forwarded->originalId = config.originalId; forwarded->originalAuthor = config.authorOriginal; + forwarded->psaType = config.forwardPsaType; forwarded->savedFromPeer = history()->owner().peerLoaded( config.savedFromPeer); forwarded->savedFromMsgId = config.savedFromMsgId; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index a88bd645a..0a247fc17 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -2269,23 +2269,23 @@ void HistoryWidget::refreshAboutTopPromotion() { : Lang::Current().getNonDefaultValue( kPsaAboutPrefix + type.toUtf8()); const auto text = type.isEmpty() - ? tr::lng_proxy_sponsor_about(tr::now) + ? tr::lng_proxy_sponsor_about(tr::now, Ui::Text::RichLangValue) : custom.isEmpty() - ? tr::lng_about_psa_default(tr::now) - : custom; + ? tr::lng_about_psa_default(tr::now, Ui::Text::RichLangValue) + : Ui::Text::RichLangValue(custom); if (!_aboutTopPromotion || _aboutTopPromotionText != text) { _aboutTopPromotionText = text; _aboutTopPromotion = object_ptr>( this, object_ptr( this, - _aboutTopPromotionText, + rpl::single(_aboutTopPromotionText), st::historyAboutProxy), st::historyAboutProxyPadding); } _aboutTopPromotion->show(); } else { - _aboutTopPromotionText = QString(); + _aboutTopPromotionText = TextWithEntities(); _aboutTopPromotion.destroy(); } } diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index eab1ba9ca..eaf8855c1 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -735,7 +735,7 @@ private: object_ptr _muteUnmute; object_ptr _discuss; object_ptr _aboutTopPromotion = { nullptr }; - QString _aboutTopPromotionText; + TextWithEntities _aboutTopPromotionText; object_ptr _attachToggle; object_ptr _tabbedSelectorToggle; object_ptr _botKeyboardShow; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 84bbd8f0d..e25fa0545 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -606,17 +606,33 @@ void Message::paintFromName( void Message::paintForwardedInfo(Painter &p, QRect &trect, bool selected) const { if (displayForwardedFrom()) { - const auto &serviceFont = st::msgServiceFont; - const auto &serviceName = st::msgServiceNameFont; - const auto item = message(); const auto outbg = hasOutLayout(); - p.setPen(selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg)); - p.setFont(serviceFont); - auto forwarded = item->Get(); - auto breakEverywhere = (forwarded->text.countHeight(trect.width()) > 2 * serviceFont->height); - p.setTextPalette(selected ? (outbg ? st::outFwdTextPaletteSelected : st::inFwdTextPaletteSelected) : (outbg ? st::outFwdTextPalette : st::inFwdTextPalette)); + + const auto &serviceFont = st::msgServiceFont; + const auto &serviceName = st::msgServiceNameFont; + const auto breakEverywhere = (forwarded->text.countHeight(trect.width()) > 2 * serviceFont->height); + + p.setPen(!forwarded->psaType.isEmpty() + ? st::boxTextFgGood + : selected + ? (outbg + ? st::msgOutServiceFgSelected + : st::msgInServiceFgSelected) + : (outbg + ? st::msgOutServiceFg + : st::msgInServiceFg)); + p.setFont(serviceFont); + p.setTextPalette(!forwarded->psaType.isEmpty() + ? st::historyPsaForwardPalette + : selected + ? (outbg + ? st::outFwdTextPaletteSelected + : st::inFwdTextPaletteSelected) + : (outbg + ? st::outFwdTextPalette + : st::inFwdTextPalette)); forwarded->text.drawElided(p, trect.x(), trect.y(), trect.width(), 2, style::al_left, 0, -1, 0, breakEverywhere); p.setTextPalette(selected ? (outbg ? st::outTextPaletteSelected : st::inTextPaletteSelected) : (outbg ? st::outTextPalette : st::inTextPalette)); @@ -1367,8 +1383,12 @@ bool Message::hasFromName() const { } bool Message::displayFromName() const { - if (!hasFromName()) return false; - if (isAttachedToPrevious()) return false; + if (!hasFromName() || isAttachedToPrevious()) { + return false; + } + if (const auto forwarded = message()->Get()) { + return forwarded->psaType.isEmpty(); + } return true; }