Disable "Commit" button in VCS plugin if there's no commit message

(cherry picked from commit 221738fb81)
This commit is contained in:
Michael Alexsander 2020-12-20 13:43:50 -03:00 committed by Rémi Verschelde
parent 23280293d4
commit 01e1369ab7
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 9 additions and 9 deletions

View File

@ -47,6 +47,7 @@ void VersionControlEditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("_stage_selected"), &VersionControlEditorPlugin::_stage_selected);
ClassDB::bind_method(D_METHOD("_view_file_diff"), &VersionControlEditorPlugin::_view_file_diff);
ClassDB::bind_method(D_METHOD("_refresh_file_diff"), &VersionControlEditorPlugin::_refresh_file_diff);
ClassDB::bind_method(D_METHOD("_update_commit_button"), &VersionControlEditorPlugin::_update_commit_button);
ClassDB::bind_method(D_METHOD("popup_vcs_set_up_dialog"), &VersionControlEditorPlugin::popup_vcs_set_up_dialog);
// Used to track the status of files in the staging area
@ -137,14 +138,6 @@ void VersionControlEditorPlugin::_initialize_vcs() {
}
void VersionControlEditorPlugin::_send_commit_msg() {
String msg = commit_message->get_text();
if (msg == "") {
commit_status->set_text(TTR("No commit message was provided"));
return;
}
if (EditorVCSInterface::get_singleton()) {
if (staged_files_count == 0) {
@ -153,7 +146,7 @@ void VersionControlEditorPlugin::_send_commit_msg() {
return;
}
EditorVCSInterface::get_singleton()->commit(msg);
EditorVCSInterface::get_singleton()->commit(commit_message->get_text());
commit_message->set_text("");
version_control_dock_button->set_pressed(false);
@ -349,6 +342,10 @@ void VersionControlEditorPlugin::_update_commit_status() {
staged_files_count = 0;
}
void VersionControlEditorPlugin::_update_commit_button() {
commit_button->set_disabled(commit_message->get_text().strip_edges() == "");
}
void VersionControlEditorPlugin::register_editor() {
if (!EditorVCSInterface::get_singleton()) {
@ -532,10 +529,12 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
commit_message->set_v_grow_direction(Control::GrowDirection::GROW_DIRECTION_END);
commit_message->set_custom_minimum_size(Size2(200, 100));
commit_message->set_wrap_enabled(true);
commit_message->connect("text_changed", this, "_update_commit_button");
commit_box_vbc->add_child(commit_message);
commit_button = memnew(Button);
commit_button->set_text(TTR("Commit Changes"));
commit_button->set_disabled(true);
commit_button->connect("pressed", this, "_send_commit_msg");
commit_box_vbc->add_child(commit_button);

View File

@ -112,6 +112,7 @@ private:
void _clear_file_diff();
void _update_stage_status();
void _update_commit_status();
void _update_commit_button();
friend class EditorVCSInterface;