diff options
Diffstat (limited to 'editor/settings_config_dialog.cpp')
-rw-r--r-- | editor/settings_config_dialog.cpp | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 6bd06aff64..c461bf0410 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -41,21 +41,19 @@ #include "scene/gui/margin_container.h" void EditorSettingsDialog::ok_pressed() { - - if (!EditorSettings::get_singleton()) + if (!EditorSettings::get_singleton()) { return; + } _settings_save(); timer->stop(); } void EditorSettingsDialog::_settings_changed() { - timer->start(); } void EditorSettingsDialog::_settings_property_edited(const String &p_name) { - String full_name = inspector->get_full_item_path(p_name); if (full_name == "interface/theme/accent_color" || full_name == "interface/theme/base_color" || full_name == "interface/theme/contrast") { @@ -66,23 +64,22 @@ void EditorSettingsDialog::_settings_property_edited(const String &p_name) { } void EditorSettingsDialog::_settings_save() { - EditorSettings::get_singleton()->notify_changes(); EditorSettings::get_singleton()->save(); } void EditorSettingsDialog::cancel_pressed() { - - if (!EditorSettings::get_singleton()) + if (!EditorSettings::get_singleton()) { return; + } EditorSettings::get_singleton()->notify_changes(); } void EditorSettingsDialog::popup_edit_settings() { - - if (!EditorSettings::get_singleton()) + if (!EditorSettings::get_singleton()) { return; + } EditorSettings::get_singleton()->list_text_editor_themes(); // make sure we have an up to date list of themes @@ -116,7 +113,6 @@ void EditorSettingsDialog::_undo_redo_callback(void *p_self, const String &p_nam } void EditorSettingsDialog::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { if (!is_visible()) { @@ -125,8 +121,8 @@ void EditorSettingsDialog::_notification(int p_what) { } } break; case NOTIFICATION_READY: { - undo_redo->set_method_notify_callback(EditorDebuggerNode::_method_changeds, NULL); - undo_redo->set_property_notify_callback(EditorDebuggerNode::_property_changeds, NULL); + undo_redo->set_method_notify_callback(EditorDebuggerNode::_method_changeds, nullptr); + undo_redo->set_property_notify_callback(EditorDebuggerNode::_property_changeds, nullptr); undo_redo->set_commit_notify_callback(_undo_redo_callback, this); } break; case NOTIFICATION_ENTER_TREE: { @@ -142,17 +138,16 @@ void EditorSettingsDialog::_notification(int p_what) { } void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { - const Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed()) { - bool handled = false; if (ED_IS_SHORTCUT("editor/undo", p_event)) { String action = undo_redo->get_current_action_name(); - if (action != "") + if (action != "") { EditorNode::get_log()->add_message("Undo: " + action, EditorLog::MSG_TYPE_EDITOR); + } undo_redo->undo(); handled = true; } @@ -160,8 +155,9 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { if (ED_IS_SHORTCUT("editor/redo", p_event)) { undo_redo->redo(); String action = undo_redo->get_current_action_name(); - if (action != "") + if (action != "") { EditorNode::get_log()->add_message("Redo: " + action, EditorLog::MSG_TYPE_EDITOR); + } handled = true; } @@ -177,7 +173,6 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) { } void EditorSettingsDialog::_update_icons() { - search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); search_box->set_clear_button_enabled(true); shortcut_search_box->set_right_icon(shortcuts->get_theme_icon("Search", "EditorIcons")); @@ -190,7 +185,6 @@ void EditorSettingsDialog::_update_icons() { } void EditorSettingsDialog::_update_shortcuts() { - Map<String, bool> collapsed; if (shortcuts->get_root() && shortcuts->get_root()->get_children()) { @@ -208,10 +202,10 @@ void EditorSettingsDialog::_update_shortcuts() { Map<String, TreeItem *> sections; for (List<String>::Element *E = slist.front(); E; E = E->next()) { - Ref<ShortCut> sc = EditorSettings::get_singleton()->get_shortcut(E->get()); - if (!sc->has_meta("original")) + if (!sc->has_meta("original")) { continue; + } Ref<InputEvent> original = sc->get_meta("original"); @@ -263,14 +257,13 @@ void EditorSettingsDialog::_update_shortcuts() { // remove sections with no shortcuts for (Map<String, TreeItem *>::Element *E = sections.front(); E; E = E->next()) { TreeItem *section = E->get(); - if (section->get_children() == NULL) { + if (section->get_children() == nullptr) { root->remove_child(section); } } } void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column, int p_idx) { - TreeItem *ti = Object::cast_to<TreeItem>(p_item); ERR_FAIL_COND(!ti); @@ -287,8 +280,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column shortcut_configured = item; } else if (p_idx == 1) { //erase - if (!sc.is_valid()) + if (!sc.is_valid()) { return; //pointless, there is nothing + } undo_redo->create_action(TTR("Erase Shortcut")); undo_redo->add_do_method(sc.ptr(), "set_shortcut", Ref<InputEvent>()); @@ -299,8 +293,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column undo_redo->add_undo_method(this, "_settings_changed"); undo_redo->commit_action(); } else if (p_idx == 2) { //revert to original - if (!sc.is_valid()) + if (!sc.is_valid()) { return; //pointless, there is nothing + } Ref<InputEvent> original = sc->get_meta("original"); @@ -316,11 +311,9 @@ void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column } void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && k->get_keycode() != 0) { - last_wait_for_key = k; const String str = keycode_get_string(k->get_keycode_with_modifiers()); @@ -330,9 +323,9 @@ void EditorSettingsDialog::_wait_for_key(const Ref<InputEvent> &p_event) { } void EditorSettingsDialog::_press_a_key_confirm() { - - if (last_wait_for_key.is_null()) + if (last_wait_for_key.is_null()) { return; + } Ref<InputEventKey> ie; ie.instance(); @@ -355,18 +348,17 @@ void EditorSettingsDialog::_press_a_key_confirm() { } void EditorSettingsDialog::_tabs_tab_changed(int p_tab) { - _focus_current_search_box(); } void EditorSettingsDialog::_focus_current_search_box() { - Control *tab = tabs->get_current_tab_control(); - LineEdit *current_search_box = NULL; - if (tab == tab_general) + LineEdit *current_search_box = nullptr; + if (tab == tab_general) { current_search_box = search_box; - else if (tab == tab_shortcuts) + } else if (tab == tab_shortcuts) { current_search_box = shortcut_search_box; + } if (current_search_box) { current_search_box->grab_focus(); @@ -388,13 +380,11 @@ void EditorSettingsDialog::_editor_restart_close() { } void EditorSettingsDialog::_bind_methods() { - ClassDB::bind_method(D_METHOD("_unhandled_input"), &EditorSettingsDialog::_unhandled_input); ClassDB::bind_method(D_METHOD("_update_shortcuts"), &EditorSettingsDialog::_update_shortcuts); } EditorSettingsDialog::EditorSettingsDialog() { - set_title(TTR("Editor Settings")); undo_redo = memnew(UndoRedo); |