Skip to content

Commit

Permalink
fix addon pref (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyAJohnston authored Feb 15, 2025
1 parent ed432b6 commit 9828342
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
8 changes: 1 addition & 7 deletions molecularnodes/entities/molecule/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
from ...style import STYLE_ITEMS


def addon_preferences() -> bpy.types.AddonPreferences:
try:
return bpy.context.preferences.addons[__package__].preferences
except KeyError:
return bpy.context.preferences.addons[
"bl_ext.vscode_development.molecularnodes"
].preferences
from ...pref import addon_preferences


def parse(filepath) -> Molecule:
Expand Down
26 changes: 21 additions & 5 deletions molecularnodes/pref.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
CACHE_DIR = str(Path("~", "MolecularNodesCache").expanduser())


def addon_preferences(
context: bpy.types.Context | None = None,
) -> bpy.types.AddonPreferences:
if context is None:
context = bpy.context
try:
return context.preferences.addons[__package__].preferences
except KeyError:
return context.preferences.addons[
"bl_ext.vscode_development.molecularnodes"
].preferences


class MN_OT_Template_Install(bpy.types.Operator):
bl_idname = "mn.template_install"
bl_label = "Install Template"
Expand Down Expand Up @@ -54,6 +67,14 @@ class MolecularNodesPreferences(bpy.types.AddonPreferences):

def draw(self, context):
layout = self.layout
layout.label(
text="Where and if to store downloaded files for faster subsequent loading:"
)
row = layout.row()
row.prop(self, "cache_download", text="")
col = row.column()
col.prop(self, "cache_dir")
col.enabled = self.cache_download
layout.label(
text="Install the Molecular Nodes template file, to start Blender with useful default settings"
)
Expand All @@ -65,11 +86,6 @@ def draw(self, context):

row.operator("mn.template_install", text=text)
row.operator("mn.template_uninstall")
row = layout.row()
row.prop(self, "cache_download", text="")
col = row.column()
col.prop(self, "cache_dir")
col.enabled = self.cache_download


CLASSES = [MN_OT_Template_Install, MN_OT_Template_Uninstall, MolecularNodesPreferences]

0 comments on commit 9828342

Please sign in to comment.