Grab/return focus in status/reactions search.

This commit is contained in:
John Preston 2023-01-25 11:30:20 +04:00
parent 2e88ada392
commit 22f9e87fbe
7 changed files with 54 additions and 1 deletions

View File

@ -718,6 +718,20 @@ object_ptr<TabbedSelector::InnerFooter> EmojiListWidget::createFooter() {
return result;
}
void EmojiListWidget::afterShown() {
const auto steal = (_mode == Mode::EmojiStatus)
|| (_mode == Mode::FullReactions);
if (_search && steal) {
_search->stealFocus();
}
}
void EmojiListWidget::beforeHiding() {
if (_search) {
_search->returnFocus();
}
}
template <typename Callback>
bool EmojiListWidget::enumerateSections(Callback callback) const {
Expects(_columnCount > 0);
@ -2153,6 +2167,10 @@ void EmojiListWidget::refreshEmoji() {
void EmojiListWidget::showSet(uint64 setId) {
clearSelection();
if (_search && _searchMode) {
_search->cancel();
applyNextSearchQuery();
}
auto y = 0;
enumerateSections([&](const SectionInfo &info) {

View File

@ -102,6 +102,9 @@ public:
void clearSelection() override;
object_ptr<TabbedSelector::InnerFooter> createFooter() override;
void afterShown() override;
void beforeHiding() override;
void showSet(uint64 setId);
[[nodiscard]] uint64 currentSet(int yOffset) const;
void setAllowWithoutPremium(bool allow);

View File

@ -282,6 +282,12 @@ void Selector::initGeometry(int innerTop) {
}
}
void Selector::beforeDestroy() {
if (_list) {
_list->beforeHiding();
}
}
void Selector::updateShowState(
float64 progress,
float64 opacity,
@ -531,6 +537,7 @@ void Selector::finishExpand() {
_footer->show();
}
_scroll->show();
_list->afterShown();
if (const auto controller = _parentController.get()) {
controller->session().api().updateCustomEmoji();
@ -940,6 +947,12 @@ AttachSelectorResult MakeJustSelectorMenu(
}
const auto selectorInnerTop = menu->preparedPadding().top()
- st::reactStripExtend.top();
menu->animatePhaseValue(
) | rpl::start_with_next([=](Ui::PopupMenu::AnimatePhase phase) {
if (phase == Ui::PopupMenu::AnimatePhase::StartHide) {
selector->beforeDestroy();
}
}, selector->lifetime());
selector->initGeometry(selectorInnerTop);
selector->show();
@ -1005,6 +1018,12 @@ AttachSelectorResult AttachSelectorToMenu(
const auto selectorInnerTop = selector->useTransparency()
? (menu->preparedPadding().top() - st::reactStripExtend.top())
: st::lineWidth;
menu->animatePhaseValue(
) | rpl::start_with_next([=](Ui::PopupMenu::AnimatePhase phase) {
if (phase == Ui::PopupMenu::AnimatePhase::StartHide) {
selector->beforeDestroy();
}
}, selector->lifetime());
selector->initGeometry(selectorInnerTop);
selector->show();

View File

@ -60,6 +60,7 @@ public:
[[nodiscard]] int minimalHeight() const;
void setSpecialExpandTopSkip(int skip);
void initGeometry(int innerTop);
void beforeDestroy();
[[nodiscard]] rpl::producer<ChosenReaction> chosen() const {
return _chosen.events();

View File

@ -526,6 +526,12 @@ auto SearchWithGroups::debouncedQueryValue() const
return _debouncedQuery.value();
}
void SearchWithGroups::cancel() {
_field->setText(QString());
_chosenGroup = QString();
scrollGroupsToStart();
}
void SearchWithGroups::setLoading(bool loading) {
_cancel->setLoadingAnimation(loading);
}
@ -637,6 +643,10 @@ QImage TabbedSearch::grab() {
return Ui::GrabWidgetToImage(&_search);
}
void TabbedSearch::cancel() {
_search.cancel();
}
void TabbedSearch::setLoading(bool loading) {
_search.setLoading(loading);
}

View File

@ -53,6 +53,7 @@ public:
[[nodiscard]] auto debouncedQueryValue() const
-> rpl::producer<std::vector<QString>>;
void cancel();
void setLoading(bool loading);
void stealFocus();
void returnFocus();
@ -118,6 +119,7 @@ public:
[[nodiscard]] auto debouncedQueryValue() const
->rpl::producer<std::vector<QString>>;
void cancel();
void setLoading(bool loading);
void stealFocus();
void returnFocus();

@ -1 +1 @@
Subproject commit 41ee2fb0f05908112c0cd132c7ab7168ba87fe0c
Subproject commit 43e9128014c5239a6732ae34bdfe007efb9692c8