UI: move preferences save options into submenu
authorWilliam Reynish <billrey@me.com>
Wed, 15 May 2019 08:39:41 +0000 (18:39 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 15 May 2019 08:41:45 +0000 (18:41 +1000)
Avoid clutter in the UI by moving save/revert options into submenu,
only show the save button when auto-save is disabled.

release/scripts/startup/bl_ui/space_userpref.py

index ca2d616..d0613b4 100644 (file)
@@ -34,15 +34,15 @@ class USERPREF_HT_header(Header):
     def draw_buttons(layout, context, *, is_vertical=False):
         prefs = context.preferences
 
-        row = layout.row()
-
-        row.operator("wm.save_userpref", text="Save")
-        row_revert = row.row(align=True)
-        row_revert.active = prefs.is_dirty
-        row_revert.operator("wm.read_userpref", text="Revert")
-        layout.operator("wm.read_factory_userpref", text="Load Factory Settings")
+        layout.scale_x = 1.0
+        layout.scale_y = 1.0
 
-        layout.prop(prefs, "use_preferences_save")
+        row = layout.row()
+        row.menu("USERPREF_MT_save_load", text="", icon='COLLAPSEMENU')
+        if not prefs.use_preferences_save:
+            sub_revert = row.row(align=True)
+            sub_revert.active = prefs.is_dirty
+            sub_revert.operator("wm.save_userpref")
 
     def draw(self, context):
         layout = self.layout
@@ -72,6 +72,25 @@ class USERPREF_PT_navigation_bar(Panel):
         col.prop(prefs, "active_section", expand=True)
 
 
+class USERPREF_MT_save_load(Menu):
+    bl_label = "Save & Load"
+
+    def draw(self, context):
+        layout = self.layout
+
+        prefs = context.preferences
+
+        layout.prop(prefs, "use_preferences_save", text="Auto-Save Preferences")
+
+        layout.separator()
+        if prefs.use_preferences_save:
+            layout.operator("wm.save_userpref", text="Save Current State")
+        sub_revert = layout.column(align=True)
+        sub_revert.active = prefs.is_dirty
+        sub_revert.operator("wm.read_userpref", text="Revert to Saved")
+        layout.operator("wm.read_factory_userpref", text="Reset to Defaults")
+
+
 class USERPREF_PT_save_preferences(Panel):
     bl_label = "Save Preferences"
     bl_space_type = 'PREFERENCES'
@@ -2040,6 +2059,7 @@ classes = (
     USERPREF_HT_header,
     USERPREF_PT_navigation_bar,
     USERPREF_PT_save_preferences,
+    USERPREF_MT_save_load,
 
     USERPREF_PT_interface_display,
     USERPREF_PT_interface_editors,