add AddDirectoryDialog
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using Godot;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||
|
||||
namespace SharpIDE.Godot.Features.SolutionExplorer.ContextMenus.Dialogs;
|
||||
|
||||
public partial class NewDirectoryDialog : ConfirmationDialog
|
||||
{
|
||||
private LineEdit _nameLineEdit = null!;
|
||||
|
||||
public SharpIdeFolder ParentFolder { get; set; } = null!;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_nameLineEdit = GetNode<LineEdit>("%DirectoryNameLineEdit");
|
||||
_nameLineEdit.GrabFocus();
|
||||
_nameLineEdit.SelectAll();
|
||||
Confirmed += OnConfirmed;
|
||||
}
|
||||
|
||||
private void OnConfirmed()
|
||||
{
|
||||
var directoryName = _nameLineEdit.Text.Trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dj57wbvqjp34r
|
||||
@@ -0,0 +1,25 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bgi4u18y8pt4x"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dj57wbvqjp34r" path="res://Features/SolutionExplorer/ContextMenus/Dialogs/NewDirectoryDialog.cs" id="1_4utum"]
|
||||
|
||||
[node name="NewDirectoryDialog" type="ConfirmationDialog"]
|
||||
oversampling_override = 1.0
|
||||
title = "Create: Directory"
|
||||
size = Vector2i(405, 115)
|
||||
visible = true
|
||||
script = ExtResource("1_4utum")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
offset_left = 8.0
|
||||
offset_top = 8.0
|
||||
offset_right = 397.0
|
||||
offset_bottom = 66.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Enter name:"
|
||||
|
||||
[node name="DirectoryNameLineEdit" type="LineEdit" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "NewDirectory1"
|
||||
@@ -1,5 +1,6 @@
|
||||
using Godot;
|
||||
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||
using SharpIDE.Godot.Features.SolutionExplorer.ContextMenus.Dialogs;
|
||||
|
||||
namespace SharpIDE.Godot.Features.SolutionExplorer;
|
||||
|
||||
@@ -26,7 +27,7 @@ public partial class SolutionExplorerPanel
|
||||
menu.AddSubmenuNodeItem("Add", createNewSubmenu, (int)FolderContextMenuOptions.CreateNew);
|
||||
createNewSubmenu.AddItem("Directory", (int)CreateNewSubmenuOptions.Directory);
|
||||
createNewSubmenu.AddItem("C# File", (int)CreateNewSubmenuOptions.CSharpFile);
|
||||
createNewSubmenu.IdPressed += OnCreateNewSubmenuPressed;
|
||||
createNewSubmenu.IdPressed += id => OnCreateNewSubmenuPressed(id, folder);
|
||||
|
||||
menu.AddItem("Reveal in File Explorer", (int)FolderContextMenuOptions.RevealInFileExplorer);
|
||||
menu.PopupHide += () => menu.QueueFree();
|
||||
@@ -44,12 +45,16 @@ public partial class SolutionExplorerPanel
|
||||
menu.Popup();
|
||||
}
|
||||
|
||||
private void OnCreateNewSubmenuPressed(long id)
|
||||
private readonly PackedScene _newDirectoryDialogScene = GD.Load<PackedScene>("uid://bgi4u18y8pt4x");
|
||||
private void OnCreateNewSubmenuPressed(long id, SharpIdeFolder folder)
|
||||
{
|
||||
var actionId = (CreateNewSubmenuOptions)id;
|
||||
if (actionId is CreateNewSubmenuOptions.Directory)
|
||||
{
|
||||
//OpenCreateNewFolderDialog(folder);
|
||||
var newDirectoryDialog = _newDirectoryDialogScene.Instantiate<NewDirectoryDialog>();
|
||||
newDirectoryDialog.ParentFolder = folder;
|
||||
AddChild(newDirectoryDialog);
|
||||
newDirectoryDialog.PopupCentered();
|
||||
}
|
||||
else if (actionId is CreateNewSubmenuOptions.CSharpFile)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user