diff options
Diffstat (limited to 'editor/plugins/version_control_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/version_control_editor_plugin.cpp | 88 |
1 files changed, 42 insertions, 46 deletions
diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 9173838471..beed89ea10 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -75,8 +75,8 @@ void VersionControlEditorPlugin::_notification(int p_what) { void VersionControlEditorPlugin::_populate_available_vcs_names() { set_up_choice->clear(); - for (int i = 0; i < available_plugins.size(); i++) { - set_up_choice->add_item(available_plugins[i]); + for (const StringName &available_plugin : available_plugins) { + set_up_choice->add_item(available_plugin); } } @@ -193,10 +193,11 @@ void VersionControlEditorPlugin::_refresh_branch_list() { String current_branch = EditorVCSInterface::get_singleton()->get_current_branch_name(); - for (int i = 0; i < branch_list.size(); i++) { - branch_select->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("VcsBranches"), EditorStringName(EditorIcons)), branch_list[i], i); + int i = 0; + for (List<String>::ConstIterator itr = branch_list.begin(); itr != branch_list.end(); ++itr, ++i) { + branch_select->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("VcsBranches"), EditorStringName(EditorIcons)), *itr, i); - if (branch_list[i] == current_branch) { + if (*itr == current_branch) { branch_select->select(i); } } @@ -253,11 +254,12 @@ void VersionControlEditorPlugin::_refresh_remote_list() { remote_select->set_disabled(remotes.is_empty()); - for (int i = 0; i < remotes.size(); i++) { - remote_select->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)), remotes[i], i); - remote_select->set_item_metadata(i, remotes[i]); + int i = 0; + for (List<String>::ConstIterator itr = remotes.begin(); itr != remotes.end(); ++itr, ++i) { + remote_select->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)), *itr, i); + remote_select->set_item_metadata(i, *itr); - if (remotes[i] == current_remote) { + if (*itr == current_remote) { remote_select->select(i); } } @@ -589,9 +591,7 @@ void VersionControlEditorPlugin::_display_diff(int p_idx) { diff->pop(); } - for (int i = 0; i < diff_content.size(); i++) { - EditorVCSInterface::DiffFile diff_file = diff_content[i]; - + for (const EditorVCSInterface::DiffFile &diff_file : diff_content) { diff->push_font(EditorNode::get_singleton()->get_editor_theme()->get_font(SNAME("doc_bold"), EditorStringName(EditorFonts))); diff->push_color(EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("accent_color"), EditorStringName(Editor))); diff->add_text(TTR("File:") + " " + diff_file.new_file); @@ -599,9 +599,7 @@ void VersionControlEditorPlugin::_display_diff(int p_idx) { diff->pop(); diff->push_font(EditorNode::get_singleton()->get_editor_theme()->get_font(SNAME("status_source"), EditorStringName(EditorFonts))); - for (int j = 0; j < diff_file.diff_hunks.size(); j++) { - EditorVCSInterface::DiffHunk hunk = diff_file.diff_hunks[j]; - + for (EditorVCSInterface::DiffHunk hunk : diff_file.diff_hunks) { String old_start = String::num_int64(hunk.old_start); String new_start = String::num_int64(hunk.new_start); String old_lines = String::num_int64(hunk.old_lines); @@ -628,10 +626,9 @@ void VersionControlEditorPlugin::_display_diff(int p_idx) { } void VersionControlEditorPlugin::_display_diff_split_view(List<EditorVCSInterface::DiffLine> &p_diff_content) { - List<EditorVCSInterface::DiffLine> parsed_diff; + LocalVector<EditorVCSInterface::DiffLine> parsed_diff; - for (int i = 0; i < p_diff_content.size(); i++) { - EditorVCSInterface::DiffLine diff_line = p_diff_content[i]; + for (EditorVCSInterface::DiffLine diff_line : p_diff_content) { String line = diff_line.content.strip_edges(false, true); if (diff_line.new_line_no >= 0 && diff_line.old_line_no >= 0) { @@ -643,12 +640,12 @@ void VersionControlEditorPlugin::_display_diff_split_view(List<EditorVCSInterfac diff_line.old_text = line; parsed_diff.push_back(diff_line); } else if (diff_line.old_line_no == -1) { - int j = parsed_diff.size() - 1; + int32_t j = parsed_diff.size() - 1; while (j >= 0 && parsed_diff[j].new_line_no == -1) { j--; } - if (j == parsed_diff.size() - 1) { + if (j == (int32_t)parsed_diff.size() - 1) { // no lines are modified diff_line.new_text = line; diff_line.old_text = ""; @@ -677,7 +674,7 @@ void VersionControlEditorPlugin::_display_diff_split_view(List<EditorVCSInterfac diff->set_table_column_expand(2, true); diff->set_table_column_expand(5, true); - for (int i = 0; i < parsed_diff.size(); i++) { + for (uint32_t i = 0; i < parsed_diff.size(); i++) { EditorVCSInterface::DiffLine diff_line = parsed_diff[i]; bool has_change = diff_line.status != " "; @@ -757,8 +754,7 @@ void VersionControlEditorPlugin::_display_diff_unified_view(List<EditorVCSInterf [cell]status[/cell] [cell]code[/cell] */ - for (int i = 0; i < p_diff_content.size(); i++) { - EditorVCSInterface::DiffLine diff_line = p_diff_content[i]; + for (const EditorVCSInterface::DiffLine &diff_line : p_diff_content) { String line = diff_line.content.strip_edges(false, true); Color color; @@ -945,7 +941,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { metadata_dialog = memnew(ConfirmationDialog); metadata_dialog->set_title(TTR("Create Version Control Metadata")); metadata_dialog->set_min_size(Size2(200, 40)); - metadata_dialog->get_ok_button()->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_create_vcs_metadata_files)); + metadata_dialog->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_create_vcs_metadata_files)); EditorInterface::get_singleton()->get_base_control()->add_child(metadata_dialog); VBoxContainer *metadata_vb = memnew(VBoxContainer); @@ -979,7 +975,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { Button *set_up_apply_button = set_up_dialog->get_ok_button(); set_up_apply_button->set_text(TTR("Apply")); - set_up_apply_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_set_credentials)); + set_up_apply_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_set_credentials)); set_up_vbc = memnew(VBoxContainer); set_up_vbc->set_alignment(BoxContainer::ALIGNMENT_CENTER); @@ -1086,7 +1082,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { Button *select_public_path_button = memnew(Button); select_public_path_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon("Folder")); - select_public_path_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_popup_file_dialog).bind(set_up_ssh_public_key_file_dialog)); + select_public_path_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_popup_file_dialog).bind(set_up_ssh_public_key_file_dialog)); select_public_path_button->set_tooltip_text(TTR("Select SSH public key path")); set_up_ssh_public_key_input_hbc->add_child(select_public_path_button); @@ -1119,7 +1115,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { Button *select_private_path_button = memnew(Button); select_private_path_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon("Folder")); - select_private_path_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_popup_file_dialog).bind(set_up_ssh_private_key_file_dialog)); + select_private_path_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_popup_file_dialog).bind(set_up_ssh_private_key_file_dialog)); select_private_path_button->set_tooltip_text(TTR("Select SSH private key path")); set_up_ssh_private_key_input_hbc->add_child(select_private_path_button); @@ -1164,10 +1160,10 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { refresh_button->set_tooltip_text(TTR("Detect new changes")); refresh_button->set_theme_type_variation("FlatButton"); refresh_button->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Reload"), EditorStringName(EditorIcons))); - refresh_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area)); - refresh_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_commit_list)); - refresh_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_branch_list)); - refresh_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_remote_list)); + refresh_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area)); + refresh_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_commit_list)); + refresh_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_branch_list)); + refresh_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_remote_list)); unstage_title->add_child(refresh_button); discard_all_confirm = memnew(AcceptDialog); @@ -1179,12 +1175,12 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { discard_all_confirm->add_cancel_button(); version_commit_dock->add_child(discard_all_confirm); - discard_all_confirm->get_ok_button()->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_discard_all)); + discard_all_confirm->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_discard_all)); discard_all_button = memnew(Button); discard_all_button->set_tooltip_text(TTR("Discard all changes")); discard_all_button->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Close"), EditorStringName(EditorIcons))); - discard_all_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_confirm_discard_all)); + discard_all_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_confirm_discard_all)); discard_all_button->set_theme_type_variation("FlatButton"); unstage_title->add_child(discard_all_button); @@ -1236,8 +1232,8 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { stage_area->add_child(staged_files); // Editor crashes if bind is null - unstage_all_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_move_all).bind(staged_files)); - stage_all_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_move_all).bind(unstaged_files)); + unstage_all_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_move_all).bind(staged_files)); + stage_all_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_move_all).bind(unstaged_files)); version_commit_dock->add_child(memnew(HSeparator)); @@ -1256,7 +1252,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { commit_message->set_custom_minimum_size(Size2(200, 100)); commit_message->set_line_wrapping_mode(TextEdit::LINE_WRAPPING_BOUNDARY); commit_message->connect(SNAME("text_changed"), callable_mp(this, &VersionControlEditorPlugin::_update_commit_button)); - commit_message->connect(SNAME("gui_input"), callable_mp(this, &VersionControlEditorPlugin::_commit_message_gui_input)); + commit_message->connect(SceneStringName(gui_input), callable_mp(this, &VersionControlEditorPlugin::_commit_message_gui_input)); commit_area->add_child(commit_message); ED_SHORTCUT("version_control/commit", TTR("Commit"), KeyModifierMask::CMD_OR_CTRL | Key::ENTER); @@ -1264,7 +1260,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { commit_button = memnew(Button); commit_button->set_text(TTR("Commit Changes")); commit_button->set_disabled(true); - commit_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_commit)); + commit_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_commit)); commit_area->add_child(commit_button); version_commit_dock->add_child(memnew(HSeparator)); @@ -1312,7 +1308,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { branch_select->set_tooltip_text(TTR("Branches")); branch_select->set_h_size_flags(Control::SIZE_EXPAND_FILL); branch_select->connect(SNAME("item_selected"), callable_mp(this, &VersionControlEditorPlugin::_branch_item_selected)); - branch_select->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_branch_list)); + branch_select->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_branch_list)); menu_bar->add_child(branch_select); branch_create_confirm = memnew(AcceptDialog); @@ -1324,7 +1320,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { branch_create_ok = branch_create_confirm->get_ok_button(); branch_create_ok->set_text(TTR("Create")); branch_create_ok->set_disabled(true); - branch_create_ok->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_create_branch)); + branch_create_ok->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_create_branch)); branch_remove_confirm = memnew(AcceptDialog); branch_remove_confirm->set_title(TTR("Remove Branch")); @@ -1333,7 +1329,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { Button *branch_remove_ok = branch_remove_confirm->get_ok_button(); branch_remove_ok->set_text(TTR("Remove")); - branch_remove_ok->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_remove_branch)); + branch_remove_ok->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_remove_branch)); VBoxContainer *branch_create_vbc = memnew(VBoxContainer); branch_create_vbc->set_alignment(BoxContainer::ALIGNMENT_CENTER); @@ -1357,7 +1353,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { remote_select->set_tooltip_text(TTR("Remotes")); remote_select->set_h_size_flags(Control::SIZE_EXPAND_FILL); remote_select->connect(SNAME("item_selected"), callable_mp(this, &VersionControlEditorPlugin::_remote_selected)); - remote_select->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_remote_list)); + remote_select->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_remote_list)); menu_bar->add_child(remote_select); remote_create_confirm = memnew(AcceptDialog); @@ -1369,7 +1365,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { remote_create_ok = remote_create_confirm->get_ok_button(); remote_create_ok->set_text(TTR("Create")); remote_create_ok->set_disabled(true); - remote_create_ok->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_create_remote)); + remote_create_ok->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_create_remote)); remote_remove_confirm = memnew(AcceptDialog); remote_remove_confirm->set_title(TTR("Remove Remote")); @@ -1378,7 +1374,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { Button *remote_remove_ok = remote_remove_confirm->get_ok_button(); remote_remove_ok->set_text(TTR("Remove")); - remote_remove_ok->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_remove_remote)); + remote_remove_ok->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_remove_remote)); VBoxContainer *remote_create_vbc = memnew(VBoxContainer); remote_create_vbc->set_alignment(BoxContainer::ALIGNMENT_CENTER); @@ -1416,21 +1412,21 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { fetch_button->set_theme_type_variation("FlatButton"); fetch_button->set_tooltip_text(TTR("Fetch")); fetch_button->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Reload"), EditorStringName(EditorIcons))); - fetch_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_fetch)); + fetch_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_fetch)); menu_bar->add_child(fetch_button); pull_button = memnew(Button); pull_button->set_theme_type_variation("FlatButton"); pull_button->set_tooltip_text(TTR("Pull")); pull_button->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("MoveDown"), EditorStringName(EditorIcons))); - pull_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_pull)); + pull_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_pull)); menu_bar->add_child(pull_button); push_button = memnew(Button); push_button->set_theme_type_variation("FlatButton"); push_button->set_tooltip_text(TTR("Push")); push_button->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("MoveUp"), EditorStringName(EditorIcons))); - push_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_push)); + push_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_push)); menu_bar->add_child(push_button); extra_options = memnew(MenuButton); |