diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py index 0c4dcca7a0570279bf2c6062debf382a6a6c9a46..ab34c24cc871fb2ab6e829c17cefc23ca3d01891 100644 --- a/object_collection_manager/__init__.py +++ b/object_collection_manager/__init__.py @@ -22,7 +22,7 @@ bl_info = { "name": "Collection Manager", "description": "Manage collections and their objects", "author": "Ryan Inch", - "version": (1,8,3), + "version": (1,8,4), "blender": (2, 80, 0), "location": "View3D - Object Mode (Shortcut - M)", "warning": '', # used for warning icon and text in addons panel @@ -55,6 +55,7 @@ addon_keymaps = [] classes = ( internals.CMListCollection, + internals.CMSendReport, operators.ExpandAllOperator, operators.ExpandSublevelOperator, operators.CMExcludeOperator, diff --git a/object_collection_manager/internals.py b/object_collection_manager/internals.py index 5deadececa9cd7cc94c1269ed5ac968dd7571529..eeef823809538bca09a237cfca27bfe246cfb167 100644 --- a/object_collection_manager/internals.py +++ b/object_collection_manager/internals.py @@ -18,7 +18,13 @@ # Copyright 2011, Ryan Inch -from bpy.types import PropertyGroup +import bpy + +from bpy.types import ( + PropertyGroup, + Operator, +) + from bpy.props import StringProperty layer_collections = {} @@ -127,3 +133,66 @@ def create_property_group(context, tree): if laycol["has_children"]: create_property_group(context, laycol["children"]) + + +class CMSendReport(Operator): + bl_label = "Send Report" + bl_idname = "view3d.cm_send_report" + + message: StringProperty() + + def draw(self, context): + layout = self.layout + + first = True + string = "" + + for num, char in enumerate(self.message): + if char == "\n": + if first: + layout.row().label(text=string, icon='ERROR') + first = False + else: + layout.row().label(text=string, icon='BLANK1') + + string = "" + continue + + string = string + char + + if first: + layout.row().label(text=string, icon='ERROR') + else: + layout.row().label(text=string, icon='BLANK1') + + def invoke(self, context, event): + wm = context.window_manager + + max_len = 0 + length = 0 + + for char in self.message: + if char == "\n": + if length > max_len: + max_len = length + length = 0 + else: + length += 1 + + if length > max_len: + max_len = length + + return wm.invoke_popup(self, width=(30 + (max_len*5.5))) + + def execute(self, context): + self.report({'INFO'}, self.message) + print(self.message) + return {'FINISHED'} + +def send_report(message): + def report(): + window = bpy.context.window_manager.windows[0] + ctx = {'window': window, 'screen': window.screen, } + bpy.ops.view3d.cm_send_report(ctx, 'INVOKE_DEFAULT', message=message) + + bpy.app.timers.register(report) diff --git a/object_collection_manager/operators.py b/object_collection_manager/operators.py index 57e1c537a8912871687dfd696f6a2e7a421963ec..604eb7522b8912da41472470ec3a4625bb680919 100644 --- a/object_collection_manager/operators.py +++ b/object_collection_manager/operators.py @@ -36,6 +36,7 @@ from .internals import ( expanded, layer_collections, update_property_group, + send_report, ) rto_history = {