diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 5780a1211a..927997ce44 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -37,6 +37,14 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "window/window_controller.h" #include "profile/profile_channel_controllers.h" +namespace { + +QString SwitchToChooseFromQuery() { + return qsl("from:"); +} + +} // namespace + class DialogsWidget::UpdateButton : public Ui::RippleButton { public: UpdateButton(QWidget *parent); @@ -809,6 +817,16 @@ void DialogsWidget::onFilterUpdate(bool force) { _peerSearchQueries.clear(); _peerSearchQuery = QString(); } + + if (!_chooseFromUser->isHiddenOrHiding() || _searchFromUser) { + auto switchToChooseFrom = SwitchToChooseFromQuery(); + if (_lastFilterText != switchToChooseFrom + && switchToChooseFrom.startsWith(_lastFilterText) + && filterText == switchToChooseFrom) { + showSearchFrom(); + } + } + _lastFilterText = filterText; } void DialogsWidget::searchInPeer(PeerData *peer) { @@ -836,6 +854,10 @@ void DialogsWidget::setSearchInPeer(PeerData *peer, UserData *from) { clearSearchCache(); } _inner->searchInPeer(_searchInPeer, _searchFromUser); + if (_searchFromUser && _lastFilterText == SwitchToChooseFromQuery()) { + onCancelSearch(); + } + _filter->setFocus(); } void DialogsWidget::clearSearchCache() { diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index 1ff4d59653..bfb188b01a 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -198,6 +198,7 @@ private: PeerData *_searchInPeer = nullptr; PeerData *_searchInMigrated = nullptr; UserData *_searchFromUser = nullptr; + QString _lastFilterText; QTimer _searchTimer; diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index b0f84367ae..8f715d1cec 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -732,9 +732,10 @@ void MainWindow::noLayerStack(LayerStackWidget *was) { void MainWindow::layerFinishedHide(LayerStackWidget *was) { if (was == _layerBg) { + auto resetFocus = (was == App::wnd()->focusWidget()); destroyLayerDelayed(); - InvokeQueued(this, [this] { - setInnerFocus(); + InvokeQueued(this, [this, resetFocus] { + if (resetFocus) setInnerFocus(); checkHistoryActivation(); }); }