mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-13 04:37:11 +02:00
Tab toggles search focus, Backspace doesn't focus.
This commit is contained in:
parent
f10f3c08de
commit
ec6d6a78cf
2 changed files with 22 additions and 13 deletions
|
@ -98,6 +98,15 @@ base::options::toggle OptionForumHideChatsList({
|
|||
.description = "Don't keep a narrow column of chats list.",
|
||||
});
|
||||
|
||||
[[nodiscard]] bool RedirectTextToSearch(const QString &text) {
|
||||
for (const auto &ch : text) {
|
||||
if (ch.unicode() >= 32) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
const char kOptionForumHideChatsList[] = "forum-hide-chats-list";
|
||||
|
@ -454,7 +463,6 @@ Widget::Widget(
|
|||
loadMoreBlockedByDate();
|
||||
}, lifetime());
|
||||
|
||||
_search->setFocusPolicy(Qt::StrongFocus);
|
||||
_search->customUpDown(true);
|
||||
|
||||
updateJumpToDateVisibility(true);
|
||||
|
@ -1514,16 +1522,17 @@ void Widget::checkUpdateStatus() {
|
|||
updateControlsGeometry();
|
||||
}
|
||||
|
||||
void Widget::setInnerFocus() {
|
||||
void Widget::setInnerFocus(bool unfocusSearch) {
|
||||
if (_childList) {
|
||||
_childList->setInnerFocus();
|
||||
} else if ((_openedFolder || _openedForum)
|
||||
&& _subsectionTopBar->searchSetFocus()) {
|
||||
return;
|
||||
} else if (!_search->getLastText().isEmpty()
|
||||
|| _searchInChat
|
||||
|| _searchHasFocus
|
||||
|| _searchSuggestionsLocked) {
|
||||
} else if (!unfocusSearch
|
||||
&& (!_search->getLastText().isEmpty()
|
||||
|| _searchInChat
|
||||
|| _searchHasFocus
|
||||
|| _searchSuggestionsLocked)) {
|
||||
_search->setFocus();
|
||||
} else {
|
||||
setFocus();
|
||||
|
@ -2874,7 +2883,7 @@ bool Widget::setSearchInChat(
|
|||
if (_searchInChat || !_search->getLastText().isEmpty()) {
|
||||
_search->setFocus();
|
||||
} else {
|
||||
setFocus();
|
||||
setInnerFocus(true);
|
||||
}
|
||||
updateForceDisplayWide();
|
||||
return true;
|
||||
|
@ -3255,7 +3264,7 @@ void Widget::keyPressEvent(QKeyEvent *e) {
|
|||
//} else {
|
||||
// e->ignore();
|
||||
//}
|
||||
} else if (e->key() == Qt::Key_Backspace
|
||||
} else if ((e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Tab)
|
||||
&& _searchHasFocus
|
||||
&& !_searchInChat) {
|
||||
escape();
|
||||
|
@ -3339,7 +3348,7 @@ bool Widget::redirectKeyToSearch(QKeyEvent *e) const {
|
|||
}
|
||||
const auto character = !(e->modifiers() & ~Qt::ShiftModifier)
|
||||
&& (e->key() != Qt::Key_Shift)
|
||||
&& !e->text().isEmpty();
|
||||
&& RedirectTextToSearch(e->text());
|
||||
if (character) {
|
||||
return true;
|
||||
} else if (e != QKeySequence::Paste) {
|
||||
|
@ -3467,7 +3476,7 @@ bool Widget::cancelSearch() {
|
|||
if (!clearingQuery
|
||||
&& _subsectionTopBar
|
||||
&& _subsectionTopBar->toggleSearch(false, anim::type::normal)) {
|
||||
setFocus();
|
||||
setInnerFocus(true);
|
||||
clearingInChat = true;
|
||||
}
|
||||
const auto clearSearchFocus = !_searchInChat
|
||||
|
@ -3478,7 +3487,7 @@ bool Widget::cancelSearch() {
|
|||
}
|
||||
if (!_suggestions && clearSearchFocus) {
|
||||
// Don't create suggestions in unfocus case.
|
||||
setFocus();
|
||||
setInnerFocus(true);
|
||||
}
|
||||
_lastSearchPeer = nullptr;
|
||||
_lastSearchId = _lastSearchMigratedId = 0;
|
||||
|
@ -3486,7 +3495,7 @@ bool Widget::cancelSearch() {
|
|||
clearSearchField();
|
||||
applySearchUpdate();
|
||||
if (_suggestions && clearSearchFocus) {
|
||||
setFocus();
|
||||
setInnerFocus(true);
|
||||
}
|
||||
return clearingQuery || clearingInChat || clearSearchFocus;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
not_null<Data::Forum*> forum,
|
||||
const Window::SectionShow ¶ms);
|
||||
void searchInChat(Key chat);
|
||||
void setInnerFocus();
|
||||
void setInnerFocus(bool unfocusSearch = false);
|
||||
[[nodiscard]] bool searchHasFocus() const;
|
||||
|
||||
void jumpToTop(bool belowPinned = false);
|
||||
|
|
Loading…
Add table
Reference in a new issue