Changeset View
Standalone View
source/blender/windowmanager/intern/wm_files.c
| Context not available. | |||||
| userdef_curr->runtime.is_dirty = is_dirty; | userdef_curr->runtime.is_dirty = is_dirty; | ||||
| } | } | ||||
| /* Load Factory Preferences/Settings warning dialog */ | |||||
| static void wm_block_load_factory_cancel(bContext *C, void *arg_block, void *UNUSED(arg)) | |||||
| { | |||||
| wmWindow *win = CTX_wm_window(C); | |||||
| UI_popup_block_close(C, win, arg_block); | |||||
| } | |||||
| static void wm_block_load_factory_load(bContext *C, void *arg_block, void *arg) | |||||
| { | |||||
| wmWindow *win = CTX_wm_window(C); | |||||
| UI_popup_block_close(C, win, arg_block); | |||||
| WM_operator_name_call(C, | |||||
| arg ? "WM_OT_read_factory_userpref" : "WM_OT_read_factory_settings", | |||||
| WM_OP_EXEC_DEFAULT, NULL); | |||||
| } | |||||
| static void wm_block_load_factory_cancel_button(uiBlock *block) | |||||
| { | |||||
| uiBut *but = uiDefIconTextBut( | |||||
| block, UI_BTYPE_BUT, 0, ICON_NONE, IFACE_("Cancel"), 0, 0, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | |||||
| UI_but_func_set(but, wm_block_load_factory_cancel, block, NULL); | |||||
| UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); | |||||
| } | |||||
| static void wm_block_load_factory_load_button(uiBlock *block, const bool *prefs) | |||||
| { | |||||
| uiBut *but = uiDefIconTextBut( | |||||
| block, UI_BTYPE_BUT, 0, ICON_NONE, | |||||
| prefs ? IFACE_("Load Factory Preferences") : IFACE_("Load Factory Settings"), | |||||
| 0, 0, 0, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); | |||||
| UI_but_func_set(but, wm_block_load_factory_load, block, (void *)prefs); | |||||
| UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); | |||||
| UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT); | |||||
| } | |||||
| static uiBlock *block_create_load_factory_dialog(struct bContext *C, struct ARegion *ar, void *arg) | |||||
| { | |||||
| /* Load Factory Preferences (not Settings) */ | |||||
| const bool *prefs = arg; | |||||
| uiStyle *style = UI_style_get(); | |||||
| uiBlock *block = UI_block_begin(C, ar, "load_factory_dialog", 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); | |||||
| UI_block_emboss_set(block, UI_EMBOSS); | |||||
| uiLayout *layout = UI_block_layout(block, | |||||
| UI_LAYOUT_VERTICAL, | |||||
| UI_LAYOUT_PANEL, | |||||
| 10, | |||||
| 2, | |||||
| U.widget_unit * 24, | |||||
| U.widget_unit * 6, | |||||
| 0, | |||||
| style); | |||||
| /* Text and some vertical space */ | |||||
| uiItemL(layout, | |||||
| prefs ? | |||||
| TIP_("Load Factory Preferences?") : | |||||
| TIP_("Load Factory Startup File and Preferences?"), | |||||
| ICON_ERROR); | |||||
| uiItemS(layout); | |||||
| uiLayout *col = uiLayoutColumn(layout, true); | |||||
| uiItemL(col, | |||||
| TIP_("Loading factory settings won't automatically save your preferences on quit."), | |||||
| ICON_BLANK1); | |||||
| uiItemL(col, | |||||
| prefs ? | |||||
| TIP_("To make changes to preferences permanent, use \"Save Preferences\".") : | |||||
| TIP_("To make changes permanent, use \"Save Startup File\" and \"Save Preferences\"."), | |||||
| ICON_BLANK1); | |||||
| /* Load Factory Settings */ | |||||
| if (!prefs) { | |||||
| /* The current file will not be saved before loading the factory startup file. */ | |||||
| if (U.uiflag & USER_SAVE_PROMPT && wm_file_or_image_is_modified(C)) { | |||||
| uiItemS(layout); | |||||
| uiLayout *sub = uiLayoutRow(layout, true); | |||||
| uiLayoutSetRedAlert(sub, true); | |||||
| uiItemL(sub, TIP_("WARNING: The current file will not be saved."), ICON_BLANK1); | |||||
| } | |||||
| } | |||||
| uiItemS_ex(layout, 3.0f); | |||||
| /* Buttons */ | |||||
| uiLayout *split = uiLayoutSplit(layout, 0.0f, true); | |||||
| uiLayoutSetScaleY(split, 1.2f); | |||||
| /* empty space */ | |||||
| col = uiLayoutColumn(split, false); | |||||
| uiItemS(col); | |||||
| #ifdef _WIN32 | |||||
| const bool windows_layout = true; | |||||
| #else | |||||
| const bool windows_layout = false; | |||||
| #endif | |||||
| if (windows_layout) { | |||||
| /* Windows standard layout. */ | |||||
| col = uiLayoutColumn(split, false); | |||||
| wm_block_load_factory_load_button(block, prefs); | |||||
| col = uiLayoutColumn(split, false); | |||||
| wm_block_load_factory_cancel_button(block); | |||||
| } | |||||
| else { | |||||
| /* macOS and Linux standard layout. */ | |||||
| col = uiLayoutColumn(split, false); | |||||
| wm_block_load_factory_cancel_button(block); | |||||
| col = uiLayoutColumn(split, false); | |||||
| wm_block_load_factory_load_button(block, prefs); | |||||
| } | |||||
| UI_block_bounds_set_centered(block, 14 * U.dpi_fac); | |||||
| return block; | |||||
| } | |||||
| static int wm_load_factory_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | |||||
| { | |||||
Severin: Where is this function coming from? I can't find it in master. | |||||
| const bool prefs = STREQ(op->type->idname, "WM_OT_read_factory_userpref"); | |||||
| UI_popup_block_invoke(C, block_create_load_factory_dialog, (void *)prefs, NULL); | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| static int wm_userpref_read_exec(bContext *C, wmOperator *op) | static int wm_userpref_read_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| const bool use_data = false; | const bool use_data = false; | ||||
| Context not available. | |||||
| { | { | ||||
| ot->name = "Load Factory Preferences"; | ot->name = "Load Factory Preferences"; | ||||
| ot->idname = "WM_OT_read_factory_userpref"; | ot->idname = "WM_OT_read_factory_userpref"; | ||||
| ot->description = | ot->description = "Load factory default preferences"; | ||||
| "Load factory default preferences. " | |||||
| "To make changes to preferences permanent, use \"Save Preferences\""; | |||||
| ot->invoke = WM_operator_confirm; | ot->invoke = wm_load_factory_invoke; | ||||
| ot->exec = wm_userpref_read_exec; | ot->exec = wm_userpref_read_exec; | ||||
| } | } | ||||
Done Inline ActionsWhat about using the warning icon here? I think that's more common, I've never seen "WARNING" in Blender before. HooglyBoogly: What about using the warning icon here? I think that's more common, I've never seen "WARNING"… | |||||
Done Inline ActionsI would suggest something more like: "Preferences will not be saved when quitting after loading factory settings." HooglyBoogly: I would suggest something more like: "Preferences will not be saved when quitting after loading… | |||||
Done Inline ActionsHere I would suggest "Use \"Save Startup File\" and \"Save Preferences\" to make permanent changes to preferences." HooglyBoogly: Here I would suggest "Use \"Save Startup File\" and \"Save Preferences\" to make permanent… | |||||
Done Inline ActionsThis static variable is easy to avoid I think. Just pass it as arg to UI_popup_block_invoke(), to the functions that need it, and via arg2 in UI_but_func_set() to the buttons that need it. You should use POINTER_FROM_INT()/POINTER_AS_INT() for that. Severin: This static variable is easy to avoid I think. Just pass it as `arg` to `UI_popup_block_invoke… | |||||
Done Inline ActionsThis should take into account rBbdad412fa76e6f so the dialog is wide enough with any text size setting. HooglyBoogly: This should take into account rBbdad412fa76e6f so the dialog is wide enough with any text size… | |||||
| Context not available. | |||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| ot->name = "Reload Start-Up File"; | ot->name = "Reload Start-Up File"; | ||||
| ot->idname = "WM_OT_read_homefile"; | ot->idname = "WM_OT_read_homefile"; | ||||
| ot->description = "Open the default file (doesn't save the current file)"; | ot->description = "Open the default file"; | ||||
| ot->invoke = wm_homefile_read_invoke; | ot->invoke = wm_homefile_read_invoke; | ||||
| ot->exec = wm_homefile_read_exec; | ot->exec = wm_homefile_read_exec; | ||||
Done Inline ActionsI know this follows existing code, but I'd prefer logic to not depend on operator names. Severin: I know this follows existing code, but I'd prefer logic to not depend on operator names. | |||||
| Context not available. | |||||
| { | { | ||||
| ot->name = "Load Factory Settings"; | ot->name = "Load Factory Settings"; | ||||
| ot->idname = "WM_OT_read_factory_settings"; | ot->idname = "WM_OT_read_factory_settings"; | ||||
| ot->description = | ot->description = "Load factory default startup file and preferences"; | ||||
| "Load factory default startup file and preferences. " | |||||
| "To make changes permanent, use \"Save Startup File\" and \"Save Preferences\""; | |||||
| ot->invoke = WM_operator_confirm; | ot->invoke = wm_load_factory_invoke; | ||||
| ot->exec = wm_homefile_read_exec; | ot->exec = wm_homefile_read_exec; | ||||
| read_homefile_props(ot); | read_homefile_props(ot); | ||||
| Context not available. | |||||
Where is this function coming from? I can't find it in master.