summaryrefslogtreecommitdiffstats
path: root/scene/gui
diff options
context:
space:
mode:
authorSpartan322 <Megacake1234@gmail.com>2024-11-15 14:24:07 -0500
committerSpartan322 <Megacake1234@gmail.com>2024-11-15 14:24:07 -0500
commit4a5836e5462554a738b502aa8bbde5e4a051eb56 (patch)
treed58eaa8daad3e30c8b84a50e70a21f93b05525c5 /scene/gui
parentac1a49725fc038ae11ef9060fecb2b0f9c6333b2 (diff)
parent6c05ec3d6732cac44cf85c91db7d3fd1075bcb23 (diff)
downloadredot-engine-4a5836e5462554a738b502aa8bbde5e4a051eb56.tar.gz
Merge commit godotengine/godot@6c05ec3d6732cac44cf85c91db7d3fd1075bcb23
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/file_dialog.cpp33
-rw-r--r--scene/gui/file_dialog.h1
-rw-r--r--scene/gui/line_edit.cpp14
-rw-r--r--scene/gui/text_edit.cpp6
4 files changed, 36 insertions, 18 deletions
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index c8378f2b1d..b885565cdc 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -70,9 +70,9 @@ void FileDialog::_native_popup() {
root = OS::get_singleton()->get_user_data_dir();
}
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE_EXTRA)) {
- DisplayServer::get_singleton()->file_dialog_with_options_show(get_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, _get_options(), callable_mp(this, &FileDialog::_native_dialog_cb_with_options));
+ DisplayServer::get_singleton()->file_dialog_with_options_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, _get_options(), callable_mp(this, &FileDialog::_native_dialog_cb_with_options));
} else {
- DisplayServer::get_singleton()->file_dialog_show(get_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, callable_mp(this, &FileDialog::_native_dialog_cb));
+ DisplayServer::get_singleton()->file_dialog_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, callable_mp(this, &FileDialog::_native_dialog_cb));
}
}
@@ -853,37 +853,54 @@ void FileDialog::_filename_filter_selected() {
void FileDialog::update_filters() {
filter->clear();
+ processed_filters.clear();
if (filters.size() > 1) {
String all_filters;
+ String all_filters_full;
const int max_filters = 5;
for (int i = 0; i < MIN(max_filters, filters.size()); i++) {
- String flt = filters[i].get_slice(";", 0).strip_edges();
+ String flt = filters[i].get_slicec(';', 0).strip_edges();
if (i > 0) {
all_filters += ", ";
}
all_filters += flt;
}
+ for (int i = 0; i < filters.size(); i++) {
+ String flt = filters[i].get_slicec(';', 0).strip_edges();
+ if (i > 0) {
+ all_filters_full += ",";
+ }
+ all_filters_full += flt;
+ }
if (max_filters < filters.size()) {
all_filters += ", ...";
}
- filter->add_item(atr(ETR("All Recognized")) + " (" + all_filters + ")");
+ String f = atr(ETR("All Recognized")) + " (" + all_filters + ")";
+ filter->add_item(f);
+ processed_filters.push_back(all_filters_full + ";" + f);
}
for (int i = 0; i < filters.size(); i++) {
- String flt = filters[i].get_slice(";", 0).strip_edges();
+ String flt = filters[i].get_slicec(';', 0).strip_edges();
String desc = filters[i].get_slice(";", 1).strip_edges();
if (desc.length()) {
- filter->add_item(String(tr(desc)) + " (" + flt + ")");
+ String f = atr(desc) + " (" + flt + ")";
+ filter->add_item(f);
+ processed_filters.push_back(flt + ";" + f);
} else {
- filter->add_item("(" + flt + ")");
+ String f = "(" + flt + ")";
+ filter->add_item(f);
+ processed_filters.push_back(flt + ";" + f);
}
}
- filter->add_item(atr(ETR("All Files")) + " (*)");
+ String f = atr(ETR("All Files")) + " (*)";
+ filter->add_item(f);
+ processed_filters.push_back("*.*;" + f);
}
void FileDialog::clear_filename_filter() {
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 84a3334503..5eeed5b220 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -103,6 +103,7 @@ private:
Button *show_filename_filter_button = nullptr;
Vector<String> filters;
+ Vector<String> processed_filters;
String file_name_filter;
bool show_filename_filter = false;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 6dcd944004..819d467da7 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1454,13 +1454,12 @@ void LineEdit::undo() {
return;
}
+ if (!has_undo()) {
+ return;
+ }
+
if (undo_stack_pos == nullptr) {
- if (undo_stack.size() <= 1) {
- return;
- }
undo_stack_pos = undo_stack.back();
- } else if (undo_stack_pos == undo_stack.front()) {
- return;
}
deselect();
@@ -1481,10 +1480,7 @@ void LineEdit::redo() {
return;
}
- if (undo_stack_pos == nullptr) {
- return;
- }
- if (undo_stack_pos == undo_stack.back()) {
+ if (!has_redo()) {
return;
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 526c2a9b36..d885b07d14 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4177,7 +4177,7 @@ void TextEdit::redo() {
}
_push_current_op();
- if (undo_stack_pos == nullptr) {
+ if (!has_redo()) {
return; // Nothing to do.
}
@@ -7312,6 +7312,10 @@ void TextEdit::_paste_internal(int p_caret) {
}
String clipboard = DisplayServer::get_singleton()->clipboard_get();
+ if (clipboard.is_empty()) {
+ // Nothing to paste.
+ return;
+ }
// Paste a full line. Ignore '\r' characters that may have been added to the clipboard by the OS.
if (get_caret_count() == 1 && !has_selection(0) && !cut_copy_line.is_empty() && cut_copy_line == clipboard.replace("\r", "")) {