Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilém Duha <vilda.novak@gmail.com>2021-04-08 14:06:06 +0300
committerVilém Duha <vilda.novak@gmail.com>2021-04-09 09:29:38 +0300
commit85d715495836b6990202e2993ad2dfe835bf9691 (patch)
tree9a54e683e027e2e27bc63e5ff82101a3260cde42 /blenderkit
parent4e1ab4a386d5c78bf173bd5d58a4ceb8783c8661 (diff)
BlenderKit: fixes for search
queries with diacritics or too long queries are now stripped of diacritics or cropped correctly Scroll jumps back to beginning for new searches.
Diffstat (limited to 'blenderkit')
-rw-r--r--blenderkit/search.py28
-rw-r--r--blenderkit/ui_panels.py3
2 files changed, 20 insertions, 11 deletions
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 5c3a56f5..51dea4a8 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -47,6 +47,7 @@ import bpy
import copy
import json
import math
+import unicodedata
import logging
@@ -417,7 +418,6 @@ def timer_update():
return .2
rdata = thread[0].result
-
result_field = []
ok, error = check_errors(rdata)
if ok:
@@ -435,7 +435,8 @@ def timer_update():
load_previews()
ui_props = bpy.context.scene.blenderkitUI
- if len(result_field) < ui_props.scrolloffset:
+ if len(result_field) < ui_props.scrolloffset or not(thread[0].params.get('get_next')):
+ #jump back
ui_props.scrolloffset = 0
props.is_searching = False
props.search_error = False
@@ -1434,6 +1435,18 @@ def search(category='', get_next=False, author_id=''):
props = scene.blenderkit_brush
query = build_query_brush()
+ # crop long searches
+ if query.get('query'):
+ if len(query['query']) > 50:
+ print('strip it now strip it good')
+ print(query['query'])
+ query['query'] = strip_accents(query['query'])
+ print(query['query'])
+
+ if len(query['query']) > 150:
+ idx = query['query'].find(' ', 142)
+ query['query'] = query['query'][:idx]
+
# it's possible get_net was requested more than once.
if props.is_searching and get_next == True:
return;
@@ -1464,8 +1477,6 @@ def search(category='', get_next=False, author_id=''):
'free_first': props.free_only
}
- # if free_only:
- # query['keywords'] += '+is_free:true'
orig_results = bpy.context.window_manager.get(f'bkit {ui_props.asset_type.lower()} search orig', {})
if orig_results != {}:
# ensure it's a copy in dict for what we are passing to thread:
@@ -1516,6 +1527,10 @@ def search_update(self, context):
search()
+# accented_string is of type 'unicode'
+def strip_accents(s):
+ return ''.join(c for c in unicodedata.normalize('NFD', s)
+ if unicodedata.category(c) != 'Mn')
class SearchOperator(Operator):
"""Tooltip"""
@@ -1565,10 +1580,7 @@ class SearchOperator(Operator):
sprops.search_keywords = ''
if self.keywords != '':
sprops.search_keywords = self.keywords
- #crop long searches
- if len(self.keywords) > 150:
- idx = self.keywords.find(' ', 142)
- self.keywords = self.keywords[:idx]
+
search(category=self.category, get_next=self.get_next, author_id=self.author_id)
# bpy.ops.view3d.blenderkit_asset_bar()
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 4ccddcfe..0dbeaf89 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -1580,9 +1580,6 @@ def draw_panel_categories(self, context):
layout = self.layout
# row = layout.row()
# row.prop(ui_props, 'asset_type', expand=True, icon_only=True)
- layout.separator()
-
- layout.label(text='Categories')
wm = bpy.context.window_manager
if wm.get('bkit_categories') == None:
return