[Bf-extensions-cvs] [42d5e009] master: Collection Manager: Fix send_report error. Task: T69577
Ryan Inch
noreply at git.blender.org
Mon Jan 6 07:01:43 CET 2020
Commit: 42d5e009be49e560f3e4ebe42b6c4aa0721bef44
Author: Ryan Inch
Date: Mon Jan 6 00:16:53 2020 -0500
Branches: master
https://developer.blender.org/rBA42d5e009be49e560f3e4ebe42b6c4aa0721bef44
Collection Manager: Fix send_report error. Task: T69577
Transferred the send_report function and class from my
Advanced UI Menus addon that I forgot to include when
I first separated the Collection Manager from it.
===================================================================
M object_collection_manager/__init__.py
M object_collection_manager/internals.py
M object_collection_manager/operators.py
===================================================================
diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index 0c4dcca7..ab34c24c 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 5deadece..eeef8238 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 57e1c537..604eb752 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 = {
More information about the Bf-extensions-cvs
mailing list