feat: disable custom backgrounds

This commit is contained in:
AlexeyZavar 2024-02-22 22:46:46 +03:00
parent e580640adc
commit 039795cab8
5 changed files with 43 additions and 0 deletions

View file

@ -4835,12 +4835,18 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ayu_KeepAliveService" = "AyuGram Push Service";
"ayu_DisableAds" = "Disable ads";
"ayu_DisableStories" = "Disable stories";
"ayu_DisableCustomBackgrounds" = "Disable custom backgrounds";
"ayu_DisableNotificationsDelay" = "Disable notify delay";
"ayu_LocalPremium" = "Local Telegram Premium";
"ayu_CopyUsernameAsLink" = "Copy username as link";
"ayu_CustomizationHeader" = "Customization";
"ayu_DeletedMarkText" = "Deleted mark";
"ayu_DeletedMarkNothing" = "Nothing";
"ayu_DeletedMarkTrashBin" = "Trash Bin";
"ayu_DeletedMarkCross" = "Cross";
"ayu_DeletedMarkEyeCrossed" = "Eye crossed";
"ayu_EditedMarkText" = "Edited mark";
"ayu_SemiTransparentDeletedMessages" = "Semi-transparent deleted messages";
"ayu_HideNotificationCounters" = "Hide notification counters";
"ayu_HideAllChats" = "Hide \"All chats\" folder";
"ayu_ShowGhostToggleInDrawer" = "Show ghost mode toggle";

View file

@ -200,6 +200,7 @@ AyuGramSettings::AyuGramSettings() {
// ~ QoL toggles
disableAds = true;
disableStories = false;
disableCustomBackgrounds = true;
collapseSimilarChannels = true;
hideSimilarChannels = false;
@ -326,6 +327,10 @@ void AyuGramSettings::set_disableStories(bool val) {
disableStories = val;
}
void AyuGramSettings::set_disableCustomBackgrounds(bool val) {
disableCustomBackgrounds = val;
}
void AyuGramSettings::set_collapseSimilarChannels(bool val) {
collapseSimilarChannels = val;
}

View file

@ -33,6 +33,7 @@ public:
bool disableAds;
bool disableStories;
bool disableCustomBackgrounds;
bool collapseSimilarChannels;
bool hideSimilarChannels;
@ -94,6 +95,7 @@ public:
void set_disableAds(bool val);
void set_disableStories(bool val);
void set_disableCustomBackgrounds(bool val);
void set_collapseSimilarChannels(bool val);
void set_hideSimilarChannels(bool val);
@ -153,6 +155,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
saveMessagesHistory,
disableAds,
disableStories,
disableCustomBackgrounds,
collapseSimilarChannels,
hideSimilarChannels,
uploadSpeedBoost,

View file

@ -595,6 +595,25 @@ void SetupQoLToggles(not_null<Ui::VerticalLayout*> container) {
},
container->lifetime());
AddButtonWithIcon(
container,
tr::ayu_DisableCustomBackgrounds(),
st::settingsButtonNoIcon
)->toggleOn(
rpl::single(settings->disableCustomBackgrounds)
)->toggledValue(
) | rpl::filter(
[=](bool enabled)
{
return (enabled != settings->disableCustomBackgrounds);
}) | start_with_next(
[=](bool enabled)
{
settings->set_disableCustomBackgrounds(enabled);
AyuSettings::save();
},
container->lifetime());
AddButtonWithIcon(
container,
tr::ayu_SimpleQuotesAndReplies(),

View file

@ -32,6 +32,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <rpl/range.h>
// AyuGram includes
#include "ayu/ayu_settings.h"
namespace Window {
namespace {
@ -471,6 +475,12 @@ auto ChatThemeValueFromPeer(
peer
) | rpl::map([=](ResolvedTheme resolved)
-> rpl::producer<std::shared_ptr<Ui::ChatTheme>> {
const auto settings = &AyuSettings::getInstance();
// this check ensures that background is not a pattern wallpaper in a private chat
if (settings->disableCustomBackgrounds && resolved.paper && resolved.paper->media) {
resolved.paper = std::nullopt;
}
if (!resolved.theme && !resolved.paper) {
return rpl::single(controller->defaultChatTheme());
}