Skip to content

Commit

Permalink
finally bring back recent sticker count setting
Browse files Browse the repository at this point in the history
  • Loading branch information
xmdnx committed Jun 19, 2024
1 parent 79768ce commit b293600
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
9 changes: 2 additions & 7 deletions Telegram/Resources/langs/rabbit/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "Сделать папкой по умолчанию",
Expand Down Expand Up @@ -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
}
10 changes: 9 additions & 1 deletion Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -284,6 +286,12 @@ StickersListWidget::StickersListWidget(
refreshStickers();
}, lifetime());
}

RabbitSettings::JsonSettings::Events(
"recent_stickers_limit"
) | rpl::start_with_next([=] {
refreshStickers();
}, lifetime());
}

rpl::producer<FileChosen> StickersListWidget::chosen() const {
Expand Down Expand Up @@ -2216,7 +2224,7 @@ auto StickersListWidget::collectRecentStickers() -> std::vector<Sticker> {
_custom.reserve(cloudCount + recent.size() + customCount);

auto add = [&](not_null<DocumentData*> 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);
Expand Down
4 changes: 4 additions & 0 deletions Telegram/SourceFiles/rabbit/settings/rabbit_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ const std::map<QString, Definition, std::greater<QString>> 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, }},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,35 @@ namespace Settings {
updateStickerHeight);
updateStickerHeightLabel(::RabbitSettings::JsonSettings::GetInt("sticker_height"));

const auto recentStickersLimitLabel = container->add(
object_ptr<Ui::LabelSimple>(
container,
st::settingsAudioVolumeLabel),
st::settingsAudioVolumeLabelPadding);
const auto recentStickersLimitSlider = container->add(
object_ptr<Ui::MediaSlider>(
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"),
Expand Down

0 comments on commit b293600

Please sign in to comment.