Show file icon in search all files dialog

This commit is contained in:
Matt Parker
2025-11-29 13:58:02 +10:00
parent 66228d6034
commit 64eab3ceb4
2 changed files with 15 additions and 2 deletions

View File

@@ -1,12 +1,14 @@
using Godot;
using SharpIDE.Application.Features.Analysis;
using SharpIDE.Application.Features.Search;
using SharpIDE.Godot.Features.SolutionExplorer;
namespace SharpIDE.Godot.Features.Search.SearchAllFiles;
public partial class SearchAllFilesResultComponent : MarginContainer
{
private TextureRect _textureRect = null!;
private TextureRect _overlayTextureRect = null!;
private Label _fileNameLabel = null!;
private Label _filePathLabel = null!;
private Button _button = null!;
@@ -21,6 +23,7 @@ public partial class SearchAllFilesResultComponent : MarginContainer
{
_button = GetNode<Button>("Button");
_textureRect = GetNode<TextureRect>("%IconTextureRect");
_overlayTextureRect = GetNode<TextureRect>("%IconOverlayTextureRect");
_fileNameLabel = GetNode<Label>("%FileNameLabel");
_filePathLabel = GetNode<Label>("%FilePathLabel");
SetValue(Result);
@@ -36,7 +39,9 @@ public partial class SearchAllFilesResultComponent : MarginContainer
private void SetValue(FindFilesSearchResult result)
{
if (result is null) return;
_textureRect.Texture = _csharpFileIcon;
var (icon, overlayIcon) = FileIconHelper.GetIconForFileExtension(result.File.Extension);
_textureRect.Texture = icon;
_overlayTextureRect.Texture = overlayIcon;
_fileNameLabel.Text = result.File.Name;
_filePathLabel.Text = result.File.Path;
}

View File

@@ -42,7 +42,15 @@ theme_override_constants/margin_right = 5
[node name="HBoxContainer" type="HBoxContainer" parent="Button/MarginContainer"]
layout_mode = 2
[node name="IconTextureRect" type="TextureRect" parent="Button/MarginContainer/HBoxContainer"]
[node name="CenterContainer" type="CenterContainer" parent="Button/MarginContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
[node name="IconTextureRect" type="TextureRect" parent="Button/MarginContainer/HBoxContainer/CenterContainer"]
unique_name_in_owner = true
layout_mode = 2
[node name="IconOverlayTextureRect" type="TextureRect" parent="Button/MarginContainer/HBoxContainer/CenterContainer"]
unique_name_in_owner = true
layout_mode = 2