UI: support searching for more recent files
When trying to find and open an older file, it is annoying when it is not in the recent files list anymore. This patch increases the length of the recent files list, without making the menu huge by making better use of menu-search. Specifically the following is changed: * Number of remembered recent files is increased from 20 to 200 by default. * The recent files menu is limited to 20 entries. * When activating menu search (by pressing space when in the menu), all available recent files can be searched. * There is a new "More..." menu entry at the bottom, which also activates the menu search. Pull Request: https://projects.blender.org/blender/blender/pulls/146884
This commit is contained in:
@@ -140,7 +140,7 @@ const UserDef U_default = {
|
||||
.pad_rot_angle = 15,
|
||||
.rvisize = 25,
|
||||
.rvibright = 8,
|
||||
.recent_files = 20,
|
||||
.recent_files = 200,
|
||||
.smooth_viewtx = 200,
|
||||
.glreslimit = 0,
|
||||
.color_picker_type = USER_CP_CIRCLE_HSV,
|
||||
|
||||
@@ -3422,10 +3422,15 @@ class WM_MT_splash(Menu):
|
||||
col2 = split.column()
|
||||
col2_title = col2.row()
|
||||
|
||||
found_recent = col2.template_recent_files()
|
||||
found_recent = col2.template_recent_files(rows=5)
|
||||
|
||||
if found_recent:
|
||||
col2_title.label(text="Recent Files")
|
||||
|
||||
col_more = col2.column()
|
||||
col_more.operator_context = 'INVOKE_DEFAULT'
|
||||
more_props = col_more.operator("wm.search_single_menu", text="More...", icon='VIEWZOOM')
|
||||
more_props.menu_idname = "TOPBAR_MT_file_open_recent"
|
||||
else:
|
||||
# Links if no recent files.
|
||||
col2_title.label(text="Getting Started")
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 95
|
||||
#define BLENDER_FILE_SUBVERSION 96
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
|
||||
|
||||
@@ -1684,6 +1684,13 @@ void blo_do_versions_userdef(UserDef *userdef)
|
||||
userdef->flag |= USER_FILECOMPRESS;
|
||||
}
|
||||
|
||||
if (!USER_VERSION_ATLEAST(500, 96)) {
|
||||
/* Increase the number of recently-used files if using the old default value. */
|
||||
if (userdef->recent_files == 20) {
|
||||
userdef->recent_files = 200;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Always bump subversion in BKE_blender_version.h when adding versioning
|
||||
* code here, and wrap it inside a USER_VERSION_ATLEAST check.
|
||||
|
||||
@@ -186,16 +186,26 @@ static void topbar_header_region_message_subscribe(const wmRegionMessageSubscrib
|
||||
mbus, &workspace->id, workspace, WorkSpace, tools, &msg_sub_value_region_tag_redraw);
|
||||
}
|
||||
|
||||
static void recent_files_menu_draw(const bContext * /*C*/, Menu *menu)
|
||||
static void recent_files_menu_draw(const bContext *C, Menu *menu)
|
||||
{
|
||||
uiLayout *layout = menu->layout;
|
||||
layout->operator_context_set(blender::wm::OpCallContext::InvokeDefault);
|
||||
if (uiTemplateRecentFiles(layout, U.recent_files) != 0) {
|
||||
layout->separator();
|
||||
layout->op("WM_OT_clear_recent_files", IFACE_("Clear Recent Files List..."), ICON_TRASH);
|
||||
const bool is_menu_search = CTX_data_int_get(C, "is_menu_search").value_or(false);
|
||||
if (is_menu_search) {
|
||||
uiTemplateRecentFiles(layout, U.recent_files);
|
||||
}
|
||||
else {
|
||||
layout->label(IFACE_("No Recent Files"), ICON_NONE);
|
||||
const int limit = std::min<int>(U.recent_files, 20);
|
||||
if (uiTemplateRecentFiles(layout, limit) != 0) {
|
||||
layout->separator();
|
||||
PointerRNA search_props = layout->op(
|
||||
"WM_OT_search_single_menu", IFACE_("More..."), ICON_VIEWZOOM);
|
||||
RNA_string_set(&search_props, "menu_idname", "TOPBAR_MT_file_open_recent");
|
||||
layout->op("WM_OT_clear_recent_files", IFACE_("Clear Recent Files List..."), ICON_TRASH);
|
||||
}
|
||||
else {
|
||||
layout->label(IFACE_("No Recent Files"), ICON_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7177,7 +7177,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_autosave_update");
|
||||
|
||||
prop = RNA_def_property(srna, "recent_files", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_range(prop, 0, 30);
|
||||
RNA_def_property_range(prop, 0, 1000);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Recent Files", "Maximum number of recently opened files to remember");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user