mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +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.",
|
.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
|
} // namespace
|
||||||
|
|
||||||
const char kOptionForumHideChatsList[] = "forum-hide-chats-list";
|
const char kOptionForumHideChatsList[] = "forum-hide-chats-list";
|
||||||
|
@ -454,7 +463,6 @@ Widget::Widget(
|
||||||
loadMoreBlockedByDate();
|
loadMoreBlockedByDate();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_search->setFocusPolicy(Qt::StrongFocus);
|
|
||||||
_search->customUpDown(true);
|
_search->customUpDown(true);
|
||||||
|
|
||||||
updateJumpToDateVisibility(true);
|
updateJumpToDateVisibility(true);
|
||||||
|
@ -1514,16 +1522,17 @@ void Widget::checkUpdateStatus() {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setInnerFocus() {
|
void Widget::setInnerFocus(bool unfocusSearch) {
|
||||||
if (_childList) {
|
if (_childList) {
|
||||||
_childList->setInnerFocus();
|
_childList->setInnerFocus();
|
||||||
} else if ((_openedFolder || _openedForum)
|
} else if ((_openedFolder || _openedForum)
|
||||||
&& _subsectionTopBar->searchSetFocus()) {
|
&& _subsectionTopBar->searchSetFocus()) {
|
||||||
return;
|
return;
|
||||||
} else if (!_search->getLastText().isEmpty()
|
} else if (!unfocusSearch
|
||||||
|| _searchInChat
|
&& (!_search->getLastText().isEmpty()
|
||||||
|| _searchHasFocus
|
|| _searchInChat
|
||||||
|| _searchSuggestionsLocked) {
|
|| _searchHasFocus
|
||||||
|
|| _searchSuggestionsLocked)) {
|
||||||
_search->setFocus();
|
_search->setFocus();
|
||||||
} else {
|
} else {
|
||||||
setFocus();
|
setFocus();
|
||||||
|
@ -2874,7 +2883,7 @@ bool Widget::setSearchInChat(
|
||||||
if (_searchInChat || !_search->getLastText().isEmpty()) {
|
if (_searchInChat || !_search->getLastText().isEmpty()) {
|
||||||
_search->setFocus();
|
_search->setFocus();
|
||||||
} else {
|
} else {
|
||||||
setFocus();
|
setInnerFocus(true);
|
||||||
}
|
}
|
||||||
updateForceDisplayWide();
|
updateForceDisplayWide();
|
||||||
return true;
|
return true;
|
||||||
|
@ -3255,7 +3264,7 @@ void Widget::keyPressEvent(QKeyEvent *e) {
|
||||||
//} else {
|
//} else {
|
||||||
// e->ignore();
|
// e->ignore();
|
||||||
//}
|
//}
|
||||||
} else if (e->key() == Qt::Key_Backspace
|
} else if ((e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Tab)
|
||||||
&& _searchHasFocus
|
&& _searchHasFocus
|
||||||
&& !_searchInChat) {
|
&& !_searchInChat) {
|
||||||
escape();
|
escape();
|
||||||
|
@ -3339,7 +3348,7 @@ bool Widget::redirectKeyToSearch(QKeyEvent *e) const {
|
||||||
}
|
}
|
||||||
const auto character = !(e->modifiers() & ~Qt::ShiftModifier)
|
const auto character = !(e->modifiers() & ~Qt::ShiftModifier)
|
||||||
&& (e->key() != Qt::Key_Shift)
|
&& (e->key() != Qt::Key_Shift)
|
||||||
&& !e->text().isEmpty();
|
&& RedirectTextToSearch(e->text());
|
||||||
if (character) {
|
if (character) {
|
||||||
return true;
|
return true;
|
||||||
} else if (e != QKeySequence::Paste) {
|
} else if (e != QKeySequence::Paste) {
|
||||||
|
@ -3467,7 +3476,7 @@ bool Widget::cancelSearch() {
|
||||||
if (!clearingQuery
|
if (!clearingQuery
|
||||||
&& _subsectionTopBar
|
&& _subsectionTopBar
|
||||||
&& _subsectionTopBar->toggleSearch(false, anim::type::normal)) {
|
&& _subsectionTopBar->toggleSearch(false, anim::type::normal)) {
|
||||||
setFocus();
|
setInnerFocus(true);
|
||||||
clearingInChat = true;
|
clearingInChat = true;
|
||||||
}
|
}
|
||||||
const auto clearSearchFocus = !_searchInChat
|
const auto clearSearchFocus = !_searchInChat
|
||||||
|
@ -3478,7 +3487,7 @@ bool Widget::cancelSearch() {
|
||||||
}
|
}
|
||||||
if (!_suggestions && clearSearchFocus) {
|
if (!_suggestions && clearSearchFocus) {
|
||||||
// Don't create suggestions in unfocus case.
|
// Don't create suggestions in unfocus case.
|
||||||
setFocus();
|
setInnerFocus(true);
|
||||||
}
|
}
|
||||||
_lastSearchPeer = nullptr;
|
_lastSearchPeer = nullptr;
|
||||||
_lastSearchId = _lastSearchMigratedId = 0;
|
_lastSearchId = _lastSearchMigratedId = 0;
|
||||||
|
@ -3486,7 +3495,7 @@ bool Widget::cancelSearch() {
|
||||||
clearSearchField();
|
clearSearchField();
|
||||||
applySearchUpdate();
|
applySearchUpdate();
|
||||||
if (_suggestions && clearSearchFocus) {
|
if (_suggestions && clearSearchFocus) {
|
||||||
setFocus();
|
setInnerFocus(true);
|
||||||
}
|
}
|
||||||
return clearingQuery || clearingInChat || clearSearchFocus;
|
return clearingQuery || clearingInChat || clearSearchFocus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ public:
|
||||||
not_null<Data::Forum*> forum,
|
not_null<Data::Forum*> forum,
|
||||||
const Window::SectionShow ¶ms);
|
const Window::SectionShow ¶ms);
|
||||||
void searchInChat(Key chat);
|
void searchInChat(Key chat);
|
||||||
void setInnerFocus();
|
void setInnerFocus(bool unfocusSearch = false);
|
||||||
[[nodiscard]] bool searchHasFocus() const;
|
[[nodiscard]] bool searchHasFocus() const;
|
||||||
|
|
||||||
void jumpToTop(bool belowPinned = false);
|
void jumpToTop(bool belowPinned = false);
|
||||||
|
|
Loading…
Add table
Reference in a new issue