mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Don't scroll through from chats list to stories.
This commit is contained in:
parent
7f583f86c0
commit
c61e1b9139
3 changed files with 31 additions and 1 deletions
|
@ -73,11 +73,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/qt/qt_common_adapters.h"
|
||||
|
||||
#include <QtCore/QMimeData>
|
||||
#include <QtWidgets/QScrollBar>
|
||||
|
||||
namespace Dialogs {
|
||||
namespace {
|
||||
|
||||
constexpr auto kSearchPerPage = 50;
|
||||
constexpr auto kWaitTillAllowStoriesExpand = crl::time(200);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -208,6 +210,9 @@ Widget::Widget(
|
|||
, _cancelSearch(_searchControls, st::dialogsCancelSearch)
|
||||
, _lockUnlock(_searchControls, st::dialogsLock)
|
||||
, _scroll(this)
|
||||
, _allowStoriesExpandTimer([=] {
|
||||
_scroll->verticalScrollBar()->setMinimum(0);
|
||||
})
|
||||
, _scrollToTop(_scroll, st::dialogsToUp)
|
||||
, _searchTimer([=] { searchMessages(); })
|
||||
, _singleMessageSearch(&controller->session()) {
|
||||
|
@ -319,6 +324,9 @@ Widget::Widget(
|
|||
) | rpl::start_with_next([=] {
|
||||
listScrollUpdated();
|
||||
}, lifetime());
|
||||
_scroll->setCustomWheelProcess([=](not_null<QWheelEvent*> e) {
|
||||
return customWheelProcess(e);
|
||||
});
|
||||
|
||||
session().data().chatsListChanges(
|
||||
) | rpl::filter([=](Data::Folder *folder) {
|
||||
|
@ -1122,6 +1130,9 @@ void Widget::jumpToTop(bool belowPinned) {
|
|||
}
|
||||
|
||||
void Widget::scrollToDefault(bool verytop) {
|
||||
if (verytop) {
|
||||
_scroll->verticalScrollBar()->setMinimum(0);
|
||||
}
|
||||
_scrollToAnimation.stop();
|
||||
auto scrollTop = _scroll->scrollTop();
|
||||
const auto scrollTo = verytop ? 0 : _inner->defaultScrollTop();
|
||||
|
@ -2365,6 +2376,23 @@ void Widget::completeHashtag(QString tag) {
|
|||
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) {
|
||||
updateControlsGeometry();
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ private:
|
|||
void cancelSearchInChat();
|
||||
void filterCursorMoved();
|
||||
void completeHashtag(QString tag);
|
||||
bool customWheelProcess(not_null<QWheelEvent*> e);
|
||||
|
||||
[[nodiscard]] QString currentSearchQuery() const;
|
||||
void clearSearchField();
|
||||
|
@ -245,6 +246,7 @@ private:
|
|||
std::unique_ptr<HistoryView::ContactStatus> _forumReportBar;
|
||||
|
||||
object_ptr<Ui::ScrollArea> _scroll;
|
||||
base::Timer _allowStoriesExpandTimer;
|
||||
QPointer<InnerWidget> _inner;
|
||||
class BottomButton;
|
||||
object_ptr<BottomButton> _updateTelegram = { nullptr };
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit fc8d4d25dee6e3ded99749c06fd870e6df4615f8
|
||||
Subproject commit 8908c9b5c041f51176383a55e0b324588b28b68d
|
Loading…
Add table
Reference in a new issue