Skip to content

Commit

Permalink
setup/enginedialog: Improve the search for engines
Browse files Browse the repository at this point in the history
- strip whitespace from the search entry
- make the filter entry get focus after clicking on the view-more row
- split the contents of the search entry into words and
  make the result True if all words match in any order.

BUG=#2581
  • Loading branch information
mike-fabian committed Feb 19, 2024
1 parent fe4958b commit d3d7762
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions setup/enginedialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,28 @@ def __list_filter(self, row, data):
if row.back:
return True

word = self.__filter_word.lower()
if word in row.name.lower():
words = self.__filter_word.lower().strip().split()
if all(word in row.name.lower() for word in words):
return True
if word in row.untrans.lower():
if all(word in row.untrans.lower() for word in words):
return True
# Search engine name in language list
if row.lang_info:
if row.name in self.__engines_for_lang.keys():
for row_l in self.__engines_for_lang[row.name]:
if word in row_l.name.lower():
if all(word in row_l.name.lower() for word in words):
return True
if word in row_l.untrans.lower():
if all(word in row_l.untrans.lower() for word in words):
return True
# Search language name in engine list
if not row.lang_info:
for l in self.__engines_for_lang.keys():
if word in l.lower():
if all(word in l.lower() for word in words):
for row_l in self.__engines_for_lang[l]:
if row.name == row_l.name:
return True
for (trans, untrans) in self.__untrans_for_lang.items():
if word in untrans.lower():
if all(word in untrans.lower() for word in words):
for row_l in self.__engines_for_lang[trans]:
if row.name == row_l.name:
return True
Expand Down Expand Up @@ -305,6 +305,8 @@ def __show_lang_rows(self):
def __show_more(self):
self.__set_fixed_size()
self.__filter_entry.show()
# Get focus after clicking on the view-more row:
self.__filter_entry.grab_focus_without_selecting()
self.__showing_extra = True
self.__list.invalidate_filter()

Expand Down

0 comments on commit d3d7762

Please sign in to comment.