Don't scroll through from chats list to stories.
This commit is contained in:
parent
7f583f86c0
commit
c61e1b9139
|
@ -73,11 +73,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/qt/qt_common_adapters.h"
|
#include "base/qt/qt_common_adapters.h"
|
||||||
|
|
||||||
#include <QtCore/QMimeData>
|
#include <QtCore/QMimeData>
|
||||||
|
#include <QtWidgets/QScrollBar>
|
||||||
|
|
||||||
namespace Dialogs {
|
namespace Dialogs {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kSearchPerPage = 50;
|
constexpr auto kSearchPerPage = 50;
|
||||||
|
constexpr auto kWaitTillAllowStoriesExpand = crl::time(200);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -208,6 +210,9 @@ Widget::Widget(
|
||||||
, _cancelSearch(_searchControls, st::dialogsCancelSearch)
|
, _cancelSearch(_searchControls, st::dialogsCancelSearch)
|
||||||
, _lockUnlock(_searchControls, st::dialogsLock)
|
, _lockUnlock(_searchControls, st::dialogsLock)
|
||||||
, _scroll(this)
|
, _scroll(this)
|
||||||
|
, _allowStoriesExpandTimer([=] {
|
||||||
|
_scroll->verticalScrollBar()->setMinimum(0);
|
||||||
|
})
|
||||||
, _scrollToTop(_scroll, st::dialogsToUp)
|
, _scrollToTop(_scroll, st::dialogsToUp)
|
||||||
, _searchTimer([=] { searchMessages(); })
|
, _searchTimer([=] { searchMessages(); })
|
||||||
, _singleMessageSearch(&controller->session()) {
|
, _singleMessageSearch(&controller->session()) {
|
||||||
|
@ -319,6 +324,9 @@ Widget::Widget(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
listScrollUpdated();
|
listScrollUpdated();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
_scroll->setCustomWheelProcess([=](not_null<QWheelEvent*> e) {
|
||||||
|
return customWheelProcess(e);
|
||||||
|
});
|
||||||
|
|
||||||
session().data().chatsListChanges(
|
session().data().chatsListChanges(
|
||||||
) | rpl::filter([=](Data::Folder *folder) {
|
) | rpl::filter([=](Data::Folder *folder) {
|
||||||
|
@ -1122,6 +1130,9 @@ void Widget::jumpToTop(bool belowPinned) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::scrollToDefault(bool verytop) {
|
void Widget::scrollToDefault(bool verytop) {
|
||||||
|
if (verytop) {
|
||||||
|
_scroll->verticalScrollBar()->setMinimum(0);
|
||||||
|
}
|
||||||
_scrollToAnimation.stop();
|
_scrollToAnimation.stop();
|
||||||
auto scrollTop = _scroll->scrollTop();
|
auto scrollTop = _scroll->scrollTop();
|
||||||
const auto scrollTo = verytop ? 0 : _inner->defaultScrollTop();
|
const auto scrollTo = verytop ? 0 : _inner->defaultScrollTop();
|
||||||
|
@ -2365,6 +2376,23 @@ void Widget::completeHashtag(QString tag) {
|
||||||
applyFilterUpdate(true);
|
applyFilterUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Widget::customWheelProcess(not_null<QWheelEvent*> e) {
|
||||||
|
const auto now = _scroll->scrollTop();
|
||||||
|
const auto def = _inner->defaultScrollTop();
|
||||||
|
const auto bar = _scroll->verticalScrollBar();
|
||||||
|
const auto allow = (def <= 0)
|
||||||
|
|| (now < def)
|
||||||
|
|| (now == def && !_allowStoriesExpandTimer.isActive());
|
||||||
|
if (allow) {
|
||||||
|
_scroll->verticalScrollBar()->setMinimum(0);
|
||||||
|
_allowStoriesExpandTimer.cancel();
|
||||||
|
} else {
|
||||||
|
bar->setMinimum(def);
|
||||||
|
_allowStoriesExpandTimer.callOnce(kWaitTillAllowStoriesExpand);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::resizeEvent(QResizeEvent *e) {
|
void Widget::resizeEvent(QResizeEvent *e) {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,7 @@ private:
|
||||||
void cancelSearchInChat();
|
void cancelSearchInChat();
|
||||||
void filterCursorMoved();
|
void filterCursorMoved();
|
||||||
void completeHashtag(QString tag);
|
void completeHashtag(QString tag);
|
||||||
|
bool customWheelProcess(not_null<QWheelEvent*> e);
|
||||||
|
|
||||||
[[nodiscard]] QString currentSearchQuery() const;
|
[[nodiscard]] QString currentSearchQuery() const;
|
||||||
void clearSearchField();
|
void clearSearchField();
|
||||||
|
@ -245,6 +246,7 @@ private:
|
||||||
std::unique_ptr<HistoryView::ContactStatus> _forumReportBar;
|
std::unique_ptr<HistoryView::ContactStatus> _forumReportBar;
|
||||||
|
|
||||||
object_ptr<Ui::ScrollArea> _scroll;
|
object_ptr<Ui::ScrollArea> _scroll;
|
||||||
|
base::Timer _allowStoriesExpandTimer;
|
||||||
QPointer<InnerWidget> _inner;
|
QPointer<InnerWidget> _inner;
|
||||||
class BottomButton;
|
class BottomButton;
|
||||||
object_ptr<BottomButton> _updateTelegram = { nullptr };
|
object_ptr<BottomButton> _updateTelegram = { nullptr };
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit fc8d4d25dee6e3ded99749c06fd870e6df4615f8
|
Subproject commit 8908c9b5c041f51176383a55e0b324588b28b68d
|
Loading…
Reference in New Issue
Block a user