Commit: 14999945573428c0cb9ae65651d9c3587716105a
Author: Campbell Barton
Date:   Fri Jul 12 15:45:52 2019 +1000
Branches: master
https://developer.blender.org/rB14999945573428c0cb9ae65651d9c3587716105a

Fix T66675: Auto-Save override button has no tooltip

===================================================================

M       release/scripts/startup/bl_ui/space_userpref.py
M       source/blender/editors/space_userpref/userpref_ops.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_userpref.py 
b/release/scripts/startup/bl_ui/space_userpref.py
index 4fc54de7c4d..2f573d83132 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -40,17 +40,22 @@ class USERPREF_HT_header(Header):
 
         row = layout.row()
         row.menu("USERPREF_MT_save_load", text="", icon='COLLAPSEMENU')
+        # Use '_is_startup' so once factory settings are loaded
+        # this display option will show, since it's confusing if disabling
+        # the option makes it dissapiers.
         if prefs.use_preferences_save:
-            if bpy.app.use_userpref_skip_save_on_exit:
-                # We should have an 'alert' icon, for now use 'error'.
+            use_userpref_skip_save_on_exit = 
bpy.app.use_userpref_skip_save_on_exit
+            if use_userpref_skip_save_on_exit or getattr(USERPREF_HT_header, 
"_is_startup", False):
+                USERPREF_HT_header._is_startup = True
+
                 sub = row.row(align=True)
+                sub.alignment = 'LEFT'
                 props = sub.operator(
-                    "wm.context_toggle",
+                    "preferences.autosave_override_toggle",
                     text="Skip Auto-Save",
-                    icon='CHECKBOX_HLT',
+                    emboss=False,
+                    icon='CHECKBOX_HLT' if use_userpref_skip_save_on_exit else 
'CHECKBOX_DEHLT',
                 )
-                props.module = "bpy.app"
-                props.data_path = "use_userpref_skip_save_on_exit"
         else:
             sub = row.row(align=True)
             sub.active = prefs.is_dirty
diff --git a/source/blender/editors/space_userpref/userpref_ops.c 
b/source/blender/editors/space_userpref/userpref_ops.c
index bd3ddf18144..c932d537b54 100644
--- a/source/blender/editors/space_userpref/userpref_ops.c
+++ b/source/blender/editors/space_userpref/userpref_ops.c
@@ -26,6 +26,7 @@
 #include "DNA_screen_types.h"
 
 #include "BKE_context.h"
+#include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_report.h"
 
@@ -71,7 +72,39 @@ static void 
PREFERENCES_OT_reset_default_theme(wmOperatorType *ot)
 
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name Toggle Auto-Save Override
+ *
+ * This operator only exists so there is a useful tool-tip for for adjusting 
the global flag.
+ * \{ */
+
+static int preferences_autosave_override_toggle_exec(bContext *UNUSED(C), 
wmOperator *UNUSED(op))
+{
+  G.f ^= G_FLAG_USERPREF_NO_SAVE_ON_EXIT;
+  return OPERATOR_FINISHED;
+}
+
+static void PREFERENCES_OT_autosave_override_toggle(wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Toggle Override Auto-Save";
+  ot->idname = "PREFERENCES_OT_autosave_override_toggle";
+  ot->description =
+      "The current session has \"Factory Preferences\" loaded "
+      "which disables automatically saving.\n"
+      "Disable this to auto-save the preferences";
+
+  /* callbacks */
+  ot->exec = preferences_autosave_override_toggle_exec;
+
+  /* flags */
+  ot->flag = OPTYPE_REGISTER;
+}
+
+/** \} */
+
 void ED_operatortypes_userpref(void)
 {
   WM_operatortype_append(PREFERENCES_OT_reset_default_theme);
+  WM_operatortype_append(PREFERENCES_OT_autosave_override_toggle);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to