diff --git a/source/blender/editors/space_topbar/space_topbar.cc b/source/blender/editors/space_topbar/space_topbar.cc index 59af59d5059..c107eb10740 100644 --- a/source/blender/editors/space_topbar/space_topbar.cc +++ b/source/blender/editors/space_topbar/space_topbar.cc @@ -206,6 +206,8 @@ static void recent_files_menu_draw(const bContext * /*C*/, Menu *menu) RNA_string_set(&ptr, "filepath", recent->filepath); RNA_boolean_set(&ptr, "display_file_selector", false); } + uiItemS(layout); + uiItemO(layout, nullptr, ICON_TRASH, "WM_OT_clear_recent_files"); } else { uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE); diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index cfd2041a066..161b797a419 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -3571,6 +3571,30 @@ void WM_OT_save_mainfile(wmOperatorType *ot) /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Clear Recent Files List Operator + * \{ */ + +static int wm_clear_recent_files_exec(bContext * /*C*/, wmOperator * /*op*/) +{ + wm_history_files_free(); + wm_history_file_write(); + + return OPERATOR_FINISHED; +} + +void WM_OT_clear_recent_files(wmOperatorType *ot) +{ + ot->name = "Clear Recent Files List"; + ot->idname = "WM_OT_clear_recent_files"; + ot->description = "Clear the Recent Files List"; + + ot->invoke = WM_operator_confirm; + ot->exec = wm_clear_recent_files_exec; +} + +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Auto Script Execution Warning Dialog * \{ */ diff --git a/source/blender/windowmanager/intern/wm_operators.cc b/source/blender/windowmanager/intern/wm_operators.cc index 428463cdb71..0763ec88b88 100644 --- a/source/blender/windowmanager/intern/wm_operators.cc +++ b/source/blender/windowmanager/intern/wm_operators.cc @@ -3888,6 +3888,7 @@ void wm_operatortypes_register() WM_operatortype_append(WM_OT_recover_auto_save); WM_operatortype_append(WM_OT_save_as_mainfile); WM_operatortype_append(WM_OT_save_mainfile); + WM_operatortype_append(WM_OT_clear_recent_files); WM_operatortype_append(WM_OT_redraw_timer); WM_operatortype_append(WM_OT_memory_statistics); WM_operatortype_append(WM_OT_debug_menu); diff --git a/source/blender/windowmanager/wm_files.hh b/source/blender/windowmanager/wm_files.hh index 6d0c7d6891f..d62ef68dc27 100644 --- a/source/blender/windowmanager/wm_files.hh +++ b/source/blender/windowmanager/wm_files.hh @@ -116,6 +116,8 @@ void WM_OT_recover_auto_save(wmOperatorType *ot); void WM_OT_save_as_mainfile(wmOperatorType *ot); void WM_OT_save_mainfile(wmOperatorType *ot); +void WM_OT_clear_recent_files(wmOperatorType *ot); + /* `wm_files_link.cc` */ void WM_OT_link(wmOperatorType *ot);