Fix #93769: Improved File Browser Button Tooltips

In the File Browser the "Cancel" button always has a tooltip hint of
"Cancel loading of selected file", even when you are saving. This PR
changes that to a more generic "Cancel file operation". Similarly the
save/load button always shows "Execute selected file", even when
loading. This PR instead uses the description of the operator that is
called when that button is pressed. When opening a file it shows "Open
a Blender file", saving shows "Save the current file in the desired
location", etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/131703
This commit is contained in:
Harley Acheson
2024-12-11 18:11:27 +01:00
committed by Harley Acheson
parent de8f882817
commit f05fff0d97

View File

@@ -1563,8 +1563,8 @@ static int file_cancel_exec(bContext *C, wmOperator * /*unused*/)
void FILE_OT_cancel(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Cancel File Load";
ot->description = "Cancel loading of selected file";
ot->name = "Cancel File Operation";
ot->description = "Cancel file operation";
ot->idname = "FILE_OT_cancel";
/* api callbacks */
@@ -2123,12 +2123,26 @@ static int file_exec(bContext *C, wmOperator * /*op*/)
return OPERATOR_FINISHED;
}
static std::string file_execute_get_description(bContext *C,
wmOperatorType * /*ot*/,
PointerRNA * /*ptr*/)
{
SpaceFile *sfile = CTX_wm_space_file(C);
if (sfile->op && sfile->op->type) {
/* Return the description of the executed operator. Don't use get_description
* as that will return file details for WM_OT_open_mainfile. */
return TIP_(sfile->op->type->description);
}
return {};
}
void FILE_OT_execute(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Execute File Window";
ot->description = "Execute selected file";
ot->idname = "FILE_OT_execute";
ot->get_description = file_execute_get_description;
/* api callbacks */
ot->exec = file_exec;