feat: add disable Greeting Sticker

This commit is contained in:
Ireina
2026-04-30 00:19:57 +08:00
committed by AlexeyZavar
parent f3f6b349ea
commit 21775bd509
7 changed files with 85 additions and 30 deletions
+1
View File
@@ -8050,6 +8050,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_HideReactionsInGroups" = "Groups"; "ayu_HideReactionsInGroups" = "Groups";
"ayu_HideReactionsInPrivateChats" = "Private Chats"; "ayu_HideReactionsInPrivateChats" = "Private Chats";
"ayu_QuickAdminShortcuts" = "Quick Admin Shortcuts"; "ayu_QuickAdminShortcuts" = "Quick Admin Shortcuts";
"ayu_DisableGreetingSticker" = "Disable Greeting Sticker";
"ayu_TranslationProvider" = "Translation Provider"; "ayu_TranslationProvider" = "Translation Provider";
"ayu_LinksHeader" = "Links"; "ayu_LinksHeader" = "Links";
"ayu_LinksChannel" = "Channel"; "ayu_LinksChannel" = "Channel";
@@ -963,6 +963,12 @@ void AyuSettings::setQuickAdminShortcuts(bool val) {
save(); save();
} }
void AyuSettings::setDisableGreetingSticker(bool val) {
if (_disableGreetingSticker.current() == val) return;
_disableGreetingSticker = val;
save();
}
void AyuSettings::setShowPeerId(PeerIdDisplay val) { void AyuSettings::setShowPeerId(PeerIdDisplay val) {
if (_showPeerId.current() == val) return; if (_showPeerId.current() == val) return;
_showPeerId = val; _showPeerId = val;
@@ -1129,6 +1135,7 @@ void to_json(nlohmann::json &j, const AyuSettings &s) {
{"hideAllChatsFolder", s._hideAllChatsFolder.current()}, {"hideAllChatsFolder", s._hideAllChatsFolder.current()},
{"channelBottomButton", s._channelBottomButton.current()}, {"channelBottomButton", s._channelBottomButton.current()},
{"quickAdminShortcuts", s._quickAdminShortcuts.current()}, {"quickAdminShortcuts", s._quickAdminShortcuts.current()},
{"disableGreetingSticker", s._disableGreetingSticker.current()},
{"showPeerId", s._showPeerId.current()}, {"showPeerId", s._showPeerId.current()},
{"showMessageSeconds", s._showMessageSeconds.current()}, {"showMessageSeconds", s._showMessageSeconds.current()},
{"showMessageShot", s._showMessageShot.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._hideAllChatsFolder = j.value("hideAllChatsFolder", defaults._hideAllChatsFolder.current());
s._channelBottomButton = j.value("channelBottomButton", defaults._channelBottomButton.current()); s._channelBottomButton = j.value("channelBottomButton", defaults._channelBottomButton.current());
s._quickAdminShortcuts = j.value("quickAdminShortcuts", defaults._quickAdminShortcuts.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._showPeerId = j.value("showPeerId", defaults._showPeerId.current());
s._showMessageSeconds = j.value("showMessageSeconds", defaults._showMessageSeconds.current()); s._showMessageSeconds = j.value("showMessageSeconds", defaults._showMessageSeconds.current());
s._showMessageShot = j.value("showMessageShot", defaults._showMessageShot.current()); s._showMessageShot = j.value("showMessageShot", defaults._showMessageShot.current());
+5
View File
@@ -337,6 +337,7 @@ public:
[[nodiscard]] bool hideAllChatsFolder() const { return _hideAllChatsFolder.current(); } [[nodiscard]] bool hideAllChatsFolder() const { return _hideAllChatsFolder.current(); }
[[nodiscard]] ChannelBottomButton channelBottomButton() const { return _channelBottomButton.current(); } [[nodiscard]] ChannelBottomButton channelBottomButton() const { return _channelBottomButton.current(); }
[[nodiscard]] bool quickAdminShortcuts() const { return _quickAdminShortcuts.current(); } [[nodiscard]] bool quickAdminShortcuts() const { return _quickAdminShortcuts.current(); }
[[nodiscard]] bool disableGreetingSticker() const { return _disableGreetingSticker.current(); }
[[nodiscard]] PeerIdDisplay showPeerId() const { return _showPeerId.current(); } [[nodiscard]] PeerIdDisplay showPeerId() const { return _showPeerId.current(); }
[[nodiscard]] bool showMessageSeconds() const { return _showMessageSeconds.current(); } [[nodiscard]] bool showMessageSeconds() const { return _showMessageSeconds.current(); }
[[nodiscard]] bool showMessageShot() const { return _showMessageShot.current(); } [[nodiscard]] bool showMessageShot() const { return _showMessageShot.current(); }
@@ -421,6 +422,7 @@ public:
void setHideAllChatsFolder(bool val); void setHideAllChatsFolder(bool val);
void setChannelBottomButton(ChannelBottomButton val); void setChannelBottomButton(ChannelBottomButton val);
void setQuickAdminShortcuts(bool val); void setQuickAdminShortcuts(bool val);
void setDisableGreetingSticker(bool val);
void setShowPeerId(PeerIdDisplay val); void setShowPeerId(PeerIdDisplay val);
void setShowMessageSeconds(bool val); void setShowMessageSeconds(bool val);
void setShowMessageShot(bool val); void setShowMessageShot(bool val);
@@ -577,6 +579,8 @@ public:
[[nodiscard]] rpl::producer<ChannelBottomButton> channelBottomButtonChanges() const { return _channelBottomButton.changes(); } [[nodiscard]] rpl::producer<ChannelBottomButton> channelBottomButtonChanges() const { return _channelBottomButton.changes(); }
[[nodiscard]] rpl::producer<bool> quickAdminShortcutsValue() const { return _quickAdminShortcuts.value(); } [[nodiscard]] rpl::producer<bool> quickAdminShortcutsValue() const { return _quickAdminShortcuts.value(); }
[[nodiscard]] rpl::producer<bool> quickAdminShortcutsChanges() const { return _quickAdminShortcuts.changes(); } [[nodiscard]] rpl::producer<bool> quickAdminShortcutsChanges() const { return _quickAdminShortcuts.changes(); }
[[nodiscard]] rpl::producer<bool> disableGreetingStickerValue() const { return _disableGreetingSticker.value(); }
[[nodiscard]] rpl::producer<bool> disableGreetingStickerChanges() const { return _disableGreetingSticker.changes(); }
[[nodiscard]] rpl::producer<PeerIdDisplay> showPeerIdValue() const { return _showPeerId.value(); } [[nodiscard]] rpl::producer<PeerIdDisplay> showPeerIdValue() const { return _showPeerId.value(); }
[[nodiscard]] rpl::producer<PeerIdDisplay> showPeerIdChanges() const { return _showPeerId.changes(); } [[nodiscard]] rpl::producer<PeerIdDisplay> showPeerIdChanges() const { return _showPeerId.changes(); }
[[nodiscard]] rpl::producer<bool> showMessageSecondsValue() const { return _showMessageSeconds.value(); } [[nodiscard]] rpl::producer<bool> showMessageSecondsValue() const { return _showMessageSeconds.value(); }
@@ -683,6 +687,7 @@ private:
rpl::variable<bool> _hideAllChatsFolder = false; rpl::variable<bool> _hideAllChatsFolder = false;
rpl::variable<ChannelBottomButton> _channelBottomButton = ChannelBottomButton::DiscussWithFallback; rpl::variable<ChannelBottomButton> _channelBottomButton = ChannelBottomButton::DiscussWithFallback;
rpl::variable<bool> _quickAdminShortcuts = true; rpl::variable<bool> _quickAdminShortcuts = true;
rpl::variable<bool> _disableGreetingSticker = false;
rpl::variable<PeerIdDisplay> _showPeerId = PeerIdDisplay::BotApi; rpl::variable<PeerIdDisplay> _showPeerId = PeerIdDisplay::BotApi;
rpl::variable<bool> _showMessageSeconds = false; rpl::variable<bool> _showMessageSeconds = false;
rpl::variable<bool> _showMessageShot = true; rpl::variable<bool> _showMessageShot = true;
@@ -204,7 +204,6 @@ void BuildAppearance(SectionBuilder &builder, AyuSectionBuilder &ayu) {
.getter = &AyuSettings::disableCustomBackgrounds, .getter = &AyuSettings::disableCustomBackgrounds,
.setter = &AyuSettings::setDisableCustomBackgrounds, .setter = &AyuSettings::setDisableCustomBackgrounds,
}); });
ayu.addSettingToggle({ ayu.addSettingToggle({
.id = u"ayu/hidePremiumStatuses"_q, .id = u"ayu/hidePremiumStatuses"_q,
.title = tr::ayu_HidePremiumStatuses(), .title = tr::ayu_HidePremiumStatuses(),
@@ -117,6 +117,12 @@ void BuildGroupsAndChannels(SectionBuilder &builder, AyuSectionBuilder &ayu) {
.getter = &AyuSettings::quickAdminShortcuts, .getter = &AyuSettings::quickAdminShortcuts,
.setter = &AyuSettings::setQuickAdminShortcuts, .setter = &AyuSettings::setQuickAdminShortcuts,
}); });
ayu.addSettingToggle({
.id = u"ayu/disableGreetingSticker"_q,
.title = tr::ayu_DisableGreetingSticker(),
.getter = &AyuSettings::disableGreetingSticker,
.setter = &AyuSettings::setDisableGreetingSticker,
});
ayu.addSettingToggle({ ayu.addSettingToggle({
.id = u"ayu/showMessageShot"_q, .id = u"ayu/showMessageShot"_q,
.title = tr::ayu_SettingsShowMessageShot(), .title = tr::ayu_SettingsShowMessageShot(),
@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_premium.h" #include "api/api_premium.h"
#include "api/api_sending.h" #include "api/api_sending.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "ayu/ayu_settings.h"
#include "base/random.h" #include "base/random.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "ui/effects/premium_stars.h" #include "ui/effects/premium_stars.h"
@@ -268,6 +269,7 @@ auto GenerateChatIntro(
st::defaultTextStyle, st::defaultTextStyle,
links)); links));
}; };
const auto disableGreeting = AyuSettings::getInstance().disableGreetingSticker();
const auto title = data.customPhrases() const auto title = data.customPhrases()
? data.title ? data.title
: tr::lng_chat_intro_default_title(tr::now); : tr::lng_chat_intro_default_title(tr::now);
@@ -275,37 +277,41 @@ auto GenerateChatIntro(
? data.description ? data.description
: tr::lng_chat_intro_default_message(tr::now); : tr::lng_chat_intro_default_message(tr::now);
pushText(tr::bold(title), st::chatIntroTitleMargin); pushText(tr::bold(title), st::chatIntroTitleMargin);
pushText({ description }, title.isEmpty() if (!disableGreeting || data.customPhrases()) {
? st::chatIntroTitleMargin pushText({ description }, title.isEmpty()
: st::chatIntroMargin); ? st::chatIntroTitleMargin
const auto sticker = [=] { : st::chatIntroMargin);
using Tag = ChatHelpers::StickerLottieSize; }
auto sticker = data.sticker; if (!disableGreeting || data.sticker) {
if (!sticker) { const auto sticker = [=] {
const auto api = &parent->history()->session().api(); using Tag = ChatHelpers::StickerLottieSize;
const auto &list = api->premium().helloStickers(); auto sticker = data.sticker;
if (!list.empty()) { if (!sticker && !disableGreeting) {
sticker = list[base::RandomIndex(list.size())]; const auto api = &parent->history()->session().api();
if (helloChosen) { const auto &list = api->premium().helloStickers();
helloChosen(sticker); if (!list.empty()) {
sticker = list[base::RandomIndex(list.size())];
if (helloChosen) {
helloChosen(sticker);
}
} }
} }
} const auto send = [=] {
const auto send = [=] { sendIntroSticker(sticker);
sendIntroSticker(sticker); };
return StickerInBubblePart::Data{
.sticker = sticker,
.size = st::chatIntroStickerSize,
.cacheTag = Tag::ChatIntroHelloSticker,
.link = std::make_shared<LambdaClickHandler>(send),
};
}; };
return StickerInBubblePart::Data{ push(std::make_unique<StickerInBubblePart>(
.sticker = sticker, parent,
.size = st::chatIntroStickerSize, replacing,
.cacheTag = Tag::ChatIntroHelloSticker, sticker,
.link = std::make_shared<LambdaClickHandler>(send), st::chatIntroStickerPadding));
}; }
};
push(std::make_unique<StickerInBubblePart>(
parent,
replacing,
sticker,
st::chatIntroStickerPadding));
}; };
} }
@@ -753,7 +759,7 @@ bool AboutView::refresh() {
makeIntro(user); makeIntro(user);
} else if (const auto stars = user->starsPerMessageChecked()) { } else if (const auto stars = user->starsPerMessageChecked()) {
setItem(makeStarsPerMessage(stars), nullptr); setItem(makeStarsPerMessage(stars), nullptr);
} else { } else if (!AyuSettings::getInstance().disableGreetingSticker()) {
makeIntro(user); makeIntro(user);
} }
return true; return true;
@@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_info.h" #include "styles/style_info.h"
// AyuGram includes // AyuGram includes
#include "ayu/ayu_settings.h"
#include "ayu/utils/telegram_helpers.h" #include "ayu/utils/telegram_helpers.h"
#include "styles/style_ayu_styles.h" #include "styles/style_ayu_styles.h"
@@ -998,6 +999,9 @@ EmptyPainter::EmptyPainter(not_null<History*> history)
, _text(st::msgMinWidth) { , _text(st::msgMinWidth) {
if (NeedAboutGroup(_history)) { if (NeedAboutGroup(_history)) {
fillAboutGroup(); 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<const Ui::ChatStyle*> st, not_null<const Ui::ChatStyle*> st,
int width, int width,
int height) { int height) {
if (_phrases.empty() && _text.isEmpty() && _header.isEmpty()) {
return;
}
if (_phrases.empty() && _text.isEmpty()) { 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; return;
} }
constexpr auto kMaxTextLines = 3; constexpr auto kMaxTextLines = 3;