2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Reworked monospace expand option

* Added Ui::SlideWrap
* Clean redundant code
* Restored accumulate_min on disabled adaptive bubbles
* Make _bubbleWidthLimit depend on monospace expand option
* Added Russian translation
This commit is contained in:
RadRussianRus
2020-06-27 23:23:35 +03:00
parent 7974f64b01
commit f8c18a4820
4 changed files with 47 additions and 17 deletions

View File

@@ -131,5 +131,6 @@
"few": "{count} дней",
"many": "{count} дней",
"other": "{count} дней"
}
},
"ktg_settings_monospace_large_bubbles": "Расширять моноширинные сообщения"
}

View File

@@ -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);

View File

@@ -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);
});

View File

@@ -312,8 +312,45 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> 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<Ui::SlideWrap<Button>>(
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);