From d63d73326efd083a8f71eb7b3d171e3bf20397d0 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Fri, 9 Sep 2022 20:55:33 +0300 Subject: [PATCH] [Option][GUI] Unfocused autoscroll --- Telegram/Resources/langs/rewrites/en.json | 1 + Telegram/SourceFiles/kotato/kotato_settings.cpp | 3 +++ Telegram/SourceFiles/kotato/kotato_settings_menu.cpp | 4 ++++ Telegram/SourceFiles/mainwindow.cpp | 10 ++++++++++ 4 files changed, 18 insertions(+) diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index 3879adcb4..256e6919c 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -33,6 +33,7 @@ "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", + "ktg_settings_auto_scroll_unfocused": "Unfocused auto-scroll", "ktg_settings_always_show_scheduled": "Always show scheduled", "ktg_settings_chat_list_compact": "Compact chat list", "ktg_fonts_title": "Fonts", diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index 9521ac059..b28fa0c36 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -427,6 +427,9 @@ const std::map> DefinitionMap { { "profile_top_mute", { .type = SettingType::BoolSetting, .defaultValue = false, }}, + { "auto_scroll_unfocused", { + .type = SettingType::BoolSetting, + .defaultValue = false, }}, { "folders/local", { .scope = SettingScope::Account, .type = SettingType::QJsonArraySetting, }}, diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index 84eab386b..6989a97d0 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -216,6 +216,10 @@ void SetupKotatoChats( SettingsMenuJsonSwitch(ktg_settings_top_bar_mute, profile_top_mute); SettingsMenuJsonSwitch(ktg_settings_disable_up_edit, disable_up_edit); + if (Ui::Platform::IsOverlapped(container, QRect()).has_value()) { + SettingsMenuJsonSwitch(ktg_settings_auto_scroll_unfocused, auto_scroll_unfocused); + } + AddButton( container, rktr("ktg_settings_chat_list_compact"), diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index 56f74933b..cce2ab5bb 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -597,6 +597,16 @@ bool MainWindow::doWeMarkAsRead() { if (!_main || Ui::isLayerShown()) { return false; } + if (::Kotato::JsonSettings::GetBool("auto_scroll_unfocused")) { + // for tile grid in case other windows have shadows + // i've seen some windows with >70px shadow margins + const auto margin = style::ConvertScale(100); + const auto inner = body()->rect(); + return Ui::IsContentVisible( + this, + inner.marginsRemoved(QMargins(margin, margin, margin, margin))) + && _main->doWeMarkAsRead(); + } return isActive() && _main->doWeMarkAsRead(); }