Added auto-scroll-inactive-chat option.
This commit is contained in:
parent
df17f20a47
commit
8f076b0c9e
|
@ -122,6 +122,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
#include "base/options.h"
|
||||||
#include "base/qthelp_regex.h"
|
#include "base/qthelp_regex.h"
|
||||||
#include "ui/boxes/report_box.h"
|
#include "ui/boxes/report_box.h"
|
||||||
#include "ui/chat/pinned_bar.h"
|
#include "ui/chat/pinned_bar.h"
|
||||||
|
@ -165,6 +166,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
#include <QtCore/QMimeData>
|
#include <QtCore/QMimeData>
|
||||||
|
|
||||||
|
const char kOptionAutoScrollInactiveChat[] =
|
||||||
|
"auto-scroll-inactive-chat";
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kMessagesPerPageFirst = 30;
|
constexpr auto kMessagesPerPageFirst = 30;
|
||||||
|
@ -185,6 +189,13 @@ constexpr auto kCommonModifiers = 0
|
||||||
| Qt::ControlModifier;
|
| Qt::ControlModifier;
|
||||||
const auto kPsaAboutPrefix = "cloud_lng_about_psa_";
|
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) {
|
[[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) {
|
||||||
return std::clamp(
|
return std::clamp(
|
||||||
crl::time(1000) * int(text.text.size()) / 14,
|
crl::time(1000) * int(text.text.size()) / 14,
|
||||||
|
@ -5434,6 +5445,9 @@ int HistoryWidget::countAutomaticScrollTop() {
|
||||||
Expects(_list != nullptr);
|
Expects(_list != nullptr);
|
||||||
|
|
||||||
if (const auto unread = _history->firstUnreadMessage()) {
|
if (const auto unread = _history->firstUnreadMessage()) {
|
||||||
|
if (AutoScrollInactiveChat.value()) {
|
||||||
|
return ScrollMax;
|
||||||
|
}
|
||||||
const auto firstUnreadTop = _list->itemTop(unread);
|
const auto firstUnreadTop = _list->itemTop(unread);
|
||||||
const auto possibleUnreadBarTop = _scroll->scrollTopMax()
|
const auto possibleUnreadBarTop = _scroll->scrollTopMax()
|
||||||
+ HistoryView::UnreadBar::height()
|
+ HistoryView::UnreadBar::height()
|
||||||
|
|
|
@ -122,6 +122,8 @@ class MessageField;
|
||||||
class HistoryInner;
|
class HistoryInner;
|
||||||
struct HistoryMessageMarkupButton;
|
struct HistoryMessageMarkupButton;
|
||||||
|
|
||||||
|
extern const char kOptionAutoScrollInactiveChat[];
|
||||||
|
|
||||||
class HistoryWidget final : public Window::AbstractSectionWidget {
|
class HistoryWidget final : public Window::AbstractSectionWidget {
|
||||||
public:
|
public:
|
||||||
using FieldHistoryAction = Ui::InputField::HistoryAction;
|
using FieldHistoryAction = Ui::InputField::HistoryAction;
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/options.h"
|
#include "base/options.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "chat_helpers/tabbed_panel.h"
|
#include "chat_helpers/tabbed_panel.h"
|
||||||
|
#include "history/history_widget.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
#include "webview/webview_embed.h"
|
#include "webview/webview_embed.h"
|
||||||
|
@ -137,6 +138,7 @@ void SetupExperimental(
|
||||||
addToggle(Media::Player::kOptionDisableAutoplayNext);
|
addToggle(Media::Player::kOptionDisableAutoplayNext);
|
||||||
addToggle(Settings::kOptionMonoSettingsIcons);
|
addToggle(Settings::kOptionMonoSettingsIcons);
|
||||||
addToggle(Webview::kOptionWebviewDebugEnabled);
|
addToggle(Webview::kOptionWebviewDebugEnabled);
|
||||||
|
addToggle(kOptionAutoScrollInactiveChat);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in New Issue