summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-07-04 17:12:13 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-07-04 17:12:13 +0200
commitf986a801fc9c4ac375f212e0d2c545919463844a (patch)
tree0dacaea6e62f4d5eea8b9a425859a2cc5f510e63
parentaf55caff36d9f7b1c5a272191d26557bfaf3e6b6 (diff)
parent681769e2c91124057d0421c44ff1e6582d926483 (diff)
downloadredot-engine-f986a801fc9c4ac375f212e0d2c545919463844a.tar.gz
Merge pull request #93898 from KoBeWi/rundo_edo
Fix undoredo handling in some dialogs
-rw-r--r--editor/editor_node.cpp8
-rw-r--r--editor/editor_node.h3
-rw-r--r--editor/editor_settings_dialog.cpp15
-rw-r--r--editor/plugins/animation_library_editor.cpp22
-rw-r--r--editor/plugins/animation_library_editor.h1
-rw-r--r--editor/plugins/polygon_2d_editor_plugin.cpp30
-rw-r--r--editor/project_settings_editor.cpp15
7 files changed, 66 insertions, 28 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 71603e6190..632b36c705 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -5261,6 +5261,14 @@ bool EditorNode::has_scenes_in_session() {
return !scenes.is_empty();
}
+void EditorNode::undo() {
+ trigger_menu_option(EDIT_UNDO, true);
+}
+
+void EditorNode::redo() {
+ trigger_menu_option(EDIT_REDO, true);
+}
+
bool EditorNode::ensure_main_scene(bool p_from_native) {
pick_main_scene->set_meta("from_native", p_from_native); // Whether from play button or native run.
String main_scene = GLOBAL_GET("application/run/main_scene");
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 28bd692ddf..7a26156ab8 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -916,6 +916,9 @@ public:
bool has_scenes_in_session();
+ void undo();
+ void redo();
+
int execute_and_show_output(const String &p_title, const String &p_path, const List<String> &p_arguments, bool p_close_on_ok = true, bool p_close_on_errors = false, String *r_output = nullptr);
EditorNode();
diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp
index 6fd6a7103f..a71d43ad51 100644
--- a/editor/editor_settings_dialog.cpp
+++ b/editor/editor_settings_dialog.cpp
@@ -168,28 +168,17 @@ void EditorSettingsDialog::_notification(int p_what) {
}
void EditorSettingsDialog::shortcut_input(const Ref<InputEvent> &p_event) {
- ERR_FAIL_COND(p_event.is_null());
- EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
-
const Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed()) {
bool handled = false;
if (ED_IS_SHORTCUT("ui_undo", p_event)) {
- String action = undo_redo->get_current_action_name();
- if (!action.is_empty()) {
- EditorNode::get_log()->add_message(vformat(TTR("Undo: %s"), action), EditorLog::MSG_TYPE_EDITOR);
- }
- undo_redo->undo();
+ EditorNode::get_singleton()->undo();
handled = true;
}
if (ED_IS_SHORTCUT("ui_redo", p_event)) {
- undo_redo->redo();
- String action = undo_redo->get_current_action_name();
- if (!action.is_empty()) {
- EditorNode::get_log()->add_message(vformat(TTR("Redo: %s"), action), EditorLog::MSG_TYPE_EDITOR);
- }
+ EditorNode::get_singleton()->redo();
handled = true;
}
diff --git a/editor/plugins/animation_library_editor.cpp b/editor/plugins/animation_library_editor.cpp
index afe7ea83d8..b07db993ba 100644
--- a/editor/plugins/animation_library_editor.cpp
+++ b/editor/plugins/animation_library_editor.cpp
@@ -781,6 +781,27 @@ void AnimationLibraryEditor::_update_editor(Object *p_mixer) {
emit_signal("update_editor", p_mixer);
}
+void AnimationLibraryEditor::shortcut_input(const Ref<InputEvent> &p_event) {
+ const Ref<InputEventKey> k = p_event;
+ if (k.is_valid() && k->is_pressed()) {
+ bool handled = false;
+
+ if (ED_IS_SHORTCUT("ui_undo", p_event)) {
+ EditorNode::get_singleton()->undo();
+ handled = true;
+ }
+
+ if (ED_IS_SHORTCUT("ui_redo", p_event)) {
+ EditorNode::get_singleton()->redo();
+ handled = true;
+ }
+
+ if (handled) {
+ set_input_as_handled();
+ }
+ }
+}
+
void AnimationLibraryEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_editor", "mixer"), &AnimationLibraryEditor::_update_editor);
ADD_SIGNAL(MethodInfo("update_editor"));
@@ -788,6 +809,7 @@ void AnimationLibraryEditor::_bind_methods() {
AnimationLibraryEditor::AnimationLibraryEditor() {
set_title(TTR("Edit Animation Libraries"));
+ set_process_shortcut_input(true);
file_dialog = memnew(EditorFileDialog);
add_child(file_dialog);
diff --git a/editor/plugins/animation_library_editor.h b/editor/plugins/animation_library_editor.h
index c8d9274f4f..beb34c6343 100644
--- a/editor/plugins/animation_library_editor.h
+++ b/editor/plugins/animation_library_editor.h
@@ -113,6 +113,7 @@ class AnimationLibraryEditor : public AcceptDialog {
protected:
void _notification(int p_what);
void _update_editor(Object *p_mixer);
+ virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
static void _bind_methods();
public:
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp
index b5db7bef70..e442c37edd 100644
--- a/editor/plugins/polygon_2d_editor_plugin.cpp
+++ b/editor/plugins/polygon_2d_editor_plugin.cpp
@@ -52,6 +52,31 @@
#include "scene/gui/texture_rect.h"
#include "scene/gui/view_panner.h"
+class UVEditDialog : public AcceptDialog {
+ GDCLASS(UVEditDialog, AcceptDialog);
+
+ void shortcut_input(const Ref<InputEvent> &p_event) override {
+ const Ref<InputEventKey> k = p_event;
+ if (k.is_valid() && k->is_pressed()) {
+ bool handled = false;
+
+ if (ED_IS_SHORTCUT("ui_undo", p_event)) {
+ EditorNode::get_singleton()->undo();
+ handled = true;
+ }
+
+ if (ED_IS_SHORTCUT("ui_redo", p_event)) {
+ EditorNode::get_singleton()->redo();
+ handled = true;
+ }
+
+ if (handled) {
+ set_input_as_handled();
+ }
+ }
+ }
+};
+
Node2D *Polygon2DEditor::_get_node() const {
return node;
}
@@ -1305,9 +1330,10 @@ Polygon2DEditor::Polygon2DEditor() {
button_uv->connect(SceneStringName(pressed), callable_mp(this, &Polygon2DEditor::_menu_option).bind(MODE_EDIT_UV));
uv_mode = UV_MODE_EDIT_POINT;
- uv_edit = memnew(AcceptDialog);
- add_child(uv_edit);
+ uv_edit = memnew(UVEditDialog);
uv_edit->set_title(TTR("Polygon 2D UV Editor"));
+ uv_edit->set_process_shortcut_input(true);
+ add_child(uv_edit);
uv_edit->connect(SceneStringName(confirmed), callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
uv_edit->connect("canceled", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 943e345e97..bdf4e41c5f 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -235,28 +235,17 @@ void ProjectSettingsEditor::_select_type(Variant::Type p_type) {
}
void ProjectSettingsEditor::shortcut_input(const Ref<InputEvent> &p_event) {
- ERR_FAIL_COND(p_event.is_null());
- EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
-
const Ref<InputEventKey> k = p_event;
if (k.is_valid() && k->is_pressed()) {
bool handled = false;
if (ED_IS_SHORTCUT("ui_undo", p_event)) {
- String action = undo_redo->get_current_action_name();
- if (!action.is_empty()) {
- EditorNode::get_log()->add_message(vformat(TTR("Undo: %s"), action), EditorLog::MSG_TYPE_EDITOR);
- }
- undo_redo->undo();
+ EditorNode::get_singleton()->undo();
handled = true;
}
if (ED_IS_SHORTCUT("ui_redo", p_event)) {
- undo_redo->redo();
- String action = undo_redo->get_current_action_name();
- if (!action.is_empty()) {
- EditorNode::get_log()->add_message(vformat(TTR("Redo: %s"), action), EditorLog::MSG_TYPE_EDITOR);
- }
+ EditorNode::get_singleton()->redo();
handled = true;
}