[Bf-extensions-cvs] [7a871722] master: BlenderKit: close popup menu when it makes sense after running an operator
Vilem Duha
noreply at git.blender.org
Fri Jul 23 16:02:59 CEST 2021
Commit: 7a871722abfc7968d49e2cf28dd410bd97a69095
Author: Vilem Duha
Date: Tue Jul 20 15:09:44 2021 +0200
Branches: master
https://developer.blender.org/rBA7a871722abfc7968d49e2cf28dd410bd97a69095
BlenderKit: close popup menu when it makes sense after running an operator
===================================================================
M blenderkit/paths.py
M blenderkit/search.py
M blenderkit/ui_panels.py
===================================================================
diff --git a/blenderkit/paths.py b/blenderkit/paths.py
index b9847be2..e074d966 100644
--- a/blenderkit/paths.py
+++ b/blenderkit/paths.py
@@ -97,6 +97,8 @@ def get_categories_filepath():
return os.path.join(tempdir, 'categories.json')
dirs_exist_dict = {}#cache these results since this is used very often
+# this causes the function to fail if user deletes the directory while blender is running,
+# but comes back when blender is restarted.
def get_temp_dir(subdir=None):
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
diff --git a/blenderkit/search.py b/blenderkit/search.py
index d8344aca..b58dd28d 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -1458,6 +1458,12 @@ class SearchOperator(Operator):
bl_description = "Search online for assets"
bl_options = {'REGISTER', 'UNDO', 'INTERNAL'}
+ esc: BoolProperty(name="Escape window",
+ description="Escape window right after start",
+ default=False,
+ options={'SKIP_SAVE'}
+ )
+
own: BoolProperty(name="own assets only",
description="Find all own assets",
default=False)
@@ -1506,6 +1512,8 @@ class SearchOperator(Operator):
def execute(self, context):
# TODO ; this should all get transferred to properties of the search operator, so sprops don't have to be fetched here at all.
+ if self.esc:
+ bpy.ops.view3d.close_popup_button('INVOKE_DEFAULT')
sprops = utils.get_search_props()
if self.author_id != '':
sprops.search_keywords = ''
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 292d8359..bc20169f 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -1206,6 +1206,7 @@ def draw_asset_context_menu(layout, context, asset_data, from_panel=False):
op.author_id = author_id
op = layout.operator('view3d.blenderkit_search', text='Search Similar')
+ op.esc = True
op.tooltip = 'Search for similar assets in the library'
# build search string from description and tags:
op.keywords = asset_data['name']
@@ -1721,6 +1722,7 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
op.url = url
op = button_row.operator('view3d.blenderkit_search', text="Find Assets By Author")
+ op.esc = True
op.keywords = ''
op.author_id = self.asset_data['author']['id']
More information about the Bf-extensions-cvs
mailing list