don't select emoji completion by default and add minimum string length before showing completions

This commit is contained in:
Jussi Kuokkanen 2020-08-29 23:05:40 +03:00
parent f40d8d15b5
commit aed8d23aca
1 changed files with 8 additions and 7 deletions

View File

@ -250,15 +250,18 @@ FilteredTextEdit::keyPressEvent(QKeyEvent *event)
QTextEdit::keyPressEvent(event);
emoji_popup_open_ = true;
emoji_completion_model_->setFilterRegExp(wordUnderCursor());
completer_->popup()->setCurrentIndex(completer_->completionModel()->index(0, 0));
completer_->complete(completerRect());
break;
}
case Qt::Key_Return:
case Qt::Key_Enter:
if (emoji_popup_open_) {
event->ignore();
return;
if (!completer_->popup()->currentIndex().isValid()) {
// No completion to select, do normal behavior
completer_->popup()->hide();
emoji_popup_open_ = false;
}
else
event->ignore();
}
if (!(event->modifiers() & Qt::ShiftModifier)) {
@ -307,11 +310,9 @@ FilteredTextEdit::keyPressEvent(QKeyEvent *event)
if (isModifier)
return;
if (emoji_popup_open_) {
if (emoji_popup_open_ && wordUnderCursor().length() > 2) {
// Update completion
emoji_completion_model_->setFilterRegExp(wordUnderCursor());
completer_->popup()->setCurrentIndex(
completer_->completionModel()->index(0, 0));
completer_->complete(completerRect());
}