Fix T66675: Auto-Save override button has no tooltip

This commit is contained in:
Campbell Barton 2019-07-12 15:45:52 +10:00
parent f2df520698
commit 1499994557
Notes: blender-bot 2023-02-14 09:36:46 +01:00
Referenced by issue #66675, Tooltip urgently needed for Preferences editor button to avoid user data loss with factory-defaults.
2 changed files with 44 additions and 6 deletions

View File

@ -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

View File

@ -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);
}