diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py index c6ced37d0fcc6e774566f7ac8145bf6906ec9338..575538f80971f4f97427579fad0b4bfd48c525d2 100644 --- a/blenderkit/__init__.py +++ b/blenderkit/__init__.py @@ -17,12 +17,12 @@ # ##### END GPL LICENSE BLOCK ##### bl_info = { - "name": "BlenderKit Asset Library", + "name": "BlenderKit Online Asset Library", "author": "Vilem Duha, Petr Dlouhy", "version": (1, 0, 30), "blender": (2, 82, 0), "location": "View3D > Properties > BlenderKit", - "description": "Online BlenderKit library (materials, models, brushes and more)", + "description": "Online BlenderKit library (materials, models, brushes and more). Connects to the internet.", "warning": "", "doc_url": "{BLENDER_MANUAL_URL}/addons/add_mesh/blenderkit.html", "category": "3D View", diff --git a/blenderkit/bkit_oauth.py b/blenderkit/bkit_oauth.py index d56629e54f2094fb3cbcb05827de5f4265fff260..4d2f09dce7a31dbff72d87374deb4a971a573cdb 100644 --- a/blenderkit/bkit_oauth.py +++ b/blenderkit/bkit_oauth.py @@ -139,6 +139,7 @@ class Logout(bpy.types.Operator): preferences.login_attempt = False preferences.api_key_refresh = '' preferences.api_key = '' + del (bpy.context.window_manager['bkit profile']) return {'FINISHED'} diff --git a/blenderkit/download.py b/blenderkit/download.py index 31b6bae0022da1cc24b04b786e462ffd184246db..feed4e9569f28c7989b6eaed167ca1d2eba8a237 100644 --- a/blenderkit/download.py +++ b/blenderkit/download.py @@ -770,6 +770,8 @@ def get_download_url(asset_data, scene_id, api_key, tcom=None): data = { 'scene_uuid': scene_id } + r = None + try: r = rerequests.get(asset_data['download_url'], params=data, headers=headers) except Exception as e: diff --git a/blenderkit/ratings.py b/blenderkit/ratings.py index 2a6b95b0103dc48f642fd66f8d23ca469612eb6c..c6ae4f8caf2e913593f2461f25a8f02645303a3b 100644 --- a/blenderkit/ratings.py +++ b/blenderkit/ratings.py @@ -109,6 +109,7 @@ def get_rating(asset_id): def update_ratings_quality(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 bkit_ratings = asset.bkit_ratings diff --git a/blenderkit/search.py b/blenderkit/search.py index 8406e47d54581748a530d86c93cf1d39ccf27649..a51ff0635b4448701bc34076b5f0a68ae44a6af2 100644 --- a/blenderkit/search.py +++ b/blenderkit/search.py @@ -156,7 +156,7 @@ def timer_update(): preferences = bpy.context.preferences.addons['blenderkit'].preferences if first_time: # first time first_time = False - if preferences.show_on_start or preferences.first_run: + if preferences.show_on_start: # TODO here it should check if there are some results, and only open assetbar if this is the case, not search. # if bpy.context.scene.get('search results') is None: search() @@ -167,6 +167,10 @@ def timer_update(): ui.add_report(text='BlenderKit Tip: ' + random.choice(rtips), timeout=12, color=colors.GREEN) return 3.0 + if preferences.first_run: + search() + preferences.first_run = False + check_clipboard() global search_threads @@ -765,7 +769,11 @@ class Searcher(threading.Thread): if query.get('query') is None and query.get('category_subtree') == None: # assumes no keywords and no category, thus an empty search that is triggered on start. # orders by last core file upload - requeststring += '+order:-last_upload' + if query.get('verification_status') == 'uploaded': + #for validators, sort uploaded from oldest + requeststring += '+order:created' + else: + requeststring += '+order:-last_upload' elif query.get('author_id') is not None and utils.profile_is_validator(): requeststring += '+order:-created' diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py index 1dbc7ab50c739ebb6706ccde8e765b040d53bdb0..0dfa54ff5a70ebc51a683bb7799496255384958f 100644 --- a/blenderkit/ui_panels.py +++ b/blenderkit/ui_panels.py @@ -73,6 +73,11 @@ def draw_ratings(layout, context): # this function should run only when asset was already checked to be existing if asset == None: return; + + if not utils.user_logged_in(): + label_multiline(layout, text='Please login or sign up ' + 'to rate assets.') + return bkit_ratings = asset.bkit_ratings ratings.draw_rating(layout, bkit_ratings, 'rating_quality', 'Quality') @@ -89,6 +94,14 @@ def draw_ratings(layout, context): # op = row.operator("object.blenderkit_rating_upload", text="Send rating", icon='URL') # return op +def draw_not_logged_in(source): + title = "User not logged in" + def draw_message(source, context): + layout = source.layout + label_multiline(layout, text='Please login or sign up ' + 'to upload files.') + draw_login_buttons(layout) + bpy.context.window_manager.popup_menu(draw_message, title=title, icon='INFO') def draw_upload_common(layout, props, asset_type, context): op = layout.operator("wm.url_open", text="Read upload instructions", @@ -919,8 +932,10 @@ class OBJECT_MT_blenderkit_asset_menu(bpy.types.Menu): op = layout.operator('view3d.blenderkit_search', text='Search Similar') op.keywords = asset_data['name'] + ' ' + asset_data['description'] + ' ' + ' '.join(asset_data['tags']) if asset_data.get('canDownload') != 0: - if bpy.context.view_layer.objects.active is not None and ui_props.asset_type == 'MODEL': + if len(bpy.context.selected_objects)>0 and ui_props.asset_type == 'MODEL': aob = bpy.context.active_object + if aob is None: + aob = bpy.context.selected_objects[0] op = layout.operator('scene.blenderkit_download', text='Replace Active Models') op.asset_type = ui_props.asset_type op.asset_index = ui_props.active_index diff --git a/blenderkit/upload.py b/blenderkit/upload.py index 980fbf7f88de8b9b548c612136572772dfdd20d0..2d38808a88a5e326cf26e15442937eab653dba9d 100644 --- a/blenderkit/upload.py +++ b/blenderkit/upload.py @@ -750,6 +750,8 @@ class UploadOperator(Operator): return result + + def draw(self, context): props = utils.get_upload_props() layout = self.layout @@ -774,6 +776,10 @@ class UploadOperator(Operator): def invoke(self, context, event): props = utils.get_upload_props() + if not utils.user_logged_in(): + ui_panels.draw_not_logged_in(self) + return {'CANCELLED'} + if props.is_private == 'PUBLIC': return context.window_manager.invoke_props_dialog(self) else: diff --git a/blenderkit/utils.py b/blenderkit/utils.py index b9bd17f1a5a3344fa439e3b4ef4766f7720494aa..92e61de0f0d8142ff41e35d2ac4eb2972e00e7ee 100644 --- a/blenderkit/utils.py +++ b/blenderkit/utils.py @@ -546,6 +546,13 @@ def dict_to_params(inputs, parameters=None): return parameters +def user_logged_in(): + a = bpy.context.window_manager.get('bkit profile') + if a is not None: + return True + return False + + def profile_is_validator(): a = bpy.context.window_manager.get('bkit profile') if a is not None and a['user'].get('exmenu'):