summaryrefslogtreecommitdiff
path: root/editor/find_in_files.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/find_in_files.cpp')
-rw-r--r--editor/find_in_files.cpp48
1 files changed, 25 insertions, 23 deletions
diff --git a/editor/find_in_files.cpp b/editor/find_in_files.cpp
index e1c9689f73..b7e7200b11 100644
--- a/editor/find_in_files.cpp
+++ b/editor/find_in_files.cpp
@@ -168,7 +168,7 @@ void FindInFiles::_iterate() {
String folder_name = folders_to_scan[folders_to_scan.size() - 1];
pop_back(folders_to_scan);
- _current_dir = _current_dir.plus_file(folder_name);
+ _current_dir = _current_dir.path_join(folder_name);
PackedStringArray sub_dirs;
_scan_dir("res://" + _current_dir, sub_dirs);
@@ -246,7 +246,7 @@ void FindInFiles::_scan_dir(String path, PackedStringArray &out_folders) {
} else {
String file_ext = file.get_extension();
if (_extension_filter.has(file_ext)) {
- _files_to_scan.push_back(path.plus_file(file));
+ _files_to_scan.push_back(path.path_join(file));
}
}
}
@@ -373,7 +373,7 @@ FindInFilesDialog::FindInFilesDialog() {
Label *filter_label = memnew(Label);
filter_label->set_text(TTR("Filters:"));
- filter_label->set_tooltip(TTR("Include the files with the following extensions. Add or remove them in ProjectSettings."));
+ filter_label->set_tooltip_text(TTR("Include the files with the following extensions. Add or remove them in ProjectSettings."));
gc->add_child(filter_label);
_filters_container = memnew(HBoxContainer);
@@ -422,8 +422,7 @@ void FindInFilesDialog::set_find_in_files_mode(FindInFilesMode p_mode) {
}
String FindInFilesDialog::get_search_text() const {
- String text = _search_text_line_edit->get_text();
- return text.strip_edges();
+ return _search_text_line_edit->get_text();
}
String FindInFilesDialog::get_replace_text() const {
@@ -464,9 +463,9 @@ void FindInFilesDialog::_notification(int p_what) {
_search_text_line_edit->select_all();
// Extensions might have changed in the meantime, we clean them and instance them again.
for (int i = 0; i < _filters_container->get_child_count(); i++) {
- _filters_container->get_child(i)->queue_delete();
+ _filters_container->get_child(i)->queue_free();
}
- Array exts = ProjectSettings::get_singleton()->get("editor/script/search_in_file_extensions");
+ Array exts = GLOBAL_GET("editor/script/search_in_file_extensions");
for (int i = 0; i < exts.size(); ++i) {
CheckBox *cb = memnew(CheckBox);
cb->set_text(exts[i]);
@@ -607,6 +606,7 @@ FindInFilesPanel::FindInFilesPanel() {
_results_display->set_hide_root(true);
_results_display->set_select_mode(Tree::SELECT_ROW);
_results_display->set_allow_rmb_select(true);
+ _results_display->set_allow_reselect(true);
_results_display->create_item(); // Root
vbc->add_child(_results_display);
@@ -718,6 +718,10 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin
file_item = E->value;
}
+ Color file_item_color = _results_display->get_theme_color(SNAME("font_color")) * Color(1, 1, 1, 0.67);
+ file_item->set_custom_color(0, file_item_color);
+ file_item->set_selectable(0, false);
+
int text_index = _with_replace ? 1 : 0;
TreeItem *item = _results_display->create_item(file_item);
@@ -764,13 +768,13 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) {
int font_size = _results_display->get_theme_font_size(SNAME("font_size"));
Rect2 match_rect = rect;
- match_rect.position.x += font->get_string_size(item_text.left(r.begin_trimmed), font_size).x;
- match_rect.size.x = font->get_string_size(_search_text_label->get_text(), font_size).x;
+ match_rect.position.x += font->get_string_size(item_text.left(r.begin_trimmed), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x - 1;
+ match_rect.size.x = font->get_string_size(_search_text_label->get_text(), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x + 1;
match_rect.position.y += 1 * EDSCALE;
match_rect.size.y -= 2 * EDSCALE;
- // Use the inverted accent color to help match rectangles stand out even on the currently selected line.
- _results_display->draw_rect(match_rect, get_theme_color(SNAME("accent_color"), SNAME("Editor")).inverted() * Color(1, 1, 1, 0.5));
+ _results_display->draw_rect(match_rect, get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.33), false, 2.0);
+ _results_display->draw_rect(match_rect, get_theme_color(SNAME("accent_color"), SNAME("Editor")) * Color(1, 1, 1, 0.17), true);
// Text is drawn by Tree already.
}
@@ -778,14 +782,12 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) {
void FindInFilesPanel::_on_item_edited() {
TreeItem *item = _results_display->get_selected();
- if (item->is_checked(0)) {
- item->set_custom_color(1, _results_display->get_theme_color(SNAME("font_color")));
- } else {
- // Grey out.
- Color color = _results_display->get_theme_color(SNAME("font_color"));
- color.a /= 2.0;
- item->set_custom_color(1, color);
+ // Change opacity to half if checkbox is checked, otherwise full.
+ Color use_color = _results_display->get_theme_color(SNAME("font_color"));
+ if (!item->is_checked(0)) {
+ use_color.a *= 0.5;
}
+ item->set_custom_color(1, use_color);
}
void FindInFilesPanel::_on_finished() {
@@ -794,11 +796,11 @@ void FindInFilesPanel::_on_finished() {
int file_count = _file_items.size();
if (result_count == 1 && file_count == 1) {
- results_text = vformat(TTR("%d match in %d file."), result_count, file_count);
+ results_text = vformat(TTR("%d match in %d file"), result_count, file_count);
} else if (result_count != 1 && file_count == 1) {
- results_text = vformat(TTR("%d matches in %d file."), result_count, file_count);
+ results_text = vformat(TTR("%d matches in %d file"), result_count, file_count);
} else {
- results_text = vformat(TTR("%d matches in %d files."), result_count, file_count);
+ results_text = vformat(TTR("%d matches in %d files"), result_count, file_count);
}
_status_label->set_text(results_text);
@@ -968,8 +970,8 @@ void FindInFilesPanel::update_replace_buttons() {
_replace_all_button->set_disabled(disabled);
}
-void FindInFilesPanel::set_progress_visible(bool visible) {
- _progress_bar->set_self_modulate(Color(1, 1, 1, visible ? 1 : 0));
+void FindInFilesPanel::set_progress_visible(bool p_visible) {
+ _progress_bar->set_self_modulate(Color(1, 1, 1, p_visible ? 1 : 0));
}
void FindInFilesPanel::_bind_methods() {