diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index bed8ac2a8..d95996c6c 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3881,6 +3881,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "ayu_GhostModeShortcut" = "Enter with Ghost"; "ayu_SettingsWatermark" = "AyuGram developed and maintained by Radolyn Labs."; "ayu_SettingsCustomizationHint" = "After making changes to the \"Customization\" section, you must restart the application."; +"ayu_SettingsRecentStickersCount" = "Recent stickers count"; "ayu_SettingsShowID" = "Show peer ID"; "ayu_SettingsShowID_Hide" = "Hide"; "ayu_SettingsShowMessageSeconds" = "Show message seconds"; diff --git a/Telegram/SourceFiles/ayu/ayu_settings.cpp b/Telegram/SourceFiles/ayu/ayu_settings.cpp index 10d6f4d99..3fa10dc5d 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.cpp +++ b/Telegram/SourceFiles/ayu/ayu_settings.cpp @@ -128,6 +128,10 @@ namespace AyuSettings { editedMarkReactive = editedMark; } + void AyuGramSettings::set_recentStickersCount(int val) { + recentStickersCount = val; + } + void AyuGramSettings::set_showGhostToggleInDrawer(bool val) { showGhostToggleInDrawer = val; } diff --git a/Telegram/SourceFiles/ayu/ayu_settings.h b/Telegram/SourceFiles/ayu/ayu_settings.h index a96264552..a01d29857 100644 --- a/Telegram/SourceFiles/ayu/ayu_settings.h +++ b/Telegram/SourceFiles/ayu/ayu_settings.h @@ -33,6 +33,7 @@ namespace AyuSettings { // ~ Customization deletedMark = "🧹"; editedMark = tr::lng_edited(tr::now); + recentStickersCount = 20; showGhostToggleInDrawer = true; /* @@ -69,6 +70,8 @@ namespace AyuSettings { QS_FIELD(QString, editedMark) + QS_FIELD(int, recentStickersCount) + QS_FIELD(bool, showGhostToggleInDrawer) QS_FIELD(int, showPeerId) @@ -92,6 +95,7 @@ namespace AyuSettings { void set_deletedMark(QString val); void set_editedMark(QString val); + void set_recentStickersCount(int val); void set_showGhostToggleInDrawer(bool val); void set_showPeerId(int val); void set_showMessageSeconds(bool val); diff --git a/Telegram/SourceFiles/ayu/settings/settings_ayu.cpp b/Telegram/SourceFiles/ayu/settings/settings_ayu.cpp index 6b3bd79d2..05cbc5cc7 100644 --- a/Telegram/SourceFiles/ayu/settings/settings_ayu.cpp +++ b/Telegram/SourceFiles/ayu/settings/settings_ayu.cpp @@ -11,7 +11,6 @@ #include "ui/widgets/buttons.h" #include "ui/widgets/checkbox.h" #include "boxes/connection_box.h" -#include "ui/boxes/confirm_box.h" #include "platform/platform_specific.h" #include "window/window_session_controller.h" #include "lang/lang_instance.h" @@ -22,6 +21,7 @@ #include "styles/style_settings.h" #include "apiwrap.h" #include "api/api_blocked_peers.h" +#include "ui/widgets/continuous_sliders.h" namespace Settings { @@ -207,6 +207,8 @@ namespace Settings { Ui::show(std::move(box)); }); + SetupRecentStickersLimitSlider(container); + SetupShowPeerId(container, controller); AddButton( @@ -274,6 +276,46 @@ namespace Settings { }); } + void Ayu::SetupRecentStickersLimitSlider(not_null container) { + auto settings = &AyuSettings::getInstance(); + + container->add( + CreateButton( + container, + tr::ayu_SettingsRecentStickersCount(), + st::settingsButtonNoIcon) + ); + + auto recentStickersLimitSlider = MakeSliderWithLabel( + container, + st::settingsScale, + st::settingsScaleLabel, + st::normalFont->spacew * 2, + st::settingsScaleLabel.style.font->width("300%")); + container->add( + std::move(recentStickersLimitSlider.widget), + st::settingsScalePadding); + const auto slider = recentStickersLimitSlider.slider; + const auto label = recentStickersLimitSlider.label; + + const auto updateLabel = [=](int amount) { + label->setText(QString::number(amount)); + }; + updateLabel(settings->recentStickersCount); + + slider->setPseudoDiscrete( + 40 + 1, // thx tg + [=](int amount) { return amount; }, + settings->recentStickersCount, + [=](int amount) { updateLabel(amount); }, + [=](int amount) { + updateLabel(amount); + + settings->set_recentStickersCount(amount); + AyuSettings::save(); + }); + } + void Ayu::SetupAyuGramSettings(not_null container, not_null controller) { AddSkip(container); SetupGhostEssentials(container); diff --git a/Telegram/SourceFiles/ayu/settings/settings_ayu.h b/Telegram/SourceFiles/ayu/settings/settings_ayu.h index 38a5a13bb..c5600ef58 100644 --- a/Telegram/SourceFiles/ayu/settings/settings_ayu.h +++ b/Telegram/SourceFiles/ayu/settings/settings_ayu.h @@ -22,7 +22,9 @@ namespace Settings { void SetupSpyEssentials(not_null container); void SetupQoLToggles(not_null container); void SetupCustomization(not_null container, not_null controller); + void SetupShowPeerId(not_null container, not_null controller); + void SetupRecentStickersLimitSlider(not_null container); void SetupAyuGramSettings(not_null container, not_null null); void setupContent(not_null controller); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 349980b6c..46f3f3d4e 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -54,6 +54,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include +#include "ayu/ayu_settings.h" + namespace ChatHelpers { namespace { @@ -2089,8 +2091,10 @@ auto StickersListWidget::collectRecentStickers() -> std::vector { result.reserve(cloudCount + recent.size() + customCount); _custom.reserve(cloudCount + recent.size() + customCount); + auto settings = &AyuSettings::getInstance(); + auto add = [&](not_null document, bool custom) { - if (result.size() >= kRecentDisplayLimit) { + if (result.size() >= settings->recentStickersCount) { return; } const auto i = ranges::find(result, document, &Sticker::document); diff --git a/ayu-scripts/desktop-specific.json b/ayu-scripts/desktop-specific.json index 5d55374ed..b2cc4edcf 100644 --- a/ayu-scripts/desktop-specific.json +++ b/ayu-scripts/desktop-specific.json @@ -1,6 +1,7 @@ { "SettingsWatermark": "AyuGram developed and maintained by Radolyn Labs.", "SettingsCustomizationHint": "After making changes to the \"Customization\" section, you must restart the application.", + "SettingsRecentStickersCount": "Recent stickers count", "SettingsShowID": "Show peer ID", "SettingsShowID_Hide": "Hide", "SettingsShowMessageSeconds": "Show message seconds",