Preferences: auto-save on exit
Save modified preferences on exit by default, with the option to disable this.
This commit is contained in:
parent
3d923f3eaf
commit
741f29d499
Notes:
blender-bot
2023-04-14 09:18:04 +02:00
Referenced by issue #64174, Automatically Store Quick Favorites
|
@ -30,18 +30,28 @@ from bpy.app.translations import contexts as i18n_contexts
|
|||
class USERPREF_HT_header(Header):
|
||||
bl_space_type = 'PREFERENCES'
|
||||
|
||||
def draw(self, _context):
|
||||
@staticmethod
|
||||
def draw_buttons(layout, context, *, is_vertical=False):
|
||||
if is_vertical:
|
||||
sub = layout.column(align=True)
|
||||
else:
|
||||
sub = layout.row(align=True)
|
||||
|
||||
sub.operator("wm.save_userpref")
|
||||
sub.operator("wm.read_userpref")
|
||||
sub.operator("wm.read_factory_userpref")
|
||||
|
||||
prefs = context.preferences
|
||||
layout.prop(prefs, "use_preferences_save")
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator_context = 'EXEC_AREA'
|
||||
|
||||
layout.template_header()
|
||||
|
||||
layout.separator_spacer()
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator("wm.save_userpref")
|
||||
row.operator("wm.read_userpref")
|
||||
row.operator("wm.read_factory_userpref")
|
||||
self.draw_buttons(layout, context)
|
||||
|
||||
|
||||
class USERPREF_PT_navigation_bar(Panel):
|
||||
|
@ -77,17 +87,14 @@ class USERPREF_PT_save_preferences(Panel):
|
|||
|
||||
return False
|
||||
|
||||
def draw(self, _context):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.operator_context = 'EXEC_AREA'
|
||||
|
||||
layout.scale_x = 1.3
|
||||
layout.scale_y = 1.3
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.operator("wm.save_userpref")
|
||||
col.operator("wm.read_userpref")
|
||||
col.operator("wm.read_factory_userpref")
|
||||
USERPREF_HT_header.draw_buttons(layout, context, is_vertical=True)
|
||||
|
||||
|
||||
# Panel mix-in.
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* \note Use #STRINGIFY() rather than defining with quotes.
|
||||
*/
|
||||
#define BLENDER_VERSION 280
|
||||
#define BLENDER_SUBVERSION 61
|
||||
#define BLENDER_SUBVERSION 62
|
||||
/** Several breakages with 280, e.g. collections vs layers. */
|
||||
#define BLENDER_MINVERSION 280
|
||||
#define BLENDER_MINSUBVERSION 0
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
/* Disallow access to global userdef. */
|
||||
#define U (_error_)
|
||||
|
||||
static void do_versions_theme(UserDef *userdef, bTheme *btheme)
|
||||
static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
|
||||
{
|
||||
|
||||
#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(userdef, ver, subver)
|
||||
|
@ -580,10 +580,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include next version bump.
|
||||
*/
|
||||
{
|
||||
if (!USER_VERSION_ATLEAST(280, 62)) {
|
||||
/* (keep this block even if it becomes empty). */
|
||||
if (userdef->vbotimeout == 0) {
|
||||
userdef->vbocollectrate = 60;
|
||||
|
@ -593,6 +590,15 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
|
|||
if (userdef->lookdev_sphere_size == 0) {
|
||||
userdef->lookdev_sphere_size = 150;
|
||||
}
|
||||
|
||||
userdef->pref_flag |= USER_PREF_FLAG_SAVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Include next version bump.
|
||||
*/
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
if (userdef->pixelsize == 0.0f) {
|
||||
|
|
|
@ -549,8 +549,12 @@ typedef struct UserDef {
|
|||
/** #eUserPref_Flag. */
|
||||
int flag;
|
||||
/** #eDupli_ID_Flags. */
|
||||
int dupflag;
|
||||
int savetime;
|
||||
short dupflag;
|
||||
/**
|
||||
* #eUserPref_PrefFlag preferences for the preferences. */
|
||||
char pref_flag;
|
||||
char savetime;
|
||||
char _pad4[4];
|
||||
/** FILE_MAXDIR length. */
|
||||
char tempdir[768];
|
||||
char fontdir[768];
|
||||
|
@ -844,6 +848,10 @@ typedef enum eUserPref_Flag {
|
|||
USER_TOOLTIPS_PYTHON = (1 << 26),
|
||||
} eUserPref_Flag;
|
||||
|
||||
typedef enum eUserPref_PrefFlag {
|
||||
USER_PREF_FLAG_SAVE = (1 << 0),
|
||||
} eUserPref_PrefFlag;
|
||||
|
||||
/** #bPathCompare.flag */
|
||||
typedef enum ePathCompare_Flag {
|
||||
USER_PATHCMP_GLOB = (1 << 0),
|
||||
|
|
|
@ -5687,6 +5687,11 @@ void RNA_def_userdef(BlenderRNA *brna)
|
|||
NULL);
|
||||
RNA_def_property_ui_text(prop, "Studio Lights", "");
|
||||
|
||||
/* Preferences Flags */
|
||||
prop = RNA_def_property(srna, "use_preferences_save", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "pref_flag", USER_PREF_FLAG_SAVE);
|
||||
RNA_def_property_ui_text(prop, "Save on Exit", "Save modified preferences on exit");
|
||||
|
||||
rna_def_userdef_view(brna);
|
||||
rna_def_userdef_edit(brna);
|
||||
rna_def_userdef_input(brna);
|
||||
|
|
|
@ -475,12 +475,11 @@ void WM_exit_ext(bContext *C, const bool do_python)
|
|||
ED_screen_exit(C, win, WM_window_get_active_screen(win));
|
||||
}
|
||||
|
||||
/* Disable until we have a revert button. */
|
||||
#if 0
|
||||
if (U.runtime.is_dirty) {
|
||||
BKE_blendfile_userdef_write_all(NULL);
|
||||
if (U.pref_flag & USER_PREF_FLAG_SAVE) {
|
||||
BKE_blendfile_userdef_write_all(NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
BLI_timer_free();
|
||||
|
|
Loading…
Reference in New Issue