UI: Remember ID-Filter in-between File Browser calls
authorJulian Eisel <eiseljulian@gmail.com>
Wed, 16 Oct 2019 10:04:56 +0000 (12:04 +0200)
committerJulian Eisel <eiseljulian@gmail.com>
Wed, 16 Oct 2019 12:06:48 +0000 (14:06 +0200)
This adds the ID-Filters visible on append/link to the settings the file
browser remembers, potentially storing them in the Preferences.

Artists in the studio here requested this. They typically have to set up
the same or similar settings every time, so this saves them from that.

release/datafiles/userdef/userdef_default.c
source/blender/blenkernel/BKE_blender_version.h
source/blender/blenloader/intern/versioning_userdef.c
source/blender/editors/space_file/filesel.c
source/blender/makesdna/DNA_userdef_types.h

index dc35187ab7ed2e8eda2a8cd38d2de91306f1b89f..d8b87480f29f9916e6396c8060fddfd846121e98 100644 (file)
@@ -213,6 +213,7 @@ const UserDef U_default = {
             .sort_type = FILE_SORT_ALPHA,
             .details_flags = FILE_DETAILS_SIZE | FILE_DETAILS_DATETIME,
             .flag = FILE_HIDE_DOT,
+            .filter_id = FILTER_ID_ALL,
 
             .temp_win_sizex = 1020,
             .temp_win_sizey = 600,
index 9bd90f76b79eee4f4e8ed28253c916b5a547c0c5..dfa1b311eb071ecec35c1955191cf87a2bdc6135 100644 (file)
@@ -27,7 +27,7 @@
  * \note Use #STRINGIFY() rather than defining with quotes.
  */
 #define BLENDER_VERSION 282
-#define BLENDER_SUBVERSION 0
+#define BLENDER_SUBVERSION 1
 /** Several breakages with 280, e.g. collections vs layers. */
 #define BLENDER_MINVERSION 280
 #define BLENDER_MINSUBVERSION 0
index d2192f1e22aed98328d24e74a342913700b9d7ea..e1ee020940e739be06e1a8358615c5eb33117e69 100644 (file)
@@ -637,6 +637,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
     }
   }
 
+  if (!USER_VERSION_ATLEAST(282, 1)) {
+    userdef->file_space_data.filter_id = U_default.file_space_data.filter_id;
+  }
+
   /**
    * Include next version bump.
    */
index ba4ccb4fba94b1812ec6d37673759c7d09cec7d5..bb3906a961b5713f11fed85ef94ad0bf06f05737 100644 (file)
@@ -103,10 +103,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
                       sizeof(sfile->params->dir),
                       sizeof(sfile->params->file));
     sfile->params->filter_glob[0] = '\0';
-    /* set the default thumbnails size */
     sfile->params->thumbnail_size = U_default.file_space_data.thumbnail_size;
-    /* Show size column by default. */
     sfile->params->details_flags = U_default.file_space_data.details_flags;
+    sfile->params->filter_id = U_default.file_space_data.filter_id;
   }
 
   params = sfile->params;
@@ -246,9 +245,6 @@ short ED_fileselect_set_params(SpaceFile *sfile)
       }
     }
 
-    /* For now, always init filterid to 'all true' */
-    params->filter_id = FILTER_ID_ALL;
-
     if (U.uiflag & USER_HIDE_DOT) {
       params->flag |= FILE_HIDE_DOT;
     }
@@ -348,6 +344,7 @@ void ED_fileselect_set_params_from_userdef(SpaceFile *sfile)
   }
   sfile->params->thumbnail_size = sfile_udata->thumbnail_size;
   sfile->params->details_flags = sfile_udata->details_flags;
+  sfile->params->filter_id = sfile_udata->filter_id;
 
   /* Combine flags we take from params with the flags we take from userdef. */
   sfile->params->flag = (sfile->params->flag & ~PARAMS_FLAGS_REMEMBERED) |
@@ -371,6 +368,7 @@ void ED_fileselect_params_to_userdef(SpaceFile *sfile, int temp_win_size[2])
   sfile_udata_new->sort_type = sfile->params->sort;
   sfile_udata_new->details_flags = sfile->params->details_flags;
   sfile_udata_new->flag = sfile->params->flag & PARAMS_FLAGS_REMEMBERED;
+  sfile_udata_new->filter_id = sfile->params->filter_id;
 
   if (temp_win_size) {
     sfile_udata_new->temp_win_sizex = temp_win_size[0];
index b9f43c0e5792e94380c79fdd43a33a80153eee61..c726c5e132e1cc43458d364795739e3ffeb43c74 100644 (file)
@@ -588,8 +588,7 @@ typedef struct UserDef_FileSpaceData {
   int sort_type;      /* FileSelectParams.sort */
   int details_flags;  /* FileSelectParams.details_flags */
   int flag;           /* FileSelectParams.flag */
-
-  char _pad[4];
+  int filter_id;      /* FileSelectParams.filter_id */
 
   /** Info used when creating the file browser in a temporary window. */
   int temp_win_sizex;