diff --git a/Telegram/Resources/langs/rewrites/ru.json b/Telegram/Resources/langs/rewrites/ru.json index c9a8be40e..a15fd6e13 100644 --- a/Telegram/Resources/langs/rewrites/ru.json +++ b/Telegram/Resources/langs/rewrites/ru.json @@ -131,5 +131,6 @@ "few": "{count} дней", "many": "{count} дней", "other": "{count} дней" - } + }, + "ktg_settings_monospace_large_bubbles": "Расширять моноширинные сообщения" } diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 61478127f..87aae36df 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1814,9 +1814,7 @@ QRect Message::countGeometry() const { } accumulate_min(contentWidth, maxWidth()); if (!AdaptiveBubbles()) { - if (MonospaceLargeBubbles()) { - accumulate_min(contentWidth, _bubbleWidthLimit); - } + accumulate_min(contentWidth, _bubbleWidthLimit); } if (mediaWidth < contentWidth) { const auto textualWidth = plainMaxWidth(); @@ -1859,11 +1857,11 @@ int Message::resizeContentGetHeight(int newWidth) { contentWidth -= st::msgPhotoSkip; } accumulate_min(contentWidth, maxWidth()); - _bubbleWidthLimit = std::max(st::msgMaxWidth, monospaceMaxWidth()); + _bubbleWidthLimit = (MonospaceLargeBubbles() + ? std::max(st::msgMaxWidth, monospaceMaxWidth()) + : st::msgMaxWidth); if (!AdaptiveBubbles()) { - if (MonospaceLargeBubbles()) { - accumulate_min(contentWidth, _bubbleWidthLimit); - } + accumulate_min(contentWidth, _bubbleWidthLimit); } if (mediaDisplayed) { media->resizeGetHeight(contentWidth); diff --git a/Telegram/SourceFiles/kotato/json_settings.cpp b/Telegram/SourceFiles/kotato/json_settings.cpp index 42d410516..d55976754 100644 --- a/Telegram/SourceFiles/kotato/json_settings.cpp +++ b/Telegram/SourceFiles/kotato/json_settings.cpp @@ -315,16 +315,10 @@ bool Manager::readCustomFile() { }); } - auto isMonospaceLargeBubblesSet = ReadBoolOption(settings, "monospace_large_bubbles", [&](auto v) { + ReadBoolOption(settings, "monospace_large_bubbles", [&](auto v) { SetMonospaceLargeBubbles(v); }); - if (!isMonospaceLargeBubblesSet) { - ReadBoolOption(settings, "monospace_large_bubbles", [&](auto v) { - SetMonospaceLargeBubbles(v); - }); - } - ReadBoolOption(settings, "big_emoji_outline", [&](auto v) { SetBigEmojiOutline(v); }); diff --git a/Telegram/SourceFiles/kotato/settings_menu.cpp b/Telegram/SourceFiles/kotato/settings_menu.cpp index c70b29d8b..aa5e49c29 100644 --- a/Telegram/SourceFiles/kotato/settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/settings_menu.cpp @@ -312,8 +312,45 @@ void SetupKotatoMessages(not_null container) { AddDividerText(container, tr::ktg_settings_sticker_scale_both_about()); AddSkip(container); - SettingsMenuSwitch(ktg_settings_adaptive_bubbles, AdaptiveBubbles); - SettingsMenuSwitch(ktg_settings_monospace_large_bubbles, MonospaceLargeBubbles); + auto adaptiveBubblesButton = AddButton( + container, + tr::ktg_settings_adaptive_bubbles(), + st::settingsButton + ); + + auto monospaceLargeBubblesButton = container->add( + object_ptr>( + container, + CreateButton( + container, + tr::ktg_settings_monospace_large_bubbles(), + st::settingsButton))); + + adaptiveBubblesButton->toggleOn( + rpl::single(AdaptiveBubbles()) + )->toggledValue( + ) | rpl::filter([](bool enabled) { + return (enabled != AdaptiveBubbles()); + }) | rpl::start_with_next([monospaceLargeBubblesButton](bool enabled) { + monospaceLargeBubblesButton->toggle(!enabled, anim::type::normal); + SetAdaptiveBubbles(enabled); + ::Kotato::JsonSettings::Write(); + }, container->lifetime()); + + monospaceLargeBubblesButton->entity()->toggleOn( + rpl::single(MonospaceLargeBubbles()) + )->toggledValue( + ) | rpl::filter([](bool enabled) { + return (enabled != MonospaceLargeBubbles()); + }) | rpl::start_with_next([](bool enabled) { + SetMonospaceLargeBubbles(enabled); + ::Kotato::JsonSettings::Write(); + }, container->lifetime()); + + if (adaptiveBubblesButton->toggled()) { + monospaceLargeBubblesButton->hide(anim::type::instant); + } + SettingsMenuSwitch(ktg_settings_emoji_outline, BigEmojiOutline); AddSkip(container);