UI: Implement a Clear Recent Files List Operator #116494

Merged
Harley Acheson merged 4 commits from Brainzman/blender:clear-recent-files into main 2024-01-03 21:26:24 +01:00
4 changed files with 29 additions and 0 deletions

View File

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

View File

@ -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
* \{ */

View File

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

View File

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