Path: blob/master/editor/version_control/version_control_editor_plugin.h
21025 views
/**************************************************************************/1/* version_control_editor_plugin.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/plugins/editor_plugin.h"33#include "editor/version_control/editor_vcs_interface.h"34#include "scene/gui/check_button.h"35#include "scene/gui/file_dialog.h"36#include "scene/gui/menu_button.h"37#include "scene/gui/rich_text_label.h"38#include "scene/gui/text_edit.h"39#include "scene/gui/tree.h"4041class EditorDock;4243class VersionControlEditorPlugin : public EditorPlugin {44GDCLASS(VersionControlEditorPlugin, EditorPlugin)4546public:47enum ButtonType {48BUTTON_TYPE_OPEN = 0,49BUTTON_TYPE_DISCARD = 1,50};5152enum DiffViewType {53DIFF_VIEW_TYPE_SPLIT = 0,54DIFF_VIEW_TYPE_UNIFIED = 1,55};5657enum ExtraOption {58EXTRA_OPTION_FORCE_PUSH,59EXTRA_OPTION_CREATE_BRANCH,60EXTRA_OPTION_CREATE_REMOTE,61};6263private:64static VersionControlEditorPlugin *singleton;6566List<StringName> available_plugins;6768PopupMenu *version_control_actions = nullptr;69ConfirmationDialog *metadata_dialog = nullptr;70OptionButton *metadata_selection = nullptr;71AcceptDialog *set_up_dialog = nullptr;72CheckButton *toggle_vcs_choice = nullptr;73OptionButton *set_up_choice = nullptr;74VBoxContainer *set_up_vbc = nullptr;75VBoxContainer *set_up_settings_vbc = nullptr;76LineEdit *set_up_username = nullptr;77LineEdit *set_up_password = nullptr;78LineEdit *set_up_ssh_public_key_path = nullptr;79LineEdit *set_up_ssh_private_key_path = nullptr;80LineEdit *set_up_ssh_passphrase = nullptr;81FileDialog *set_up_ssh_public_key_file_dialog = nullptr;82FileDialog *set_up_ssh_private_key_file_dialog = nullptr;83Label *set_up_warning_text = nullptr;84Button *select_public_path_button = nullptr;85Button *select_private_path_button = nullptr;8687AcceptDialog *discard_all_confirm = nullptr;8889OptionButton *commit_list_size_button = nullptr;9091AcceptDialog *branch_create_confirm = nullptr;92LineEdit *branch_create_name_input = nullptr;93Button *branch_create_ok = nullptr;9495AcceptDialog *remote_create_confirm = nullptr;96LineEdit *remote_create_name_input = nullptr;97LineEdit *remote_create_url_input = nullptr;98Button *remote_create_ok = nullptr;99100HashMap<EditorVCSInterface::ChangeType, String> change_type_to_strings;101HashMap<EditorVCSInterface::ChangeType, Color> change_type_to_color;102HashMap<EditorVCSInterface::ChangeType, Ref<Texture>> change_type_to_icon;103104EditorDock *version_commit_dock = nullptr;105Tree *staged_files = nullptr;106Tree *unstaged_files = nullptr;107Tree *commit_list = nullptr;108109OptionButton *branch_select = nullptr;110Button *branch_remove_button = nullptr;111AcceptDialog *branch_remove_confirm = nullptr;112113Button *fetch_button = nullptr;114Button *pull_button = nullptr;115Button *push_button = nullptr;116OptionButton *remote_select = nullptr;117Button *remote_remove_button = nullptr;118AcceptDialog *remote_remove_confirm = nullptr;119MenuButton *extra_options = nullptr;120PopupMenu *extra_options_remove_branch_list = nullptr;121PopupMenu *extra_options_remove_remote_list = nullptr;122123String branch_to_remove;124String remote_to_remove;125126Button *stage_all_button = nullptr;127Button *unstage_all_button = nullptr;128Button *discard_all_button = nullptr;129Button *refresh_button = nullptr;130TextEdit *commit_message = nullptr;131Button *commit_button = nullptr;132133EditorDock *version_control_dock = nullptr;134Label *diff_title = nullptr;135RichTextLabel *diff = nullptr;136OptionButton *diff_view_type_select = nullptr;137bool show_commit_diff_header = false;138List<EditorVCSInterface::DiffFile> diff_content;139140void _notification(int p_what);141void _update_theme();142void _initialize_vcs();143void _set_vcs_ui_state(bool p_enabled);144void _set_credentials();145void _ssh_public_key_selected(const String &p_path);146void _ssh_private_key_selected(const String &p_path);147void _populate_available_vcs_names();148void _update_remotes_list();149void _update_set_up_warning(const String &p_new_text);150void _update_opened_tabs();151void _update_extra_options();152153bool _load_plugin(const String &p_name);154155void _pull();156void _push();157void _force_push();158void _fetch();159void _commit();160void _confirm_discard_all();161void _discard_all();162void _refresh_stage_area();163void _refresh_branch_list();164void _set_commit_list_size(int p_index);165void _refresh_commit_list();166void _refresh_remote_list();167void _display_diff(int p_idx);168void _move_all(Object *p_tree);169void _load_diff(Object *p_tree);170void _clear_diff();171int _get_item_count(Tree *p_tree);172void _item_activated(Object *p_tree);173void _create_branch();174void _create_remote();175void _update_branch_create_button(const String &p_new_text);176void _update_remote_create_button(const String &p_new_text);177void _branch_item_selected(int p_index);178void _remote_selected(int p_index);179void _remove_branch();180void _remove_remote();181void _popup_branch_remove_confirm(int p_index);182void _popup_remote_remove_confirm(int p_index);183void _move_item(Tree *p_tree, TreeItem *p_itme);184void _display_diff_split_view(List<EditorVCSInterface::DiffLine> &p_diff_content);185void _display_diff_unified_view(List<EditorVCSInterface::DiffLine> &p_diff_content);186void _discard_file(const String &p_file_path, EditorVCSInterface::ChangeType p_change);187void _cell_button_pressed(Object *p_item, int p_column, int p_id, int p_mouse_button_index);188void _add_new_item(Tree *p_tree, const String &p_file_path, EditorVCSInterface::ChangeType p_change);189void _update_commit_button();190void _commit_message_gui_input(const Ref<InputEvent> &p_event);191void _extra_option_selected(int p_index);192bool _is_staging_area_empty();193String _get_date_string_from(int64_t p_unix_timestamp, int64_t p_offset_minutes) const;194void _create_vcs_metadata_files();195void _popup_file_dialog(const Variant &p_file_dialog_variant);196void _toggle_vcs_integration(bool p_toggled);197198friend class EditorVCSInterface;199200protected:201static void _bind_methods();202203public:204static VersionControlEditorPlugin *get_singleton();205206void popup_vcs_metadata_dialog();207void popup_vcs_set_up_dialog(const Control *p_gui_base);208209PopupMenu *get_version_control_actions_panel() const { return version_control_actions; }210211void register_editor();212void fetch_available_vcs_plugin_names();213void shut_down();214215VersionControlEditorPlugin();216~VersionControlEditorPlugin();217};218219220