diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2021-11-12 11:36:38 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2021-11-12 11:36:38 +0300 |
commit | fccc9b04f23ccf445b009e5e61a0e86f7410cb44 (patch) | |
tree | 32c2c549c224c65e1496b07d1e08ac3c316ea945 /blenderkit | |
parent | c0ef14803b92e09a67b122b87b70b4366baf6259 (diff) | |
parent | a0d1647839180388805be150794a812c44e59053 (diff) |
Merge branch 'blender-v3.0-release'
Diffstat (limited to 'blenderkit')
-rw-r--r-- | blenderkit/asset_bar_op.py | 25 | ||||
-rw-r--r-- | blenderkit/autothumb.py | 14 | ||||
-rw-r--r-- | blenderkit/comments_utils.py | 8 | ||||
-rw-r--r-- | blenderkit/paths.py | 2 | ||||
-rw-r--r-- | blenderkit/ratings_utils.py | 4 | ||||
-rw-r--r-- | blenderkit/search.py | 32 | ||||
-rw-r--r-- | blenderkit/ui_panels.py | 3 | ||||
-rw-r--r-- | blenderkit/upload.py | 1 | ||||
-rw-r--r-- | blenderkit/utils.py | 1 |
9 files changed, 72 insertions, 18 deletions
diff --git a/blenderkit/asset_bar_op.py b/blenderkit/asset_bar_op.py index 98b89f14..3afb37e9 100644 --- a/blenderkit/asset_bar_op.py +++ b/blenderkit/asset_bar_op.py @@ -444,6 +444,7 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator): def update_layout(self, context, event): # restarting asset_bar completely since the widgets are too hard to get working with updates. + self.scroll_update() self.position_and_hide_buttons() @@ -468,7 +469,7 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator): self.tooltip_height - self.author_text_size - self.margin) # to hide arrows accordingly - self.scroll_update() + def asset_button_init(self, asset_x, asset_y, button_idx): ui_scale = bpy.context.preferences.view.ui_scale @@ -796,7 +797,11 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator): self.tooltip_image.set_image(img.filepath) get_tooltip_data(asset_data) - self.asset_name.text = asset_data['name'] + an = asset_data['name'] + max_name_length = 30 + if len(an)>max_name_length+3: + an = an[:30]+'...' + self.asset_name.text = an self.authors_name.text = asset_data['tooltip_data']['author_text'] self.quality_label.text = asset_data['tooltip_data']['quality'] # print(asset_data['tooltip_data']['quality']) @@ -893,7 +898,9 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator): for asset_button in self.asset_buttons: if asset_button.visible: asset_button.asset_index = asset_button.button_index + self.scroll_offset + # print(asset_button.asset_index, len(sr)) if asset_button.asset_index < len(sr): + asset_button.visible = True asset_data = sr[asset_button.asset_index] @@ -920,10 +927,18 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator): asset_button.red_alert.visible = False elif utils.profile_is_validator(): asset_button.red_alert.visible = False +<<<<<<< HEAD else: asset_button.validation_icon.visible = False if utils.profile_is_validator(): asset_button.red_alert.visible = False +======= + else: + asset_button.visible = False + asset_button.validation_icon.visible = False + if utils.profile_is_validator(): + asset_button.red_alert.visible = False +>>>>>>> blender-v3.0-release def scroll_update(self): sr = bpy.context.window_manager.get('search results') @@ -937,6 +952,10 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator): self.scroll_offset = min(self.scroll_offset, len(sr) - (self.wcount * self.hcount)) self.scroll_offset = max(self.scroll_offset, 0) self.update_images() +<<<<<<< HEAD +======= + +>>>>>>> blender-v3.0-release # print(sro) if sro['count'] > len(sr) and len(sr) - self.scroll_offset < (self.wcount * self.hcount) + 15: self.search_more() @@ -959,7 +978,7 @@ class BlenderKitAssetBarOperator(BL_UI_OT_draw_operator): sprops = utils.get_search_props() sprops.search_keywords = '' sprops.search_verification_status = 'ALL' - utils.p('author:', a) + # utils.p('author:', a) search.search(author_id=a) return True diff --git a/blenderkit/autothumb.py b/blenderkit/autothumb.py index 2d376852..330d31a2 100644 --- a/blenderkit/autothumb.py +++ b/blenderkit/autothumb.py @@ -481,13 +481,16 @@ class GenerateMaterialThumbnailOperator(bpy.types.Operator): bpy.ops.wm.save_as_mainfile(filepath=filepath, compress=False, copy=True) thumb_dir = os.path.dirname(bpy.data.filepath) - thumb_path = os.path.join(thumb_dir, asset.name) - rel_thumb_path = os.path.join('//', asset.name) + an_slug = paths.slugify(asset.name) + + thumb_path = os.path.join(thumb_dir, an_slug) + rel_thumb_path = os.path.join('//', an_slug) + # auto increase number of the generated thumbnail. i = 0 while os.path.isfile(thumb_path + '.png'): - thumb_path = os.path.join(thumb_dir, asset.name + '_' + str(i).zfill(4)) - rel_thumb_path = os.path.join('//', asset.name + '_' + str(i).zfill(4)) + thumb_path = os.path.join(thumb_dir, an_slug + '_' + str(i).zfill(4)) + rel_thumb_path = os.path.join('//', an_slug + '_' + str(i).zfill(4)) i += 1 asset.blenderkit.thumbnail = rel_thumb_path + '.png' @@ -606,10 +609,11 @@ class ReGenerateMaterialThumbnailOperator(bpy.types.Operator): # either get the data from search results sr = bpy.context.window_manager['search results'] asset_data = sr[self.asset_index].to_dict() + an_slug = paths.slugify(asset_data['name']) tempdir = tempfile.mkdtemp() - thumb_path = os.path.join(tempdir, asset_data['name']) + thumb_path = os.path.join(tempdir,an_slug) args_dict = { "type": "material", diff --git a/blenderkit/comments_utils.py b/blenderkit/comments_utils.py index 4be80bd8..654bbb54 100644 --- a/blenderkit/comments_utils.py +++ b/blenderkit/comments_utils.py @@ -50,9 +50,9 @@ def upload_comment_thread(url, comment='', api_key=None): # try: r = rerequests.put(url, data=data, verify=True, headers=headers) - print(r) + # print(r) # print(dir(r)) - print(r.text) + # print(r.text) # except requests.exceptions.RequestException as e: # print('ratings upload failed: %s' % str(e)) @@ -72,7 +72,7 @@ def upload_comment_flag_thread( asset_id = '', comment_id='', flag='like', api_k # try: r = rerequests.post(url, data=data, verify=True, headers=headers) - print(r.text) + # print(r.text) #here it's important we read back, so likes are updated accordingly: get_comments(asset_id, api_key) @@ -129,7 +129,7 @@ def get_comments(asset_id, api_key): r = rerequests.get(url, params=params, verify=True, headers=headers) if r is None: return - print(r.status_code) + # print(r.status_code) if r.status_code == 200: rj = r.json() # store comments - send them to task queue diff --git a/blenderkit/paths.py b/blenderkit/paths.py index 889aa286..0170ae7b 100644 --- a/blenderkit/paths.py +++ b/blenderkit/paths.py @@ -187,7 +187,7 @@ def slugify(slug): import unicodedata, re slug = slug.lower() - characters = '<>:"/\\|?*., ()#' + characters = '<>:"/\\|?\*., ()#' for ch in characters: slug = slug.replace(ch, '_') # import re diff --git a/blenderkit/ratings_utils.py b/blenderkit/ratings_utils.py index d813f444..46dc031b 100644 --- a/blenderkit/ratings_utils.py +++ b/blenderkit/ratings_utils.py @@ -101,7 +101,11 @@ def get_rating(asset_id, headers): if r.status_code == 200: rj = r.json() ratings = {} +<<<<<<< HEAD print(rj) +======= + # print(rj) +>>>>>>> blender-v3.0-release # store ratings - send them to task queue for r in rj['results']: ratings[r['ratingType']] = r['score'] diff --git a/blenderkit/search.py b/blenderkit/search.py index f86a9a5e..24e46da7 100644 --- a/blenderkit/search.py +++ b/blenderkit/search.py @@ -117,7 +117,7 @@ def refresh_notifications_timer(): fetch_server_data() all_notifications_count = comments_utils.count_all_notifications() comments_utils.get_notifications_thread(preferences.api_key, all_count = all_notifications_count) - return 300 + return 7200 def update_ad(ad): @@ -197,9 +197,15 @@ def scene_load(context): categories.load_categories() if not bpy.app.timers.is_registered(refresh_token_timer) and not bpy.app.background: bpy.app.timers.register(refresh_token_timer, persistent=True, first_interval=36000) +<<<<<<< HEAD if utils.experimental_enabled() and not bpy.app.timers.is_registered( refresh_notifications_timer) and not bpy.app.background: bpy.app.timers.register(refresh_notifications_timer, persistent=True, first_interval=5) +======= + # if utils.experimental_enabled() and not bpy.app.timers.is_registered( + # refresh_notifications_timer) and not bpy.app.background: + # bpy.app.timers.register(refresh_notifications_timer, persistent=True, first_interval=5) +>>>>>>> blender-v3.0-release update_assets_data() @@ -218,10 +224,16 @@ def fetch_server_data(): get_profile() if bpy.context.window_manager.get('bkit_categories') is None: categories.fetch_categories_thread(api_key, force=False) +<<<<<<< HEAD all_notifications_count = comments_utils.count_all_notifications() comments_utils.get_notifications_thread(api_key, all_count = all_notifications_count) +======= + # all_notifications_count = comments_utils.count_all_notifications() + # comments_utils.get_notifications_thread(api_key, all_count = all_notifications_count) +>>>>>>> blender-v3.0-release first_time = True +first_search_parsing = True last_clipboard = '' @@ -408,7 +420,7 @@ def search_timer(): all_thumbs_loaded = all_loaded - global search_threads + global search_threads, first_search_parsing if len(search_threads) == 0: # utils.p('end search timer') props = utils.get_search_props() @@ -426,6 +438,15 @@ def search_timer(): # but most of the time only one is running anyway if not thread[0].is_alive(): + #check for notifications only for users that actually use the add-on + if first_search_parsing: + first_search_parsing = False + all_notifications_count = comments_utils.count_all_notifications() + comments_utils.get_notifications_thread(api_key, all_count=all_notifications_count) + if utils.experimental_enabled() and not bpy.app.timers.is_registered( + refresh_notifications_timer) and not bpy.app.background: + bpy.app.timers.register(refresh_notifications_timer, persistent=True, first_interval=5) + search_threads.remove(thread) # icons_dir = thread[1] scene = bpy.context.scene @@ -487,9 +508,14 @@ def search_timer(): # jump back ui_props.scroll_offset = 0 props.search_error = False - props.report = 'Found %i results. ' % (wm['search results orig']['count']) + props.report = f"Found {wm['search results orig']['count']} results." if len(wm['search results']) == 0: tasks_queue.add_task((reports.add_report, ('No matching results found.',))) +<<<<<<< HEAD +======= + else: + tasks_queue.add_task((reports.add_report, (f"Found {wm['search results orig']['count']} results.",))) +>>>>>>> blender-v3.0-release # undo push # bpy.ops.wm.undo_push_context(message='Get BlenderKit search') # show asset bar automatically, but only on first page - others are loaded also when asset bar is hidden. diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py index d20b1f6e..c2d17a51 100644 --- a/blenderkit/ui_panels.py +++ b/blenderkit/ui_panels.py @@ -2250,8 +2250,11 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties): def prefill_ratings(self): # pre-fill ratings ratings = ratings_utils.get_rating_local(self.asset_id) +<<<<<<< HEAD print('prefill ratings') print(ratings) +======= +>>>>>>> blender-v3.0-release if ratings and ratings.get('quality'): self.rating_quality = ratings['quality'] if ratings and ratings.get('working_hours'): diff --git a/blenderkit/upload.py b/blenderkit/upload.py index dfca4d94..3d8b705b 100644 --- a/blenderkit/upload.py +++ b/blenderkit/upload.py @@ -582,7 +582,6 @@ def can_edit_asset(active_index=-1, asset_data=None): if not asset_data: sr = bpy.context.window_manager['search results'] asset_data = dict(sr[active_index]) - # print(profile, asset_data) if int(asset_data['author']['id']) == int(profile['user']['id']): return True return False diff --git a/blenderkit/utils.py b/blenderkit/utils.py index 79998c26..5bdace75 100644 --- a/blenderkit/utils.py +++ b/blenderkit/utils.py @@ -844,7 +844,6 @@ def asset_from_newer_blender_version(asset_data): '''checks if asset is from a newer blender version, to avoid incompatibility''' bver = bpy.app.version aver = asset_data['sourceAppVersion'].split('.') - #print(aver,bver) bver_f = bver[0] + bver[1] * .01 + bver[2] * .0001 if len(aver)>=3: aver_f = int(aver[0]) + int(aver[1]) * .01 + int(aver[2]) * .0001 |