Added an option to toggle the auto-expansion of the bubbles when a message is formatted in monospace (#58) [skip ci]

This commit is contained in:
CrisMystik 2020-06-27 22:16:29 +02:00 committed by GitHub
parent 632738b80d
commit 7974f64b01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 2 deletions

View file

@ -2531,4 +2531,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ktg_message_id" = "Message ID: {id}";
"ktg_emoji_panel_hover" = "Emoji panel on hover";
"ktg_settings_monospace_large_bubbles" = "Expand bubbles with monospace";
// Keys finished

View file

@ -546,6 +546,20 @@ HistoryWidget::HistoryWidget(
});
}, lifetime());
MonospaceLargeBubblesChanges(
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {
if (_history) {
_history->forceFullResize();
if (_migrated) {
_migrated->forceFullResize();
}
updateHistoryGeometry();
update();
}
});
}, lifetime());
HoverEmojiPanelChanges(
) | rpl::start_with_next([=] {
crl::on_main(this, [=] {

View file

@ -1814,7 +1814,9 @@ QRect Message::countGeometry() const {
}
accumulate_min(contentWidth, maxWidth());
if (!AdaptiveBubbles()) {
accumulate_min(contentWidth, _bubbleWidthLimit);
if (MonospaceLargeBubbles()) {
accumulate_min(contentWidth, _bubbleWidthLimit);
}
}
if (mediaWidth < contentWidth) {
const auto textualWidth = plainMaxWidth();
@ -1859,7 +1861,9 @@ int Message::resizeContentGetHeight(int newWidth) {
accumulate_min(contentWidth, maxWidth());
_bubbleWidthLimit = std::max(st::msgMaxWidth, monospaceMaxWidth());
if (!AdaptiveBubbles()) {
accumulate_min(contentWidth, _bubbleWidthLimit);
if (MonospaceLargeBubbles()) {
accumulate_min(contentWidth, _bubbleWidthLimit);
}
}
if (mediaDisplayed) {
media->resizeGetHeight(contentWidth);

View file

@ -194,6 +194,7 @@ QByteArray GenerateSettingsJson(bool areDefault = false) {
settings.insert(qsl("custom_app_icon"), cCustomAppIcon());
settings.insert(qsl("profile_top_mute"), cProfileTopBarNotifications());
settings.insert(qsl("hover_emoji_panel"), HoverEmojiPanel());
settings.insert(qsl("monospace_large_bubbles"), MonospaceLargeBubbles());
settingsFonts.insert(qsl("use_system_font"), cUseSystemFont());
settingsFonts.insert(qsl("use_original_metrics"), cUseOriginalMetrics());
@ -314,6 +315,16 @@ bool Manager::readCustomFile() {
});
}
auto isMonospaceLargeBubblesSet = 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

@ -64,6 +64,17 @@ rpl::producer<bool> AdaptiveBubblesChanges() {
return gAdaptiveBubbles.changes();
}
rpl::variable<bool> gMonospaceLargeBubbles = false;
void SetMonospaceLargeBubbles(bool enabled) {
gMonospaceLargeBubbles = enabled;
}
bool MonospaceLargeBubbles() {
return gMonospaceLargeBubbles.current();
}
rpl::producer<bool> MonospaceLargeBubblesChanges() {
return gMonospaceLargeBubbles.changes();
}
bool gAlwaysShowScheduled = false;
int gShowChatId = 0;

View file

@ -47,6 +47,10 @@ void SetAdaptiveBubbles(bool enabled);
[[nodiscard]] bool AdaptiveBubbles();
[[nodiscard]] rpl::producer<bool> AdaptiveBubblesChanges();
void SetMonospaceLargeBubbles(bool enabled);
[[nodiscard]] bool MonospaceLargeBubbles();
[[nodiscard]] rpl::producer<bool> MonospaceLargeBubblesChanges();
DeclareSetting(bool, AlwaysShowScheduled);
DeclareSetting(int, ShowChatId);

View file

@ -313,6 +313,7 @@ void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
AddSkip(container);
SettingsMenuSwitch(ktg_settings_adaptive_bubbles, AdaptiveBubbles);
SettingsMenuSwitch(ktg_settings_monospace_large_bubbles, MonospaceLargeBubbles);
SettingsMenuSwitch(ktg_settings_emoji_outline, BigEmojiOutline);
AddSkip(container);