Show "choose from user" box when typing "from:".

This commit is contained in:
John Preston 2017-08-06 19:32:05 +02:00
parent ce51abd9d0
commit 0a6535ea94
3 changed files with 26 additions and 2 deletions

View File

@ -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() {

View File

@ -198,6 +198,7 @@ private:
PeerData *_searchInPeer = nullptr;
PeerData *_searchInMigrated = nullptr;
UserData *_searchFromUser = nullptr;
QString _lastFilterText;
QTimer _searchTimer;

View File

@ -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();
});
}