[Bf-extensions-cvs] [d1701786] master: BlenderKit: search field on top - a dialog box telling the user why an asset is locked -verification status change now in thread - Search UI small changes, getting rid of show assetbar button (now a small eye)

Vilém Duha noreply at git.blender.org
Thu Jan 9 17:29:26 CET 2020


Commit: d1701786f237df9cbcd7b12b5383a283d4f12e3b
Author: Vilém Duha
Date:   Thu Jan 9 13:46:21 2020 +0100
Branches: master
https://developer.blender.org/rBAd1701786f237df9cbcd7b12b5383a283d4f12e3b

BlenderKit: search field on top
 - a dialog box telling the user why an asset is locked
 -verification status change now in thread
 - Search UI small changes, getting rid of show assetbar button (now a small eye)

===================================================================

M	blenderkit/__init__.py
M	blenderkit/download.py
M	blenderkit/search.py
M	blenderkit/ui.py
M	blenderkit/ui_panels.py
M	blenderkit/upload.py

===================================================================

diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index af323336..2734ad69 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -244,6 +244,26 @@ def switch_search_results(self, context):
         s['search results orig'] = s.get('bkit brush search orig')
     search.load_previews()
 
+def asset_type_callback(self, context):
+    #s = bpy.context.scene
+    #ui_props = s.blenderkitUI
+    if self.down_up == 'SEARCH':
+        items = (
+            ('MODEL', 'Search Models', 'Browse models', 'OBJECT_DATAMODE', 0),
+            # ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
+            ('MATERIAL', 'Search Materials', 'Browse materials', 'MATERIAL', 2),
+            # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
+            ('BRUSH', 'Search Brushes', 'Browse brushes', 'BRUSH_DATA', 3)
+        )
+    else:
+        items = (
+            ('MODEL', 'Upload Model', 'Browse models', 'OBJECT_DATAMODE', 0),
+            # ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
+            ('MATERIAL', 'Uplaod Material', 'Browse materials', 'MATERIAL', 2),
+            # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
+            ('BRUSH', 'Upload Brush', 'Browse brushes', 'BRUSH_DATA', 3)
+        )
+    return items
 
 class BlenderKitUIProps(PropertyGroup):
     down_up: EnumProperty(
@@ -258,15 +278,9 @@ class BlenderKitUIProps(PropertyGroup):
     )
     asset_type: EnumProperty(
         name="Active Asset Type",
-        items=(
-            ('MODEL', 'Model', 'Browse models', 'OBJECT_DATAMODE', 0),
-            # ('SCENE', 'SCENE', 'Browse scenes', 'SCENE_DATA', 1),
-            ('MATERIAL', 'Material', 'Browse models', 'MATERIAL', 2),
-            # ('TEXTURE', 'Texture', 'Browse textures', 'TEXTURE', 3),
-            ('BRUSH', 'Brush', 'Browse brushes', 'BRUSH_DATA', 3)
-        ),
+        items=asset_type_callback,
         description="Activate asset in UI",
-        default="MATERIAL",
+        default=None,
         update=switch_search_results
     )
     # these aren't actually used ( by now, seems to better use globals in UI module:
diff --git a/blenderkit/download.py b/blenderkit/download.py
index 296a7639..d652807e 100644
--- a/blenderkit/download.py
+++ b/blenderkit/download.py
@@ -762,8 +762,8 @@ def get_download_url(asset_data, scene_id, api_key, tcom=None):
 
     if r.status_code == 403:
         r = 'You need Full plan to get this item.'
-        r1 = 'All materials and brushes are available for free. Only users registered to Standard plan can use all models.'
-        tasks_queue.add_task((ui.add_report, (r1, 5, colors.RED)))
+        # r1 = 'All materials and brushes are available for free. Only users registered to Standard plan can use all models.'
+        # tasks_queue.add_task((ui.add_report, (r1, 5, colors.RED)))
         if tcom is not None:
             tcom.report = r
             tcom.error = True
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 56c1d0cb..b4459167 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -95,8 +95,6 @@ def refresh_token_timer():
 def scene_load(context):
     wm = bpy.context.window_manager
     fetch_server_data()
-    # following doesn't necessarily happen if version isn't checked yet or similar, first run.
-    # wm['bkit_update'] = version_checker.compare_versions(blenderkit)
     categories.load_categories()
     if not bpy.app.timers.is_registered(refresh_token_timer):
         bpy.app.timers.register(refresh_token_timer, persistent=True, first_interval=36000)
@@ -1118,6 +1116,10 @@ def search(category='', get_next=False, author_id=''):
 def search_update(self, context):
     utils.p('search updater')
     #if self.search_keywords != '':
+    ui_props = bpy.context.scene.blenderkitUI
+    if ui_props.down_up != 'SEARCH':
+        ui_props.down_up = 'SEARCH'
+
     search()
 
 
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index b29e24af..0e8b0744 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -1161,7 +1161,7 @@ def get_largest_3dview():
         for a in screen.areas:
             if a.type == 'VIEW_3D':
                 asurf = a.width * a.height
-                if asurf>maxsurf:
+                if asurf > maxsurf:
                     maxa = a
                     maxw = w
                     maxsurf = asurf
@@ -1171,7 +1171,6 @@ def get_largest_3dview():
                             region = r
     return maxw, maxa, region
 
-
 class AssetBarOperator(bpy.types.Operator):
     '''runs search and displays the asset bar at the same time'''
     bl_idname = "view3d.blenderkit_asset_bar"
@@ -1459,6 +1458,17 @@ class AssetBarOperator(bpy.types.Operator):
             ui_props = context.scene.blenderkitUI
             if event.value == 'PRESS' and ui_props.active_index > -1:
                 if ui_props.asset_type == 'MODEL' or ui_props.asset_type == 'MATERIAL':
+                    # check if asset is locked and let the user know in that case
+                    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.'
+                        url = paths.get_bkit_url() + '/get-blenderkit/' + asset_data['id']
+                        bpy.ops.wm.blenderkit_url_dialog('INVOKE_REGION_WIN', url=url, message=message,
+                                                         link_text=link_text)
+                        return {'RUNNING_MODAL'}
+                    # go on with drag init
                     ui_props.drag_init = True
                     bpy.context.window.cursor_set("NONE")
                     ui_props.draw_tooltip = False
@@ -1720,12 +1730,13 @@ class TransferBlenderkitData(bpy.types.Operator):
         source_ob.property_unset('blenderkit')
         return {'FINISHED'}
 
+
 class RunAssetBarWithContext(bpy.types.Operator):
     """Regenerate cobweb"""
     bl_idname = "object.run_assetbar_fix_context"
     bl_label = "BlnenderKit assetbar with fixed context"
     bl_description = "Run assetbar with fixed context"
-    bl_options = {'REGISTER', 'UNDO',  'INTERNAL'}
+    bl_options = {'REGISTER', 'UNDO', 'INTERNAL'}
 
     # def modal(self, context, event):
     #     return {'RUNNING_MODAL'}
@@ -1772,9 +1783,9 @@ def register_ui():
     kmi.properties.keep_running = False
     kmi.properties.do_search = False
     addon_keymapitems.append(kmi)
-    #auto open after searching:
-    kmi = km.keymap_items.new(RunAssetBarWithContext.bl_idname, 'SEMI_COLON', 'PRESS',\
-                              ctrl=True, shift=True, alt = True)
+    # auto open after searching:
+    kmi = km.keymap_items.new(RunAssetBarWithContext.bl_idname, 'SEMI_COLON', 'PRESS', \
+                              ctrl=True, shift=True, alt=True)
     addon_keymapitems.append(kmi)
 
 
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index fb3f944b..24d64cb3 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -108,7 +108,6 @@ def draw_upload_common(layout, props, asset_type, context):
     # if props.upload_state.find('Error') > -1:
     #     layout.label(text = props.upload_state)
 
-
     if props.asset_base_id == '':
         optext = 'Upload %s' % asset_type.lower()
         op = layout.operator("object.blenderkit_upload", text=optext, icon='EXPORT')
@@ -263,12 +262,28 @@ def draw_panel_scene_upload(self, context):
     row.prop(props, 'work_hours')
     layout.prop(props, 'adult')
 
+def draw_assetbar_show_hide(layout, props):
+    s = bpy.context.scene
+    ui_props = s.blenderkitUI
+
+    if ui_props.assetbar_on:
+        icon = 'HIDE_OFF'
+    else:
+        icon = 'HIDE_ON'
+    op = layout.operator('view3d.blenderkit_asset_bar', text='', icon=icon)
+    op.keep_running = False
+    op.do_search = False
+
 
 def draw_panel_model_search(self, context):
     s = context.scene
+
     props = s.blenderkit_models
     layout = self.layout
-    layout.prop(props, "search_keywords", text="", icon='VIEWZOOM')
+
+    row = layout.row()
+    row.prop(props, "search_keywords", text="", icon='VIEWZOOM')
+    draw_assetbar_show_hide(row, props)
 
     icon = 'NONE'
     if props.report == 'You need Full plan to get this item.':
@@ -342,7 +357,9 @@ def draw_panel_scene_search(self, context):
     props = s.blenderkit_scene
     layout = self.layout
     # layout.label(text = "common search properties:")
-    layout.prop(props, "search_keywords", text="", icon='VIEWZOOM')
+    row = layout.row()
+    row.prop(props, "search_keywords", text="", icon='VIEWZOOM')
+    draw_assetbar_show_hide(row, props)
 
     label_multiline(layout, text=props.report)
 
@@ -381,12 +398,12 @@ class VIEW3D_PT_blenderkit_model_properties(Panel):
             # if 'rig' in ad['tags']:
             #     # layout.label(text = 'can make proxy')
             #     layout.operator('object.blenderkit_make_proxy', text = 'Make Armature proxy')
-        #fast upload, blocked by now
+        # fast upload, blocked by now
         # else:
         #     op = layout.operator("object.blenderkit_upload", text='Store as private', icon='EXPORT')
         #     op.asset_type = 'MODEL'
         #     op.fast = True
-        #fun override project, not finished
+        # fun override project, not finished
         # layout.operator('object.blenderkit_color_corrector')
 
 
@@ -500,7 +517,9 @@ def draw_panel_material_search(self, context):
     props = wm.blenderkit_mat
 
     layout = self.layout
-    layout.prop(props, "search_keywords", text="", icon='VIEWZOOM')
+    row = layout.row()
+    row.prop(props, "search_keywords", text="", icon='VIEWZOOM')
+    draw_assetbar_show_hide(row, props)
 
     label_multiline(layout, text=props.report)
 
@@ -540,7 +559,11 @@ def draw_panel_brush_search(self, context):
     props = wm.blenderkit_brush
 
     layout = self.layout
-    layout.prop(props, "search_keywords", text="", icon='VIEWZOOM')
+    row = layout.row()
+    row.prop(props, "search_keywords", text="", icon='VIEWZOOM')
+    draw_assetbar_show_hide(row, props)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list