[Bf-extensions-cvs] [14ee8dfc] master: BlenderKit: attempt to fix asset bar hang bug
Vilém Duha
noreply at git.blender.org
Mon Feb 24 17:13:39 CET 2020
Commit: 14ee8dfc0f360d7ea53c467e218f45fbf965da74
Author: Vilém Duha
Date: Mon Feb 24 16:54:17 2020 +0100
Branches: master
https://developer.blender.org/rBA14ee8dfc0f360d7ea53c467e218f45fbf965da74
BlenderKit: attempt to fix asset bar hang bug
-caused by wrong order of checks in the modal operator
add 'first run' assetbar appearance, helpful for first time users.
Improve clipboard checking
tweak asset locked message
add plans to profile panel
===================================================================
M blenderkit/__init__.py
M blenderkit/search.py
M blenderkit/ui.py
M blenderkit/ui_panels.py
===================================================================
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index d64ea133..c8834823 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -1527,6 +1527,11 @@ class BlenderKitAddonPreferences(AddonPreferences):
min=0,
max=20000)
+ first_run: BoolProperty(
+ name="First run",
+ description="Detects if addon was already registered/run.",
+ default=True
+ )
# allow_proximity : BoolProperty(
# name="allow proximity data reports",
# description="This sends anonymized proximity data \n \
diff --git a/blenderkit/search.py b/blenderkit/search.py
index bf430d91..94b0c94c 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -130,35 +130,38 @@ def fetch_server_data():
first_time = True
last_clipboard = ''
+def check_clipboard():
+ # clipboard monitoring to search assets from web
+ global last_clipboard
+ if bpy.context.window_manager.clipboard != last_clipboard:
+ last_clipboard = bpy.context.window_manager.clipboard
+ instr = 'asset_base_id:'
+ # first check if contains asset id, then asset type
+ if last_clipboard[:len(instr)] == instr:
+ atstr = 'asset_type:'
+ ati = last_clipboard.find(atstr)
+ # this only checks if the asset_type keyword is there but let's the keywords update function do the parsing.
+ if ati > -1:
+ search_props = utils.get_search_props()
+ search_props.search_keywords = last_clipboard
+ # don't run search after this - assigning to keywords runs the search_update function.
@bpy.app.handlers.persistent
def timer_update():
# this makes a first search after opening blender. showing latest assets.
global first_time
preferences = bpy.context.preferences.addons['blenderkit'].preferences
- if first_time:
+ if first_time:# first time
first_time = False
- if preferences.show_on_start:
+ if preferences.show_on_start or preferences.first_run:
search()
+ preferences.first_run = False
if preferences.tips_on_start:
ui.get_largest_3dview()
ui.update_ui_size(ui.active_area, ui.active_region)
ui.add_report(text='BlenderKit Tip: ' + random.choice(rtips), timeout=12, color=colors.GREEN)
- # clipboard monitoring to search assets from web
- global last_clipboard
- if bpy.context.window_manager.clipboard != last_clipboard:
- last_clipboard = bpy.context.window_manager.clipboard
- instr = 'asset_base_id:'
- # first check if contains asset id, then asset type
- if last_clipboard[:len(instr)] == instr:
- atstr = 'asset_type:'
- ati = last_clipboard.find(atstr)
- #this only checks if the asset_type keyword is there but let's the keywords update function do the parsing.
- if ati > -1:
- search_props = utils.get_search_props()
- search_props.search_keywords = last_clipboard
- # don't run search after this - assigning to keywords runs the search_update function.
+ check_clipboard()
global search_threads
# don't do anything while dragging - this could switch asset during drag, and make results list length different,
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index b0753a08..f5efae7d 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -1288,10 +1288,7 @@ class AssetBarOperator(bpy.types.Operator):
update_ui_size(self.area, self.region)
- if context.region != self.region:
- print(time.time(), 'pass through because of region')
- print(context.region.type, self.region.type)
- return {'PASS_THROUGH'}
+
# this was here to check if sculpt stroke is running, but obviously that didn't help,
# since the RELEASE event is cought by operator and thus there is no way to detect a stroke has ended...
@@ -1313,6 +1310,11 @@ class AssetBarOperator(bpy.types.Operator):
ui_props.draw_tooltip = False
return {'CANCELLED'}
+ if context.region != self.region:
+ # print(time.time(), 'pass through because of region')
+ # print(context.region.type, self.region.type)
+ return {'PASS_THROUGH'}
+
if ui_props.down_up == 'UPLOAD':
ui_props.mouse_x = 0
@@ -1504,8 +1506,8 @@ class AssetBarOperator(bpy.types.Operator):
asset_search_index = ui_props.active_index
asset_data = sr[asset_search_index]
if not asset_data['can_download']:
- message = 'Asset locked. Find out how to unlock Everything and ...'
- link_text = 'support all BlenderKit artists.'
+ message = "Let's support asset creators and Blender development."
+ link_text = 'Unlock the asset.'
url = paths.get_bkit_url() + '/get-blenderkit/' + asset_data['id'] + '/?from_addon'
bpy.ops.wm.blenderkit_url_dialog('INVOKE_REGION_WIN', url=url, message=message,
link_text=link_text)
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index cacc1df4..0330bf88 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -470,13 +470,20 @@ class VIEW3D_PT_blenderkit_profile(Panel):
# plan information
- # pcoll = icons.icon_collections["main"]
- # my_icon = pcoll['free']
- # row = layout.row()
- # row.label(text='My plan:')
- # row.label(text='Free plan', icon_value=my_icon.icon_id)
- # layout.operator("wm.url_open", text="Change plan",
- # icon='URL').url = paths.get_bkit_url() + paths.BLENDERKIT_PLANS
+ if me.get('currentPlanName') is not None:
+ pn = me['currentPlanName']
+ pcoll = icons.icon_collections["main"]
+ if pn == 'Free':
+ my_icon = pcoll['free']
+ else:
+ my_icon = pcoll['full']
+
+ row = layout.row()
+ row.label(text='My plan:')
+ row.label(text='%s plan' % pn, icon_value=my_icon.icon_id)
+ if pn =='Free':
+ layout.operator("wm.url_open", text="Change plan",
+ icon='URL').url = paths.get_bkit_url() + paths.BLENDERKIT_PLANS
# storage statistics
# if me.get('sumAssetFilesSize') is not None: # TODO remove this when production server has these too.
More information about the Bf-extensions-cvs
mailing list