Skip to content

Commit

Permalink
feat: disable custom backgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyZavar committed Feb 22, 2024
1 parent e580640 commit 039795c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 5 additions & 0 deletions Telegram/SourceFiles/ayu/ayu_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ AyuGramSettings::AyuGramSettings() {
// ~ QoL toggles
disableAds = true;
disableStories = false;
disableCustomBackgrounds = true;
collapseSimilarChannels = true;
hideSimilarChannels = false;

Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/ayu/ayu_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class AyuGramSettings

bool disableAds;
bool disableStories;
bool disableCustomBackgrounds;
bool collapseSimilarChannels;
bool hideSimilarChannels;

Expand Down Expand Up @@ -94,6 +95,7 @@ class AyuGramSettings

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);

Expand Down Expand Up @@ -153,6 +155,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
saveMessagesHistory,
disableAds,
disableStories,
disableCustomBackgrounds,
collapseSimilarChannels,
hideSimilarChannels,
uploadSpeedBoost,
Expand Down
19 changes: 19 additions & 0 deletions Telegram/SourceFiles/ayu/ui/settings/settings_ayu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
10 changes: 10 additions & 0 deletions Telegram/SourceFiles/window/section_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ For license and copyright information please follow this link:

#include <rpl/range.h>

// AyuGram includes
#include "ayu/ayu_settings.h"


namespace Window {
namespace {

Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 039795c

Please sign in to comment.