2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-01 23:15:59 +00:00

Redirect IME to search on Windows.

This commit is contained in:
John Preston
2024-05-07 13:18:58 +04:00
parent 1f3a3ec04b
commit 2cb0651b04
6 changed files with 56 additions and 6 deletions

View File

@@ -356,6 +356,14 @@ Widget::Widget(
Ui::PostponeCall(this, [=] { listScrollUpdated(); });
}, lifetime());
setAttribute(Qt::WA_InputMethodEnabled);
controller->widget()->imeCompositionStarts(
) | rpl::filter([=] {
return redirectImeToSearch();
}) | rpl::start_with_next([=] {
_search->setFocusFast();
}, lifetime());
_search->changes(
) | rpl::start_with_next([=] {
applySearchUpdate();
@@ -3290,12 +3298,17 @@ void Widget::keyPressEvent(QKeyEvent *e) {
}
}
bool Widget::redirectToSearchPossible() const {
return !_openedFolder
&& !_openedForum
&& !_childList
&& _search->isVisible()
&& !_search->hasFocus()
&& hasFocus();
}
bool Widget::redirectKeyToSearch(QKeyEvent *e) const {
if (_openedFolder
|| _openedForum
|| _childList
|| !_search->isVisible()
|| _search->hasFocus()) {
if (!redirectToSearchPossible()) {
return false;
}
const auto character = !(e->modifiers() & ~Qt::ShiftModifier)
@@ -3316,6 +3329,10 @@ bool Widget::redirectKeyToSearch(QKeyEvent *e) const {
return data && data->hasText();
}
bool Widget::redirectImeToSearch() const {
return redirectToSearchPossible();
}
void Widget::paintEvent(QPaintEvent *e) {
if (controller()->contentOverlapped(this, e)) {
return;