refactor sln explorer context menus
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
using Godot;
|
||||||
|
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||||
|
|
||||||
|
namespace SharpIDE.Godot.Features.SolutionExplorer;
|
||||||
|
|
||||||
|
file enum FileContextMenuOptions
|
||||||
|
{
|
||||||
|
Open = 0,
|
||||||
|
RevealInFileExplorer = 1,
|
||||||
|
CopyFullPath = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class SolutionExplorerPanel
|
||||||
|
{
|
||||||
|
private void OpenContextMenuFile(SharpIdeFile file)
|
||||||
|
{
|
||||||
|
var menu = new PopupMenu();
|
||||||
|
AddChild(menu);
|
||||||
|
menu.AddItem("Open", (int)FileContextMenuOptions.Open);
|
||||||
|
menu.AddItem("Reveal in File Explorer", (int)FileContextMenuOptions.RevealInFileExplorer);
|
||||||
|
menu.AddSeparator();
|
||||||
|
menu.AddItem("Copy Full Path", (int)FileContextMenuOptions.CopyFullPath);
|
||||||
|
menu.PopupHide += () => menu.QueueFree();
|
||||||
|
menu.IdPressed += id =>
|
||||||
|
{
|
||||||
|
var actionId = (FileContextMenuOptions)id;
|
||||||
|
if (actionId is FileContextMenuOptions.Open)
|
||||||
|
{
|
||||||
|
GodotGlobalEvents.Instance.FileSelected.InvokeParallelFireAndForget(file, null);
|
||||||
|
}
|
||||||
|
else if (actionId is FileContextMenuOptions.RevealInFileExplorer)
|
||||||
|
{
|
||||||
|
OS.ShellOpen(Path.GetDirectoryName(file.Path)!);
|
||||||
|
}
|
||||||
|
else if (actionId is FileContextMenuOptions.CopyFullPath)
|
||||||
|
{
|
||||||
|
DisplayServer.ClipboardSet(file.Path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var globalMousePosition = GetGlobalMousePosition();
|
||||||
|
menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y);
|
||||||
|
menu.Popup();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using Godot;
|
||||||
|
using SharpIDE.Application.Features.SolutionDiscovery;
|
||||||
|
|
||||||
|
namespace SharpIDE.Godot.Features.SolutionExplorer;
|
||||||
|
|
||||||
|
file enum FolderContextMenuOptions
|
||||||
|
{
|
||||||
|
RevealInFileExplorer = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class SolutionExplorerPanel
|
||||||
|
{
|
||||||
|
private void OpenContextMenuFolder(SharpIdeFolder folder)
|
||||||
|
{
|
||||||
|
var menu = new PopupMenu();
|
||||||
|
AddChild(menu);
|
||||||
|
menu.AddItem("Reveal in File Explorer", (int)FolderContextMenuOptions.RevealInFileExplorer);
|
||||||
|
menu.PopupHide += () => menu.QueueFree();
|
||||||
|
menu.IdPressed += id =>
|
||||||
|
{
|
||||||
|
var actionId = (FolderContextMenuOptions)id;
|
||||||
|
if (actionId is FolderContextMenuOptions.RevealInFileExplorer)
|
||||||
|
{
|
||||||
|
OS.ShellOpen(folder.Path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var globalMousePosition = GetGlobalMousePosition();
|
||||||
|
menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y);
|
||||||
|
menu.Popup();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using Godot;
|
||||||
|
using SharpIDE.Application.Features.SolutionDiscovery.VsPersistence;
|
||||||
|
|
||||||
|
namespace SharpIDE.Godot.Features.SolutionExplorer;
|
||||||
|
|
||||||
|
file enum ProjectContextMenuOptions
|
||||||
|
{
|
||||||
|
Run = 0,
|
||||||
|
Build = 1,
|
||||||
|
Rebuild = 2,
|
||||||
|
Clean = 3,
|
||||||
|
Restore = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
public partial class SolutionExplorerPanel
|
||||||
|
{
|
||||||
|
private void OpenContextMenuProject(SharpIdeProjectModel project)
|
||||||
|
{
|
||||||
|
var menu = new PopupMenu();
|
||||||
|
AddChild(menu);
|
||||||
|
menu.AddItem("Run", (int)ProjectContextMenuOptions.Run);
|
||||||
|
menu.AddSeparator();
|
||||||
|
menu.AddItem("Build", (int)ProjectContextMenuOptions.Build);
|
||||||
|
menu.AddItem("Rebuild", (int)ProjectContextMenuOptions.Rebuild);
|
||||||
|
menu.AddItem("Clean", (int)ProjectContextMenuOptions.Clean);
|
||||||
|
menu.AddItem("Restore", (int)ProjectContextMenuOptions.Restore);
|
||||||
|
menu.PopupHide += () => menu.QueueFree();
|
||||||
|
menu.IdPressed += id =>
|
||||||
|
{
|
||||||
|
var actionId = (ProjectContextMenuOptions)id;
|
||||||
|
if (actionId is ProjectContextMenuOptions.Run)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
if (actionId is ProjectContextMenuOptions.Build)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (actionId is ProjectContextMenuOptions.Rebuild)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (actionId is ProjectContextMenuOptions.Clean)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (actionId is ProjectContextMenuOptions.Restore)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var globalMousePosition = GetGlobalMousePosition();
|
||||||
|
menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y);
|
||||||
|
menu.Popup();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,99 +50,6 @@ public partial class SolutionExplorerPanel : MarginContainer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenContextMenuFolder(SharpIdeFolder folder)
|
|
||||||
{
|
|
||||||
var menu = new PopupMenu();
|
|
||||||
AddChild(menu);
|
|
||||||
menu.AddItem("Reveal in File Explorer", 0);
|
|
||||||
menu.PopupHide += () => menu.QueueFree();
|
|
||||||
menu.IdPressed += id =>
|
|
||||||
{
|
|
||||||
if (id is 0)
|
|
||||||
{
|
|
||||||
// Reveal in File Explorer
|
|
||||||
OS.ShellOpen(folder.Path);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var globalMousePosition = GetGlobalMousePosition();
|
|
||||||
menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y);
|
|
||||||
menu.Popup();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OpenContextMenuProject(SharpIdeProjectModel project)
|
|
||||||
{
|
|
||||||
var menu = new PopupMenu();
|
|
||||||
AddChild(menu);
|
|
||||||
menu.AddItem("Run", 0);
|
|
||||||
menu.AddSeparator();
|
|
||||||
menu.AddItem("Build", 1);
|
|
||||||
menu.AddItem("Rebuild", 2);
|
|
||||||
menu.AddItem("Clean", 3);
|
|
||||||
menu.PopupHide += () =>
|
|
||||||
{
|
|
||||||
GD.Print("QueueFree menu");
|
|
||||||
menu.QueueFree();
|
|
||||||
};
|
|
||||||
menu.IdPressed += id =>
|
|
||||||
{
|
|
||||||
if (id is 0)
|
|
||||||
{
|
|
||||||
// Run project
|
|
||||||
}
|
|
||||||
if (id is 1)
|
|
||||||
{
|
|
||||||
// Build project
|
|
||||||
}
|
|
||||||
else if (id is 2)
|
|
||||||
{
|
|
||||||
// Rebuild project
|
|
||||||
}
|
|
||||||
else if (id is 3)
|
|
||||||
{
|
|
||||||
// Clean project
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var globalMousePosition = GetGlobalMousePosition();
|
|
||||||
menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y);
|
|
||||||
menu.Popup();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OpenContextMenuFile(SharpIdeFile file)
|
|
||||||
{
|
|
||||||
var menu = new PopupMenu();
|
|
||||||
AddChild(menu);
|
|
||||||
menu.AddItem("Open", 0);
|
|
||||||
menu.AddItem("Reveal in File Explorer", 1);
|
|
||||||
menu.AddSeparator();
|
|
||||||
menu.AddItem("Copy Full Path", 2);
|
|
||||||
menu.PopupHide += () =>
|
|
||||||
{
|
|
||||||
GD.Print("QueueFree menu");
|
|
||||||
menu.QueueFree();
|
|
||||||
};
|
|
||||||
menu.IdPressed += id =>
|
|
||||||
{
|
|
||||||
if (id is 0)
|
|
||||||
{
|
|
||||||
GodotGlobalEvents.Instance.FileSelected.InvokeParallelFireAndForget(file, null);
|
|
||||||
}
|
|
||||||
else if (id is 1)
|
|
||||||
{
|
|
||||||
OS.ShellOpen(Path.GetDirectoryName(file.Path)!);
|
|
||||||
}
|
|
||||||
else if (id is 2)
|
|
||||||
{
|
|
||||||
DisplayServer.ClipboardSet(file.Path);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var globalMousePosition = GetGlobalMousePosition();
|
|
||||||
menu.Position = new Vector2I((int)globalMousePosition.X, (int)globalMousePosition.Y);
|
|
||||||
menu.Popup();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task OnFileExternallySelected(SharpIdeFile file, SharpIdeFileLinePosition? fileLinePosition)
|
private async Task OnFileExternallySelected(SharpIdeFile file, SharpIdeFileLinePosition? fileLinePosition)
|
||||||
{
|
{
|
||||||
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
|
await Task.CompletedTask.ConfigureAwait(ConfigureAwaitOptions.ForceYielding);
|
||||||
|
|||||||
Reference in New Issue
Block a user