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-05-11 18:16:44 +0300
committerVilém Duha <vilda.novak@gmail.com>2021-05-11 18:16:44 +0300
commitbc704993268d31d053a9db0937722d9c949a78ca (patch)
tree0f7be174fcf6c2d556507b774a3ca10e152b88bc
parent1a04237c5086416c4d58ce898ad769b077905791 (diff)
BlenderKit: fix ratingon Linux
also introduce simple visual feedback in the interface, using the heart icon.
-rw-r--r--blenderkit/ratings.py9
-rw-r--r--blenderkit/ratings_utils.py13
-rw-r--r--blenderkit/search.py3
-rw-r--r--blenderkit/ui_panels.py6
4 files changed, 20 insertions, 11 deletions
diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py
index 24e56a45..851e9360 100644
--- a/blenderkit/ratings.py
+++ b/blenderkit/ratings.py
@@ -184,10 +184,13 @@ def draw_ratings_menu(self, context, layout):
row = col.row()
row.label(text='Quality:', icon = 'SOLO_ON')
row = col.row()
- row.label(text='Please help us by rating this asset quality:')
+ 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:
+ # row = col.row()
+ row.label(text=' Thanks!', icon = 'FUND')
# row.label(text=str(self.rating_quality))
col.separator()
col.separator()
@@ -216,6 +219,7 @@ def draw_ratings_menu(self, context, layout):
text=f"\nThat's a lot! please be sure to give such rating only to amazing {self.asset_type}s.\n",
width=500)
+
elif self.asset_type == 'hdr':
row = col.row()
row.prop(self, 'rating_work_hours_ui_1_10', expand=True, icon_only=False, emboss=True)
@@ -223,6 +227,9 @@ 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:
+ row = col.row()
+ row.label(text='Thanks, 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"""
diff --git a/blenderkit/ratings_utils.py b/blenderkit/ratings_utils.py
index 9ceea9d0..ea005dfc 100644
--- a/blenderkit/ratings_utils.py
+++ b/blenderkit/ratings_utils.py
@@ -74,8 +74,10 @@ def update_ratings_quality(self, context):
api_key = user_preferences.api_key
headers = utils.get_headers(api_key)
- asset = self.id_data
- if asset:
+
+ if not(hasattr(self, 'rating_quality')):
+ # first option is for rating of assets that are from scene
+ asset = self.id_data
bkit_ratings = asset.bkit_ratings
url = paths.get_api_url() + 'assets/' + asset['asset_data']['id'] + '/rating/'
else:
@@ -92,8 +94,9 @@ def update_ratings_work_hours(self, context):
user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
api_key = user_preferences.api_key
headers = utils.get_headers(api_key)
- asset = self.id_data
- if asset:
+ if not(hasattr(self, 'rating_work_hours')):
+ # first option is for rating of assets that are from scene
+ asset = self.id_data
bkit_ratings = asset.bkit_ratings
url = paths.get_api_url() + 'assets/' + asset['asset_data']['id'] + '/rating/'
else:
@@ -140,8 +143,6 @@ def update_ratings_work_hours_ui_1_5(self, context):
bpy.ops.wm.blenderkit_login('INVOKE_DEFAULT',
message='Please login/signup to rate assets. Clicking OK takes you to web login.')
# self.rating_work_hours_ui_1_5 = '0'
- # print('updating 1-5')
- # print(float(self.rating_work_hours_ui_1_5))
self.rating_work_hours = float(self.rating_work_hours_ui_1_5)
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 49337888..7c02be5a 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -629,12 +629,13 @@ class ThumbDownloader(threading.Thread):
def run(self):
# print('thumb downloader', self.url)
+ r = None
try:
r = requests.get(self.url, stream=False)
except Exception as e:
bk_logger.error('Thumbnail download failed')
bk_logger.error(str(e))
- if r.status_code == 200:
+ if r and r.status_code == 200:
with open(self.path, 'wb') as f:
f.write(r.content)
# ORIGINALLY WE DOWNLOADED THUMBNAILS AS STREAM, BUT THIS WAS TOO SLOW.
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index 3b9cd0c0..f5758ffd 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -1681,9 +1681,9 @@ class AssetPopupCard(bpy.types.Operator, ratings_utils.RatingsProperties):
box_thumbnail.template_icon(icon_value=self.img.preview.icon_id, scale=34.0)
- row = box_thumbnail.row()
- row.scale_y = 3
- op = row.operator('view3d.asset_drag_drop', text='Drag & Drop from here', depress=True)
+ # row = box_thumbnail.row()
+ # row.scale_y = 3
+ # op = row.operator('view3d.asset_drag_drop', text='Drag & Drop from here', depress=True)
row = box_thumbnail.row()
row.alignment = 'EXPAND'