Merge pull request #109480 from Rindbee/apply-different-strategies-when-check-theme-override-properties

Disallow clicking to toggle the checkbox of a theme override of type `Resource` to checked
This commit is contained in:
Thaddeus Crews
2025-08-13 18:42:11 -05:00

View File

@@ -39,6 +39,7 @@
#include "editor/editor_node.h" #include "editor/editor_node.h"
#include "editor/editor_string_names.h" #include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h" #include "editor/editor_undo_redo_manager.h"
#include "editor/gui/editor_toaster.h"
#include "editor/gui/editor_validation_panel.h" #include "editor/gui/editor_validation_panel.h"
#include "editor/inspector/add_metadata_dialog.h" #include "editor/inspector/add_metadata_dialog.h"
#include "editor/inspector/editor_properties.h" #include "editor/inspector/editor_properties.h"
@@ -1062,6 +1063,16 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
if (check_rect.has_point(mpos)) { if (check_rect.has_point(mpos)) {
accept_event(); accept_event();
if (!checked && Object::cast_to<Control>(object) && property_path.begins_with("theme_override_")) {
List<PropertyInfo> pinfo;
object->get_property_list(&pinfo);
for (const PropertyInfo &E : pinfo) {
if (E.type == Variant::OBJECT && E.name == property_path) {
EditorToaster::get_singleton()->popup_str(TTR("Toggling the checkbox is disabled for Resource properties. Modify the property using the resource picker instead."), EditorToaster::SEVERITY_WARNING);
return; // Disallow clicking to toggle the checkbox of type Resource to checked.
}
}
}
checked = !checked; checked = !checked;
queue_redraw(); queue_redraw();
emit_signal(SNAME("property_checked"), property, checked); emit_signal(SNAME("property_checked"), property, checked);
@@ -1080,6 +1091,17 @@ void EditorProperty::gui_input(const Ref<InputEvent> &p_event) {
void EditorProperty::_accessibility_action_click(const Variant &p_data) { void EditorProperty::_accessibility_action_click(const Variant &p_data) {
select(); select();
if (checkable) { if (checkable) {
if (!checked && Object::cast_to<Control>(object) && property_path.begins_with("theme_override_")) {
List<PropertyInfo> pinfo;
object->get_property_list(&pinfo);
for (const PropertyInfo &E : pinfo) {
if (E.type == Variant::OBJECT && E.name == property_path) {
EditorToaster::get_singleton()->popup_str(TTR("Toggling the checkbox is disabled for Resource properties. Modify the property using the resource picker instead."), EditorToaster::SEVERITY_WARNING);
return;
}
}
}
checked = !checked; checked = !checked;
queue_redraw(); queue_redraw();
emit_signal(SNAME("property_checked"), property, checked); emit_signal(SNAME("property_checked"), property, checked);
@@ -5155,17 +5177,9 @@ void EditorInspector::_property_checked(const String &p_path, bool p_checked) {
} else { } else {
Variant to_create; Variant to_create;
Control *control = Object::cast_to<Control>(object); Control *control = Object::cast_to<Control>(object);
bool skip = false;
if (control && p_path.begins_with("theme_override_")) { if (control && p_path.begins_with("theme_override_")) {
to_create = control->get_used_theme_item(p_path); to_create = control->get_used_theme_item(p_path);
Ref<Resource> resource = to_create; } else {
if (resource.is_valid()) {
to_create = resource->duplicate();
}
skip = true;
}
if (!skip) {
List<PropertyInfo> pinfo; List<PropertyInfo> pinfo;
object->get_property_list(&pinfo); object->get_property_list(&pinfo);
for (const PropertyInfo &E : pinfo) { for (const PropertyInfo &E : pinfo) {