Cleanup: strip trailing space
[blender-addons.git] / space_view3d_pie_menus / pie_defaults_menu.py
blobf103e0b547c14e866ea46b296d0de7696f957793
1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 bl_info = {
6 "name": "Hotkey: 'Ctrl U'",
7 "description": "Save/Open & File Menus",
8 "blender": (2, 80, 0),
9 "location": "All Editors",
10 "warning": "",
11 "doc_url": "",
12 "category": "Interface"
15 import bpy
16 from bpy.types import (
17 Menu,
18 Operator,
20 import os
23 # Pie Save/Open
24 class PIE_MT_Load_Defaults(Menu):
25 bl_idname = "PIE_MT_loaddefaults"
26 bl_label = "Save Defaults"
28 def draw(self, context):
29 layout = self.layout
30 prefs = context.preferences
31 pie = layout.menu_pie()
32 # 4 - LEFT
33 pie.operator("wm.read_factory_settings", text="Load Factory Settings", icon='IMPORT')
34 # 6 - RIGHT
35 pie.operator("wm.read_factory_userpref", text="Load Factory Preferences", icon='RECOVER_LAST')
36 # 2 - BOTTOM
37 pie.operator("wm.read_userpref", text="Revert to Saved Prefs", icon='NONE')
38 # 8 - TOP
39 pie.operator("wm.save_homefile", text="Save StartUp File", icon='FILE_NEW')
40 # 7 - TOP - LEFT
41 pie.prop(prefs, "use_preferences_save", text="Auto-Save Preferences", icon='LINK_BLEND')
42 # 9 - TOP - RIGHT
43 pie.operator("wm.save_userpref", text="Save User Preferences", icon='NONE')
44 # 1 - BOTTOM - LEFT
45 pie.separator()
46 # 3 - BOTTOM - RIGHT
47 pie.separator()
50 classes = (
51 PIE_MT_Load_Defaults,
54 addon_keymaps = []
57 def register():
58 for cls in classes:
59 bpy.utils.register_class(cls)
61 wm = bpy.context.window_manager
62 if wm.keyconfigs.addon:
63 # Save/Open/...
64 km = wm.keyconfigs.addon.keymaps.new(name='Window')
65 kmi = km.keymap_items.new('wm.call_menu_pie', 'U', 'PRESS', ctrl=True)
66 kmi.properties.name = "PIE_MT_loaddefaults"
67 addon_keymaps.append((km, kmi))
70 def unregister():
71 for cls in classes:
72 bpy.utils.unregister_class(cls)
74 wm = bpy.context.window_manager
75 kc = wm.keyconfigs.addon
76 if kc:
77 for km, kmi in addon_keymaps:
78 km.keymap_items.remove(kmi)
79 addon_keymaps.clear()
82 if __name__ == "__main__":
83 register()