mirror of https://github.com/procxx/kepka.git
Added Search Shortcut in Shared Media.
- Works for Documents, Audio files and Shared links.
This commit is contained in:
parent
178c0078c1
commit
9dc9e019f6
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -82,6 +82,8 @@ public:
|
|||
updateControlsVisibility(anim::type::instant);
|
||||
}
|
||||
|
||||
void showSearch();
|
||||
|
||||
protected:
|
||||
int resizeGetHeight(int newWidth) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -171,6 +171,7 @@ private:
|
|||
//void createTabs();
|
||||
void createTopBar();
|
||||
void highlightTopBar();
|
||||
void setupShortcuts();
|
||||
|
||||
not_null<RpWidget*> topWidget() const;
|
||||
|
||||
|
|
Loading…
Reference in New Issue