From bc704993268d31d053a9db0937722d9c949a78ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vil=C3=A9m=20Duha?= Date: Tue, 11 May 2021 17:16:44 +0200 Subject: BlenderKit: fix ratingon Linux also introduce simple visual feedback in the interface, using the heart icon. --- blenderkit/ratings.py | 9 ++++++++- blenderkit/ratings_utils.py | 13 +++++++------ blenderkit/search.py | 3 ++- blenderkit/ui_panels.py | 6 +++--- 4 files changed, 20 insertions(+), 11 deletions(-) (limited to 'blenderkit') 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' -- cgit v1.2.3