From 2b33fb3ad28cdef8e19fe998fc085c38eae0970b Mon Sep 17 00:00:00 2001 From: derrod Date: Sun, 12 Feb 2023 15:45:40 +0100 Subject: [PATCH] UI: Massive improve hotkey search performance --- UI/window-basic-settings.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index f97eb8978..97c5630ed 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -4519,7 +4519,6 @@ void OBSBasicSettings::SearchHotkeys(const QString &text, std::vector combos; bool showHotkey; ui->hotkeyScrollArea->ensureVisible(0, 0); - ui->hotkeyScrollArea->setUpdatesEnabled(false); QLayoutItem *hotkeysItem = ui->hotkeyFormLayout->itemAt(0); QWidget *hotkeys = hotkeysItem->widget(); @@ -4528,6 +4527,9 @@ void OBSBasicSettings::SearchHotkeys(const QString &text, QFormLayout *hotkeysLayout = qobject_cast(hotkeys->layout()); + hotkeysLayout->setEnabled(false); + + QString needle = text.toLower(); for (int i = 0; i < hotkeysLayout->rowCount(); i++) { auto label = hotkeysLayout->itemAt(i, QFormLayout::LabelRole); @@ -4539,18 +4541,19 @@ void OBSBasicSettings::SearchHotkeys(const QString &text, if (!item) continue; - item->widget->GetCombinations(combos); QString fullname = item->property("fullName").value(); - showHotkey = text.isEmpty() || - fullname.toLower().contains(text.toLower()); + showHotkey = needle.isEmpty() || + fullname.toLower().contains(needle); if (showHotkey && !obs_key_combination_is_empty(filterCombo)) { showHotkey = false; + + item->widget->GetCombinations(combos); for (auto combo : combos) { if (combo == filterCombo) { showHotkey = true; - continue; + break; } } } @@ -4561,7 +4564,7 @@ void OBSBasicSettings::SearchHotkeys(const QString &text, if (field) field->widget()->setVisible(showHotkey); } - ui->hotkeyScrollArea->setUpdatesEnabled(true); + hotkeysLayout->setEnabled(true); } void OBSBasicSettings::on_hotkeyFilterReset_clicked()