Collection Manager: Add QCD widget preference. Task: T69577

Add a preference to enable/disable the QCD 3D Viewport header widget.
This commit is contained in:
Ryan Inch 2022-04-19 02:13:12 -04:00
parent 754d05ac7e
commit a65df677f7
3 changed files with 29 additions and 6 deletions

View File

@ -6,7 +6,7 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
"version": (2, 23, 1),
"version": (2, 24, 0),
"blender": (2, 80, 0),
"location": "View3D - Object Mode (Shortcut - M)",
"warning": '', # used for warning icon and text in addons panel

View File

@ -39,6 +39,12 @@ def update_qcd_view_edit_mode_hotkeys_status(self, context):
else:
qcd_init.unregister_qcd_view_edit_mode_hotkeys()
def update_qcd_3dview_header_widget_status(self, context):
if self.enable_qcd_3dview_header_widget:
qcd_init.register_qcd_3dview_header_widget()
else:
qcd_init.unregister_qcd_3dview_header_widget()
def get_tool_text(self):
if self.tool_text_override:
return self["tool_text_color"]
@ -188,7 +194,7 @@ class CMPreferences(AddonPreferences):
# ENABLE QCD BOOLS
enable_qcd: BoolProperty(
name="QCD",
description="Enable/Disable QCD System.\nThe Quick Content Display system allows you to specify collections as QCD \"slots\" up to a maximum of 20. You can then interact with them through numerical hotkeys, a popup move widget, and a 3D View header widget",
description="Enable/Disable QCD System.\nThe Quick Content Display system allows you to specify collections as QCD \"slots\" up to a maximum of 20. You can then interact with them through numerical hotkeys, a popup move widget, and a 3D Viewport header widget",
default=True,
update=update_qcd_status,
)
@ -207,6 +213,13 @@ class CMPreferences(AddonPreferences):
update=update_qcd_view_edit_mode_hotkeys_status,
)
enable_qcd_3dview_header_widget: BoolProperty(
name="QCD 3D Viewport Header Widget",
description="Enable/Disable the 3D Viewport header widget. This widget graphically represents the 20 QCD slots and allows you to interact with them through the GUI",
default=True,
update=update_qcd_3dview_header_widget_status,
)
# OVERRIDE BOOLS
tool_text_override: BoolProperty(
@ -431,6 +444,7 @@ class CMPreferences(AddonPreferences):
box.row().prop(self, "enable_qcd_view_hotkeys")
box.row().prop(self, "enable_qcd_view_edit_mode_hotkeys")
box.row().prop(self, "enable_qcd_3dview_header_widget")
box.row().label(text="QCD Move Widget")

View File

@ -104,8 +104,8 @@ def register_qcd():
if prefs.enable_qcd_view_edit_mode_hotkeys:
register_qcd_view_edit_mode_hotkeys()
bpy.types.VIEW3D_HT_header.append(ui.view3d_header_qcd_slots)
bpy.types.TOPBAR_HT_upper_bar.append(ui.view_layer_update)
if prefs.enable_qcd_3dview_header_widget:
register_qcd_3dview_header_widget()
def register_qcd_view_hotkeys():
@ -247,10 +247,14 @@ def register_qcd_view_edit_mode_hotkeys():
addon_qcd_view_edit_mode_hotkey_keymaps.append((km, kmi))
def register_qcd_3dview_header_widget():
bpy.types.VIEW3D_HT_header.append(ui.view3d_header_qcd_slots)
bpy.types.TOPBAR_HT_upper_bar.append(ui.view_layer_update)
def unregister_qcd():
bpy.types.VIEW3D_HT_header.remove(ui.view3d_header_qcd_slots)
bpy.types.TOPBAR_HT_upper_bar.remove(ui.view_layer_update)
unregister_qcd_3dview_header_widget()
for cls in qcd_classes:
bpy.utils.unregister_class(cls)
@ -288,3 +292,8 @@ def unregister_qcd_view_edit_mode_hotkeys():
for km, kmi in addon_qcd_view_edit_mode_hotkey_keymaps:
km.keymap_items.remove(kmi)
addon_qcd_view_edit_mode_hotkey_keymaps.clear()
def unregister_qcd_3dview_header_widget():
bpy.types.VIEW3D_HT_header.remove(ui.view3d_header_qcd_slots)
bpy.types.TOPBAR_HT_upper_bar.remove(ui.view_layer_update)