Added auto-scroll-inactive-chat option.

This commit is contained in:
23rd 2022-06-04 09:59:48 +03:00
parent df17f20a47
commit 8f076b0c9e
3 changed files with 18 additions and 0 deletions

View File

@ -122,6 +122,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/player/media_player_instance.h"
#include "core/application.h"
#include "apiwrap.h"
#include "base/options.h"
#include "base/qthelp_regex.h"
#include "ui/boxes/report_box.h"
#include "ui/chat/pinned_bar.h"
@ -165,6 +166,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtGui/QWindow>
#include <QtCore/QMimeData>
const char kOptionAutoScrollInactiveChat[] =
"auto-scroll-inactive-chat";
namespace {
constexpr auto kMessagesPerPageFirst = 30;
@ -185,6 +189,13 @@ constexpr auto kCommonModifiers = 0
| Qt::ControlModifier;
const auto kPsaAboutPrefix = "cloud_lng_about_psa_";
base::options::toggle AutoScrollInactiveChat({
.id = kOptionAutoScrollInactiveChat,
.name = "Enable auto-scroll of inactive chat",
.description = "Enable auto-scrolling chat for new messages, "
"even when the window is not in focus.",
});
[[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) {
return std::clamp(
crl::time(1000) * int(text.text.size()) / 14,
@ -5434,6 +5445,9 @@ int HistoryWidget::countAutomaticScrollTop() {
Expects(_list != nullptr);
if (const auto unread = _history->firstUnreadMessage()) {
if (AutoScrollInactiveChat.value()) {
return ScrollMax;
}
const auto firstUnreadTop = _list->itemTop(unread);
const auto possibleUnreadBarTop = _scroll->scrollTopMax()
+ HistoryView::UnreadBar::height()

View File

@ -122,6 +122,8 @@ class MessageField;
class HistoryInner;
struct HistoryMessageMarkupButton;
extern const char kOptionAutoScrollInactiveChat[];
class HistoryWidget final : public Window::AbstractSectionWidget {
public:
using FieldHistoryAction = Ui::InputField::HistoryAction;

View File

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/options.h"
#include "core/application.h"
#include "chat_helpers/tabbed_panel.h"
#include "history/history_widget.h"
#include "lang/lang_keys.h"
#include "media/player/media_player_instance.h"
#include "webview/webview_embed.h"
@ -137,6 +138,7 @@ void SetupExperimental(
addToggle(Media::Player::kOptionDisableAutoplayNext);
addToggle(Settings::kOptionMonoSettingsIcons);
addToggle(Webview::kOptionWebviewDebugEnabled);
addToggle(kOptionAutoScrollInactiveChat);
}
} // namespace