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-07-15 20:06:53 +0300
committerVilém Duha <vilda.novak@gmail.com>2020-07-29 23:17:10 +0300
commit66bd6dea71862d8f55ede79879117d9e7de882a4 (patch)
tree002f4d6838c402eb68474a9c29ff4c7c8ace34d6
parenta3a1815d36afbccbd45b52c91afc4e543d4154df (diff)
BlenderKit: on-registration popup
This popup informs the user that BlenderKit connects to the internet directly after registration, and asks for consent with it and also performs first search. (cherry picked from commit 00fefe2d147288e3a218d640668b54331e82d3e8)
-rw-r--r--blenderkit/__init__.py5
-rw-r--r--blenderkit/search.py8
-rw-r--r--blenderkit/tasks_queue.py9
-rw-r--r--blenderkit/ui.py2
-rw-r--r--blenderkit/ui_panels.py56
-rw-r--r--blenderkit/utils.py16
6 files changed, 78 insertions, 18 deletions
diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index a7e148ea..23ee89c5 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -1725,6 +1725,11 @@ def register():
bpy.app.timers.register(check_timers_timer, persistent=True)
bpy.app.handlers.load_post.append(scene_load)
+ # detect if the user just enabled the addon in preferences, thus enable to run
+ for w in bpy.context.window_manager.windows:
+ for a in w.screen.areas:
+ if a.type == 'PREFERENCES':
+ tasks_queue.add_task((bpy.ops.wm.blenderkit_welcome,( 'INVOKE_DEFAULT',)),fake_context = True, fake_context_area = 'PREFERENCES')
def unregister():
diff --git a/blenderkit/search.py b/blenderkit/search.py
index f6226049..cee0b14b 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -282,14 +282,14 @@ def timer_update():
search()
preferences.first_run = False
if preferences.tips_on_start:
- utils.get_largest_3dview()
+ utils.get_largest_area()
ui.update_ui_size(ui.active_area, ui.active_region)
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
+ # if preferences.first_run:
+ # search()
+ # preferences.first_run = False
# check_clipboard()
diff --git a/blenderkit/tasks_queue.py b/blenderkit/tasks_queue.py
index a253aa96..5a327290 100644
--- a/blenderkit/tasks_queue.py
+++ b/blenderkit/tasks_queue.py
@@ -45,16 +45,17 @@ def get_queue():
return t.task_queue
class task_object:
- def __init__(self, command = '', arguments = (), wait = 0, only_last = False, fake_context = False):
+ def __init__(self, command = '', arguments = (), wait = 0, only_last = False, fake_context = False, fake_context_area = 'VIEW_3D'):
self.command = command
self.arguments = arguments
self.wait = wait
self.only_last = only_last
self.fake_context = fake_context
+ self.fake_context_area = fake_context_area
-def add_task(task, wait = 0, only_last = False, fake_context = False):
+def add_task(task, wait = 0, only_last = False, fake_context = False, fake_context_area = 'VIEW_3D'):
q = get_queue()
- taskob = task_object(task[0],task[1], wait = wait, only_last = only_last, fake_context = fake_context)
+ taskob = task_object(task[0],task[1], wait = wait, only_last = only_last, fake_context = fake_context, fake_context_area = fake_context_area)
q.put(taskob)
@@ -92,7 +93,7 @@ def queue_worker():
utils.p(task.command, task.arguments)
try:
if task.fake_context:
- fc = utils.get_fake_context(bpy.context)
+ fc = utils.get_fake_context(bpy.context, area_type = task.fake_context_area)
task.command(fc,*task.arguments)
else:
task.command(*task.arguments)
diff --git a/blenderkit/ui.py b/blenderkit/ui.py
index fa26d8a3..30195168 100644
--- a/blenderkit/ui.py
+++ b/blenderkit/ui.py
@@ -1784,7 +1784,7 @@ class UndoWithContext(bpy.types.Operator):
C_dict = bpy.context.copy()
C_dict.update(region='WINDOW')
if context.area is None or context.area.type != 'VIEW_3D':
- w, a, r = utils.get_largest_3dview()
+ w, a, r = utils.get_largest_area()
override = {'window': w, 'screen': w.screen, 'area': a, 'region': r}
C_dict.update(override)
bpy.ops.ed.undo_push(C_dict, 'INVOKE_REGION_WIN', message=self.message)
diff --git a/blenderkit/ui_panels.py b/blenderkit/ui_panels.py
index b8d8ce73..d067afa0 100644
--- a/blenderkit/ui_panels.py
+++ b/blenderkit/ui_panels.py
@@ -25,12 +25,22 @@ if "bpy" in locals():
download = importlib.reload(download)
categories = importlib.reload(categories)
icons = importlib.reload(icons)
+ icons = importlib.reload(search)
else:
- from blenderkit import paths, ratings, utils, download, categories, icons
+ from blenderkit import paths, ratings, utils, download, categories, icons, search
from bpy.types import (
Panel
)
+from bpy.props import (
+ IntProperty,
+ FloatProperty,
+ FloatVectorProperty,
+ StringProperty,
+ EnumProperty,
+ BoolProperty,
+ PointerProperty,
+)
import bpy
import os
@@ -962,6 +972,47 @@ class VIEW3D_PT_blenderkit_unified(Panel):
if ui_props.asset_type == 'TEXTURE':
layout.label(text='not yet implemented')
+class BlenderKitWelcomeOperator(bpy.types.Operator):
+ """Login online on BlenderKit webpage"""
+
+ bl_idname = "wm.blenderkit_welcome"
+ bl_label = "Welcome to BlenderKit!"
+ bl_options = {'REGISTER', 'UNDO', 'INTERNAL'}
+
+ step: IntProperty(
+ name="step",
+ description="Tutorial Step",
+ default=0,
+ options={'SKIP_SAVE'}
+ )
+
+ @classmethod
+ def poll(cls, context):
+ return True
+
+ def draw(self, context):
+ layout = self.layout
+ if self.step == 0:
+ message = "BlenderKit is an addon that connects to the internet to search and upload for models, materials, and brushes. \n\n Let's start by searching for some cool materials?"
+ else:
+ message = "This shouldn't be here at all"
+ utils.label_multiline(layout, text= message, width = 300)
+
+ def execute(self, context):
+ if self.step == 0:
+ #move mouse:
+ #bpy.context.window_manager.windows[0].cursor_warp(1000, 1000)
+ #show n-key sidebar (spaces[index] has to be found for view3d too:
+ # bpy.context.window_manager.windows[0].screen.areas[5].spaces[0].show_region_ui = False
+ print('running search no')
+ ui_props = bpy.context.scene.blenderkitUI
+ ui_props.asset_type = 'MATERIAL'
+ search.search()
+ return {'FINISHED'}
+
+ def invoke(self, context, event):
+ wm = bpy.context.window_manager
+ return wm.invoke_props_dialog(self)
def draw_asset_context_menu(self, context, asset_data):
layout = self.layout
@@ -1298,7 +1349,8 @@ classess = (
VIEW3D_PT_blenderkit_downloads,
OBJECT_MT_blenderkit_asset_menu,
OBJECT_MT_blenderkit_login_menu,
- UrlPopupDialog
+ UrlPopupDialog,
+ BlenderKitWelcomeOperator,
)
diff --git a/blenderkit/utils.py b/blenderkit/utils.py
index 78eff216..effc2627 100644
--- a/blenderkit/utils.py
+++ b/blenderkit/utils.py
@@ -614,15 +614,14 @@ def guard_from_crash():
return True
-def get_largest_3dview():
+def get_largest_area( area_type = 'VIEW_3D'):
maxsurf = 0
maxa = None
maxw = None
region = None
for w in bpy.context.window_manager.windows:
- screen = w.screen
- for a in screen.areas:
- if a.type == 'VIEW_3D':
+ for a in w.screen.areas:
+ if a.type == area_type:
asurf = a.width * a.height
if asurf > maxsurf:
maxa = a
@@ -638,15 +637,18 @@ def get_largest_3dview():
active_region = region
return maxw, maxa, region
-def get_fake_context(context):
+def get_fake_context(context, area_type = 'VIEW_3D'):
C_dict = context.copy()
C_dict.update(region='WINDOW')
- if context.area is None or context.area.type != 'VIEW_3D':
- w, a, r = get_largest_3dview()
+ if context.area is None or context.area.type != area_type:
+ w, a, r = get_largest_area(area_type = area_type)
+
override = {'window': w, 'screen': w.screen, 'area': a, 'region': r}
C_dict.update(override)
+ # print(w,a,r)
return C_dict
+
def label_multiline(layout, text='', icon='NONE', width=-1):
''' draw a ui label, but try to split it in multiple lines.'''
if text.strip() == '':