[Option][GUI] Unfocused autoscroll

This commit is contained in:
Eric Kotato 2022-09-09 20:55:33 +03:00 committed by Eric Kotato
parent c815639bbb
commit b4a08ae851
4 changed files with 21 additions and 0 deletions

View file

@ -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",

View file

@ -406,6 +406,9 @@ const std::map<QString, Definition, std::greater<QString>> 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, }},

View file

@ -202,6 +202,12 @@ void SetupKotatoChats(
SettingsMenuJsonSwitch(ktg_settings_top_bar_mute, profile_top_mute);
SettingsMenuJsonSwitch(ktg_settings_disable_up_edit, disable_up_edit);
#ifndef Q_OS_WIN
if (Ui::Platform::IsOverlapped(container, QRect()).has_value()) {
SettingsMenuJsonSwitch(ktg_settings_auto_scroll_unfocused, auto_scroll_unfocused);
}
#endif
AddButton(
container,
rktr("ktg_settings_chat_list_compact"),

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "mainwindow.h"
#include "kotato/kotato_settings.h"
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_document_media.h"
@ -543,6 +544,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();
}