1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 "name": "Hotkey: 'Ctrl S'",
7 "description": "Save/Open & File Menus",
9 "location": "All Editors",
12 "category": "Save Open Pie"
16 from bpy
.types
import (
24 class PIE_MT_SaveOpen(Menu
):
25 bl_idname
= "PIE_MT_saveopen"
26 bl_label
= "Pie Save/Open"
29 def _save_as_mainfile_calc_incremental_name():
31 dirname
, base_name
= os
.path
.split(bpy
.data
.filepath
)
32 base_name_no_ext
, ext
= os
.path
.splitext(base_name
)
33 match
= re
.match(r
"(.*)_([\d]+)$", base_name_no_ext
)
35 prefix
, number
= match
.groups()
36 number
= int(number
) + 1
38 prefix
, number
= base_name_no_ext
, 1
39 prefix
= os
.path
.join(dirname
, prefix
)
40 while os
.path
.isfile(output
:= "%s_%03d%s" % (prefix
, number
, ext
)):
44 def draw(self
, context
):
46 pie
= layout
.menu_pie()
48 pie
.operator("wm.read_homefile", text
="New", icon
='FILE_NEW')
50 pie
.menu("PIE_MT_link", text
="Link Menu", icon
='LINK_BLEND')
52 pie
.menu("PIE_MT_fileio", text
="Import/Export Menu", icon
='IMPORT')
54 pie
.menu("PIE_MT_openio", text
="Open Menu", icon
='FILE_FOLDER')
56 pie
.operator("wm.save_mainfile", text
="Save", icon
='FILE_TICK')
58 pie
.operator("wm.save_as_mainfile", text
="Save As...", icon
='NONE')
61 default_operator_contest
= layout
.operator_context
62 layout
.operator_context
= 'EXEC_DEFAULT'
64 "wm.save_as_mainfile", text
="Incremental Save", icon
='NONE',
65 ).filepath
= self
._save
_as
_mainfile
_calc
_incremental
_name
()
66 layout
.operator_context
= default_operator_contest
68 pie
.box().label(text
="Incremental Save (unsaved)")
71 pie
.menu("PIE_MT_recover", text
="Recovery Menu", icon
='RECOVER_LAST')
74 class PIE_MT_link(Menu
):
75 bl_idname
= "PIE_MT_link"
78 def draw(self
, context
):
80 pie
= layout
.menu_pie()
81 box
= pie
.split().column()
82 box
.operator("wm.link", text
="Link", icon
='LINK_BLEND')
83 box
.operator("wm.append", text
="Append", icon
='APPEND_BLEND')
85 box
.operator("file.autopack_toggle", text
="Automatically Pack Into .blend")
86 box
.operator("file.pack_all", text
="Pack All Into .blend")
87 box
.operator("file.unpack_all", text
="Unpack All Into Files")
89 box
.operator("file.make_paths_relative", text
="Make All Paths Relative")
90 box
.operator("file.make_paths_absolute", text
="Make All Paths Absolute")
93 class PIE_MT_recover(Menu
):
94 bl_idname
= "PIE_MT_recover"
97 def draw(self
, context
):
99 pie
= layout
.menu_pie()
100 box
= pie
.split().column()
101 box
.operator("wm.recover_auto_save", text
="Recover Auto Save...", icon
='NONE')
102 box
.operator("wm.recover_last_session", text
="Recover Last Session", icon
='RECOVER_LAST')
103 box
.operator("wm.revert_mainfile", text
="Revert", icon
='FILE_REFRESH')
105 box
.operator("file.report_missing_files", text
="Report Missing Files")
106 box
.operator("file.find_missing_files", text
="Find Missing Files")
109 class PIE_MT_fileio(Menu
):
110 bl_idname
= "PIE_MT_fileio"
111 bl_label
= "Import/Export"
113 def draw(self
, context
):
115 pie
= layout
.menu_pie()
116 box
= pie
.split().column()
117 box
.menu("TOPBAR_MT_file_import", icon
='IMPORT')
119 box
.menu("TOPBAR_MT_file_export", icon
='EXPORT')
122 class PIE_MT_openio(Menu
):
123 bl_idname
= "PIE_MT_openio"
124 bl_label
= "Open/Open Recent"
126 def draw(self
, context
):
128 pie
= layout
.menu_pie()
129 box
= pie
.split().column()
130 box
.operator("wm.open_mainfile", text
="Open File", icon
='FILE_FOLDER')
132 box
.menu("TOPBAR_MT_file_open_recent", icon
='FILE_FOLDER')
148 bpy
.utils
.register_class(cls
)
150 wm
= bpy
.context
.window_manager
151 if wm
.keyconfigs
.addon
:
153 km
= wm
.keyconfigs
.addon
.keymaps
.new(name
='Window')
154 kmi
= km
.keymap_items
.new('wm.call_menu_pie', 'S', 'PRESS', ctrl
=True)
155 kmi
.properties
.name
= "PIE_MT_saveopen"
156 addon_keymaps
.append((km
, kmi
))
161 bpy
.utils
.unregister_class(cls
)
163 wm
= bpy
.context
.window_manager
164 kc
= wm
.keyconfigs
.addon
166 for km
, kmi
in addon_keymaps
:
167 km
.keymap_items
.remove(kmi
)
168 addon_keymaps
.clear()
171 if __name__
== "__main__":