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-02-28 23:57:32 +0300
committerVilém Duha <vilda.novak@gmail.com>2021-03-16 19:12:17 +0300
commit7164debdd6cea41807e5bdc160f05175f1a1d804 (patch)
tree0930d0be5226ccbb8438afdfdc79588c188ee858 /blenderkit
parentc3b43de9ece49e4f72a35f9b6e8734657e039adf (diff)
BlenderKit: several fixes
drag drop start was too sensitive and practically disabled click behaviour. resolution - swapping from original resolution invoke asset name is shortened for the purpose of saving to files - There were some assets that couldn't download because of super-long names. category fix mode -
Diffstat (limited to 'blenderkit')
-rw-r--r--blenderkit/__init__.py8
-rw-r--r--blenderkit/download.py8
-rw-r--r--blenderkit/image_utils.py2
-rw-r--r--blenderkit/paths.py4
-rw-r--r--blenderkit/ratings.py2
-rw-r--r--blenderkit/resolutions.py3
-rw-r--r--blenderkit/search.py2
-rw-r--r--blenderkit/ui.py4
-rw-r--r--blenderkit/ui_panels.py9
9 files changed, 28 insertions, 14 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index b61861ee..fc81c0f0 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -1687,6 +1687,13 @@ class BlenderKitAddonPreferences(AddonPreferences):
default=False,
update=utils.save_prefs
)
+
+ categories_fix: BoolProperty(
+ name="Enable category fixing mode",
+ description="Enable category fixing mode.",
+ default=False,
+ update=utils.save_prefs
+ )
# allow_proximity : BoolProperty(
# name="allow proximity data reports",
# description="This sends anonymized proximity data \n \
@@ -1728,6 +1735,7 @@ class BlenderKitAddonPreferences(AddonPreferences):
if bpy.context.preferences.view.show_developer_ui:
layout.prop(self, "use_timers")
layout.prop(self, "experimental_features")
+ layout.prop(self, "categories_fix")
# registration
diff --git a/blenderkit/download.py b/blenderkit/download.py
index 26ae0745..f6209b5f 100644
--- a/blenderkit/download.py
+++ b/blenderkit/download.py
@@ -1267,6 +1267,7 @@ class BlenderkitDownloadOperator(bpy.types.Operator):
description='Replace resolution'
)
+ #needs to be passed to the operator to not show all resolution possibilities
max_resolution: IntProperty(
name="Max resolution",
description="",
@@ -1382,13 +1383,14 @@ class BlenderkitDownloadOperator(bpy.types.Operator):
# only make a pop up in case of switching resolutions
if self.invoke_resolution:
# show_enum_values(self, 'resolution')
- # print('ENUM VALUES')
self.asset_data = self.get_asset_data(context)
sprops = utils.get_search_props()
- if int(sprops.resolution) <= int(self.max_resolution):
+
+ #set initial resolutions enum activation
+ if sprops.resolution != 'ORIGINAL' and int(sprops.resolution) <= int(self.max_resolution):
self.resolution = sprops.resolution
elif int(self.max_resolution) > 0:
- self.resolution = self.max_resolution
+ self.resolution = str(self.max_resolution)
else:
self.resolution = 'ORIGINAL'
return wm.invoke_props_dialog(self)
diff --git a/blenderkit/image_utils.py b/blenderkit/image_utils.py
index fce1cafd..214168af 100644
--- a/blenderkit/image_utils.py
+++ b/blenderkit/image_utils.py
@@ -1,5 +1,4 @@
import bpy
-import numpy
import os
def get_orig_render_settings():
@@ -67,6 +66,7 @@ def set_colorspace(img, colorspace):
print(f'Colorspace {colorspace} not found.')
def generate_hdr_thumbnail():
+ import numpy
scene = bpy.context.scene
ui_props = scene.blenderkitUI
hdr_image = ui_props.hdr_upload_image#bpy.data.images.get(ui_props.hdr_upload_image)
diff --git a/blenderkit/paths.py b/blenderkit/paths.py
index 2a133064..f5e9a3f2 100644
--- a/blenderkit/paths.py
+++ b/blenderkit/paths.py
@@ -169,7 +169,7 @@ def slugify(slug):
import unicodedata, re
slug = slug.lower()
- characters = '.," <>()'
+ characters = '<>:"/\\|?*., ()'
for ch in characters:
slug = slug.replace(ch, '_')
# import re
@@ -179,6 +179,8 @@ def slugify(slug):
slug = re.sub(r'[-]+', '-', slug)
slug = re.sub(r'/', '_', slug)
slug = re.sub(r'\\\'\"', '_', slug)
+ if len(slug)>50:
+ slug = slug[:50]
return slug
diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py
index c273959f..fb41ca2d 100644
--- a/blenderkit/ratings.py
+++ b/blenderkit/ratings.py
@@ -295,7 +295,7 @@ def update_ratings_work_hours_ui_1_5(self, context):
class FastRateMenu(Operator):
- """Fast rating of the assets directly in the asset bar - without need to download assets"""
+ """Rating of the assets , also directly from the asset bar - without need to download assets"""
bl_idname = "wm.blenderkit_menu_rating_upload"
bl_label = "Rate asset"
bl_options = {'REGISTER', 'UNDO', 'INTERNAL'}
diff --git a/blenderkit/resolutions.py b/blenderkit/resolutions.py
index c393a30e..cc4fbb22 100644
--- a/blenderkit/resolutions.py
+++ b/blenderkit/resolutions.py
@@ -22,7 +22,6 @@ from blenderkit import paths, append_link, bg_blender, utils, download, search,
import sys, json, os, time
import subprocess
import tempfile
-import numpy as np
import bpy
import requests
import math
@@ -128,6 +127,8 @@ def numpytoimage(a, iname, width=0, height=0, channels=3):
def imagetonumpy(i):
t = time.time()
+ import numpy as np
+
width = i.size[0]
height = i.size[1]
# print(i.channels)
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 86d2f31c..87148f9a 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -1394,7 +1394,7 @@ def search(category='', get_next=False, author_id=''):
return;
if category != '':
- if utils.profile_is_validator():
+ if utils.profile_is_validator() and user_preferences.categories_fix:
query['category'] = category
else:
query['category_subtree'] = category
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index 6c5ca9d5..b8e8ceac 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -1486,7 +1486,7 @@ class AssetBarOperator(bpy.types.Operator):
if ui_props.drag_init:
ui_props.drag_length += 1
- if ui_props.drag_length > 0:
+ if ui_props.drag_length > 2:
ui_props.dragging = True
ui_props.drag_init = False
@@ -1617,7 +1617,7 @@ class AssetBarOperator(bpy.types.Operator):
return {'RUNNING_MODAL'}
# Drag-drop interaction
- if ui_props.dragging and mouse_in_region(r, mx, my):
+ if ui_props.dragging and mouse_in_region(r, mx, my):# and ui_props.drag_length>10:
asset_search_index = ui_props.active_index
# raycast here
ui_props.active_index = -3
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 5fd9e07e..deb6d628 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -1588,9 +1588,10 @@ def draw_panel_categories(self, context):
# op.free_only = True
for c in cats['children']:
- if c['assetCount'] > 0 or utils.profile_is_validator():
+ if c['assetCount'] > 0 or (utils.profile_is_validator() and user_preferences.categories_fix):
row = col.row(align=True)
- if len(c['children']) > 0 and c['assetCount'] > 15 or utils.profile_is_validator():
+ if len(c['children']) > 0 and c['assetCount'] > 15 or (
+ utils.profile_is_validator() and user_preferences.categories_fix):
row = row.split(factor=.8, align=True)
# row = split.split()
ctext = '%s (%i)' % (c['name'], c['assetCount'])
@@ -1603,8 +1604,8 @@ def draw_panel_categories(self, context):
op.do_search = True
op.keep_running = True
op.category = c['slug']
- # TODO enable subcategories, now not working due to some bug on server probably
- if len(c['children']) > 0 and c['assetCount'] > 15 or utils.profile_is_validator():
+ if len(c['children']) > 0 and c['assetCount'] > 15 or (
+ utils.profile_is_validator() and user_preferences.categories_fix):
# row = row.split()
op = row.operator('view3d.blenderkit_set_category', text='>>')
op.asset_type = ui_props.asset_type