From b2936003235a3f293343938f2e8425dcb537a394 Mon Sep 17 00:00:00 2001 From: xmdnx Date: Wed, 19 Jun 2024 12:19:10 +0300 Subject: [PATCH] finally bring back recent sticker count setting --- Telegram/Resources/langs/rabbit/ru.json | 9 ++---- .../chat_helpers/stickers_list_widget.cpp | 10 ++++++- .../rabbit/settings/rabbit_settings.cpp | 4 +++ .../settings_menu/sections/rabbit_chats.cpp | 29 +++++++++++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/Telegram/Resources/langs/rabbit/ru.json b/Telegram/Resources/langs/rabbit/ru.json index 8542c78485fc8f..9a43f3773a3b66 100644 --- a/Telegram/Resources/langs/rabbit/ru.json +++ b/Telegram/Resources/langs/rabbit/ru.json @@ -87,13 +87,6 @@ "rtg_settings_adaptive_bubbles": "Адаптивная ширина сообщений", "rtg_settings_disable_sound_from_tray": "Отключить звук", "rtg_settings_enable_sound_from_tray": "Включить звук", - "rtg_settings_recent_stickers_limit.zero": "Недавние стикеры: показывать {count} стикеров", - "rtg_settings_recent_stickers_limit.one": "Недавние стикеры: показывать {count} стикер", - "rtg_settings_recent_stickers_limit.two": "Недавние стикеры: показывать {count} стикеров", - "rtg_settings_recent_stickers_limit.few": "Недавние стикеры: показывать {count} стикера", - "rtg_settings_recent_stickers_limit.many": "Недавние стикеры: показывать {count} стикеров", - "rtg_settings_recent_stickers_limit.other": "Недавние стикеры: показывать {count} стикеров", - "rtg_settings_recent_stickers_limit_none": "Недавние стикеры: скрыть все", "rtg_filters_default": "Папка по умолчанию", "rtg_filters_context_edit_all": "Изменить папки", "rtg_filters_context_make_default": "Сделать папкой по умолчанию", @@ -289,5 +282,7 @@ "rtg_quiet_3h": "...на 3 часа", "rtg_quiet_8h": "...на 8 часов", "rtg_quiet_24h": "...на 24 часа", + "rtg_settings_recent_stickers_limit": "Недавние стикеры: показывать {count}", + "rtg_settings_recent_stickers_limit_none": "Недавние стикеры: скрыть все", "dummy_last_string": null } \ No newline at end of file diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 9fee6940533488..a4a419fd70b1a4 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -7,6 +7,8 @@ For license and copyright information please follow this link: */ #include "chat_helpers/stickers_list_widget.h" +#include "rabbit/settings/rabbit_settings.h" + #include "core/application.h" #include "data/data_document.h" #include "data/data_document_media.h" @@ -284,6 +286,12 @@ StickersListWidget::StickersListWidget( refreshStickers(); }, lifetime()); } + + RabbitSettings::JsonSettings::Events( + "recent_stickers_limit" + ) | rpl::start_with_next([=] { + refreshStickers(); + }, lifetime()); } rpl::producer StickersListWidget::chosen() const { @@ -2216,7 +2224,7 @@ auto StickersListWidget::collectRecentStickers() -> std::vector { _custom.reserve(cloudCount + recent.size() + customCount); auto add = [&](not_null document, bool custom) { - if (result.size() >= kRecentDisplayLimit) { + if (result.size() >= RabbitSettings::JsonSettings::GetInt("recent_stickers_limit")) { return; } const auto i = ranges::find(result, document, &Sticker::document); diff --git a/Telegram/SourceFiles/rabbit/settings/rabbit_settings.cpp b/Telegram/SourceFiles/rabbit/settings/rabbit_settings.cpp index 23743e719e7412..07937e5132906b 100644 --- a/Telegram/SourceFiles/rabbit/settings/rabbit_settings.cpp +++ b/Telegram/SourceFiles/rabbit/settings/rabbit_settings.cpp @@ -279,6 +279,10 @@ const std::map> DefinitionMap { .type = SettingType::IntSetting, .defaultValue = 170, .limitHandler = IntLimit(64, 256, 170), }}, + { "recent_stickers_limit", { + .type = SettingType::IntSetting, + .defaultValue = 20, + .limitHandler = IntLimit(0, 200, 20), }}, { "show_seconds", { .type = SettingType::BoolSetting, .defaultValue = false, }}, diff --git a/Telegram/SourceFiles/rabbit/settings_menu/sections/rabbit_chats.cpp b/Telegram/SourceFiles/rabbit/settings_menu/sections/rabbit_chats.cpp index da99ab6f609c86..61b50b32a87a92 100644 --- a/Telegram/SourceFiles/rabbit/settings_menu/sections/rabbit_chats.cpp +++ b/Telegram/SourceFiles/rabbit/settings_menu/sections/rabbit_chats.cpp @@ -99,6 +99,35 @@ namespace Settings { updateStickerHeight); updateStickerHeightLabel(::RabbitSettings::JsonSettings::GetInt("sticker_height")); + const auto recentStickersLimitLabel = container->add( + object_ptr( + container, + st::settingsAudioVolumeLabel), + st::settingsAudioVolumeLabelPadding); + const auto recentStickersLimitSlider = container->add( + object_ptr( + container, + st::settingsAudioVolumeSlider), + st::settingsAudioVolumeSliderPadding); + const auto updateRecentStickersLimitLabel = [=](int value) { + recentStickersLimitLabel->setText( + (value == 0) + ? ktr("rtg_settings_recent_stickers_limit_none") + : ktr("rtg_settings_recent_stickers_limit", { "count", QString::number(value) }) ); + }; + const auto updateRecentStickersLimitHeight = [=](int value) { + updateRecentStickersLimitLabel(value); + ::RabbitSettings::JsonSettings::Set("recent_stickers_limit", value); + ::RabbitSettings::JsonSettings::Write(); + }; + recentStickersLimitSlider->resize(st::settingsAudioVolumeSlider.seekSize); + recentStickersLimitSlider->setPseudoDiscrete( + 201, + [](int val) { return val; }, + ::RabbitSettings::JsonSettings::GetInt("recent_stickers_limit"), + updateRecentStickersLimitHeight); + updateRecentStickersLimitLabel(::RabbitSettings::JsonSettings::GetInt("recent_stickers_limit")); + AddButtonWithIcon( container, rktr("rtg_settings_show_seconds"),