mirror of https://github.com/procxx/kepka.git
Support PSA forwarded info.
This commit is contained in:
parent
266c1531ce
commit
c14e20b33f
Binary file not shown.
After Width: | Height: | Size: 549 B |
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -6,10 +6,10 @@ For license and copyright information please follow this link:
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
"cloud_lng_badge_psa_covid" = "Covid-19";
|
"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_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_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_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_ar" = "Arabic";
|
||||||
"cloud_lng_passport_in_az" = "Azerbaijani";
|
"cloud_lng_passport_in_az" = "Azerbaijani";
|
||||||
|
|
|
@ -509,12 +509,17 @@ historyGroupRadialLine: 3px;
|
||||||
historyAboutProxy: FlatLabel(defaultFlatLabel) {
|
historyAboutProxy: FlatLabel(defaultFlatLabel) {
|
||||||
align: align(top);
|
align: align(top);
|
||||||
textFg: windowSubTextFg;
|
textFg: windowSubTextFg;
|
||||||
|
minWidth: 300px;
|
||||||
}
|
}
|
||||||
historyAboutProxyPadding: margins(20px, 10px, 20px, 10px);
|
historyAboutProxyPadding: margins(20px, 10px, 20px, 10px);
|
||||||
|
|
||||||
historyMapPoint: icon {{ "map_point", mapPointDrop }};
|
historyMapPoint: icon {{ "map_point", mapPointDrop }};
|
||||||
historyMapPointInner: icon {{ "map_point_inner", mapPointDot }};
|
historyMapPointInner: icon {{ "map_point_inner", mapPointDot }};
|
||||||
|
|
||||||
|
historyPsaForwardPalette: TextPalette(defaultTextPalette) {
|
||||||
|
linkFg: boxTextFgGood;
|
||||||
|
}
|
||||||
|
|
||||||
webPageLeft: 10px;
|
webPageLeft: 10px;
|
||||||
webPageBar: 2px;
|
webPageBar: 2px;
|
||||||
webPageTitleFont: semiboldFont;
|
webPageTitleFont: semiboldFont;
|
||||||
|
|
|
@ -32,6 +32,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const auto kPsaForwardedPrefix = "cloud_lng_forwarded_psa_";
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void HistoryMessageVia::create(UserId userId) {
|
void HistoryMessageVia::create(UserId userId) {
|
||||||
bot = Auth().data().user(userId);
|
bot = Auth().data().user(userId);
|
||||||
maxWidth = st::msgServiceNameFont->width(
|
maxWidth = st::msgServiceNameFont->width(
|
||||||
|
@ -127,7 +133,7 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
|
||||||
} else {
|
} else {
|
||||||
phrase = name;
|
phrase = name;
|
||||||
}
|
}
|
||||||
if (via) {
|
if (via && psaType.isEmpty()) {
|
||||||
if (fromChannel) {
|
if (fromChannel) {
|
||||||
phrase = tr::lng_forwarded_channel_via(
|
phrase = tr::lng_forwarded_channel_via(
|
||||||
tr::now,
|
tr::now,
|
||||||
|
@ -144,11 +150,19 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
|
||||||
textcmdLink(2, '@' + via->bot->username));
|
textcmdLink(2, '@' + via->bot->username));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (fromChannel) {
|
if (fromChannel || !psaType.isEmpty()) {
|
||||||
phrase = tr::lng_forwarded_channel(
|
auto custom = psaType.isEmpty()
|
||||||
tr::now,
|
? QString()
|
||||||
lt_channel,
|
: Lang::Current().getNonDefaultValue(
|
||||||
textcmdLink(1, phrase));
|
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 {
|
} else {
|
||||||
phrase = tr::lng_forwarded(
|
phrase = tr::lng_forwarded(
|
||||||
tr::now,
|
tr::now,
|
||||||
|
|
|
@ -77,6 +77,7 @@ struct HistoryMessageForwarded : public RuntimeComponent<HistoryMessageForwarded
|
||||||
PeerData *originalSender = nullptr;
|
PeerData *originalSender = nullptr;
|
||||||
std::unique_ptr<HiddenSenderInfo> hiddenSenderInfo;
|
std::unique_ptr<HiddenSenderInfo> hiddenSenderInfo;
|
||||||
QString originalAuthor;
|
QString originalAuthor;
|
||||||
|
QString psaType;
|
||||||
MsgId originalId = 0;
|
MsgId originalId = 0;
|
||||||
mutable Ui::Text::String text = { 1 };
|
mutable Ui::Text::String text = { 1 };
|
||||||
|
|
||||||
|
|
|
@ -383,6 +383,7 @@ struct HistoryMessage::CreateConfig {
|
||||||
QString author;
|
QString author;
|
||||||
PeerId senderOriginal = 0;
|
PeerId senderOriginal = 0;
|
||||||
QString senderNameOriginal;
|
QString senderNameOriginal;
|
||||||
|
QString forwardPsaType;
|
||||||
MsgId originalId = 0;
|
MsgId originalId = 0;
|
||||||
PeerId savedFromPeer = 0;
|
PeerId savedFromPeer = 0;
|
||||||
MsgId savedFromMsgId = 0;
|
MsgId savedFromMsgId = 0;
|
||||||
|
@ -407,6 +408,7 @@ void HistoryMessage::FillForwardedInfo(
|
||||||
}
|
}
|
||||||
config.originalDate = data.vdate().v;
|
config.originalDate = data.vdate().v;
|
||||||
config.senderNameOriginal = qs(data.vfrom_name().value_or_empty());
|
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.originalId = data.vchannel_post().value_or_empty();
|
||||||
config.authorOriginal = qs(data.vpost_author().value_or_empty());
|
config.authorOriginal = qs(data.vpost_author().value_or_empty());
|
||||||
const auto savedFromPeer = data.vsaved_from_peer();
|
const auto savedFromPeer = data.vsaved_from_peer();
|
||||||
|
@ -867,6 +869,7 @@ void HistoryMessage::setupForwardedComponent(const CreateConfig &config) {
|
||||||
}
|
}
|
||||||
forwarded->originalId = config.originalId;
|
forwarded->originalId = config.originalId;
|
||||||
forwarded->originalAuthor = config.authorOriginal;
|
forwarded->originalAuthor = config.authorOriginal;
|
||||||
|
forwarded->psaType = config.forwardPsaType;
|
||||||
forwarded->savedFromPeer = history()->owner().peerLoaded(
|
forwarded->savedFromPeer = history()->owner().peerLoaded(
|
||||||
config.savedFromPeer);
|
config.savedFromPeer);
|
||||||
forwarded->savedFromMsgId = config.savedFromMsgId;
|
forwarded->savedFromMsgId = config.savedFromMsgId;
|
||||||
|
|
|
@ -2269,23 +2269,23 @@ void HistoryWidget::refreshAboutTopPromotion() {
|
||||||
: Lang::Current().getNonDefaultValue(
|
: Lang::Current().getNonDefaultValue(
|
||||||
kPsaAboutPrefix + type.toUtf8());
|
kPsaAboutPrefix + type.toUtf8());
|
||||||
const auto text = type.isEmpty()
|
const auto text = type.isEmpty()
|
||||||
? tr::lng_proxy_sponsor_about(tr::now)
|
? tr::lng_proxy_sponsor_about(tr::now, Ui::Text::RichLangValue)
|
||||||
: custom.isEmpty()
|
: custom.isEmpty()
|
||||||
? tr::lng_about_psa_default(tr::now)
|
? tr::lng_about_psa_default(tr::now, Ui::Text::RichLangValue)
|
||||||
: custom;
|
: Ui::Text::RichLangValue(custom);
|
||||||
if (!_aboutTopPromotion || _aboutTopPromotionText != text) {
|
if (!_aboutTopPromotion || _aboutTopPromotionText != text) {
|
||||||
_aboutTopPromotionText = text;
|
_aboutTopPromotionText = text;
|
||||||
_aboutTopPromotion = object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>(
|
_aboutTopPromotion = object_ptr<Ui::PaddingWrap<Ui::FlatLabel>>(
|
||||||
this,
|
this,
|
||||||
object_ptr<Ui::FlatLabel>(
|
object_ptr<Ui::FlatLabel>(
|
||||||
this,
|
this,
|
||||||
_aboutTopPromotionText,
|
rpl::single(_aboutTopPromotionText),
|
||||||
st::historyAboutProxy),
|
st::historyAboutProxy),
|
||||||
st::historyAboutProxyPadding);
|
st::historyAboutProxyPadding);
|
||||||
}
|
}
|
||||||
_aboutTopPromotion->show();
|
_aboutTopPromotion->show();
|
||||||
} else {
|
} else {
|
||||||
_aboutTopPromotionText = QString();
|
_aboutTopPromotionText = TextWithEntities();
|
||||||
_aboutTopPromotion.destroy();
|
_aboutTopPromotion.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -735,7 +735,7 @@ private:
|
||||||
object_ptr<Ui::FlatButton> _muteUnmute;
|
object_ptr<Ui::FlatButton> _muteUnmute;
|
||||||
object_ptr<Ui::FlatButton> _discuss;
|
object_ptr<Ui::FlatButton> _discuss;
|
||||||
object_ptr<Ui::RpWidget> _aboutTopPromotion = { nullptr };
|
object_ptr<Ui::RpWidget> _aboutTopPromotion = { nullptr };
|
||||||
QString _aboutTopPromotionText;
|
TextWithEntities _aboutTopPromotionText;
|
||||||
object_ptr<Ui::IconButton> _attachToggle;
|
object_ptr<Ui::IconButton> _attachToggle;
|
||||||
object_ptr<Ui::EmojiButton> _tabbedSelectorToggle;
|
object_ptr<Ui::EmojiButton> _tabbedSelectorToggle;
|
||||||
object_ptr<Ui::IconButton> _botKeyboardShow;
|
object_ptr<Ui::IconButton> _botKeyboardShow;
|
||||||
|
|
|
@ -606,17 +606,33 @@ void Message::paintFromName(
|
||||||
|
|
||||||
void Message::paintForwardedInfo(Painter &p, QRect &trect, bool selected) const {
|
void Message::paintForwardedInfo(Painter &p, QRect &trect, bool selected) const {
|
||||||
if (displayForwardedFrom()) {
|
if (displayForwardedFrom()) {
|
||||||
const auto &serviceFont = st::msgServiceFont;
|
|
||||||
const auto &serviceName = st::msgServiceNameFont;
|
|
||||||
|
|
||||||
const auto item = message();
|
const auto item = message();
|
||||||
const auto outbg = hasOutLayout();
|
const auto outbg = hasOutLayout();
|
||||||
p.setPen(selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg));
|
|
||||||
p.setFont(serviceFont);
|
|
||||||
|
|
||||||
auto forwarded = item->Get<HistoryMessageForwarded>();
|
auto forwarded = item->Get<HistoryMessageForwarded>();
|
||||||
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);
|
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));
|
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 {
|
bool Message::displayFromName() const {
|
||||||
if (!hasFromName()) return false;
|
if (!hasFromName() || isAttachedToPrevious()) {
|
||||||
if (isAttachedToPrevious()) return false;
|
return false;
|
||||||
|
}
|
||||||
|
if (const auto forwarded = message()->Get<HistoryMessageForwarded>()) {
|
||||||
|
return forwarded->psaType.isEmpty();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue