diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2021-05-25 12:54:54 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2021-05-25 12:54:54 +0300 |
commit | c2acc4613ca6bb5549ae2fd572f724cc7de874cc (patch) | |
tree | 70669084608f108fa1a4f354b469382e1ae06fdc | |
parent | acfb296988f106084f95a3db80ec35caab1368a3 (diff) | |
parent | b2948ae5fa060f6891d7edfefbee3c9f37394027 (diff) |
Merge remote-tracking branch 'origin/master' into asset-browser-poselib
-rw-r--r-- | blenderkit/ratings.py | 60 | ||||
-rw-r--r-- | blenderkit/search.py | 16 | ||||
-rw-r--r-- | blenderkit/ui.py | 7 | ||||
-rw-r--r-- | object_edit_linked.py | 15 |
4 files changed, 41 insertions, 57 deletions
diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py index 10d815ba..f6a221c4 100644 --- a/blenderkit/ratings.py +++ b/blenderkit/ratings.py @@ -50,7 +50,6 @@ def pretty_print_POST(req): )) - def upload_review_thread(url, reviews, headers): r = rerequests.put(url, data=reviews, verify=True, headers=headers) @@ -58,9 +57,6 @@ def upload_review_thread(url, reviews, headers): # print('reviews upload failed: %s' % str(e)) - - - def upload_rating(asset): user_preferences = bpy.context.preferences.addons['blenderkit'].preferences api_key = user_preferences.api_key @@ -76,10 +72,12 @@ def upload_rating(asset): if bkit_ratings.rating_quality > 0.1: ratings = (('quality', bkit_ratings.rating_quality),) - tasks_queue.add_task((ratings_utils.send_rating_to_thread_quality, (url, ratings, headers)), wait=2.5, only_last=True) + tasks_queue.add_task((ratings_utils.send_rating_to_thread_quality, (url, ratings, headers)), wait=2.5, + only_last=True) if bkit_ratings.rating_work_hours > 0.1: ratings = (('working_hours', round(bkit_ratings.rating_work_hours, 1)),) - tasks_queue.add_task((ratings_utils.send_rating_to_thread_work_hours, (url, ratings, headers)), wait=2.5, only_last=True) + tasks_queue.add_task((ratings_utils.send_rating_to_thread_work_hours, (url, ratings, headers)), wait=2.5, + only_last=True) thread = threading.Thread(target=ratings_utils.upload_rating_thread, args=(url, ratings, headers)) thread.start() @@ -168,22 +166,22 @@ def draw_ratings_menu(self, context, layout): profile_name = '' profile = bpy.context.window_manager.get('bkit profile') - if profile and len(profile['user']['firstName'])>0: + if profile and len(profile['user']['firstName']) > 0: profile_name = ' ' + profile['user']['firstName'] col = layout.column() # layout.template_icon_view(bkit_ratings, property, show_labels=False, scale=6.0, scale_popup=5.0) row = col.row() - row.label(text='Quality:', icon = 'SOLO_ON') + row.label(text='Quality:', icon='SOLO_ON') row = col.row() row.label(text='Please help the community by rating quality:') row = col.row() row.prop(self, 'rating_quality_ui', expand=True, icon_only=True, emboss=False) - if self.rating_quality>0: + if self.rating_quality > 0: # row = col.row() - row.label(text=f' Thanks{profile_name}!', icon = 'FUND') + row.label(text=f' Thanks{profile_name}!', icon='FUND') # row.label(text=str(self.rating_quality)) col.separator() col.separator() @@ -220,17 +218,17 @@ def draw_ratings_menu(self, context, layout): row = col.row() row.prop(self, 'rating_work_hours_ui_1_5', expand=True, icon_only=False, emboss=True) - if self.rating_work_hours>0: + if self.rating_work_hours > 0: row = col.row() row.label(text=f'Thanks{profile_name}, you are amazing!', icon='FUND') + class FastRateMenu(Operator, ratings_utils.RatingsProperties): """Rating of the assets , also directly from the asset bar - without need to download assets""" bl_idname = "wm.blenderkit_menu_rating_upload" - bl_label = "" + bl_label = "Ratings" bl_options = {'REGISTER', 'UNDO', 'INTERNAL'} - @classmethod def poll(cls, context): scene = bpy.context.scene @@ -239,39 +237,12 @@ class FastRateMenu(Operator, ratings_utils.RatingsProperties): def draw(self, context): layout = self.layout - layout.label(text=self.message) - layout.separator() - draw_ratings_menu(self, context, layout) def execute(self, context): - user_preferences = bpy.context.preferences.addons['blenderkit'].preferences - api_key = user_preferences.api_key - headers = utils.get_headers(api_key) - - url = paths.get_api_url() + f'assets/{self.asset_id}/rating/' - - rtgs = [ - - ] - - if self.rating_quality_ui == '': - self.rating_quality = 0 - else: - self.rating_quality = float(self.rating_quality_ui) - - if self.rating_quality > 0.1: - rtgs = (('quality', self.rating_quality),) - tasks_queue.add_task((ratings_utils.send_rating_to_thread_quality, (url, rtgs, headers)), wait=2.5, only_last=True) - - if self.rating_work_hours > 0.45: - rtgs = (('working_hours', round(self.rating_work_hours, 1)),) - tasks_queue.add_task((ratings_utils.send_rating_to_thread_work_hours, (url, rtgs, headers)), wait=2.5, only_last=True) - return {'FINISHED'} - - def invoke(self, context, event): scene = bpy.context.scene ui_props = scene.blenderkitUI + #get asset id if ui_props.active_index > -1: sr = bpy.context.window_manager['search results'] asset_data = dict(sr[ui_props.active_index]) @@ -280,15 +251,16 @@ class FastRateMenu(Operator, ratings_utils.RatingsProperties): if self.asset_id == '': return {'CANCELLED'} - self.message = f"{self.asset_name}" + wm = context.window_manager + self.prefill_ratings() if self.asset_type in ('model', 'scene'): # spawn a wider one for validators for the enum buttons - return wm.invoke_props_dialog(self, width=500) + return wm.invoke_popup(self, width=500) else: - return wm.invoke_props_dialog(self) + return wm.invoke_popup(self) def rating_menu_draw(self, context): diff --git a/blenderkit/search.py b/blenderkit/search.py index f0d1fec6..534f4a09 100644 --- a/blenderkit/search.py +++ b/blenderkit/search.py @@ -424,18 +424,22 @@ def timer_update(): if ok: bpy.ops.object.run_assetbar_fix_context() - user_preferences = bpy.context.preferences.addons['blenderkit'].preferences - api_key = user_preferences.api_key - headers = utils.get_headers(api_key) + for r in rdata['results']: asset_data = parse_result(r) if asset_data != None: result_field.append(asset_data) - if utils.profile_is_validator() and ratings_utils.get_rating_local(asset_data['id']) is None: - thread = threading.Thread(target=ratings_utils.get_rating, args=([asset_data['id'], headers]), daemon=True) - thread.start() + # Get ratings from BlenderKit server + if utils.profile_is_validator(): + user_preferences = bpy.context.preferences.addons['blenderkit'].preferences + api_key = user_preferences.api_key + headers = utils.get_headers(api_key) + for r in rdata['results']: + if ratings_utils.get_rating_local(asset_data['id']) is None: + thread = threading.Thread(target=ratings_utils.get_rating, args=([r['id'], headers]), daemon=True) + thread.start() wm[search_name] = result_field wm['search results'] = result_field diff --git a/blenderkit/ui.py b/blenderkit/ui.py index 09a1f88e..f6438d85 100644 --- a/blenderkit/ui.py +++ b/blenderkit/ui.py @@ -391,8 +391,11 @@ def draw_tooltip_with_author(asset_data, x, y): rcount = min(rc['quality'], rc['workingHours']) if rcount > show_rating_threshold: quality = round(asset_data['ratingsAverage'].get('quality')) + author_text = '' + if len(a['firstName'])>0 or len(a['lastName'])>0: + author_text = f"by {a['firstName']} {a['lastName']}" - draw_tooltip(x, y, name=aname, author=f"by {a['firstName']} {a['lastName']}", quality=quality, img=img, + draw_tooltip(x, y, name=aname, author=author_text, quality=quality, img=img, gravatar=gimg) @@ -693,7 +696,7 @@ def draw_asset_bar(self, context): v_icon = verification_icons[result.get('verificationStatus', 'validated')] if v_icon is None and utils.profile_is_validator(): - # poke for validators to rate + # poke for validators to rate if ratings_utils.get_rating_local(result['id']) in (None, {}): v_icon = 'star_grey.png' diff --git a/object_edit_linked.py b/object_edit_linked.py index f27fb82e..95b4ec52 100644 --- a/object_edit_linked.py +++ b/object_edit_linked.py @@ -22,8 +22,8 @@ bl_info = { "author": "Jason van Gumster (Fweeb), Bassam Kurdali, Pablo Vazquez, Rainer Trummer", "version": (0, 9, 2), "blender": (2, 80, 0), - "location": "File > External Data / View3D > Sidebar > Item Tab", - "description": "Allows editing of assets linked from a .blend library.", + "location": "File > External Data / View3D > Sidebar > Item Tab / Node Editor > Sidebar > Node Tab", + "description": "Allows editing of objects, collections, and node groups linked from a .blend library.", "doc_url": "{BLENDER_MANUAL_URL}/addons/object/edit_linked_library.html", "category": "Object", } @@ -110,7 +110,8 @@ class OBJECT_OT_EditLinked(bpy.types.Operator): bpy.ops.wm.save_mainfile() settings["original_file"] = bpy.data.filepath - settings["linked_file"] = bpy.path.abspath(targetpath) + # Using both bpy and os abspath functions because Windows doesn't like relative routes as part of an absolute path + settings["linked_file"] = os.path.abspath(bpy.path.abspath(targetpath)) if self.use_instance: import subprocess @@ -169,7 +170,8 @@ class NODE_OT_EditLinked(bpy.types.Operator): bpy.ops.wm.save_mainfile() settings["original_file"] = bpy.data.filepath - settings["linked_file"] = bpy.path.abspath(targetpath) + # Using both bpy and os abspath functions because Windows doesn't like relative routes as part of an absolute path + settings["linked_file"] = os.path.abspath(bpy.path.abspath(targetpath)) if self.use_instance: import subprocess @@ -311,7 +313,10 @@ class NODE_PT_PanelLinkedEdit(bpy.types.Panel): bl_label = "Edit Linked Library" bl_space_type = 'NODE_EDITOR' bl_region_type = 'UI' - bl_category = "Node" + if bpy.app.version >= (2, 93, 0): + bl_category = "Node" + else: + bl_category = "Item" bl_options = {'DEFAULT_CLOSED'} @classmethod |