[Option][GUI] Recent stickers limit
This commit is contained in:
parent
e029f6d805
commit
9519d801aa
5 changed files with 59 additions and 2 deletions
|
|
@ -53,6 +53,15 @@
|
|||
"ktg_settings_ffmpeg_multithread": "Multithread video decoding",
|
||||
"ktg_settings_ffmpeg_multithread_about": "When enabled, CPU and RAM consumption is higher, video decodes faster. When disabled, CPU and RAM consumption is lower, video decodes slower. The more CPU cores you have, the more RAM consumption you have when this option is enabled. You can set exact number of threads in the JSON configuration file.",
|
||||
"ktg_settings_adaptive_bubbles": "Adaptive bubbles",
|
||||
"ktg_settings_recent_stickers_limit": {
|
||||
"zero": "Recent stickers: show {count} stickers",
|
||||
"one": "Recent stickers: show {count} sticker",
|
||||
"two": "Recent stickers: show {count} stickers",
|
||||
"few": "Recent stickers: show {count} stickers",
|
||||
"many": "Recent stickers: show {count} stickers",
|
||||
"other": "Recent stickers: show {count} stickers"
|
||||
},
|
||||
"ktg_settings_recent_stickers_limit_none": "Recent stickers: hide all",
|
||||
"ktg_settings_filters": "Folders",
|
||||
"ktg_settings_messages": "Messages",
|
||||
"ktg_settings_chat_id": "Chat ID in profile",
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "chat_helpers/stickers_list_widget.h"
|
||||
|
||||
#include "kotato/kotato_settings.h"
|
||||
#include "core/application.h"
|
||||
#include "data/data_document.h"
|
||||
#include "data/data_document_media.h"
|
||||
|
|
@ -59,7 +60,6 @@ namespace ChatHelpers {
|
|||
namespace {
|
||||
|
||||
constexpr auto kSearchRequestDelay = 400;
|
||||
constexpr auto kRecentDisplayLimit = 20;
|
||||
constexpr auto kPreloadOfficialPages = 4;
|
||||
constexpr auto kOfficialLoadLimit = 40;
|
||||
constexpr auto kMinRepaintDelay = crl::time(33);
|
||||
|
|
@ -271,6 +271,12 @@ StickersListWidget::StickersListWidget(
|
|||
) | rpl::start_with_next([=] {
|
||||
refreshStickers();
|
||||
}, lifetime());
|
||||
|
||||
::Kotato::JsonSettings::Events(
|
||||
"recent_stickers_limit"
|
||||
) | rpl::start_with_next([=] {
|
||||
refreshStickers();
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
rpl::producer<FileChosen> StickersListWidget::chosen() const {
|
||||
|
|
@ -1822,6 +1828,10 @@ void StickersListWidget::removeRecentSticker(int section, int index) {
|
|||
}
|
||||
}
|
||||
}
|
||||
Api::ToggleRecentSticker(
|
||||
document,
|
||||
Data::FileOriginStickerSet(Data::Stickers::RecentSetId, 0),
|
||||
false);
|
||||
if (refresh) {
|
||||
refreshRecentStickers();
|
||||
updateSelected();
|
||||
|
|
@ -2132,7 +2142,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() >= ::Kotato::JsonSettings::GetInt("recent_stickers_limit")) {
|
||||
return;
|
||||
}
|
||||
const auto i = ranges::find(result, document, &Sticker::document);
|
||||
|
|
|
|||
|
|
@ -429,6 +429,8 @@ private:
|
|||
rpl::event_stream<> _scrollUpdated;
|
||||
rpl::event_stream<TabbedSelector::Action> _choosingUpdated;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::BoxContent> MakeConfirmRemoveSetBox(
|
||||
|
|
|
|||
|
|
@ -289,6 +289,10 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
|
|||
.type = SettingType::IntSetting,
|
||||
.defaultValue = 0,
|
||||
.limitHandler = IntLimitMin(0) }},
|
||||
{ "recent_stickers_limit", {
|
||||
.type = SettingType::IntSetting,
|
||||
.defaultValue = 20,
|
||||
.limitHandler = IntLimit(0, 200, 20), }},
|
||||
};
|
||||
|
||||
using OldOptionKey = QString;
|
||||
|
|
|
|||
|
|
@ -88,6 +88,38 @@ void SetupKotatoChats(
|
|||
Ui::AddSkip(container);
|
||||
Ui::AddSubsectionTitle(container, rktr("ktg_settings_chats"));
|
||||
|
||||
const auto recentStickersLimitLabel = container->add(
|
||||
object_ptr<Ui::LabelSimple>(
|
||||
container,
|
||||
st::ktgSettingsSliderLabel),
|
||||
st::groupCallDelayLabelMargin);
|
||||
const auto recentStickersLimitSlider = container->add(
|
||||
object_ptr<Ui::MediaSlider>(
|
||||
container,
|
||||
st::defaultContinuousSlider),
|
||||
st::localStorageLimitMargin);
|
||||
const auto updateRecentStickersLimitLabel = [=](int value) {
|
||||
if (value == 0) {
|
||||
recentStickersLimitLabel->setText(
|
||||
ktr("ktg_settings_recent_stickers_limit_none"));
|
||||
} else {
|
||||
recentStickersLimitLabel->setText(
|
||||
ktr("ktg_settings_recent_stickers_limit", value, { "count", QString::number(value) }));
|
||||
}
|
||||
};
|
||||
const auto updateRecentStickersLimitHeight = [=](int value) {
|
||||
updateRecentStickersLimitLabel(value);
|
||||
::Kotato::JsonSettings::Set("recent_stickers_limit", value);
|
||||
::Kotato::JsonSettings::Write();
|
||||
};
|
||||
recentStickersLimitSlider->resize(st::defaultContinuousSlider.seekSize);
|
||||
recentStickersLimitSlider->setPseudoDiscrete(
|
||||
201,
|
||||
[](int val) { return val; },
|
||||
::Kotato::JsonSettings::GetInt("recent_stickers_limit"),
|
||||
updateRecentStickersLimitHeight);
|
||||
updateRecentStickersLimitLabel(::Kotato::JsonSettings::GetInt("recent_stickers_limit"));
|
||||
|
||||
SettingsMenuJsonSwitch(ktg_settings_disable_up_edit, disable_up_edit);
|
||||
SettingsMenuJsonSwitch(ktg_settings_always_show_scheduled, always_show_scheduled);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue