mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Allow pasting text to the unfocused search.
This commit is contained in:
parent
612b81ee87
commit
12a78c1f45
2 changed files with 28 additions and 7 deletions
|
@ -3264,13 +3264,7 @@ void Widget::keyPressEvent(QKeyEvent *e) {
|
||||||
} else {
|
} else {
|
||||||
_inner->selectSkipPage(_scroll->height(), -1);
|
_inner->selectSkipPage(_scroll->height(), -1);
|
||||||
}
|
}
|
||||||
} else if (!(e->modifiers() & ~Qt::ShiftModifier)
|
} else if (redirectKeyToSearch(e)) {
|
||||||
&& e->key() != Qt::Key_Shift
|
|
||||||
&& !_openedFolder
|
|
||||||
&& !_openedForum
|
|
||||||
&& _search->isVisible()
|
|
||||||
&& !_search->hasFocus()
|
|
||||||
&& !e->text().isEmpty()) {
|
|
||||||
// This delay in search focus processing allows us not to create
|
// This delay in search focus processing allows us not to create
|
||||||
// _suggestions in case the event inserts some non-whitespace search
|
// _suggestions in case the event inserts some non-whitespace search
|
||||||
// query while still show _suggestions animated, if it is a space.
|
// query while still show _suggestions animated, if it is a space.
|
||||||
|
@ -3284,6 +3278,31 @@ void Widget::keyPressEvent(QKeyEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Widget::redirectKeyToSearch(QKeyEvent *e) const {
|
||||||
|
if (_openedFolder
|
||||||
|
|| _openedForum
|
||||||
|
|| !_search->isVisible()
|
||||||
|
|| _search->hasFocus()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto character = !(e->modifiers() & ~Qt::ShiftModifier)
|
||||||
|
&& (e->key() != Qt::Key_Shift)
|
||||||
|
&& !e->text().isEmpty();
|
||||||
|
if (character) {
|
||||||
|
return true;
|
||||||
|
} else if (e != QKeySequence::Paste) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto useSelectionMode = (e->key() == Qt::Key_Insert)
|
||||||
|
&& (e->modifiers() == (Qt::CTRL | Qt::SHIFT))
|
||||||
|
&& QGuiApplication::clipboard()->supportsSelection();
|
||||||
|
const auto pasteMode = useSelectionMode
|
||||||
|
? QClipboard::Selection
|
||||||
|
: QClipboard::Clipboard;
|
||||||
|
const auto data = QGuiApplication::clipboard()->mimeData(pasteMode);
|
||||||
|
return data && data->hasText();
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::paintEvent(QPaintEvent *e) {
|
void Widget::paintEvent(QPaintEvent *e) {
|
||||||
if (controller()->contentOverlapped(this, e)) {
|
if (controller()->contentOverlapped(this, e)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -250,6 +250,8 @@ private:
|
||||||
void updateSuggestions(anim::type animated);
|
void updateSuggestions(anim::type animated);
|
||||||
void processSearchFocusChange();
|
void processSearchFocusChange();
|
||||||
|
|
||||||
|
[[nodiscard]] bool redirectKeyToSearch(QKeyEvent *e) const;
|
||||||
|
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
|
|
||||||
bool _dragInScroll = false;
|
bool _dragInScroll = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue