mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-24 10:33:15 +08:00
feat: show auto completion window when focus in AutoCompleteTextEdit
This commit is contained in:
parent
5e78dec90a
commit
bc29296716
11
3rdparty/qv2ray/v2/ui/QvAutoCompleteTextEdit.cpp
vendored
11
3rdparty/qv2ray/v2/ui/QvAutoCompleteTextEdit.cpp
vendored
@ -101,6 +101,16 @@ namespace Qv2ray::ui::widgets {
|
|||||||
if (c)
|
if (c)
|
||||||
c->setWidget(this);
|
c->setWidget(this);
|
||||||
|
|
||||||
|
if (lineUnderCursor().isEmpty()) {
|
||||||
|
c->setCompletionPrefix("");
|
||||||
|
} else if (auto word = lineUnderCursor(); word != c->completionPrefix()) {
|
||||||
|
c->setCompletionPrefix(word);
|
||||||
|
}
|
||||||
|
c->popup()->setCurrentIndex(c->completionModel()->index(0, 0));
|
||||||
|
QRect cr = cursorRect();
|
||||||
|
cr.setWidth(c->popup()->sizeHintForColumn(0) + c->popup()->verticalScrollBar()->sizeHint().width());
|
||||||
|
c->complete(cr); // popup it up!
|
||||||
|
|
||||||
QPlainTextEdit::focusInEvent(e);
|
QPlainTextEdit::focusInEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +136,7 @@ namespace Qv2ray::ui::widgets {
|
|||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
case Qt::Key_Tab:
|
case Qt::Key_Tab:
|
||||||
case Qt::Key_Backtab:
|
case Qt::Key_Backtab:
|
||||||
|
case Qt::Key_Asterisk:
|
||||||
e->ignore();
|
e->ignore();
|
||||||
return; // let the completer do default behavior
|
return; // let the completer do default behavior
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user