diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index a13c9c9e7..99a530a1d 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -215,7 +215,7 @@ void ShareBox::prepare() { setDimensions(st::boxWideWidth, st::boxMaxListHeight); _select->setQueryChangedCallback([=](const QString &query) { - onFilterUpdate(query); + applyFilterUpdate(query); }); _select->setItemRemovedCallback([=](uint64 itemId) { if (const auto peer = App::peerLoaded(itemId)) { @@ -403,7 +403,7 @@ void ShareBox::createButtons() { addButton(langFactory(lng_cancel), [=] { closeBox(); }); } -void ShareBox::onFilterUpdate(const QString &query) { +void ShareBox::applyFilterUpdate(const QString &query) { onScrollToY(0); _inner->updateFilter(query); } diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index 551496da0..5b53d7ea6 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -60,7 +60,7 @@ private: void scrollTo(Ui::ScrollToRequest request); void needSearchByUsername(); - void onFilterUpdate(const QString &query); + void applyFilterUpdate(const QString &query); void selectedChanged(); void createButtons(); int getTopScrollSkip() const; diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index dc426c081..cb5ddeeb7 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -1598,7 +1598,7 @@ void DialogsInner::handlePeerNameChange( update(); } -void DialogsInner::onFilterUpdate(QString newFilter, bool force) { +void DialogsInner::applyFilterUpdate(QString newFilter, bool force) { const auto mentionsSearch = (newFilter == qstr("@")); const auto words = mentionsSearch ? QStringList(newFilter) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index 59632e183..b36aaf191 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -88,7 +88,7 @@ public: void searchInChat(Dialogs::Key key, UserData *from); - void onFilterUpdate(QString newFilter, bool force = false); + void applyFilterUpdate(QString newFilter, bool force = false); void onHashtagFilterUpdate(QStringRef newFilter); PeerData *updateFromParentDrag(QPoint globalPosition); diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index c0cff52fa..7812635c2 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -165,13 +165,20 @@ DialogsWidget::DialogsWidget(QWidget *parent, not_null cont connect(_inner, SIGNAL(cancelSearchInChat()), this, SLOT(onCancelSearchInChat())); subscribe(_inner->searchFromUserChanged, [this](UserData *user) { setSearchInChat(_searchInChat, user); - onFilterUpdate(true); + applyFilterUpdate(true); }); connect(_scroll, SIGNAL(geometryChanged()), _inner, SLOT(onParentGeometryChanged())); connect(_scroll, SIGNAL(scrolled()), this, SLOT(onListScroll())); - connect(_filter, SIGNAL(cancelled()), this, SLOT(onCancel())); - connect(_filter, SIGNAL(changed()), this, SLOT(onFilterUpdate())); - connect(_filter, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(onFilterCursorMoved(int,int))); + connect(_filter, &Ui::FlatInput::cancelled, [=] { + onCancel(); + }); + connect(_filter, &Ui::FlatInput::changed, [=] { + applyFilterUpdate(); + }); + connect( + _filter, + &Ui::FlatInput::cursorPositionChanged, + [=](int from, int to) { onFilterCursorMoved(from, to); }); if (!Core::UpdaterDisabled()) { Core::UpdateChecker checker; @@ -395,7 +402,7 @@ void DialogsWidget::animationCallback() { updateJumpToDateVisibility(true); updateSearchFromVisibility(true); - onFilterUpdate(); + applyFilterUpdate(); if (App::wnd()) App::wnd()->setInnerFocus(); } } @@ -442,6 +449,7 @@ void DialogsWidget::dialogsReceived( if (!_dialogsRequestId) { refreshLoadMoreButton(); } + refreshSupportFilteredResults(); Auth().data().moreChatsLoaded().notify(); if (_dialogsFull && _pinnedDialogsReceived) { @@ -450,6 +458,15 @@ void DialogsWidget::dialogsReceived( Auth().api().requestContacts(); } +void DialogsWidget::refreshSupportFilteredResults() { + if (!Auth().supportMode()) { + return; + } + const auto top = _scroll->scrollTop(); + applyFilterUpdate(true); + _scroll->scrollToY(top); +} + void DialogsWidget::updateDialogsOffset( const QVector &dialogs, const QVector &messages) { @@ -741,7 +758,7 @@ void DialogsWidget::searchMessages( } _filter->setText(query); _filter->updatePlaceholder(); - onFilterUpdate(true); + applyFilterUpdate(true); _searchTimer.stop(); onSearchMessages(); @@ -1115,11 +1132,11 @@ void DialogsWidget::onListScroll() { _inner->setVisibleTopBottom(scrollTop, scrollTop + _scroll->height()); } -void DialogsWidget::onFilterUpdate(bool force) { +void DialogsWidget::applyFilterUpdate(bool force) { if (_a_show.animating() && !force) return; auto filterText = _filter->getLastText(); - _inner->onFilterUpdate(filterText, force); + _inner->applyFilterUpdate(filterText, force); if (filterText.isEmpty() && !_searchFromUser) { clearSearchCache(); } @@ -1146,7 +1163,7 @@ void DialogsWidget::onFilterUpdate(bool force) { void DialogsWidget::searchInChat(Dialogs::Key chat) { onCancelSearch(); setSearchInChat(chat); - onFilterUpdate(true); + applyFilterUpdate(true); } void DialogsWidget::setSearchInChat(Dialogs::Key chat, UserData *from) { @@ -1202,7 +1219,7 @@ void DialogsWidget::showSearchFrom() { crl::guard(this, [=](not_null user) { Ui::hideLayer(); setSearchInChat(chat, user); - onFilterUpdate(true); + applyFilterUpdate(true); }), crl::guard(this, [=] { _filter->setFocus(); })); } @@ -1239,7 +1256,7 @@ void DialogsWidget::onCompleteHashtag(QString tag) { r = t.mid(0, start + 1) + tag + ' ' + t.mid(cur); _filter->setText(r); _filter->setCursorPosition(start + 1 + tag.size() + 1); - onFilterUpdate(true); + applyFilterUpdate(true); return; } break; @@ -1248,7 +1265,7 @@ void DialogsWidget::onCompleteHashtag(QString tag) { } _filter->setText(t.mid(0, cur) + '#' + tag + ' ' + t.mid(cur)); _filter->setCursorPosition(cur + 1 + tag.size() + 1); - onFilterUpdate(true); + applyFilterUpdate(true); } void DialogsWidget::resizeEvent(QResizeEvent *e) { @@ -1451,7 +1468,7 @@ void DialogsWidget::scrollToEntry(const Dialogs::RowDescriptor &entry) { void DialogsWidget::removeDialog(Dialogs::Key key) { _inner->removeDialog(key); - onFilterUpdate(); + applyFilterUpdate(true); } Dialogs::IndexedList *DialogsWidget::contactsList() { @@ -1488,7 +1505,7 @@ bool DialogsWidget::onCancelSearch() { _inner->clearFilter(); _filter->clear(); _filter->updatePlaceholder(); - onFilterUpdate(); + applyFilterUpdate(); return clearing; } @@ -1512,7 +1529,7 @@ void DialogsWidget::onCancelSearchInChat() { _inner->clearFilter(); _filter->clear(); _filter->updatePlaceholder(); - onFilterUpdate(); + applyFilterUpdate(); if (!Adaptive::OneColumn() && !App::main()->selectingPeer()) { emit cancelled(); } diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index f57969ee7..48f493c52 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -100,7 +100,6 @@ public slots: void onCancel(); void onListScroll(); void activate(); - void onFilterUpdate(bool force = false); bool onCancelSearch(); void onCancelSearchInChat(); @@ -162,6 +161,8 @@ private: void updateForwardBar(); void checkUpdateStatus(); + void applyFilterUpdate(bool force = false); + void refreshSupportFilteredResults(); bool loadingBlockedByDate() const; void refreshLoadMoreButton(); diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index 29d1482a9..18341eded 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -234,15 +234,19 @@ void CountrySelectBox::prepare() { setTitle(langFactory(lng_country_select)); _select->resizeToWidth(st::boxWidth); - _select->setQueryChangedCallback([this](const QString &query) { onFilterUpdate(query); }); - _select->setSubmittedCallback([this](Qt::KeyboardModifiers) { onSubmit(); }); + _select->setQueryChangedCallback([=](const QString &query) { + applyFilterUpdate(query); + }); + _select->setSubmittedCallback([=](Qt::KeyboardModifiers) { + submit(); + }); _inner = setInnerWidget( object_ptr(this, _type), st::countriesScroll, _select->height()); - addButton(langFactory(lng_close), [this] { closeBox(); }); + addButton(langFactory(lng_close), [=] { closeBox(); }); setDimensions(st::boxWidth, st::boxMaxListHeight); @@ -250,7 +254,7 @@ void CountrySelectBox::prepare() { connect(_inner, SIGNAL(countryChosen(const QString&)), this, SIGNAL(countryChosen(const QString&))); } -void CountrySelectBox::onSubmit() { +void CountrySelectBox::submit() { _inner->chooseCountry(); } @@ -277,7 +281,7 @@ void CountrySelectBox::resizeEvent(QResizeEvent *e) { _inner->resizeToWidth(width()); } -void CountrySelectBox::onFilterUpdate(const QString &query) { +void CountrySelectBox::applyFilterUpdate(const QString &query) { onScrollToY(0); _inner->updateFilter(query); } diff --git a/Telegram/SourceFiles/ui/countryinput.h b/Telegram/SourceFiles/ui/countryinput.h index 9b277dc92..abcc93231 100644 --- a/Telegram/SourceFiles/ui/countryinput.h +++ b/Telegram/SourceFiles/ui/countryinput.h @@ -77,11 +77,9 @@ protected: void keyPressEvent(QKeyEvent *e) override; void resizeEvent(QResizeEvent *e) override; -private slots: - void onSubmit(); - private: - void onFilterUpdate(const QString &query); + void submit(); + void applyFilterUpdate(const QString &query); Type _type = Type::Phones; object_ptr _select;