diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp index 4ea68167d..0fef17787 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp @@ -328,7 +328,7 @@ void Widget::setupShortcuts() { return isActiveWindow() && !Ui::isLayerShown() && inFocusChain(); }) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) { using Command = Shortcuts::Command; - request->check(Command::Search, 1) && request->handle([=] { + request->check(Command::Search, 2) && request->handle([=] { _fixedBar->showSearch(); return true; }); diff --git a/Telegram/SourceFiles/history/feed/history_feed_section.cpp b/Telegram/SourceFiles/history/feed/history_feed_section.cpp index 8be72a76a..eacb70efc 100644 --- a/Telegram/SourceFiles/history/feed/history_feed_section.cpp +++ b/Telegram/SourceFiles/history/feed/history_feed_section.cpp @@ -303,7 +303,7 @@ void Widget::setupShortcuts() { return isActiveWindow() && !Ui::isLayerShown() && inFocusChain(); }) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) { using Command = Shortcuts::Command; - request->check(Command::Search, 1) && request->handle([=] { + request->check(Command::Search, 2) && request->handle([=] { App::main()->searchInChat(_feed); return true; }); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 34a04197c..1b5fbeee1 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1321,7 +1321,7 @@ void HistoryWidget::setupShortcuts() { }) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) { using Command = Shortcuts::Command; if (_history) { - request->check(Command::Search) && request->handle([=] { + request->check(Command::Search, 1) && request->handle([=] { App::main()->searchInChat(_history); return true; }); diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index d80ca32d1..ff12b1b0c 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -213,10 +213,7 @@ void TopBar::createSearchView( auto button = base::make_unique_q<Ui::IconButton>(this, _st.search); auto search = button.get(); - search->addClickHandler([=] { - _searchModeEnabled = true; - updateControlsVisibility(anim::type::normal); - }); + search->addClickHandler([=] { showSearch(); }); auto searchWrap = pushButton(std::move(button)); registerToggleControlCallback(searchWrap, [=] { return !selectionMode() @@ -286,6 +283,11 @@ void TopBar::createSearchView( }, wrap->lifetime()); } +void TopBar::showSearch() { + _searchModeEnabled = true; + updateControlsVisibility(anim::type::normal); +} + void TopBar::removeButton(not_null<Ui::RpWidget*> button) { _buttons.erase( std::remove(_buttons.begin(), _buttons.end(), button), diff --git a/Telegram/SourceFiles/info/info_top_bar.h b/Telegram/SourceFiles/info/info_top_bar.h index e83a03167..ff4d3b550 100644 --- a/Telegram/SourceFiles/info/info_top_bar.h +++ b/Telegram/SourceFiles/info/info_top_bar.h @@ -82,6 +82,8 @@ public: updateControlsVisibility(anim::type::instant); } + void showSearch(); + protected: int resizeGetHeight(int newWidth) override; void paintEvent(QPaintEvent *e) override; diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index c9fac7699..980068c07 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/wrap/fade_wrap.h" #include "ui/search_field_controller.h" #include "calls/calls_instance.h" +#include "core/shortcuts.h" #include "window/window_controller.h" #include "window/window_slide_animation.h" #include "window/window_peer_menu.h" @@ -78,6 +79,19 @@ WrapWidget::WrapWidget( restoreHistoryStack(memento->takeStack()); } +void WrapWidget::setupShortcuts() { + Shortcuts::Requests( + ) | rpl::filter([=] { + return requireTopBarSearch(); + }) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) { + using Command = Shortcuts::Command; + request->check(Command::Search) && request->handle([=] { + _topBar->showSearch(); + return true; + }); + }, lifetime()); +} + void WrapWidget::restoreHistoryStack( std::vector<std::unique_ptr<ContentMemento>> stack) { Expects(!stack.empty()); @@ -377,6 +391,7 @@ void WrapWidget::createTopBar() { } else if (requireTopBarSearch()) { auto search = _controller->searchFieldController(); Assert(search != nullptr); + setupShortcuts(); _topBar->createSearchView( search, _controller->searchEnabledByContent(), diff --git a/Telegram/SourceFiles/info/info_wrap_widget.h b/Telegram/SourceFiles/info/info_wrap_widget.h index b718c82f6..eed9f91fc 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.h +++ b/Telegram/SourceFiles/info/info_wrap_widget.h @@ -171,6 +171,7 @@ private: //void createTabs(); void createTopBar(); void highlightTopBar(); + void setupShortcuts(); not_null<RpWidget*> topWidget() const;