Merge pull request #70353 from twaritwaikar/remove-vsc-project-path

VCS: Remove `project_path` VCS property, let plugins decide
This commit is contained in:
Rémi Verschelde 2022-12-21 18:24:59 +01:00
commit ff2bd057a5
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 5 additions and 45 deletions

View File

@ -58,12 +58,10 @@ void VersionControlEditorPlugin::_create_vcs_metadata_files() {
void VersionControlEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
String installed_plugin = GLOBAL_DEF("editor/version_control/plugin_name", "");
String project_path = GLOBAL_DEF("editor/version_control/project_path", OS::get_singleton()->get_resource_dir());
project_path_input->set_text(project_path);
bool has_autoload_enable = GLOBAL_DEF("editor/version_control/autoload_on_startup", false);
if (installed_plugin != "" && has_autoload_enable) {
if (_load_plugin(installed_plugin, project_path)) {
if (_load_plugin(installed_plugin)) {
_set_credentials();
}
}
@ -108,18 +106,15 @@ void VersionControlEditorPlugin::_initialize_vcs() {
const int id = set_up_choice->get_selected_id();
String selected_plugin = set_up_choice->get_item_text(id);
if (_load_plugin(selected_plugin, project_path_input->get_text())) {
if (_load_plugin(selected_plugin)) {
ProjectSettings::get_singleton()->set("editor/version_control/autoload_on_startup", true);
ProjectSettings::get_singleton()->set("editor/version_control/plugin_name", selected_plugin);
ProjectSettings::get_singleton()->set("editor/version_control/project_path", project_path_input->get_text());
ProjectSettings::get_singleton()->save();
}
}
void VersionControlEditorPlugin::_set_vcs_ui_state(bool p_enabled) {
select_project_path_button->set_disabled(p_enabled);
set_up_dialog->get_ok_button()->set_disabled(!p_enabled);
project_path_input->set_editable(!p_enabled);
set_up_choice->set_disabled(p_enabled);
toggle_vcs_choice->set_pressed_no_signal(p_enabled);
}
@ -145,14 +140,14 @@ void VersionControlEditorPlugin::_set_credentials() {
EditorSettings::get_singleton()->set_setting("version_control/ssh_private_key_path", ssh_private_key);
}
bool VersionControlEditorPlugin::_load_plugin(String p_name, String p_project_path) {
bool VersionControlEditorPlugin::_load_plugin(String p_name) {
Object *extension_instance = ClassDB::instantiate(p_name);
ERR_FAIL_NULL_V_MSG(extension_instance, false, "Received a nullptr VCS extension instance during construction.");
EditorVCSInterface *vcs_plugin = Object::cast_to<EditorVCSInterface>(extension_instance);
ERR_FAIL_NULL_V_MSG(vcs_plugin, false, vformat("Could not cast VCS extension instance to %s.", EditorVCSInterface::get_class_static()));
String res_dir = project_path_input->get_text();
String res_dir = OS::get_singleton()->get_resource_dir();
ERR_FAIL_COND_V_MSG(!vcs_plugin->initialize(res_dir), false, "Could not initialize " + p_name);
@ -911,10 +906,6 @@ void VersionControlEditorPlugin::_toggle_vcs_integration(bool p_toggled) {
}
}
void VersionControlEditorPlugin::_project_path_selected(String p_project_path) {
project_path_input->set_text(p_project_path);
}
void VersionControlEditorPlugin::fetch_available_vcs_plugin_names() {
available_plugins.clear();
ClassDB::get_direct_inheriters_from_class(EditorVCSInterface::get_class_static(), &available_plugins);
@ -1008,34 +999,6 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
set_up_choice->set_h_size_flags(Control::SIZE_EXPAND_FILL);
set_up_hbc->add_child(set_up_choice);
HBoxContainer *project_path_hbc = memnew(HBoxContainer);
project_path_hbc->set_h_size_flags(Control::SIZE_FILL);
set_up_vbc->add_child(project_path_hbc);
Label *project_path_label = memnew(Label);
project_path_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
project_path_label->set_text(TTR("VCS Project Path"));
project_path_hbc->add_child(project_path_label);
project_path_input = memnew(LineEdit);
project_path_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);
project_path_input->set_text(OS::get_singleton()->get_resource_dir());
project_path_hbc->add_child(project_path_input);
FileDialog *select_project_path_file_dialog = memnew(FileDialog);
select_project_path_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM);
select_project_path_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_DIR);
select_project_path_file_dialog->set_show_hidden_files(true);
select_project_path_file_dialog->set_current_dir(OS::get_singleton()->get_resource_dir());
select_project_path_file_dialog->connect(SNAME("dir_selected"), callable_mp(this, &VersionControlEditorPlugin::_project_path_selected));
project_path_hbc->add_child(select_project_path_file_dialog);
select_project_path_button = memnew(Button);
select_project_path_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("Folder", "EditorIcons"));
select_project_path_button->connect(SNAME("pressed"), callable_mp(this, &VersionControlEditorPlugin::_popup_file_dialog).bind(select_project_path_file_dialog));
select_project_path_button->set_tooltip_text(TTR("Select VCS project path"));
project_path_hbc->add_child(select_project_path_button);
HBoxContainer *toggle_vcs_hbc = memnew(HBoxContainer);
toggle_vcs_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
set_up_vbc->add_child(toggle_vcs_hbc);

View File

@ -73,8 +73,6 @@ private:
AcceptDialog *set_up_dialog = nullptr;
CheckButton *toggle_vcs_choice = nullptr;
OptionButton *set_up_choice = nullptr;
LineEdit *project_path_input = nullptr;
Button *select_project_path_button = nullptr;
VBoxContainer *set_up_vbc = nullptr;
VBoxContainer *set_up_settings_vbc = nullptr;
LineEdit *set_up_username = nullptr;
@ -152,7 +150,7 @@ private:
void _update_opened_tabs();
void _update_extra_options();
bool _load_plugin(String p_name, String p_project_path);
bool _load_plugin(String p_name);
void _pull();
void _push();
@ -196,7 +194,6 @@ private:
void _create_vcs_metadata_files();
void _popup_file_dialog(Variant p_file_dialog_variant);
void _toggle_vcs_integration(bool p_toggled);
void _project_path_selected(String p_project_path);
friend class EditorVCSInterface;