From 21775bd509cec1795318b2c3f78001c5de45bb62 Mon Sep 17 00:00:00 2001 From: Ireina <140869597+re-zero001@users.noreply.github.com> Date: Thu, 30 Apr 2026 00:19:57 +0800 Subject: [PATCH] feat: add disable Greeting Sticker --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/ayu/ayu_settings.cpp | 8 +++ Telegram/SourceFiles/ayu/ayu_settings.h | 5 ++ .../ayu/ui/settings/settings_appearance.cpp | 1 - .../ayu/ui/settings/settings_chats.cpp | 6 ++ .../history/view/history_view_about_view.cpp | 64 ++++++++++--------- .../view/history_view_service_message.cpp | 30 +++++++++ 7 files changed, 85 insertions(+), 30 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 7380587e74..b7a0f2eb19 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -8050,6 +8050,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "ayu_HideReactionsInGroups" = "Groups"; "ayu_HideReactionsInPrivateChats" = "Private Chats"; "ayu_QuickAdminShortcuts" = "Quick Admin Shortcuts"; +"ayu_DisableGreetingSticker" = "Disable Greeting Sticker"; "ayu_TranslationProvider" = "Translation Provider"; "ayu_LinksHeader" = "Links"; "ayu_LinksChannel" = "Channel"; diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index 2280020ce8..7aa15560e3 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -963,6 +963,12 @@ void AyuSettings::setQuickAdminShortcuts(bool val) { save(); } +void AyuSettings::setDisableGreetingSticker(bool val) { + if (_disableGreetingSticker.current() == val) return; + _disableGreetingSticker = val; + save(); +} + void AyuSettings::setShowPeerId(PeerIdDisplay val) { if (_showPeerId.current() == val) return; _showPeerId = val; @@ -1129,6 +1135,7 @@ void to_json(nlohmann::json &j, const AyuSettings &s) { {"hideAllChatsFolder", s._hideAllChatsFolder.current()}, {"channelBottomButton", s._channelBottomButton.current()}, {"quickAdminShortcuts", s._quickAdminShortcuts.current()}, + {"disableGreetingSticker", s._disableGreetingSticker.current()}, {"showPeerId", s._showPeerId.current()}, {"showMessageSeconds", s._showMessageSeconds.current()}, {"showMessageShot", s._showMessageShot.current()}, @@ -1229,6 +1236,7 @@ void from_json(const nlohmann::json &j, AyuSettings &s) { s._hideAllChatsFolder = j.value("hideAllChatsFolder", defaults._hideAllChatsFolder.current()); s._channelBottomButton = j.value("channelBottomButton", defaults._channelBottomButton.current()); s._quickAdminShortcuts = j.value("quickAdminShortcuts", defaults._quickAdminShortcuts.current()); + s._disableGreetingSticker = j.value("disableGreetingSticker", defaults._disableGreetingSticker.current()); s._showPeerId = j.value("showPeerId", defaults._showPeerId.current()); s._showMessageSeconds = j.value("showMessageSeconds", defaults._showMessageSeconds.current()); s._showMessageShot = j.value("showMessageShot", defaults._showMessageShot.current()); diff --git a/Telegram/SourceFiles/ayu/ayu_settings.h b/Telegram/SourceFiles/ayu/ayu_settings.h index 97a0439215..2693f81995 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.h +++ b/Telegram/SourceFiles/ayu/ayu_settings.h @@ -337,6 +337,7 @@ public: [[nodiscard]] bool hideAllChatsFolder() const { return _hideAllChatsFolder.current(); } [[nodiscard]] ChannelBottomButton channelBottomButton() const { return _channelBottomButton.current(); } [[nodiscard]] bool quickAdminShortcuts() const { return _quickAdminShortcuts.current(); } + [[nodiscard]] bool disableGreetingSticker() const { return _disableGreetingSticker.current(); } [[nodiscard]] PeerIdDisplay showPeerId() const { return _showPeerId.current(); } [[nodiscard]] bool showMessageSeconds() const { return _showMessageSeconds.current(); } [[nodiscard]] bool showMessageShot() const { return _showMessageShot.current(); } @@ -421,6 +422,7 @@ public: void setHideAllChatsFolder(bool val); void setChannelBottomButton(ChannelBottomButton val); void setQuickAdminShortcuts(bool val); + void setDisableGreetingSticker(bool val); void setShowPeerId(PeerIdDisplay val); void setShowMessageSeconds(bool val); void setShowMessageShot(bool val); @@ -577,6 +579,8 @@ public: [[nodiscard]] rpl::producer channelBottomButtonChanges() const { return _channelBottomButton.changes(); } [[nodiscard]] rpl::producer quickAdminShortcutsValue() const { return _quickAdminShortcuts.value(); } [[nodiscard]] rpl::producer quickAdminShortcutsChanges() const { return _quickAdminShortcuts.changes(); } + [[nodiscard]] rpl::producer disableGreetingStickerValue() const { return _disableGreetingSticker.value(); } + [[nodiscard]] rpl::producer disableGreetingStickerChanges() const { return _disableGreetingSticker.changes(); } [[nodiscard]] rpl::producer showPeerIdValue() const { return _showPeerId.value(); } [[nodiscard]] rpl::producer showPeerIdChanges() const { return _showPeerId.changes(); } [[nodiscard]] rpl::producer showMessageSecondsValue() const { return _showMessageSeconds.value(); } @@ -683,6 +687,7 @@ private: rpl::variable _hideAllChatsFolder = false; rpl::variable _channelBottomButton = ChannelBottomButton::DiscussWithFallback; rpl::variable _quickAdminShortcuts = true; + rpl::variable _disableGreetingSticker = false; rpl::variable _showPeerId = PeerIdDisplay::BotApi; rpl::variable _showMessageSeconds = false; rpl::variable _showMessageShot = true; diff --git a/Telegram/SourceFiles/ayu/ui/settings/settings_appearance.cpp b/Telegram/SourceFiles/ayu/ui/settings/settings_appearance.cpp index c41224c5c8..98e492a804 100644 --- a/Telegram/SourceFiles/ayu/ui/settings/settings_appearance.cpp +++ b/Telegram/SourceFiles/ayu/ui/settings/settings_appearance.cpp @@ -204,7 +204,6 @@ void BuildAppearance(SectionBuilder &builder, AyuSectionBuilder &ayu) { .getter = &AyuSettings::disableCustomBackgrounds, .setter = &AyuSettings::setDisableCustomBackgrounds, }); - ayu.addSettingToggle({ .id = u"ayu/hidePremiumStatuses"_q, .title = tr::ayu_HidePremiumStatuses(), diff --git a/Telegram/SourceFiles/ayu/ui/settings/settings_chats.cpp b/Telegram/SourceFiles/ayu/ui/settings/settings_chats.cpp index 9a280e3c2e..4bb27d778a 100644 --- a/Telegram/SourceFiles/ayu/ui/settings/settings_chats.cpp +++ b/Telegram/SourceFiles/ayu/ui/settings/settings_chats.cpp @@ -117,6 +117,12 @@ void BuildGroupsAndChannels(SectionBuilder &builder, AyuSectionBuilder &ayu) { .getter = &AyuSettings::quickAdminShortcuts, .setter = &AyuSettings::setQuickAdminShortcuts, }); + ayu.addSettingToggle({ + .id = u"ayu/disableGreetingSticker"_q, + .title = tr::ayu_DisableGreetingSticker(), + .getter = &AyuSettings::disableGreetingSticker, + .setter = &AyuSettings::setDisableGreetingSticker, + }); ayu.addSettingToggle({ .id = u"ayu/showMessageShot"_q, .title = tr::ayu_SettingsShowMessageShot(), diff --git a/Telegram/SourceFiles/history/view/history_view_about_view.cpp b/Telegram/SourceFiles/history/view/history_view_about_view.cpp index c30fcf2597..f2398ec4d2 100644 --- a/Telegram/SourceFiles/history/view/history_view_about_view.cpp +++ b/Telegram/SourceFiles/history/view/history_view_about_view.cpp @@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_premium.h" #include "api/api_sending.h" #include "apiwrap.h" +#include "ayu/ayu_settings.h" #include "base/random.h" #include "base/unixtime.h" #include "ui/effects/premium_stars.h" @@ -268,6 +269,7 @@ auto GenerateChatIntro( st::defaultTextStyle, links)); }; + const auto disableGreeting = AyuSettings::getInstance().disableGreetingSticker(); const auto title = data.customPhrases() ? data.title : tr::lng_chat_intro_default_title(tr::now); @@ -275,37 +277,41 @@ auto GenerateChatIntro( ? data.description : tr::lng_chat_intro_default_message(tr::now); pushText(tr::bold(title), st::chatIntroTitleMargin); - pushText({ description }, title.isEmpty() - ? st::chatIntroTitleMargin - : st::chatIntroMargin); - const auto sticker = [=] { - using Tag = ChatHelpers::StickerLottieSize; - auto sticker = data.sticker; - if (!sticker) { - const auto api = &parent->history()->session().api(); - const auto &list = api->premium().helloStickers(); - if (!list.empty()) { - sticker = list[base::RandomIndex(list.size())]; - if (helloChosen) { - helloChosen(sticker); + if (!disableGreeting || data.customPhrases()) { + pushText({ description }, title.isEmpty() + ? st::chatIntroTitleMargin + : st::chatIntroMargin); + } + if (!disableGreeting || data.sticker) { + const auto sticker = [=] { + using Tag = ChatHelpers::StickerLottieSize; + auto sticker = data.sticker; + if (!sticker && !disableGreeting) { + const auto api = &parent->history()->session().api(); + const auto &list = api->premium().helloStickers(); + if (!list.empty()) { + sticker = list[base::RandomIndex(list.size())]; + if (helloChosen) { + helloChosen(sticker); + } } } - } - const auto send = [=] { - sendIntroSticker(sticker); + const auto send = [=] { + sendIntroSticker(sticker); + }; + return StickerInBubblePart::Data{ + .sticker = sticker, + .size = st::chatIntroStickerSize, + .cacheTag = Tag::ChatIntroHelloSticker, + .link = std::make_shared(send), + }; }; - return StickerInBubblePart::Data{ - .sticker = sticker, - .size = st::chatIntroStickerSize, - .cacheTag = Tag::ChatIntroHelloSticker, - .link = std::make_shared(send), - }; - }; - push(std::make_unique( - parent, - replacing, - sticker, - st::chatIntroStickerPadding)); + push(std::make_unique( + parent, + replacing, + sticker, + st::chatIntroStickerPadding)); + } }; } @@ -753,7 +759,7 @@ bool AboutView::refresh() { makeIntro(user); } else if (const auto stars = user->starsPerMessageChecked()) { setItem(makeStarsPerMessage(stars), nullptr); - } else { + } else if (!AyuSettings::getInstance().disableGreetingSticker()) { makeIntro(user); } return true; diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.cpp b/Telegram/SourceFiles/history/view/history_view_service_message.cpp index 7ea910a114..791670d802 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_service_message.cpp @@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_info.h" // AyuGram includes +#include "ayu/ayu_settings.h" #include "ayu/utils/telegram_helpers.h" #include "styles/style_ayu_styles.h" @@ -998,6 +999,9 @@ EmptyPainter::EmptyPainter(not_null history) , _text(st::msgMinWidth) { if (NeedAboutGroup(_history)) { fillAboutGroup(); + } else if (_history->peer->isUser() + && AyuSettings::getInstance().disableGreetingSticker()) { + SetText(_header, tr::lng_chat_intro_default_title(tr::now)); } } @@ -1049,7 +1053,33 @@ void EmptyPainter::paint( not_null st, int width, int height) { + if (_phrases.empty() && _text.isEmpty() && _header.isEmpty()) { + return; + } if (_phrases.empty() && _text.isEmpty()) { + const auto w = st::msgServiceFont->width(_header.toString()) + + st::msgPadding.left() + + st::msgPadding.right(); + const auto h = st::msgServiceFont->height + + st::msgServicePadding.top() + + st::msgServicePadding.bottom(); + const auto rect = QRect( + (width - w) / 2, + (height - h) / 2, + w, + h); + ServiceMessagePainter::PaintBubble( + p, + st->msgServiceBg(), + st->serviceBgCornersNormal(), + rect); + p.setPen(st->msgServiceFg()); + p.setFont(st::msgServiceFont->f); + p.drawTextLeft( + rect.left() + st::msgPadding.left(), + rect.top() + st::msgServicePadding.top(), + width, + _header.toString()); return; } constexpr auto kMaxTextLines = 3;