display recent solutions
This commit is contained in:
21
src/SharpIDE.Godot/Features/SlnPicker/PreviousSlnEntry.cs
Normal file
21
src/SharpIDE.Godot/Features/SlnPicker/PreviousSlnEntry.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Godot;
|
||||
using SharpIDE.Godot.Features.IdeSettings;
|
||||
|
||||
namespace SharpIDE.Godot.Features.SlnPicker;
|
||||
|
||||
public partial class PreviousSlnEntry : HBoxContainer
|
||||
{
|
||||
private Label _slnPathLabel = null!;
|
||||
private Label _slnNameLabel = null!;
|
||||
|
||||
public PreviouslyOpenedSln PreviouslyOpenedSln { get; set; } = null!;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (PreviouslyOpenedSln is null) return;
|
||||
_slnNameLabel = GetNode<Label>("%SlnNameLabel");
|
||||
_slnPathLabel = GetNode<Label>("%SlnPathLabel");
|
||||
_slnNameLabel.Text = PreviouslyOpenedSln.Name;
|
||||
_slnPathLabel.Text = PreviouslyOpenedSln.FilePath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cnfj7yfseyikh
|
||||
46
src/SharpIDE.Godot/Features/SlnPicker/PreviousSlnEntry.tscn
Normal file
46
src/SharpIDE.Godot/Features/SlnPicker/PreviousSlnEntry.tscn
Normal file
@@ -0,0 +1,46 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://x5lhwvh5dium"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cnfj7yfseyikh" path="res://Features/SlnPicker/PreviousSlnEntry.cs" id="1_2ycpd"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1rtjt"]
|
||||
content_margin_left = 0.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_right = 0.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0.38039216, 1, 0.91764706, 1)
|
||||
corner_radius_top_left = 3
|
||||
corner_radius_top_right = 3
|
||||
corner_radius_bottom_right = 3
|
||||
corner_radius_bottom_left = 3
|
||||
corner_detail = 5
|
||||
|
||||
[node name="PreviousSlnEntry" type="HBoxContainer"]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
theme_override_constants/separation = 10
|
||||
script = ExtResource("1_2ycpd")
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
custom_minimum_size = Vector2(25, 25)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_1rtjt")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="SlnNameLabel" type="Label" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Solution Name"
|
||||
|
||||
[node name="SlnPathLabel" type="Label" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.5132329, 0.5132329, 0.5132329, 1)
|
||||
text = "C:\\Users\\Matthew\\Documents\\Git\\BlazorCodeBreaker\\BlazorCodeBreaker.slnx"
|
||||
|
||||
[node name="Spacer" type="Control" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
@@ -7,6 +7,9 @@ public partial class SlnPicker : Control
|
||||
{
|
||||
private FileDialog _fileDialog = null!;
|
||||
private Button _openSlnButton = null!;
|
||||
private VBoxContainer _previousSlnsVBoxContainer = null!;
|
||||
|
||||
private PackedScene _previousSlnEntryScene = ResourceLoader.Load<PackedScene>("res://Features/SlnPicker/PreviousSlnEntry.tscn");
|
||||
|
||||
private readonly TaskCompletionSource<string?> _tcs = new TaskCompletionSource<string?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
@@ -17,12 +20,25 @@ public partial class SlnPicker : Control
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_previousSlnsVBoxContainer = GetNode<VBoxContainer>("%PreviousSlnsVBoxContainer");
|
||||
_fileDialog = GetNode<FileDialog>("%FileDialog");
|
||||
_openSlnButton = GetNode<Button>("%OpenSlnButton");
|
||||
_openSlnButton.Pressed += () => _fileDialog.PopupCentered();
|
||||
var windowParent = GetParentOrNull<Window>();
|
||||
_fileDialog.FileSelected += path => _tcs.SetResult(path);
|
||||
windowParent?.CloseRequested += () => _tcs.SetResult(null);
|
||||
PopulatePreviousSolutions();
|
||||
}
|
||||
|
||||
private void PopulatePreviousSolutions()
|
||||
{
|
||||
_previousSlnsVBoxContainer.QueueFreeChildren();
|
||||
foreach (var previousSln in Singletons.AppState.PreviouslyOpenedSolutions.Reverse())
|
||||
{
|
||||
var node = _previousSlnEntryScene.Instantiate<PreviousSlnEntry>();
|
||||
node.PreviouslyOpenedSln = previousSln;
|
||||
_previousSlnsVBoxContainer.AddChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string?> GetSelectedSolutionPath()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cwvhbsd1mdl2x"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cwvhbsd1mdl2x"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bjvwb6jg6jpsi" path="res://Features/SlnPicker/SlnPicker.cs" id="1_ciq0g"]
|
||||
[ext_resource type="PackedScene" uid="uid://x5lhwvh5dium" path="res://Features/SlnPicker/PreviousSlnEntry.tscn" id="2_t7l5q"]
|
||||
|
||||
[node name="SlnPicker" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -70,6 +71,19 @@ text = "Open Sln File"
|
||||
[node name="HSeparator" type="HSeparator" parent="VSplitContainer/Panel/MarginContainer2/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VSplitContainer/Panel/MarginContainer2/VBoxContainer2"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="PreviousSlnsVBoxContainer" type="VBoxContainer" parent="VSplitContainer/Panel/MarginContainer2/VBoxContainer2/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="PreviousSlnEntry" parent="VSplitContainer/Panel/MarginContainer2/VBoxContainer2/ScrollContainer/PreviousSlnsVBoxContainer" instance=ExtResource("2_t7l5q")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="FileDialog" type="FileDialog" parent="."]
|
||||
unique_name_in_owner = true
|
||||
oversampling_override = 1.0
|
||||
|
||||
Reference in New Issue
Block a user