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>2020-12-26 15:24:42 +0300
committerVilém Duha <vilda.novak@gmail.com>2020-12-26 15:24:42 +0300
commitfdf5ef26f695fb535c54af78c7f50969b632ddfc (patch)
treecfd649087be7f121147b901466774f5a89098227 /blenderkit/ratings.py
parent0cf887278e274324fddd70a1e2e9585ec00558db (diff)
BlenderKit: improve ratings
Trash old BGL code and UI Fix menu access and enable it for all users Fix width of the fast rating operator for validators Autotags for HDR's (only resolutions)
Diffstat (limited to 'blenderkit/ratings.py')
-rw-r--r--blenderkit/ratings.py43
1 files changed, 28 insertions, 15 deletions
diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py
index a2ade101..2ec1f462 100644
--- a/blenderkit/ratings.py
+++ b/blenderkit/ratings.py
@@ -162,10 +162,9 @@ def upload_rating(asset):
ratings = (('quality', bkit_ratings.rating_quality),)
tasks_queue.add_task((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)),)
+ ratings = (('working_hours', round(bkit_ratings.rating_work_hours, 1)),)
tasks_queue.add_task((send_rating_to_thread_work_hours, (url, ratings, headers)), wait=2.5, only_last=True)
-
thread = threading.Thread(target=upload_rating_thread, args=(url, ratings, headers))
thread.start()
@@ -285,6 +284,7 @@ def update_ratings_work_hours_ui(self, context):
# self.rating_work_hours_ui = '0'
self.rating_work_hours = float(self.rating_work_hours_ui)
+
def update_ratings_work_hours_ui_1_5(self, context):
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
if user_preferences.api_key == '':
@@ -299,7 +299,6 @@ def update_ratings_work_hours_ui_1_5(self, context):
self.rating_work_hours = float(self.rating_work_hours_ui_1_5)
-
class FastRateMenu(Operator):
"""Fast rating of the assets directly in the asset bar - without need to download assets."""
bl_idname = "wm.blenderkit_menu_rating_upload"
@@ -313,7 +312,12 @@ class FastRateMenu(Operator):
asset_id: StringProperty(
name="Asset Base Id",
- description="Unique name of the asset (hidden)",
+ description="Unique id of the asset (hidden)",
+ default="")
+
+ asset_name: StringProperty(
+ name="Asset Name",
+ description="Name of the asset (hidden)",
default="")
asset_type: StringProperty(
@@ -380,9 +384,9 @@ class FastRateMenu(Operator):
@classmethod
def poll(cls, context):
- scene = bpy.context.scene
- ui_props = scene.blenderkitUI
- return ui_props.active_index > -1
+ # scene = bpy.context.scene
+ # ui_props = scene.blenderkitUI
+ return True#ui_props.active_index > -1
def draw(self, context):
layout = self.layout
@@ -394,11 +398,13 @@ class FastRateMenu(Operator):
row.prop(self, 'rating_quality_ui', expand=True, icon_only=True, emboss=False)
col.separator()
col.prop(self, 'rating_work_hours')
- row = col.row()
- if self.asset_type == 'model':
- row.prop(self, 'rating_work_hours_ui', expand=True, icon_only=False, emboss=True)
- else:
- row.prop(self, 'rating_work_hours_ui_1_5', expand=True, icon_only=False, emboss=True)
+ if utils.profile_is_validator():
+ row = layout.row()
+ print(self.asset_type, ' asset type for rating')
+ if self.asset_type == 'model':
+ row.prop(self, 'rating_work_hours_ui', expand=True, icon_only=False, emboss=True)
+ else:
+ row.prop(self, 'rating_work_hours_ui_1_5', expand=True, icon_only=False, emboss=True)
def execute(self, context):
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
@@ -433,10 +439,15 @@ class FastRateMenu(Operator):
asset_data = dict(sr[ui_props.active_index])
self.asset_id = asset_data['id']
self.asset_type = asset_data['assetType']
- self.message = f"Rate asset {asset_data['name']}"
+
+ self.message = f"Rate asset {self.asset_name}"
wm = context.window_manager
- return wm.invoke_props_dialog(self)
+ if utils.profile_is_validator():
+ #spawn a wider one for validators for the enum buttons
+ return wm.invoke_props_dialog(self, width = 500)
+ else:
+ return wm.invoke_props_dialog(self)
def rating_menu_draw(self, context):
layout = self.layout
@@ -452,10 +463,12 @@ def rating_menu_draw(self, context):
layout.label(text='Admin rating Tools:')
col.operator_context = 'INVOKE_DEFAULT'
- op = col.operator('wm.blenderkit_menu_rating_upload', text='Fast rate')
+ op = col.operator('wm.blenderkit_menu_rating_upload', text='Rate')
op.asset_id = asset_data['id']
+ op.asset_name = asset_data['name']
op.asset_type = asset_data['assetType']
+
def register_ratings():
bpy.utils.register_class(UploadRatingOperator)
bpy.utils.register_class(FastRateMenu)