Cleanup: Tweak naming in file forwardcompat dialog
Make the function naming more generic so extending it in the future (with asset blend file information for example) won't have to adjust the function names to correct the semantics itself.
This commit is contained in:
@@ -3627,7 +3627,7 @@ static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, const wmEvent *
|
||||
|
||||
if (blendfile_path[0] != '\0') {
|
||||
if (CTX_data_main(C)->has_forward_compatibility_issues) {
|
||||
wm_save_file_forwardcompat_dialog(C, op);
|
||||
wm_save_file_overwrite_dialog(C, op);
|
||||
ret = OPERATOR_INTERFACE;
|
||||
}
|
||||
else {
|
||||
@@ -3979,9 +3979,9 @@ static void wm_free_operator_properties_callback(void *user_data)
|
||||
IDP_FreeProperty(properties);
|
||||
}
|
||||
|
||||
static const char *save_file_forwardcompat_dialog_name = "save_file_forwardcompat_popup";
|
||||
static const char *save_file_overwrite_dialog_name = "save_file_overwrite_popup";
|
||||
|
||||
static void file_forwardcompat_detailed_info_show(uiLayout *parent_layout, Main *bmain)
|
||||
static void file_overwrite_detailed_info_show(uiLayout *parent_layout, Main *bmain)
|
||||
{
|
||||
uiLayout *layout = uiLayoutColumn(parent_layout, true);
|
||||
/* Trick to make both lines of text below close enough to look like they are part of a same
|
||||
@@ -4015,21 +4015,21 @@ static void file_forwardcompat_detailed_info_show(uiLayout *parent_layout, Main
|
||||
uiItemL(layout, message_line2, ICON_NONE);
|
||||
}
|
||||
|
||||
static void save_file_forwardcompat_cancel(bContext *C, void *arg_block, void * /*arg_data*/)
|
||||
static void save_file_overwrite_cancel(bContext *C, void *arg_block, void * /*arg_data*/)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
UI_popup_block_close(C, win, static_cast<uiBlock *>(arg_block));
|
||||
}
|
||||
|
||||
static void save_file_forwardcompat_cancel_button(uiBlock *block, wmGenericCallback *post_action)
|
||||
static void save_file_overwrite_cancel_button(uiBlock *block, wmGenericCallback *post_action)
|
||||
{
|
||||
uiBut *but = uiDefIconTextBut(
|
||||
block, UI_BTYPE_BUT, 0, ICON_NONE, IFACE_("Cancel"), 0, 0, 0, UI_UNIT_Y, nullptr, 0, 0, "");
|
||||
UI_but_func_set(but, save_file_forwardcompat_cancel, block, post_action);
|
||||
UI_but_func_set(but, save_file_overwrite_cancel, block, post_action);
|
||||
UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
|
||||
}
|
||||
|
||||
static void save_file_forwardcompat_overwrite(bContext *C, void *arg_block, void *arg_data)
|
||||
static void save_file_overwrite_confirm(bContext *C, void *arg_block, void *arg_data)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
@@ -4052,8 +4052,7 @@ static void save_file_forwardcompat_overwrite(bContext *C, void *arg_block, void
|
||||
WM_generic_callback_free(callback);
|
||||
}
|
||||
|
||||
static void save_file_forwardcompat_overwrite_button(uiBlock *block,
|
||||
wmGenericCallback *post_action)
|
||||
static void save_file_overwrite_confirm_button(uiBlock *block, wmGenericCallback *post_action)
|
||||
{
|
||||
uiBut *but = uiDefIconTextBut(block,
|
||||
UI_BTYPE_BUT,
|
||||
@@ -4068,12 +4067,12 @@ static void save_file_forwardcompat_overwrite_button(uiBlock *block,
|
||||
0,
|
||||
0,
|
||||
"");
|
||||
UI_but_func_set(but, save_file_forwardcompat_overwrite, block, post_action);
|
||||
UI_but_func_set(but, save_file_overwrite_confirm, block, post_action);
|
||||
UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
|
||||
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
||||
}
|
||||
|
||||
static void save_file_forwardcompat_saveas(bContext *C, void *arg_block, void * /*arg_data*/)
|
||||
static void save_file_overwrite_saveas(bContext *C, void *arg_block, void * /*arg_data*/)
|
||||
{
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
UI_popup_block_close(C, win, static_cast<uiBlock *>(arg_block));
|
||||
@@ -4081,7 +4080,7 @@ static void save_file_forwardcompat_saveas(bContext *C, void *arg_block, void *
|
||||
WM_operator_name_call(C, "WM_OT_save_as_mainfile", WM_OP_INVOKE_DEFAULT, nullptr, nullptr);
|
||||
}
|
||||
|
||||
static void save_file_forwardcompat_saveas_button(uiBlock *block, wmGenericCallback *post_action)
|
||||
static void save_file_overwrite_saveas_button(uiBlock *block, wmGenericCallback *post_action)
|
||||
{
|
||||
uiBut *but = uiDefIconTextBut(block,
|
||||
UI_BTYPE_BUT,
|
||||
@@ -4096,19 +4095,17 @@ static void save_file_forwardcompat_saveas_button(uiBlock *block, wmGenericCallb
|
||||
0,
|
||||
0,
|
||||
"");
|
||||
UI_but_func_set(but, save_file_forwardcompat_saveas, block, post_action);
|
||||
UI_but_func_set(but, save_file_overwrite_saveas, block, post_action);
|
||||
UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
|
||||
UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT);
|
||||
}
|
||||
|
||||
static uiBlock *block_create_save_file_forwardcompat_dialog(bContext *C,
|
||||
ARegion *region,
|
||||
void *arg1)
|
||||
static uiBlock *block_create_save_file_overwrite_dialog(bContext *C, ARegion *region, void *arg1)
|
||||
{
|
||||
wmGenericCallback *post_action = static_cast<wmGenericCallback *>(arg1);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
||||
uiBlock *block = UI_block_begin(C, region, save_file_forwardcompat_dialog_name, UI_EMBOSS);
|
||||
uiBlock *block = UI_block_begin(C, region, save_file_overwrite_dialog_name, UI_EMBOSS);
|
||||
UI_block_flag_enable(
|
||||
block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_LOOP | UI_BLOCK_NO_WIN_CLIP | UI_BLOCK_NUMSELECT);
|
||||
UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
|
||||
@@ -4134,7 +4131,7 @@ static uiBlock *block_create_save_file_forwardcompat_dialog(bContext *C,
|
||||
uiItemL(layout, filename, ICON_NONE);
|
||||
|
||||
/* Detailed message info. */
|
||||
file_forwardcompat_detailed_info_show(layout, bmain);
|
||||
file_overwrite_detailed_info_show(layout, bmain);
|
||||
|
||||
uiItemS_ex(layout, 4.0f);
|
||||
|
||||
@@ -4144,7 +4141,7 @@ static uiBlock *block_create_save_file_forwardcompat_dialog(bContext *C,
|
||||
uiLayoutSetScaleY(split, 1.2f);
|
||||
|
||||
uiLayoutColumn(split, false);
|
||||
save_file_forwardcompat_overwrite_button(block, post_action);
|
||||
save_file_overwrite_confirm_button(block, post_action);
|
||||
|
||||
uiLayout *split_right = uiLayoutSplit(split, 0.1f, true);
|
||||
|
||||
@@ -4152,25 +4149,25 @@ static uiBlock *block_create_save_file_forwardcompat_dialog(bContext *C,
|
||||
/* Empty space. */
|
||||
|
||||
uiLayoutColumn(split_right, false);
|
||||
save_file_forwardcompat_cancel_button(block, post_action);
|
||||
save_file_overwrite_cancel_button(block, post_action);
|
||||
|
||||
uiLayoutColumn(split_right, false);
|
||||
save_file_forwardcompat_saveas_button(block, post_action);
|
||||
save_file_overwrite_saveas_button(block, post_action);
|
||||
|
||||
UI_block_bounds_set_centered(block, 14 * UI_SCALE_FAC);
|
||||
return block;
|
||||
}
|
||||
|
||||
void wm_save_file_forwardcompat_dialog(bContext *C, wmOperator *op)
|
||||
void wm_save_file_overwrite_dialog(bContext *C, wmOperator *op)
|
||||
{
|
||||
if (!UI_popup_block_name_exists(CTX_wm_screen(C), save_file_forwardcompat_dialog_name)) {
|
||||
if (!UI_popup_block_name_exists(CTX_wm_screen(C), save_file_overwrite_dialog_name)) {
|
||||
wmGenericCallback *callback = MEM_cnew<wmGenericCallback>(__func__);
|
||||
callback->exec = nullptr;
|
||||
callback->user_data = IDP_CopyProperty(op->properties);
|
||||
callback->free_user_data = wm_free_operator_properties_callback;
|
||||
|
||||
UI_popup_block_invoke(
|
||||
C, block_create_save_file_forwardcompat_dialog, callback, free_post_file_close_action);
|
||||
C, block_create_save_file_overwrite_dialog, callback, free_post_file_close_action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4285,7 +4282,7 @@ static void wm_block_file_close_discard_button(uiBlock *block, wmGenericCallback
|
||||
|
||||
static void wm_block_file_close_save_button(uiBlock *block,
|
||||
wmGenericCallback *post_action,
|
||||
const bool has_forwardcompat_issues)
|
||||
const bool needs_overwrite_confirm)
|
||||
{
|
||||
uiBut *but = uiDefIconTextBut(
|
||||
block,
|
||||
@@ -4293,7 +4290,7 @@ static void wm_block_file_close_save_button(uiBlock *block,
|
||||
0,
|
||||
ICON_NONE,
|
||||
/* Forward compatibility issues force using 'save as' operator instead of 'save' one. */
|
||||
has_forwardcompat_issues ? IFACE_("Save As...") : IFACE_("Save"),
|
||||
needs_overwrite_confirm ? IFACE_("Save As...") : IFACE_("Save"),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -4329,7 +4326,7 @@ static uiBlock *block_create__close_file_dialog(bContext *C, ARegion *region, vo
|
||||
|
||||
uiLayout *layout = uiItemsAlertBox(block, 34, ALERT_ICON_QUESTION);
|
||||
|
||||
const bool has_forwardcompat_issues = bmain->has_forward_compatibility_issues;
|
||||
const bool needs_overwrite_confirm = bmain->has_forward_compatibility_issues;
|
||||
|
||||
/* Title. */
|
||||
uiItemL_ex(layout, RPT_("Save changes before closing?"), ICON_NONE, true, false);
|
||||
@@ -4346,8 +4343,8 @@ static uiBlock *block_create__close_file_dialog(bContext *C, ARegion *region, vo
|
||||
uiItemL(layout, filename, ICON_NONE);
|
||||
|
||||
/* Potential forward compatibility issues message. */
|
||||
if (has_forwardcompat_issues) {
|
||||
file_forwardcompat_detailed_info_show(layout, bmain);
|
||||
if (needs_overwrite_confirm) {
|
||||
file_overwrite_detailed_info_show(layout, bmain);
|
||||
}
|
||||
|
||||
/* Image Saving Warnings. */
|
||||
@@ -4452,7 +4449,7 @@ static uiBlock *block_create__close_file_dialog(bContext *C, ARegion *region, vo
|
||||
uiLayoutSetScaleY(split, 1.2f);
|
||||
|
||||
uiLayoutColumn(split, false);
|
||||
wm_block_file_close_save_button(block, post_action, has_forwardcompat_issues);
|
||||
wm_block_file_close_save_button(block, post_action, needs_overwrite_confirm);
|
||||
|
||||
uiLayoutColumn(split, false);
|
||||
wm_block_file_close_discard_button(block, post_action);
|
||||
@@ -4478,7 +4475,7 @@ static uiBlock *block_create__close_file_dialog(bContext *C, ARegion *region, vo
|
||||
wm_block_file_close_cancel_button(block, post_action);
|
||||
|
||||
uiLayoutColumn(split_right, false);
|
||||
wm_block_file_close_save_button(block, post_action, has_forwardcompat_issues);
|
||||
wm_block_file_close_save_button(block, post_action, needs_overwrite_confirm);
|
||||
}
|
||||
|
||||
UI_block_bounds_set_centered(block, 14 * UI_SCALE_FAC);
|
||||
|
||||
@@ -97,7 +97,7 @@ bool wm_file_or_session_data_has_unsaved_changes(const Main *bmain, const wmWind
|
||||
*
|
||||
* Important to ask confirmation, as this is a very common scenario of data loss.
|
||||
*/
|
||||
void wm_save_file_forwardcompat_dialog(bContext *C, wmOperator *op);
|
||||
void wm_save_file_overwrite_dialog(bContext *C, wmOperator *op);
|
||||
|
||||
void WM_OT_save_homefile(wmOperatorType *ot);
|
||||
void WM_OT_save_userpref(wmOperatorType *ot);
|
||||
|
||||
Reference in New Issue
Block a user