diff options
Diffstat (limited to 'editor/quick_open.cpp')
-rw-r--r-- | editor/quick_open.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 8a5fad269f..1b4439f0a8 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -122,7 +122,7 @@ float EditorQuickOpen::_path_cmp(String search, String path) const { return path.to_lower().similarity(search.to_lower()); } -void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D> > > &list) { +void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D>>> &list) { if (!add_directories) { for (int i = 0; i < efsd->get_subdir_count(); i++) { @@ -140,9 +140,9 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str if (path != "res://") { path = path.substr(6, path.length()); if (search_text.is_subsequence_ofi(path)) { - Pair<String, Ref<Texture2D> > pair; + Pair<String, Ref<Texture2D>> pair; pair.first = path; - pair.second = get_icon("folder", "FileDialog"); + pair.second = search_options->get_theme_icon("folder", "FileDialog"); if (search_text != String() && list.size() > 0) { @@ -169,9 +169,9 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str file = file.substr(6, file.length()); if (ClassDB::is_parent_class(efsd->get_file_type(i), base_type) && (search_text.is_subsequence_ofi(file))) { - Pair<String, Ref<Texture2D> > pair; + Pair<String, Ref<Texture2D>> pair; pair.first = file; - pair.second = get_icon((has_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei); + pair.second = search_options->get_theme_icon((search_options->has_theme_icon(efsd->get_file_type(i), ei) ? efsd->get_file_type(i) : ot), ei); list.push_back(pair); } } @@ -184,10 +184,10 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str } } -Vector<Pair<String, Ref<Texture2D> > > EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture2D> > > &list) { +Vector<Pair<String, Ref<Texture2D>>> EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture2D>>> &list) { String search_text = search_box->get_text(); - Vector<Pair<String, Ref<Texture2D> > > sorted_list; + Vector<Pair<String, Ref<Texture2D>>> sorted_list; if (search_text == String() || list.size() == 0) return list; @@ -223,7 +223,7 @@ void EditorQuickOpen::_update_search() { search_options->clear(); TreeItem *root = search_options->create_item(); EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->get_filesystem(); - Vector<Pair<String, Ref<Texture2D> > > list; + Vector<Pair<String, Ref<Texture2D>>> list; _parse_fs(efsd, list); list = _sort_fs(list); @@ -241,7 +241,7 @@ void EditorQuickOpen::_update_search() { ti->set_as_cursor(0); } - get_ok()->set_disabled(root->get_children() == NULL); + get_ok()->set_disabled(root->get_children() == nullptr); } void EditorQuickOpen::_confirmed() { @@ -253,6 +253,11 @@ void EditorQuickOpen::_confirmed() { hide(); } +void EditorQuickOpen::_theme_changed() { + + search_box->set_right_icon(search_options->get_theme_icon("Search", "EditorIcons")); +} + void EditorQuickOpen::_notification(int p_what) { switch (p_what) { @@ -260,10 +265,6 @@ void EditorQuickOpen::_notification(int p_what) { connect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed)); search_box->set_clear_button_enabled(true); - [[fallthrough]]; - } - case NOTIFICATION_THEME_CHANGED: { - search_box->set_right_icon(get_icon("Search", "EditorIcons")); } break; case NOTIFICATION_EXIT_TREE: { disconnect("confirmed", callable_mp(this, &EditorQuickOpen::_confirmed)); @@ -284,6 +285,8 @@ void EditorQuickOpen::_bind_methods() { EditorQuickOpen::EditorQuickOpen() { VBoxContainer *vbc = memnew(VBoxContainer); + vbc->connect("theme_changed", callable_mp(this, &EditorQuickOpen::_theme_changed)); + add_child(vbc); search_box = memnew(LineEdit); vbc->add_margin_child(TTR("Search:"), search_box); @@ -298,7 +301,7 @@ EditorQuickOpen::EditorQuickOpen() { search_options->connect("item_activated", callable_mp(this, &EditorQuickOpen::_confirmed)); search_options->set_hide_root(true); search_options->set_hide_folding(true); - search_options->add_constant_override("draw_guides", 1); + search_options->add_theme_constant_override("draw_guides", 1); ei = "EditorIcons"; ot = "Object"; add_directories = false; |