Path: blob/master/editor/version_control/version_control_editor_plugin.h
9896 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 VersionControlEditorPlugin : public EditorPlugin {42GDCLASS(VersionControlEditorPlugin, EditorPlugin)4344public:45enum ButtonType {46BUTTON_TYPE_OPEN = 0,47BUTTON_TYPE_DISCARD = 1,48};4950enum DiffViewType {51DIFF_VIEW_TYPE_SPLIT = 0,52DIFF_VIEW_TYPE_UNIFIED = 1,53};5455enum ExtraOption {56EXTRA_OPTION_FORCE_PUSH,57EXTRA_OPTION_CREATE_BRANCH,58EXTRA_OPTION_CREATE_REMOTE,59};6061private:62static VersionControlEditorPlugin *singleton;6364List<StringName> available_plugins;6566PopupMenu *version_control_actions = nullptr;67ConfirmationDialog *metadata_dialog = nullptr;68OptionButton *metadata_selection = nullptr;69AcceptDialog *set_up_dialog = nullptr;70CheckButton *toggle_vcs_choice = nullptr;71OptionButton *set_up_choice = nullptr;72VBoxContainer *set_up_vbc = nullptr;73VBoxContainer *set_up_settings_vbc = nullptr;74LineEdit *set_up_username = nullptr;75LineEdit *set_up_password = nullptr;76LineEdit *set_up_ssh_public_key_path = nullptr;77LineEdit *set_up_ssh_private_key_path = nullptr;78LineEdit *set_up_ssh_passphrase = nullptr;79FileDialog *set_up_ssh_public_key_file_dialog = nullptr;80FileDialog *set_up_ssh_private_key_file_dialog = nullptr;81Label *set_up_warning_text = nullptr;8283AcceptDialog *discard_all_confirm = nullptr;8485OptionButton *commit_list_size_button = nullptr;8687AcceptDialog *branch_create_confirm = nullptr;88LineEdit *branch_create_name_input = nullptr;89Button *branch_create_ok = nullptr;9091AcceptDialog *remote_create_confirm = nullptr;92LineEdit *remote_create_name_input = nullptr;93LineEdit *remote_create_url_input = nullptr;94Button *remote_create_ok = nullptr;9596HashMap<EditorVCSInterface::ChangeType, String> change_type_to_strings;97HashMap<EditorVCSInterface::ChangeType, Color> change_type_to_color;98HashMap<EditorVCSInterface::ChangeType, Ref<Texture>> change_type_to_icon;99100VBoxContainer *version_commit_dock = nullptr;101Tree *staged_files = nullptr;102Tree *unstaged_files = nullptr;103Tree *commit_list = nullptr;104105OptionButton *branch_select = nullptr;106Button *branch_remove_button = nullptr;107AcceptDialog *branch_remove_confirm = nullptr;108109Button *fetch_button = nullptr;110Button *pull_button = nullptr;111Button *push_button = nullptr;112OptionButton *remote_select = nullptr;113Button *remote_remove_button = nullptr;114AcceptDialog *remote_remove_confirm = nullptr;115MenuButton *extra_options = nullptr;116PopupMenu *extra_options_remove_branch_list = nullptr;117PopupMenu *extra_options_remove_remote_list = nullptr;118119String branch_to_remove;120String remote_to_remove;121122Button *stage_all_button = nullptr;123Button *unstage_all_button = nullptr;124Button *discard_all_button = nullptr;125Button *refresh_button = nullptr;126TextEdit *commit_message = nullptr;127Button *commit_button = nullptr;128129VBoxContainer *version_control_dock = nullptr;130Button *version_control_dock_button = nullptr;131Label *diff_title = nullptr;132RichTextLabel *diff = nullptr;133OptionButton *diff_view_type_select = nullptr;134bool show_commit_diff_header = false;135List<EditorVCSInterface::DiffFile> diff_content;136137void _notification(int p_what);138void _initialize_vcs();139void _set_vcs_ui_state(bool p_enabled);140void _set_credentials();141void _ssh_public_key_selected(const String &p_path);142void _ssh_private_key_selected(const String &p_path);143void _populate_available_vcs_names();144void _update_remotes_list();145void _update_set_up_warning(const String &p_new_text);146void _update_opened_tabs();147void _update_extra_options();148149bool _load_plugin(const String &p_name);150151void _pull();152void _push();153void _force_push();154void _fetch();155void _commit();156void _confirm_discard_all();157void _discard_all();158void _refresh_stage_area();159void _refresh_branch_list();160void _set_commit_list_size(int p_index);161void _refresh_commit_list();162void _refresh_remote_list();163void _display_diff(int p_idx);164void _move_all(Object *p_tree);165void _load_diff(Object *p_tree);166void _clear_diff();167int _get_item_count(Tree *p_tree);168void _item_activated(Object *p_tree);169void _create_branch();170void _create_remote();171void _update_branch_create_button(const String &p_new_text);172void _update_remote_create_button(const String &p_new_text);173void _branch_item_selected(int p_index);174void _remote_selected(int p_index);175void _remove_branch();176void _remove_remote();177void _popup_branch_remove_confirm(int p_index);178void _popup_remote_remove_confirm(int p_index);179void _move_item(Tree *p_tree, TreeItem *p_itme);180void _display_diff_split_view(List<EditorVCSInterface::DiffLine> &p_diff_content);181void _display_diff_unified_view(List<EditorVCSInterface::DiffLine> &p_diff_content);182void _discard_file(const String &p_file_path, EditorVCSInterface::ChangeType p_change);183void _cell_button_pressed(Object *p_item, int p_column, int p_id, int p_mouse_button_index);184void _add_new_item(Tree *p_tree, const String &p_file_path, EditorVCSInterface::ChangeType p_change);185void _update_commit_button();186void _commit_message_gui_input(const Ref<InputEvent> &p_event);187void _extra_option_selected(int p_index);188bool _is_staging_area_empty();189String _get_date_string_from(int64_t p_unix_timestamp, int64_t p_offset_minutes) const;190void _create_vcs_metadata_files();191void _popup_file_dialog(const Variant &p_file_dialog_variant);192void _toggle_vcs_integration(bool p_toggled);193194friend class EditorVCSInterface;195196protected:197static void _bind_methods();198199public:200static VersionControlEditorPlugin *get_singleton();201202void popup_vcs_metadata_dialog();203void popup_vcs_set_up_dialog(const Control *p_gui_base);204205PopupMenu *get_version_control_actions_panel() const { return version_control_actions; }206207void register_editor();208void fetch_available_vcs_plugin_names();209void shut_down();210211VersionControlEditorPlugin();212~VersionControlEditorPlugin();213};214215216