Allow picking tags from completion menu with keyboard

* Also fixes the hiding and display of the completion menu to be more natural and less annoying.
* Fixes #7939
This commit is contained in:
Jonathan White 2022-10-18 18:24:35 -04:00
parent 5e9fa18a4d
commit 1af985fde9
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01

View File

@ -413,9 +413,9 @@ struct TagsEdit::Impl
void setupCompleter()
{
completer->setWidget(ifce);
connect(completer.get(), static_cast<void (QCompleter::*)(QString const&)>(&QCompleter::activated), [this](QString const& text) {
currentText(text);
});
connect(completer.get(),
static_cast<void (QCompleter::*)(QString const&)>(&QCompleter::activated),
[this](QString const& text) { currentText(text); });
}
QVector<QTextLayout::FormatRange> formatting() const
@ -861,10 +861,16 @@ void TagsEdit::keyPressEvent(QKeyEvent* event)
case Qt::Key_Enter:
case Qt::Key_Comma:
case Qt::Key_Semicolon:
// If completer is visible, accept the selection or hide if no selection
if (impl->completer->popup()->isVisible() && impl->completer->popup()->selectionModel()->hasSelection()) {
break;
}
// Make existing text into a tag
if (!impl->currentText().isEmpty()) {
impl->editNewTag(impl->editing_index + 1);
event->accept();
}
event->accept();
break;
default:
unknown = true;