Added "Apply to sticker width" option

This commit is contained in:
Eric Kotato 2020-05-06 02:27:04 +03:00
parent 702e2bf7e8
commit b2ef34c5d4
9 changed files with 58 additions and 1 deletions

View file

@ -2398,6 +2398,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ktg_settings_chats" = "Chats";
"ktg_settings_sticker_height" = "Sticker height: {pixels}px";
"ktg_settings_sticker_scale_both" = "Apply to sticker width";
"ktg_settings_sticker_scale_both_about" = "When enabled, sticker maximum width will be changed along with sticker height.";
"ktg_settings_emoji_outline" = "Big emoji outline";
"ktg_settings_disable_up_edit" = "Disable edit by Up key";

View file

@ -41,6 +41,8 @@
"ktg_pinned_message_hide": "Скрыть закреплённое сообщение",
"ktg_settings_chats": "Чаты",
"ktg_settings_sticker_height": "Высота стикеров: {pixels} пикс.",
"ktg_settings_sticker_scale_both": "Применять к ширине стикера",
"ktg_settings_sticker_scale_both_about": "При включении максимальная ширина стикера будет изменяться вместе с высотой.",
"ktg_settings_emoji_outline": "Обводка у больших эмодзи",
"ktg_settings_disable_up_edit": "Отключить редактирование по «Вверх»",
"ktg_settings_always_show_scheduled": "Всегда показывать отложенные",

View file

@ -522,6 +522,13 @@ HistoryWidget::HistoryWidget(
});
}, lifetime());
StickerScaleBothChanges(
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
updateHistoryGeometry();
});
}, lifetime());
AdaptiveBubblesChanges(
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {

View file

@ -37,6 +37,11 @@ UnwrappedMedia::UnwrappedMedia(
) | rpl::start_with_next([=] {
history()->owner().requestItemViewRefresh(_parent->data());
}, _lifetime);
StickerScaleBothChanges(
) | rpl::start_with_next([=] {
history()->owner().requestItemViewRefresh(_parent->data());
}, _lifetime);
}
QSize UnwrappedMedia::countOptimalSize() {

View file

@ -74,13 +74,14 @@ bool Sticker::isEmojiSticker() const {
void Sticker::initSize() {
_size = _document->dimensions;
const auto maxHeight = int(st::maxStickerSize / 256.0 * StickerHeight());
const auto maxWidth = StickerScaleBoth() ? maxHeight : st::maxStickerSize;
if (isEmojiSticker() || _diceIndex >= 0) {
_size = GetAnimatedEmojiSize(&_document->session(), _size);
[[maybe_unused]] bool result = readyToDrawLottie();
} else {
_size = DownscaledSize(
_size,
{ st::maxStickerSize, maxHeight });
{ maxWidth, maxHeight });
}
}

View file

@ -176,6 +176,7 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
}
settings.insert(qsl("sticker_height"), StickerHeight());
settings.insert(qsl("sticker_scale_both"), StickerScaleBoth());
settings.insert(qsl("adaptive_bubbles"), AdaptiveBubbles());
settings.insert(qsl("big_emoji_outline"), BigEmojiOutline());
settings.insert(qsl("always_show_scheduled"), cAlwaysShowScheduled());
@ -296,6 +297,10 @@ bool Manager::readCustomFile() {
}
});
ReadBoolOption(settings, "sticker_scale_both", [&](auto v) {
SetStickerScaleBoth(v);
});
auto isAdaptiveBubblesSet = ReadBoolOption(settings, "adaptive_bubbles", [&](auto v) {
SetAdaptiveBubbles(v);
});

View file

@ -31,6 +31,17 @@ rpl::producer<int> StickerHeightChanges() {
return gStickerHeight.changes();
}
rpl::variable<bool> gStickerScaleBoth = true;
void SetStickerScaleBoth(bool scale) {
gStickerScaleBoth = scale;
}
bool StickerScaleBoth() {
return gStickerScaleBoth.current();
}
rpl::producer<bool> StickerScaleBothChanges() {
return gStickerScaleBoth.changes();
}
rpl::variable<bool> gBigEmojiOutline = true;
void SetBigEmojiOutline(bool enabled) {
gBigEmojiOutline = enabled;

View file

@ -39,6 +39,10 @@ void SetStickerHeight(int height);
[[nodiscard]] int StickerHeight();
[[nodiscard]] rpl::producer<int> StickerHeightChanges();
void SetStickerScaleBoth(bool scale);
[[nodiscard]] bool StickerScaleBoth();
[[nodiscard]] rpl::producer<bool> StickerScaleBothChanges();
void SetAdaptiveBubbles(bool enabled);
[[nodiscard]] bool AdaptiveBubbles();
[[nodiscard]] rpl::producer<bool> AdaptiveBubblesChanges();

View file

@ -292,6 +292,25 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
updateStickerHeight);
updateStickerHeightLabel(StickerHeight());
container->add(
object_ptr<Ui::Checkbox>(
container,
tr::ktg_settings_sticker_scale_both(tr::now),
StickerScaleBoth(),
st::settingsCheckbox),
st::settingsCheckboxPadding
)->checkedChanges(
) | rpl::filter([](bool checked) {
return (checked != StickerScaleBoth());
}) | rpl::start_with_next([](bool checked) {
SetStickerScaleBoth(checked);
::Kotato::JsonSettings::Write();
}, container->lifetime());
AddSkip(container);
AddDividerText(container, tr::ktg_settings_sticker_scale_both_about());
AddSkip(container);
SettingsMenuSwitch(ktg_settings_adaptive_bubbles, AdaptiveBubbles);
SettingsMenuSwitch(ktg_settings_emoji_outline, BigEmojiOutline);