22import bpy
33import math
44from bpy .types import Operator , Context , Event
5- from bpy .props import StringProperty
5+ from bpy .props import StringProperty , IntProperty
66
77
88def get_all_icons () -> List [str ]:
@@ -16,11 +16,19 @@ class N_OT_IconShow(Operator):
1616 bl_description = "Browse and select an icon"
1717
1818 icon : StringProperty (default = "" )
19+ project_index : IntProperty (default = - 1 )
20+ subpath_index : IntProperty (default = - 1 )
1921
2022 def execute (self , context : Context ) -> set [str ]:
21- if self .icon :
22- context .window_manager .clipboard = self .icon
23- self .report ({"INFO" }, f"Icon '{ self .icon } ' copied to clipboard" )
23+ if self .icon and self .project_index >= 0 and self .subpath_index >= 0 :
24+ from ..core .preferences import get_preferences
25+ prefs = get_preferences (context )
26+
27+ if self .project_index < len (prefs .custom_project_paths ):
28+ project = prefs .custom_project_paths [self .project_index ]
29+ if self .subpath_index < len (project .subpaths ):
30+ project .subpaths [self .subpath_index ].icon = self .icon
31+ self .report ({"INFO" }, f"Icon '{ self .icon } ' set for subpath" )
2432 return {"FINISHED" }
2533
2634 def invoke (self , context : Context , event : Event ) -> set [str ]:
@@ -39,3 +47,5 @@ def draw(self, context: Context) -> None:
3947 for icon_name in icons :
4048 op = flow .operator (self .bl_idname , text = "" , icon = icon_name , emboss = False )
4149 op .icon = icon_name
50+ op .project_index = self .project_index
51+ op .subpath_index = self .subpath_index
0 commit comments